Index: leahi_dialin/dd/modules/gen_dialysate.py =================================================================== diff -u -rf0566e1e902b870166c829ec82cd2605efac62b0 -r6d104d3185ac3ed7c18c97ecdc13fd59bf53a8d1 --- leahi_dialin/dd/modules/gen_dialysate.py (.../gen_dialysate.py) (revision f0566e1e902b870166c829ec82cd2605efac62b0) +++ leahi_dialin/dd/modules/gen_dialysate.py (.../gen_dialysate.py) (revision 6d104d3185ac3ed7c18c97ecdc13fd59bf53a8d1) @@ -8,20 +8,23 @@ # @file gen_dialysate.py # # @author (last) Zoltan Miskolci -# @date (last) 07-Jan-2026 +# @date (last) 04-May-2026 # @author (original) Micahel Garthwaite # @date (original) 29-Oct-2020 # ############################################################################ -import struct +# Module imports from logging import Logger +# Project imports from leahi_dialin.common.constants import NO_RESET -from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.generic_defs import DataTypes +from leahi_dialin.common.msg_defs import MsgIds from leahi_dialin.common.override_templates import cmd_generic_broadcast_interval_override, cmd_generic_override -from leahi_dialin.protocols.CAN import DenaliChannels -from leahi_dialin.utils.base import AbstractSubSystem, publish +from leahi_dialin.protocols.CAN import DenaliCanMessenger, DenaliChannels +from leahi_dialin.utils.abstract_classes import AbstractSubSystem +from leahi_dialin.utils.base import publish from leahi_dialin.utils.conversions import integer_to_bytearray, float_to_bytearray @@ -32,7 +35,7 @@ Dialysate Delivery (DD) Dialin API sub-class for gen dialysate related commands. """ - def __init__(self, can_interface, logger: Logger): + def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): """ @param can_interface: Denali Can Messenger object """ @@ -42,10 +45,9 @@ self.logger = logger if self.can_interface is not None: - channel_id = DenaliChannels.dd_sync_broadcast_ch_id - self.msg_id_dd_gen_dialysate_mode_data = MsgIds.MSG_ID_DD_GEN_DIALYSATE_MODE_DATA.value - self.can_interface.register_receiving_publication_function(channel_id, self.msg_id_dd_gen_dialysate_mode_data, - self._handler_gen_dialysate_sync) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_GEN_DIALYSATE_MODE_DATA.value, + function = self._handler_gen_dialysate_sync) self.dd_gen_dialysate_timestamp = 0 #: The timestamp of the last message self.execution_state = 0 #: The Execution state @@ -66,14 +68,15 @@ @param message: published gen dialysate data message @return: None """ - self.execution_state = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.dialysate_delivery_in_progress = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.dialysate_good_to_deliver = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] - self.target_qd = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] + msg_list = [] + msg_list.append(('self.execution_state', DataTypes.U32)) + msg_list.append(('self.dialysate_delivery_in_progress', DataTypes.U32)) + msg_list.append(('self.dialysate_good_to_deliver', DataTypes.U32)) + msg_list.append(('self.target_qd', DataTypes.F32)) + + self.process_into_vars(decoder_list = msg_list, + message = message) + self.dd_gen_dialysate_timestamp = timestamp