Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -r20c821bd230fc7689a0275a2918981669ff5cc19 -r6d104d3185ac3ed7c18c97ecdc13fd59bf53a8d1 --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 20c821bd230fc7689a0275a2918981669ff5cc19) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 6d104d3185ac3ed7c18c97ecdc13fd59bf53a8d1) @@ -8,14 +8,15 @@ # @file dialysate_delivery.py # # @author (last) Zoltan Miskolci -# @date (last) 08-Jan-2026 +# @date (last) 04-May-2026 # @author (original) Peter Lucia # @date (original) 02-Apr-2020 # ############################################################################ import struct +# Project imports from .modules.alarms import DDAlarms from .modules.balancing_chamber import DDBalancingChamber from .modules.blood_leak import DDBloodLeak @@ -43,10 +44,12 @@ from ..common.constants import NO_RESET from ..common import dd_enum_repository +from ..common.generic_defs import DataTypes from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgFieldPositionsFWVersions from ..common.override_templates import cmd_generic_broadcast_interval_override, cmd_generic_override from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels -from ..utils.base import AbstractSubSystem, publish, LogManager +from leahi_dialin.utils.abstract_classes import AbstractSubSystem +from leahi_dialin.utils.base import publish, LogManager from ..utils.conversions import integer_to_bytearray, bytearray_to_byte @@ -86,20 +89,18 @@ self.callback_id = None # register handler for DD operation mode broadcast messages if self.can_interface is not None: - channel_id = DenaliChannels.dd_sync_broadcast_ch_id - self.msg_id_dd_op_mode_data = MsgIds.MSG_ID_DD_OP_MODE_DATA.value - self.can_interface.register_receiving_publication_function(channel_id, self.msg_id_dd_op_mode_data, - self._handler_dd_op_mode_sync) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_OP_MODE_DATA.value, + function = self._handler_dd_op_mode_sync) - self.msg_id_dd_version_response = MsgIds.MSG_ID_DD_VERSION_RESPONSE.value - self.can_interface.register_receiving_publication_function(channel_id, - self.msg_id_dd_version_response, - self._handler_dd_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_dd_version_response_sync) - self.msg_id_dd_debug_event = MsgIds.MSG_ID_DD_DEBUG_EVENT.value - self.can_interface.register_receiving_publication_function(channel_id, - self.msg_id_dd_debug_event, - self._handler_dd_debug_event_sync) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_DEBUG_EVENT.value, + function = self._handler_dd_debug_event_sync) + # 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_dd() @@ -186,13 +187,13 @@ @param message: published DD 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.dd_operation_mode', DataTypes.U32)) + msg_list.append(('self.dd_operation_sub_mode', DataTypes.U32)) - self.dd_operation_mode = mode[0] - self.dd_operation_sub_mode = smode[0] + self.process_into_vars(decoder_list = msg_list, + message = message) + self.dd_op_mode_timestamp = timestamp @@ -205,32 +206,56 @@ @return: None if not successful, the version string if unpacked successfully """ - major = struct.unpack(' 0 for each in [result['major'], result['minor'], result['micro'], result['build'], result['compatibility']]]): + self.dd_version = f"v{result['major']}.{result['minor']}.{result['micro']}-{result['build']}.{result['compatibility']}" + self.logger.debug(f'DD VERSION: {self.dd_version}') + + if all([len(each) > 0 for each in [result['fpga_id'], result['fpga_major'], result['fpga_minor'], result['fpga_lab']]]): + self.dd_version = f"v{result['fpga_id']}.{result['fpga_major']}.{result['fpga_minor']}-{result['fpga_lab']}" + self.logger.debug(f'DD VERSION: {self.dd_version}') + + """ + major = struct.unpack(DataTypes.U08.unpack_attrib(), bytearray( message['message'][MsgFieldPositionsFWVersions.START_POS_MAJOR:MsgFieldPositionsFWVersions.END_POS_MAJOR])) - minor = struct.unpack(' 0 for each in [major, minor, micro, build, compatibility]]): self.dd_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}.{compatibility[0]}" self.logger.debug(f"DD VERSION: {self.dd_version}") - + if all([len(each) > 0 for each in [fpga_id, fpga_major, fpga_minor, fpga_lab]]): self.dd_fpga_version = f"v{fpga_id[0]}.{fpga_major[0]}.{fpga_minor[0]}-{fpga_lab[0]}" self.logger.debug(f"DD FPGA VERSION: {self.dd_fpga_version}") + """ self.dd_version_response_timestamp = timestamp