Index: leahi_dialin/dd/modules/spent_chamber_fill.py =================================================================== diff -u -r20c821bd230fc7689a0275a2918981669ff5cc19 -re45b20cdc5d4c5dcff8cef530b173ca94cb2e422 --- 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 e45b20cdc5d4c5dcff8cef530b173ca94cb2e422) @@ -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.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.generic_defs import DataTypes +from leahi_dialin.common.msg_ids import MsgIds 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 CanMessenger, CanChannels +from leahi_dialin.utils.abstract_classes import AbstractSubSystem +from leahi_dialin.utils.base import publish class DDSpentChamberFill(AbstractSubSystem): @@ -30,21 +33,20 @@ 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: CanMessenger, logger: Logger): """ - @param can_interface: Denali Can Messenger object + @param can_interface: Can Messenger object """ super().__init__() self.can_interface = can_interface 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 = CanChannels.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,13 @@ @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 @@ -87,7 +89,7 @@ return cmd_generic_broadcast_interval_override( ms = ms, reset = reset, - channel_id = DenaliChannels.dialin_to_dd_ch_id, + channel_id = CanChannels.dialin_to_dd_ch_id, msg_id = MsgIds.MSG_ID_DD_SPENT_CHAMB_FILL_DATA_PUBLISH_OVERRIDE_REQUEST, module_name = 'DD Spent Chamber Fill', logger = self.logger,