Index: leahi_dialin/dd/modules/substitution_pump.py =================================================================== diff -u -rd0391ac112347f9c7021b0995bd4b22657fe9f66 -re45b20cdc5d4c5dcff8cef530b173ca94cb2e422 --- leahi_dialin/dd/modules/substitution_pump.py (.../substitution_pump.py) (revision d0391ac112347f9c7021b0995bd4b22657fe9f66) +++ leahi_dialin/dd/modules/substitution_pump.py (.../substitution_pump.py) (revision e45b20cdc5d4c5dcff8cef530b173ca94cb2e422) @@ -18,10 +18,12 @@ from logging import Logger 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, cmd_generic_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 from leahi_dialin.utils.conversions import integer_to_bytearray, float_to_bytearray @@ -32,7 +34,7 @@ Dialysate Delivery (DD) Dialin API sub-class for substitution Pump related commands. """ - def __init__(self, can_interface, logger: Logger): + def __init__(self, can_interface: CanMessenger, logger: Logger): """ @param can_interface: Denali Can Messenger object """ @@ -42,14 +44,14 @@ self.logger = logger if self.can_interface is not None: - channel_id = DenaliChannels.dd_sync_broadcast_ch_id - self.msg_id_dd_substitution_pump_data = MsgIds.MSG_ID_DD_SUBSTITUTION_PUMP_DATA.value - self.can_interface.register_receiving_publication_function(channel_id, self.msg_id_dd_substitution_pump_data, - self._handler_substitution_pump_sync) + self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_SUBSTITUTION_PUMP_DATA.value, + function = self._handler_substitution_pump_sync) self.dd_substitution_pump_timestamp = 0 #: The timestamp of the latest message self.d92_set_ml_min = 0 #: Set speed of d92 in mL/min + @publish(["msg_id_dd_rinse_pump_data", "d92_set_ml_min", "dd_substitution_pump_timestamp"]) @@ -60,11 +62,15 @@ @param message: published substitution pump data message @return: None """ - self.d92_set_ml_min = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] + msg_list =[] + msg_list.append(('self.d92_set_ml_min', DataTypes.U32)) + self.process_into_vars(decoder_list = msg_list, + message = message) + self.dd_substitution_pump_timestamp = timestamp + def cmd_substitution_pump_data_publish_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Constructs and sends the substitution pump data publish interval override command @@ -77,14 +83,15 @@ @return: 1 if successful, zero otherwise """ return cmd_generic_broadcast_interval_override( - ms=ms, - reset=reset, - channel_id=DenaliChannels.dialin_to_dd_ch_id, - msg_id=MsgIds.MSG_ID_DD_SUBSTITUTION_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, - module_name='DD Rinse Pump', - logger=self.logger, - can_interface=self.can_interface) + ms = ms, + reset = reset, + channel_id = CanChannels.dialin_to_dd_ch_id, + msg_id = MsgIds.MSG_ID_DD_SUBSTITUTION_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + module_name = 'DD Substitution Pump', + logger = self.logger, + can_interface = self.can_interface) + def cmd_substitution_pump_set_start_stop(self, pump_id: int, command: int, speed: float) -> int: """ Constructs and sends the substitution pump start stop command @@ -100,13 +107,11 @@ payload = pmp + cmd + spd return cmd_generic_override( - payload=payload, - reset=NO_RESET, - channel_id=DenaliChannels.dialin_to_dd_ch_id, - msg_id=MsgIds.MSG_ID_DD_SUBSTITUTION_PUMP_START_STOP_OVERRIDE_REQUEST, - entity_name=f'DD Substitution Pump speed', - override_text=str(spd), - logger=self.logger, - can_interface=self.can_interface) - - + payload = payload, + reset = NO_RESET, + channel_id = CanChannels.dialin_to_dd_ch_id, + msg_id = MsgIds.MSG_ID_DD_SUBSTITUTION_PUMP_START_STOP_OVERRIDE_REQUEST, + entity_name = f'DD Substitution Pump speed', + override_text = str(spd), + logger = self.logger, + can_interface = self.can_interface)