def _build_parsed_values(self): """ Take something in the data format and turn it into an array of dictionaries defining the data in the particle with the appropriate tag. """ result = list() result.append(self._encode_value( PresfAbcTideParticleKey.TM_START_TIME, self.raw_data[PresfAbcTideParticleKey.TM_START_TIME], int)) result.append(self._encode_value( PresfAbcTideParticleKey.TM_PRESSURE_NUM, self.raw_data[PresfAbcTideParticleKey.TM_PRESSURE_NUM], int)) result.append(self._encode_value( PresfAbcTideParticleKey.TM_TEMPERATURE_NUM, self.raw_data[PresfAbcTideParticleKey.TM_TEMPERATURE_NUM], int)) # The particle timestamp is the time of the tide measurement. tm_start_time = self.raw_data[PresfAbcTideParticleKey.TM_START_TIME] ntp_time = utilities.time_2000_to_ntp_time(tm_start_time) self.set_internal_timestamp(timestamp=ntp_time) return result
def _build_parsed_values(self): """ Take something in the data format and turn it into an array of dictionaries defining the data in the particle with the appropriate tag. """ result = list() result.append(self._encode_value( PresfAbcWaveParticleKey.WM_START_TIME, self.raw_data[PresfAbcWaveParticleKey.WM_START_TIME], int)) result.append(self._encode_value( PresfAbcWaveParticleKey.WM_PTCN_NUM, self.raw_data[PresfAbcWaveParticleKey.WM_PTCN_NUM], int)) result.append(self._encode_value( PresfAbcWaveParticleKey.WM_BURST_PRESSURE_NUM, self.raw_data[PresfAbcWaveParticleKey.WM_BURST_PRESSURE_NUM], lambda x: [int(y) for y in x])) # The particle timestamp is the time of the start fo the wave burst. wm_start_time = self.raw_data[PresfAbcWaveParticleKey.WM_START_TIME] ntp_time = utilities.time_2000_to_ntp_time(wm_start_time) self.set_internal_timestamp(timestamp=ntp_time) return result
def __init__(self, raw_data, port_timestamp=None, internal_timestamp=None, preferred_timestamp=DataParticleKey.PORT_TIMESTAMP, quality_flag=DataParticleValue.OK, new_sequence=None): super(CtdbpPCommonDataParticle, self).__init__(raw_data, port_timestamp, internal_timestamp, preferred_timestamp, quality_flag, new_sequence) # Calculate the internal timestamp. CTD Time is sceonds from 1/1/2000. # Internal timestamp is seconds from 1/1/1900 ctd_time = int(self.raw_data.group('ctd_time'), 16) ntp_time = utilities.time_2000_to_ntp_time(ctd_time) self.set_internal_timestamp(timestamp=ntp_time)
def _build_parsed_values(self): """ Generate a particle by iterating through the raw_data dictionary items. Convert the data in the manner necessary and return the encoded particles. """ result = [] for key in self.raw_data.keys(): if key == CtdmoGhqrImodemDataParticleKey.CONDUCTIVITY or \ key == CtdmoGhqrImodemDataParticleKey.TEMPERATURE: encoded = self._encode_value(key, self.raw_data[key], lambda x: int('0x' + x, 16)) result.append(encoded) elif key == CtdmoGhqrImodemDataParticleKey.PRESSURE or \ key == CtdmoGhqrImodemDataParticleKey.CTD_TIME: if key == CtdmoGhqrImodemDataParticleKey.PRESSURE: type_code = 'H' else: type_code = 'I' # Will first unhexlify into binary and put into an # array of longs byte_array = array.array(type_code, binascii.unhexlify( self.raw_data[key])) # Then swap bytes to get the bytes in the right order. # This is called out as necessary in the IDD byte_array.byteswap() # Then unpack the binary data to get the final value (val,) = struct.unpack('>'+type_code, byte_array) # Now we will encode it and append it to the result to # return encoded = self._encode_value(key, val, int) result.append(encoded) if key == CtdmoGhqrImodemDataParticleKey.CTD_TIME: # Need to use the CTD time for the internal timestamp ctd_time = time_2000_to_ntp_time(val) self.set_internal_timestamp(timestamp=ctd_time) return result
def _build_parsed_values(self): """ Generate a particle by iterating through the raw_data dictionary items. Convert the data in the manner necessary and return the encoded particles. """ result = [] for key in self.raw_data.keys(): if key == CtdmoGhqrImodemDataParticleKey.CONDUCTIVITY or \ key == CtdmoGhqrImodemDataParticleKey.TEMPERATURE: encoded = self._encode_value(key, self.raw_data[key], lambda x: int('0x' + x, 16)) result.append(encoded) elif key == CtdmoGhqrImodemDataParticleKey.PRESSURE or \ key == CtdmoGhqrImodemDataParticleKey.CTD_TIME: if key == CtdmoGhqrImodemDataParticleKey.PRESSURE: type_code = 'H' else: type_code = 'I' # Will first unhexlify into binary and put into an # array of longs byte_array = array.array( type_code, binascii.unhexlify(self.raw_data[key])) # Then swap bytes to get the bytes in the right order. # This is called out as necessary in the IDD byte_array.byteswap() # Then unpack the binary data to get the final value (val, ) = struct.unpack('>' + type_code, byte_array) # Now we will encode it and append it to the result to # return encoded = self._encode_value(key, val, int) result.append(encoded) if key == CtdmoGhqrImodemDataParticleKey.CTD_TIME: # Need to use the CTD time for the internal timestamp ctd_time = time_2000_to_ntp_time(val) self.set_internal_timestamp(timestamp=ctd_time) return result