Exemplo n.º 1
0
    def indexRecord(self, obj):
        if (self.queueMode and
            (self.status['numSamples'] % BATCH_SLEEP_NUM_SAMPLES) == 0):
            batchProcessDuration = time.time() - self.batchProcessStartTime
            if settings.XGDS_PLOT_BATCH_SLEEP_TIME_FACTOR > 0:
                sleepTime = batchProcessDuration * settings.XGDS_PLOT_BATCH_SLEEP_TIME_FACTOR
                print 'sleeping for %.3f seconds to avoid overloading server' % sleepTime
                time.sleep(sleepTime)
            self.batchProcessStartTime = time.time()

        posixTimeMs = self.queryManager.getTimestamp(obj)
        maxTime = self.status['maxTime'] or -99e+20
        if posixTimeMs < maxTime:
            print(
                'skipping old (duplicate?) record: posixTimeMs %.3f <= maxTime %.3f'
                % (posixTimeMs, self.status['maxTime']))
            return

        self.status['maxTime'] = max(maxTime, posixTimeMs)
        minTime = self.status['minTime'] or 99e+20
        self.status['minTime'] = min(minTime, posixTimeMs)
        self.status['numSamples'] += 1
        if self.status['numSamples'] % 100 == 0:
            print '%d %s tile update' % (self.status['numSamples'],
                                         self.valueCode)

        pos = self.poseCollector.getLastPositionBeforePosixTimeMs(posixTimeMs)
        if pos is None:
            print(
                'skipping record at time %s, no preceding positions available'
                % TimeUtil.posixToUtcDateTime(posixTimeMs / 1000.0))
            return

        timestampUtc = datetime.datetime.utcfromtimestamp(1e-3 * posixTimeMs)
        timestampLocal = pytz.utc.localize(timestampUtc).astimezone(
            OPS_TIME_ZONE)
        dayCode = timestampLocal.strftime('%Y%m%d')
        for tileParams in tile.getTilesOverlappingBounds(
                dayCode,
            (pos.longitude, pos.latitude, pos.longitude, pos.latitude)):
            val = self.valueManager.getValue(obj)
            self.addSample(tileParams, pos, val)
            self.parent.delayBox.addJob((self.valueCode, tileParams))
Exemplo n.º 2
0
    def indexRecord(self, obj):
        if (self.queueMode and
                (self.status['numSamples'] % BATCH_SLEEP_NUM_SAMPLES) == 0):
            batchProcessDuration = time.time() - self.batchProcessStartTime
            if settings.XGDS_PLOT_BATCH_SLEEP_TIME_FACTOR > 0:
                sleepTime = batchProcessDuration * settings.XGDS_PLOT_BATCH_SLEEP_TIME_FACTOR
                print 'sleeping for %.3f seconds to avoid overloading server' % sleepTime
                time.sleep(sleepTime)
            self.batchProcessStartTime = time.time()

        posixTimeMs = self.queryManager.getTimestamp(obj)
        maxTime = self.status['maxTime'] or -99e+20
        if posixTimeMs < maxTime:
            print ('skipping old (duplicate?) record: posixTimeMs %.3f <= maxTime %.3f'
                   % (posixTimeMs, self.status['maxTime']))
            return

        self.status['maxTime'] = max(maxTime, posixTimeMs)
        minTime = self.status['minTime'] or 99e+20
        self.status['minTime'] = min(minTime, posixTimeMs)
        self.status['numSamples'] += 1
        if self.status['numSamples'] % 100 == 0:
            print '%d %s tile update' % (self.status['numSamples'], self.valueCode)

        pos = self.poseCollector.getLastPositionBeforePosixTimeMs(posixTimeMs)
        if pos is None:
            print ('skipping record at time %s, no preceding positions available'
                   % TimeUtil.posixToUtcDateTime(posixTimeMs / 1000.0))
            return

        timestampUtc = datetime.datetime.utcfromtimestamp(1e-3 * posixTimeMs)
        timestampLocal = pytz.utc.localize(timestampUtc).astimezone(OPS_TIME_ZONE)
        dayCode = timestampLocal.strftime('%Y%m%d')
        for tileParams in tile.getTilesOverlappingBounds(dayCode,
                                                         (pos.longitude, pos.latitude,
                                                          pos.longitude, pos.latitude)):
            val = self.valueManager.getValue(obj)
            self.addSample(tileParams, pos, val)
            self.parent.delayBox.addJob((self.valueCode, tileParams))
Exemplo n.º 3
0
def posixTimeMsToUtcDateTime(posixTimeMs):
    return TimeUtil.posixToUtcDateTime(posixTimeMs / 1000.0)
Exemplo n.º 4
0
def posixTimeMsToUtcDateTime(posixTimeMs):
    return TimeUtil.posixToUtcDateTime(posixTimeMs / 1000.0)