Index: leahi_dialin/dd/modules/spent_chamber_fill.py =================================================================== diff -u -r20c821bd230fc7689a0275a2918981669ff5cc19 -r6d104d3185ac3ed7c18c97ecdc13fd59bf53a8d1 --- leahi_dialin/dd/modules/spent_chamber_fill.py (.../spent_chamber_fill.py) (revision 20c821bd230fc7689a0275a2918981669ff5cc19) +++ leahi_dialin/dd/modules/spent_chamber_fill.py (.../spent_chamber_fill.py) (revision 6d104d3185ac3ed7c18c97ecdc13fd59bf53a8d1) @@ -8,20 +8,23 @@ # @file spent_chamber_fill.py # # @author (last) Zoltan Miskolci -# @date (last) 07-Jan-2026 +# @date (last) 04-May-2026 # @author (original) Jonny Paguio # @date (original) 26-Aug-2025 # ############################################################################ -import struct +# Module imports from logging import Logger +# Project imports from leahi_dialin.common.constants import NO_RESET +from leahi_dialin.common.generic_defs import DataTypes from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions from leahi_dialin.common.override_templates import cmd_generic_broadcast_interval_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 class DDSpentChamberFill(AbstractSubSystem): @@ -30,7 +33,7 @@ Dialysate Delivery (DD) Dialin API sub-class for Spent Chamber Fill related commands. """ - def __init__(self, can_interface, logger: Logger): + def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): """ @param can_interface: Denali Can Messenger object @@ -41,10 +44,9 @@ self.logger = logger if self.can_interface is not None: - channel_id = DenaliChannels.dd_sync_broadcast_ch_id - self.msg_id_dd_spent_chamber_fill_data = MsgIds.MSG_ID_DD_SPENT_CHAMBER_FILL_DATA.value - self.can_interface.register_receiving_publication_function(channel_id, self.msg_id_dd_spent_chamber_fill_data, - self._handler_spent_chamber_fill_sync) + self.can_interface.register_receiving_publication_function(channel_id = DenaliChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_SPENT_CHAMBER_FILL_DATA.value, + function = self._handler_spent_chamber_fill_sync) self.dd_spent_chamber_timestamp = 0 #: The timestamp of the latest message self.execution_state = 0 #: The execution state @@ -63,13 +65,14 @@ @param message: published spent chamber fill 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.switching_period = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.total_spent_chamber_fill_counter = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] + msg_list =[] + msg_list.append(('self.execution_state', DataTypes.U32)) + msg_list.append(('self.switching_period', DataTypes.U32)) + msg_list.append(('self.total_spent_chamber_fill_counter', DataTypes.U32)) + self.process_into_vars(decoder_list = msg_list, + message = message) + self.dd_spent_chamber_timestamp = timestamp