Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -r144020fa422bc5d0db1bd62647c29022a887206e -r9c785697827d1a21021b48b57d5a14f157856ec2 --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 144020fa422bc5d0db1bd62647c29022a887206e) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 9c785697827d1a21021b48b57d5a14f157856ec2) @@ -117,9 +117,17 @@ MSG_ID_UI_SOLUTION_INFUSION_REQUEST = 0x5F MSG_ID_TD_SOLUTION_INFUSION_RESPONSE = 0x60 MSG_ID_DD_BLOOD_LEAK_DATA = 0x61 - MSG_ID_FP_INLET_PRESSURE_CHECK_DATA = 0x62 - MSG_ID_DD_VOLTAGES_DATA = 0x63 + MSG_ID_DD_FP_INLET_PRESSURE_CHECK_DATA = 0x62 + MSG_ID_UI_BLOOD_PRESSURE_REQUEST = 0x63 + MSG_ID_TD_BLOOD_PRESSURE_RESPONSE = 0x64 + MSG_ID_TD_BLOOD_PRESSURE_DATA = 0x65 + MSG_ID_USER_CONFIRM_UF_SETTINGS_CHANGE_REQUEST = 0x66 + MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE = 0x67 + MSG_ID_DD_VOLTAGES_DATA = 0x68 + MSG_ID_DD_RINSE_PUMP_DATA = 0x69 + + MSG_ID_DD_PISTON_PUMP_CONTROL_DATA = 0xF0 @@ -184,6 +192,9 @@ MSG_ID_TD_SET_TEST_CONFIGURATION = 0x803A MSG_ID_TD_GET_TEST_CONFIGURATION = 0x803B MSG_ID_TD_RESET_ALL_TEST_CONFIGURATIONS = 0x803C + MSG_ID_TD_AIR_PUMP_POWER_RAISE_OVERRIDE_REQUEST = 0x803D + MSG_ID_TD_AIR_PUMP_POWER_LOWER_OVERRIDE_REQUEST = 0x803E + MSG_ID_TD_HARD_STOP_BLOOD_PUMP = 0x803F MSG_ID_DD_TESTER_LOGIN_REQUEST = 0xA000 MSG_ID_DD_SOFTWARE_RESET_REQUEST = 0xA001 @@ -263,11 +274,17 @@ 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_FILTERED_COND_SENSOR_READINGS_OVERRIDE_REQUEST = 0xA04F - MSG_ID_DD_FILTERED_COND_SENSOR_TEMPERATURE_OVERRIDE_REQUEST = 0xA050 + #MSG_ID_DD_FILTERED_COND_SENSOR_READINGS_OVERRIDE_REQUEST = 0xA04F + #MSG_ID_DD_FILTERED_COND_SENSOR_TEMPERATURE_OVERRIDE_REQUEST = 0xA050 + MSG_ID_DD_RINSE_PUMP_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA04F + MSG_ID_DD_RINSE_PUMP_PWM_PERCENT_OVERRIDE_REQUEST = 0xA050 MSG_ID_DD_VOLTAGE_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA051 MSG_ID_DD_MONITORED_VOLTAGE_OVERRIDE_REQUEST = 0xA052 + # TODO: Placeholders for Beta conflict with above messages + MSG_ID_DD_FILTERED_COND_SENSOR_READINGS_OVERRIDE_REQUEST = 0xA060 # Original ID: 0xA04F + MSG_ID_DD_FILTERED_COND_SENSOR_TEMPERATURE_OVERRIDE_REQUEST = 0xA061 # Original ID: 0xA050 + MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST = 0xAF00 MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST = 0xAF01 MSG_ID_DD_PISTON_PUMP_FILL_AFTER_DISPENSE_OVERRIDE_REQUEST = 0xAF02 @@ -329,4 +346,4 @@ MSG_ID_FP_DEBUG_EVENT = 0xFFF3 - MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK = 0xFFFF \ No newline at end of file + MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK = 0xFFFF Index: leahi_dialin/common/test_config_defs.py =================================================================== diff -u -rf32337722f4ff798db8f260cc926b75781963046 -r9c785697827d1a21021b48b57d5a14f157856ec2 --- leahi_dialin/common/test_config_defs.py (.../test_config_defs.py) (revision f32337722f4ff798db8f260cc926b75781963046) +++ leahi_dialin/common/test_config_defs.py (.../test_config_defs.py) (revision 9c785697827d1a21021b48b57d5a14f157856ec2) @@ -23,7 +23,8 @@ TEST_CONFIG_BETA_HW = 0 # Test configuration using Beta Hardware TEST_CONFIG_DISABLE_BC_PRES_ALARM = 1 # Test configuration disabling BC pressure alarms TEST_CONFIG_DISABLE_DIENER_CONC_PUMP = 2 # Test configuration disabling Diener concentrate pump - NUM_OF_TEST_CONFIGS = 3 # Number of Test Configs + TEST_CONFIG_ENABLE_4WIRE_RINSE_PUMP = 3 # Test configuration Enabling 4 wire rinse pump + NUM_OF_TEST_CONFIGS = 4 # Number of Test Configs @unique class FPTestConfigOptions(DialinEnum): Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -r144020fa422bc5d0db1bd62647c29022a887206e -r9c785697827d1a21021b48b57d5a14f157856ec2 --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 144020fa422bc5d0db1bd62647c29022a887206e) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 9c785697827d1a21021b48b57d5a14f157856ec2) @@ -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 @@ -86,16 +87,18 @@ # register handler for DD operation mode broadcast messages if self.can_interface is not None: channel_id = DenaliChannels.dd_sync_broadcast_ch_id - msg_id = MsgIds.MSG_ID_DD_OP_MODE_DATA.value - self.can_interface.register_receiving_publication_function(channel_id, msg_id, + self.msg_id_dd_op_mode_data = MsgIds.MSG_ID_DD_OP_MODE_DATA.value + self.can_interface.register_receiving_publication_function(channel_id, self.msg_id_dd_op_mode_data, self._handler_dd_op_mode_sync) + self.msg_id_dd_version_response = MsgIds.MSG_ID_DD_VERSION_RESPONSE.value self.can_interface.register_receiving_publication_function(channel_id, - MsgIds.MSG_ID_DD_VERSION_RESPONSE.value, + self.msg_id_dd_version_response, self._handler_dd_version_response_sync) + self.msg_id_dd_debug_event = MsgIds.MSG_ID_DD_DEBUG_EVENT.value self.can_interface.register_receiving_publication_function(channel_id, - MsgIds.MSG_ID_DD_DEBUG_EVENT.value, + self.msg_id_dd_debug_event, self._handler_dd_debug_event_sync) # create properties @@ -126,6 +129,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) @@ -137,7 +141,7 @@ self.td_proxy = TDProxy(self.can_interface, self.logger) - @publish(["dd_debug_events_timestamp","dd_debug_events"]) + @publish(["msg_id_dd_debug_event", "dd_debug_events_timestamp","dd_debug_events"]) def _handler_dd_debug_event_sync(self, message, timestamp = 0.0): payload = message['message'] @@ -168,7 +172,7 @@ """ self.dd_logged_in = logged_in - @publish(["dd_op_mode_timestamp","dd_operation_mode", "dd_operation_sub_mode"]) + @publish(["msg_id_dd_op_mode_data", "dd_op_mode_timestamp","dd_operation_mode", "dd_operation_sub_mode"]) def _handler_dd_op_mode_sync(self, message, timestamp = 0.0): """ Handles published DD operation mode messages. Current DD operation mode @@ -186,7 +190,7 @@ self.dd_operation_sub_mode = smode[0] self.dd_op_mode_timestamp = timestamp - @publish(["dd_version, dd_fpga_version"]) + @publish(["msg_id_dd_version_response", "dd_version, dd_fpga_version"]) def _handler_dd_version_response_sync(self,message, timestamp = 0.0): """ Handler for response from DD regarding its version. @@ -344,4 +348,4 @@ return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") - return False \ No newline at end of file + return False 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 9c785697827d1a21021b48b57d5a14f157856ec2) @@ -0,0 +1,140 @@ +########################################################################### +# +# 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.d79_pump_pwm = 0.0 + self.d79_pump_rpm = 0 + self.dd_rinse_pump_timestamp = 0 + + @publish(["msg_id_dd_rinse_pump_data", + "d79_state", "d79_pump_pwm", "d79_pump_rpm", + "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.d79_pump_pwm = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] + self.d79_pump_rpm = 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 + + def cmd_rinse_pump_pwm_percent_override(self, pwm_percent: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the rinse pump pwm percent override command + Constraints: + Must be logged into DD. + + @param pwm_percent: integer - percentage to override the pwm with + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + reset_byte_array = integer_to_bytearray(reset) + pwm = integer_to_bytearray(pwm_percent) + payload = reset_byte_array + pwm + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_RINSE_PUMP_PWM_PERCENT_OVERRIDE_REQUEST.value, + payload=payload) + + self.logger.debug("override DD Rinse Pump PWM percentage") + + # 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