Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -r106e58f4292b0b970a3c2084af19dca26682edc5 -rd0391ac112347f9c7021b0995bd4b22657fe9f66 --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 106e58f4292b0b970a3c2084af19dca26682edc5) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision d0391ac112347f9c7021b0995bd4b22657fe9f66) @@ -354,7 +354,25 @@ MSG_ID_DD_BICARB_CHAMBER_FILL_REQUEST_OVERRIDE_REQUEST = 0xA059 MSG_ID_DD_BICART_DRAIN_REQUEST_OVERRIDE_REQUEST = 0xA05A MSG_ID_DD_BICART_CARTRIDGE_SELECT_OVERRIDE_REQUEST = 0xA05B - MSG_ID_DD_FLOATER_LEVEL_OVERRIDE_REQUEST = 0xA05C + MSG_ID_DD_SET_CONDUCTIVITY_MODEL_REQUEST = 0xA05C + MSG_ID_DD_CONDUCTIVITY_SENSOR_RESISTANCE_OVERRIDE_REQUEST = 0xA05D + MSG_ID_DD_CONDUCTIVITY_SENSOR_VERSION_REQUEST = 0xA05E + MSG_ID_DD_CONDUCTIVITY_SENSOR_VERSION_RESPONSE = 0xA05F, + MSG_ID_DD_BICARB_MIX_VOL_CONTROL_KP_GAIN_COEFF_OVERRIDE_REQUEST = 0xA060 + MSG_ID_DD_BICARB_MIX_VOL_CONTROL_KI_GAIN_COEFF_OVERRIDE_REQUEST = 0xA061 + MSG_ID_DD_ACID_MIX_VOL_CONTROL_KP_GAIN_COEFF_OVERRIDE_REQUEST = 0xA062 + MSG_ID_DD_ACID_MIX_VOL_CONTROL_KI_GAIN_COEFF_OVERRIDE_REQUEST = 0xA063 + MSG_ID_DD_ACID_MIX_VOL_OVERRIDE_REQUEST = 0xA064 + MSG_ID_DD_BICARB_MIX_VOL_OVERRIDE_REQUEST = 0xA065 + MSG_ID_DD_BICARB_TARGET_CONDUCTIVITY_OVERRIDE_REQUEST = 0xA066 + MSG_ID_DD_BICARB_DELTA_CONDUCTIVITY_OVERRIDE_REQUEST = 0xA067 + MSG_ID_DD_DIALYSATE_TARGET_CONDUCTIVITY_OVERRIDE_REQUEST = 0xA068 + MSG_ID_DD_DIALYSATE_DELTA_CONDUCTIVITY_OVERRIDE_REQUEST = 0xA069 + MSG_ID_DD_BICART_UPPER_PRESSURE_OVERRIDE_REQUEST = 0xA06A + MSG_ID_DD_BICART_LOWER_PRESSURE_OVERRIDE_REQUEST = 0xA06B + MSG_ID_DD_SUBSTITUTION_PUMP_START_STOP_OVERRIDE_REQUEST = 0xA06C + MSG_ID_DD_SUBSTITUTION_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA06D + MSG_ID_DD_FLOATER_LEVEL_OVERRIDE_REQUEST = 0xA06E MSG_ID_DD_SET_CONDUCTIVITY_MODEL_REQUEST = 0xA100 MSG_ID_DD_CONDUCTIVITY_SENSOR_RESISTANCE_OVERRIDE_REQUEST = 0xA101 Index: leahi_dialin/common/test_config_defs.py =================================================================== diff -u -rfc66ce51dca2af3afb1de1426f3eb1cf5285d66f -rd0391ac112347f9c7021b0995bd4b22657fe9f66 --- leahi_dialin/common/test_config_defs.py (.../test_config_defs.py) (revision fc66ce51dca2af3afb1de1426f3eb1cf5285d66f) +++ leahi_dialin/common/test_config_defs.py (.../test_config_defs.py) (revision d0391ac112347f9c7021b0995bd4b22657fe9f66) @@ -21,7 +21,7 @@ @unique class DDFPTestConfigOptions(DialinEnum): TEST_CONFIG_DD_FP_ENABLE_BETA_1_HW = 0 # (DD & FP) Test configuration using Beta 1.0 Hardware - TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW = 1 # (DD & FP) Test configuration using Beta 2.0 Hardware + TEST_CONFIG_DD_FP_ENABLE_BETA_1_9_HW = 1 # (DD & FP) Test configuration using Beta 1.9 Hardware TEST_CONFIG_DD_DISABLE_BC_PRES_ALARM = 2 # (DD) Test configuration disabling BC pressure alarms TEST_CONFIG_DD_ENABLE_DRY_BICARB = 3 # (DD) Test configuration enable Dry Bicarb usage TEST_CONFIG_FP_SKIP_PRE_GEN_FLUSH = 4 # (FP) Test configuration to skip pre-gen flush Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -r20c821bd230fc7689a0275a2918981669ff5cc19 -rd0391ac112347f9c7021b0995bd4b22657fe9f66 --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 20c821bd230fc7689a0275a2918981669ff5cc19) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision d0391ac112347f9c7021b0995bd4b22657fe9f66) @@ -31,6 +31,7 @@ from .modules.pre_gen_dialysate import DDPreGenDialysate from .modules.rinse_pump import DDRinsePump from .modules.spent_chamber_fill import DDSpentChamberFill +from .modules.substitution_pump import DDSubstitutionPump from .modules.drybicart import DDDryBicart from .modules.temperature_sensors import DDTemperatureSensors from .modules.dd_test_configs import DDTestConfig @@ -125,6 +126,7 @@ self.concentrate_pumps = DDConcentratePumps(self.can_interface, self.logger) #: The Concentrat Pumps module self.conductivity_sensors = DDConductivitySensors(self.can_interface, self.logger) #: The Conductivity Sensors module self.dialysate_pumps = DDDialysatePumps(self.can_interface, self.logger) #: The Dialysate Pumps module + self.drybicart = DDDryBicart(self.can_interface, self.logger) #: The Dry Bicarb module self.events = DDEvents(self.can_interface, self.logger) #: The Events module self.gen_dialysate = DDGenDialysate(self.can_interface, self.logger) #: The Generate Dialysate module self.heaters = DDHeaters(self.can_interface, self.logger) #: The Heaters module @@ -134,7 +136,7 @@ self.pre_gen_dialysate = DDPreGenDialysate(self.can_interface, self.logger) #: The Pre Generate Dialysate module self.rinse_pump = DDRinsePump(self.can_interface, self.logger) #: The Rinse Pump module self.spent_chamber_fill = DDSpentChamberFill(self.can_interface, self.logger) #: The Spent Chamber module - self.drybicart = DDDryBicart(self.can_interface, self.logger) #: The Dry Bicarb module + self.substitution_pump = DDSubstitutionPump(self.can_interface, self.logger) #: The Substitution Pump module self.temperature_sensors = DDTemperatureSensors(self.can_interface, self.logger) #: The Temperature Sensors module self.test_configs = DDTestConfig(self.can_interface, self.logger) #: The Test Configs module self.ultrafiltration = DDUltrafiltration(self.can_interface, self.logger) #: The Ultrafiltration module Index: leahi_dialin/dd/modules/substitution_pump.py =================================================================== diff -u --- leahi_dialin/dd/modules/substitution_pump.py (revision 0) +++ leahi_dialin/dd/modules/substitution_pump.py (revision d0391ac112347f9c7021b0995bd4b22657fe9f66) @@ -0,0 +1,112 @@ +########################################################################### +# +# 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) Zoltan Miskolci +# @date (last) 07-Jan-2026 +# @author (original) Jonny Paguio +# @date (original) 13-Oct-2025 +# +############################################################################ + +import struct +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.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.utils.conversions import integer_to_bytearray, float_to_bytearray + + +class DDSubstitutionPump(AbstractSubSystem): + """ + Substitution Pump + + Dialysate Delivery (DD) Dialin API sub-class for substitution 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_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.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"]) + def _handler_substitution_pump_sync(self, message, timestamp=0.0): + """ + Handles published substitution pump data messages. + + @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] + + 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 + 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 + """ + 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) + + 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 + + @param pump_id: unsigned int - substitution pump ID + @param command: int - value to command the substitution pump + @param speed: float - ml/min to set the speed to + @return: 1 if successful, zero otherwise + """ + pmp = integer_to_bytearray(pump_id) + cmd = integer_to_bytearray(command) + spd = float_to_bytearray(speed) + 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) + +