Пример #1
0
    def process(self, data):
        # avoid processing empty data
        if not data:
            # self.log.error('Ignoring empty data processing')
            return

        # self.log.debug('Processing {data}'.format(data=data))

        tokens = data.split(DELIMITER)
        sensor_data = SensorData(tokens)

        # if file not created then create it.
        # Stop gap fix for date & time not set in Atheros
        # Sync the time between Atheros and ATMega
        # UPODXX... xx has to be replaced with POD serial number
        if not self._file:
            dt = float(tokens[DATE_TIME])
            # sychronize Atheros system clock with ATMega
            self.sync_datetime(dt)
            #filename = datetime.fromtimestamp(dt).strftime('UPODXX%d%m%y.txt')
            filename = tokens[0] + '.txt'
            # self.log.info('Created file: {name}'.format(name=filename))
            self._file = TxtWriter(filename)  # RotatingTxtWriter(filename)

        # pprint(vars(sensor_data))
        # pprint(vars(sensor_data.GpsData))
        # print data
        #status = False
        #while not status:
        status = self._file.write(sensor_data)