Index: leahi_dialin/dd/modules/conductivity_sensors.py =================================================================== diff -u -rb7c705d752b93af15ec6a625c21371af065601ae -r5e60e9aed5d499a0e3244efeb8361554749233b4 --- leahi_dialin/dd/modules/conductivity_sensors.py (.../conductivity_sensors.py) (revision b7c705d752b93af15ec6a625c21371af065601ae) +++ leahi_dialin/dd/modules/conductivity_sensors.py (.../conductivity_sensors.py) (revision 5e60e9aed5d499a0e3244efeb8361554749233b4) @@ -55,8 +55,18 @@ message_id = MsgIds.MSG_ID_DD_CONDUCTIVITY_SENSOR_RESISTANCE_DATA.value, function = self._handler_conductivity_resistance_sync) + self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_CONDUCTIVITY_SENSOR_VERSION_RESPONSE.value, + function = self._handler_conductivity_version_sync) + + self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_CONDUCTIVITY_SENSOR_CAL_RESPONSE.value, + function = self._handler_conductivity_cal_sync) + self.dd_conductivity_timestamp = 0.0 #: The timestamp of the last conductivity message self.dd_conductivity_resistance_timestamp = 0.0 #: The timestamp of the last conductivity resistance message + self.dd_conductivity_cal_timestamp = 0.0 #: The timestamp of the last calibration response message + self.dd_conductivity_version_timestamp = 0.0 #: The timestamp of the last version response message #: The Conductivity Sensors data in dictionary format self.dd_conductivity = { @@ -150,7 +160,26 @@ message = message) self.dd_conductivity_resistance_timestamp = timestamp + @publish(["msg_id_dd_conductivity_version_data", "dd_conductivity_resistance", "dd_conductivity_version_timestamp"]) + def _handler_conductivity_version_sync(self, message, timestamp=0.0): + """ + Handles published DD conductivity sensor version response messages. + @param message: published DD conductivity sensor resistance data message + @return: None + """ + #TODO: complete response handler + self.dd_conductivity_version_timestamp = timestamp + @publish(["msg_id_dd_conductivity_cal_data", "dd_conductivity_resistance", "dd_conductivity_cal_timestamp"]) + def _handler_conductivity_cal_sync(self, message, timestamp=0.0): + """ + Handles published DD conductivity sensor calibration response messages. + @param message: published DD conductivity sensor resistance data message + @return: None + """ + #TODO: complete response handler + self.dd_conductivity_cal_timestamp = timestamp + def cmd_conductivity_sensor_data_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Constructs and sends the conductivity sensor data broadcast interval override command @@ -337,3 +366,47 @@ override_text = f'{str(conductivity)} microsiemens/cm', logger = self.logger, can_interface = self.can_interface) + + def cmd_conductivity_sensor_version_request(self, sensor_index: int ) -> None: + """ + Constructs and sends the conductivity version request command + Constraints: + Must be logged into DD. + Given sensor_index must be one of the sensors defined in ConductivitySensorsEnum + + @param sensor_index: unsigned int - index of the sensor + @return: None. Reponse handler will retrieve version data. + """ + sensor_byte_array = integer_to_bytearray(sensor_index) + payload = sensor_byte_array + + cmd_generic_override(payload = payload, + reset = None, + channel_id = CanChannels.dialin_to_dd_ch_id, + msg_id = MsgIds.MSG_ID_DD_CONDUCTIVITY_SENSOR_VERSION_REQUEST, + entity_name = 'DD Conductivity Version Request', + override_text = 'N/A', + logger = self.logger, + can_interface = self.can_interface) + + def cmd_conductivity_sensor_calibration_request(self, sensor_index: int ) -> None: + """ + Constructs and sends the conductivity sensor calibration request command + Constraints: + Must be logged into DD. + Given sensor_index must be one of the sensors defined in ConductivitySensorsEnum + + @param sensor_index: unsigned int - index of the sensor + @return: None. Response handler will retrieve version data. + """ + sensor_byte_array = integer_to_bytearray(sensor_index) + payload = sensor_byte_array + + cmd_generic_override(payload = payload, + reset = None, + channel_id = CanChannels.dialin_to_dd_ch_id, + msg_id = MsgIds.MSG_ID_DD_CONDUCTIVITY_SENSOR_CAL_REQUEST, + entity_name = 'DD Conductivity Calibration Request', + override_text = 'N/A', + logger = self.logger, + can_interface = self.can_interface) \ No newline at end of file