Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -rf03c9a32180573f2430105ad69eb91d9f597a96b -r34b64ff2d8a64f4b7b60b80bb7cf4c36845e5943 --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision f03c9a32180573f2430105ad69eb91d9f597a96b) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 34b64ff2d8a64f4b7b60b80bb7cf4c36845e5943) @@ -8,14 +8,13 @@ # @file filtration_purification.py # # @author (last) Zoltan Miskolci -# @date (last) 09-Jan-2026 +# @date (last) 05-May-2026 # @author (original) Peter Lucia # @date (original) 02-Apr-2020 # ############################################################################ -import struct - +# Project imports from .modules.alarms import FPAlarms from .modules.boost_pump import FPBoostPump from .modules.conductivity_sensors import FPConductivitySensors @@ -34,7 +33,8 @@ from ..common.constants import NO_RESET from ..common import fp_enum_repository -from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgFieldPositionsFWVersions +from ..common.generic_defs import DataTypes +from ..common.msg_defs import MsgIds, MsgFieldPositions from ..common.override_templates import cmd_generic_broadcast_interval_override, cmd_generic_override from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from leahi_dialin.utils.abstract_classes import AbstractSubSystem @@ -78,25 +78,26 @@ self.callback_id = None # register handler for FP operation mode broadcast messages if self.can_interface is not None: - self.can_interface.register_receiving_publication_function(DenaliChannels.fp_sync_broadcast_ch_id, - MsgIds.MSG_ID_FP_OP_MODE_DATA.value, - self._handler_fp_op_mode_sync) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.fp_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_FP_OP_MODE_DATA.value, + function = self._handler_fp_op_mode_sync) # FP's version is DD's version since they are the same FW. - self.can_interface.register_receiving_publication_function(DenaliChannels.dd_sync_broadcast_ch_id, - MsgIds.MSG_ID_DD_VERSION_RESPONSE.value, - self._handler_fp_version_response_sync) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_VERSION_RESPONSE.value, + function = self._handler_fp_version_response_sync) - self.can_interface.register_receiving_publication_function(DenaliChannels.fp_sync_broadcast_ch_id, - MsgIds.MSG_ID_FP_DEBUG_EVENT.value, - self._handler_fp_debug_event_sync) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.fp_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_FP_DEBUG_EVENT.value, + function = self._handler_fp_debug_event_sync) - self.can_interface.register_receiving_publication_function(DenaliChannels.dd_to_dialin_ch_id, - MsgIds.MSG_ID_FP_DEF_STATUS_RESPONSE.value, - self._handler_fp_defeatured_response) - self.can_interface.register_receiving_publication_function(DenaliChannels.dd_to_dialin_ch_id, - MsgIds.MSG_ID_FP_BOOST_PUMP_INSTALL_STATUS_RESPONSE.value, - self._handler_fp_boost_pump_installed_response) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.dd_to_dialin_ch_id, + message_id = MsgIds.MSG_ID_FP_DEF_STATUS_RESPONSE.value, + function = self._handler_fp_defeatured_response) + + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.dd_to_dialin_ch_id, + message_id = MsgIds.MSG_ID_FP_BOOST_PUMP_INSTALL_STATUS_RESPONSE.value, + function = self._handler_fp_boost_pump_installed_response) # Dialin will send a login message during construction. This is for the leahi subsystems to start # publishing CAN data when there is no UI connected as the UI typically does this job. self.cmd_log_in_to_fp() @@ -175,33 +176,27 @@ @return: None if not successful, the version string if unpacked successfully """ - major = struct.unpack(' 0 for each in [major, minor, micro, build, compatibility]]): - self.fp_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}.{compatibility[0]}" - self.logger.debug(f"FP VERSION: {self.fp_version}") + result = self.process_into_vars(decoder_list = msg_list, + message = message) - if all([len(each) > 0 for each in [fpga_id, fpga_major, fpga_minor, fpga_lab]]): - self.fp_fpga_version = f"v{fpga_id[0]}.{fpga_major[0]}.{fpga_minor[0]}-{fpga_lab[0]}" - self.logger.debug(f"FP FPGA VERSION: {self.fp_fpga_version}") + if all([len(each) > 0 for each in [result['major'], result['minor'], result['micro'], result['build'], result['compatibility']]]): + self.fp_version = f"v{result['major']}.{result['minor']}.{result['micro']}-{result['build']}.{result['compatibility']}" + self.logger.debug(f'FP VERSION: {self.fp_version}') + if all([len(each) > 0 for each in [result['fpga_id'], result['fpga_major'], result['fpga_minor'], result['fpga_lab']]]): + self.fp_fpga_version = f"v{result['fpga_id']}.{result['fpga_major']}.{result['fpga_minor']}-{result['fpga_lab']}" + self.logger.debug(f'FP FPGA VERSION: {self.fp_fpga_version}') self.fp_version_response_timestamp = timestamp @@ -214,13 +209,12 @@ @param message: published FP operation mode broadcast message @return: None """ - mode = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) - smode = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) + msg_list = [] + msg_list.append(('self.fp_operation_mode', DataTypes.U32)) + msg_list.append(('self.fp_operation_sub_mode', DataTypes.U32)) - self.fp_operation_mode = mode[0] - self.fp_operation_sub_mode = smode[0] + self.process_into_vars(decoder_list = msg_list, + message = message) self.fp_op_mode_timestamp = timestamp @@ -232,9 +226,11 @@ @param message: defeatured response from FP @return: None """ - self.fp_defeatured = True if struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] == 1 else False + msg_list = [] + msg_list.append(('self.fp_defeatured', DataTypes.BOOL)) + self.process_into_vars(decoder_list = msg_list, + message = message) self.fp_defeatured_timestamp = timestamp @@ -246,9 +242,11 @@ @param message: defeatured response from FP @return: None """ - self.fp_p40_installed = True if struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] == 1 else False + msg_list = [] + msg_list.append(('self.fp_p40_installed', DataTypes.BOOL)) + self.process_into_vars(decoder_list = msg_list, + message = message) self.fp_p40_installed_timestamp = timestamp