Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -r923a6cf4205ed94ae793899f3d3d2dd26b87a8f5 -r42064e6cae7bbfd89bcebafc14e9d5865c53cb8e --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 923a6cf4205ed94ae793899f3d3d2dd26b87a8f5) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 42064e6cae7bbfd89bcebafc14e9d5865c53cb8e) @@ -117,6 +117,7 @@ MSG_ID_UI_SOLUTION_INFUSION_REQUEST = 0x5F MSG_ID_TD_SOLUTION_INFUSION_RESPONSE = 0x60 MSG_ID_DD_BLOOD_LEAK_DATA = 0x61 + MSG_ID_DD_RINSE_PUMP_DATA = 0x63 MSG_ID_USER_CONFIRM_UF_SETTINGS_CHANGE_REQUEST = 0x66 MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE = 0x67 @@ -270,6 +271,7 @@ MSG_ID_DD_BLOOD_LEAK_INTENSITY_MOVING_AVERAGE_OVERRIDE_REQUEST = 0xA04C MSG_ID_DD_BLOOD_LEAK_ZEROING_INTERVAL_IN_MS_OVERRIDE_REQUEST = 0xA04D MSG_ID_DD_BLOOD_LEAK_ZERO_REQUEST = 0xA04E + MSG_ID_DD_RINSE_PUMP_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA04F MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST = 0xAF00 MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST = 0xAF01 Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -r63d26c9e41e02f8a4c0ad59dab9cc6575e501357 -r42064e6cae7bbfd89bcebafc14e9d5865c53cb8e --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 63d26c9e41e02f8a4c0ad59dab9cc6575e501357) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 42064e6cae7bbfd89bcebafc14e9d5865c53cb8e) @@ -29,6 +29,7 @@ from .modules.post_gen_dialysate import DDPostGenDialysate from .modules.pressure_sensors import DDPressureSensors from .modules.pre_gen_dialysate import DDPreGenDialysate +from .modules.rinse_pump import DDRinsePump from .modules.spent_chamber_fill import DDSpentChamberFill from .modules.temperature_sensors import DDTemperatureSensors from .modules.dd_test_configs import DDTestConfig @@ -127,6 +128,7 @@ self.post_gen_dialysate = DDPostGenDialysate(self.can_interface, self.logger) self.pressure_sensors = DDPressureSensors(self.can_interface, self.logger) self.pre_gen_dialysate = DDPreGenDialysate(self.can_interface, self.logger) + self.rinse_pump = DDRinsePump(self.can_interface, self.logger) self.spent_chamber_fill = DDSpentChamberFill(self.can_interface, self.logger) self.temperature_sensors = DDTemperatureSensors(self.can_interface, self.logger) self.test_configs = DDTestConfig(self.can_interface, self.logger) Index: leahi_dialin/dd/modules/rinse_pump.py =================================================================== diff -u --- leahi_dialin/dd/modules/rinse_pump.py (revision 0) +++ leahi_dialin/dd/modules/rinse_pump.py (revision 42064e6cae7bbfd89bcebafc14e9d5865c53cb8e) @@ -0,0 +1,102 @@ +########################################################################### +# +# Copyright (c) 2021-2025 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file rinse_pump.py +# +# @author (last) Jonny Paguio +# @date (last) 13-Oct-2025 +# @author (original) Jonny Paguio +# @date (original) 13-Oct-2025 +# +############################################################################ +import struct +from logging import Logger + +from .constants import RESET, NO_RESET +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.protocols.CAN import DenaliMessage, DenaliChannels +from leahi_dialin.utils.base import AbstractSubSystem, publish, DialinEnum +from leahi_dialin.utils.checks import check_broadcast_interval_override_ms +from leahi_dialin.utils.conversions import integer_to_bytearray, float_to_bytearray + +class DDRinsePump(AbstractSubSystem): + """ + Rinse Pump + + Dialysate Delivery (DD) Dialin API sub-class for Rinse Pump related commands. + """ + + def __init__(self, can_interface, logger: Logger): + """ + + @param can_interface: Denali 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_rinse_pump_data = MsgIds.MSG_ID_DD_RINSE_PUMP_DATA.value + self.can_interface.register_receiving_publication_function(channel_id, self.msg_id_dd_rinse_pump_data, + self._handler_rinse_pump_sync) + + self.d79_state = 0 + self.dd_rinse_pump_timestamp = 0 + + @publish(["msg_id_dd_rinse_pump_data", + "d79_state", + "dd_rinse_pump_timestamp"]) + def _handler_rinse_pump_sync(self, message, timestamp=0.0): + """ + Handles published rinse pump data messages. + + @param message: published rinse pump data message + @return: None + """ + + self.d79_state = struct.unpack('I', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] + + self.dd_rinse_pump_timestamp = timestamp + + def cmd_rinse_pump_data_publish_interval_override(self, ms: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the rinse pump data publish interval override command + Constraints: + Must be logged into DD. + Given interval must be non-zero and a multiple of the DD general task interval (50 ms). + + @param ms: integer - interval (in ms) to override with + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + if not check_broadcast_interval_override_ms(ms): + return False + + reset_byte_array = integer_to_bytearray(reset) + ms_byte_array = integer_to_bytearray(ms) + payload = reset_byte_array + ms_byte_array + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_RINSE_PUMP_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, + payload=payload) + + self.logger.debug("override DD Rinse Pump data publish interval") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.error("Timeout!!!!") + return False \ No newline at end of file