Example #1
0
    def _build_parsed_values(self):
        """
        Take something in the data format and turn it into
        a particle with the appropriate tag.
        """
        result = []

        for key in self.raw_data.keys():

            if key == Pco2wAbcDataParticleKey.RECORD_TIME:
                unix_time = mac_timestamp_to_utc_timestamp(self.raw_data[key])
                self.set_internal_timestamp(unix_time=unix_time)

            if self.raw_data[key] is None:

                result.append({DataParticleKey.VALUE_ID: key,
                               DataParticleKey.VALUE: None})
            else:

                result.append(
                    self._encode_value(key,
                                       self.raw_data[key],
                                       self._encoding_rules[key]))

        return result
    def _build_parsed_values(self):
        """
        Take something in the data format and turn it into
        a particle with the appropriate tag.
        """
        result = []

        for key in self.raw_data.keys():

            if key == Pco2wAbcDataParticleKey.RECORD_TIME:
                unix_time = mac_timestamp_to_utc_timestamp(self.raw_data[key])
                self.set_internal_timestamp(unix_time=unix_time)

            if self.raw_data[key] is None:

                result.append({
                    DataParticleKey.VALUE_ID: key,
                    DataParticleKey.VALUE: None
                })
            else:

                result.append(
                    self._encode_value(key, self.raw_data[key],
                                       self._encoding_rules[key]))

        return result
    def _generate_internal_timestamp(record_dict):
        """
        Generate the internal timestamp from the given record time contained
        in the record dict. The time is seconds since 1/1/1904 (or Mac time).
        :param record_dict: dictionary containing the record_time parameter
        :return: the internal timestamp
        """

        utc_time = float(mac_timestamp_to_utc_timestamp(
            record_dict[PhsenAbcdefImodemDataParticleKey.RECORD_TIME]))

        return float(ntplib.system_to_ntp_time(utc_time))
    def _generate_internal_timestamp(record_dict):
        """
        Generate the internal timestamp from the given record time contained
        in the record dict. The time is seconds since 1/1/1904 (or Mac time).
        :param record_dict: dictionary containing the record_time parameter
        :return: the internal timestamp
        """

        utc_time = float(
            mac_timestamp_to_utc_timestamp(
                record_dict[PhsenAbcdefImodemDataParticleKey.RECORD_TIME]))

        return float(ntplib.system_to_ntp_time(utc_time))
Example #5
0
    def __init__(self,
                 raw_data,
                 port_timestamp=None,
                 internal_timestamp=None,
                 preferred_timestamp=DataParticleKey.PORT_TIMESTAMP,
                 quality_flag=DataParticleValue.OK,
                 new_sequence=None):
        super(PhsenRecoveredMetadataDataParticle,
              self).__init__(raw_data, port_timestamp, internal_timestamp,
                             preferred_timestamp, quality_flag, new_sequence)

        # use the timestamp from the sio header as internal timestamp
        sec_since_1904 = int(self.raw_data[TIMESTAMP_FIELD])

        unix_time = mac_timestamp_to_utc_timestamp(sec_since_1904)
        self.set_internal_timestamp(unix_time=unix_time)
Example #6
0
    def __init__(self, raw_data,
                 port_timestamp=None,
                 internal_timestamp=None,
                 preferred_timestamp=DataParticleKey.PORT_TIMESTAMP,
                 quality_flag=DataParticleValue.OK,
                 new_sequence=None):
        super(PhsenRecoveredMetadataDataParticle, self).__init__(raw_data,
                                                                 port_timestamp,
                                                                 internal_timestamp,
                                                                 preferred_timestamp,
                                                                 quality_flag,
                                                                 new_sequence)

        # use the timestamp from the sio header as internal timestamp
        sec_since_1904 = int(self.raw_data[TIMESTAMP_FIELD])

        unix_time = mac_timestamp_to_utc_timestamp(sec_since_1904)
        self.set_internal_timestamp(unix_time=unix_time)