Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -r29476a4a7b58c6d6decee115ac9bcadb0aa262ca -r0e852e50782a638367a1139f8c56cd8d722ba648 --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 29476a4a7b58c6d6decee115ac9bcadb0aa262ca) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 0e852e50782a638367a1139f8c56cd8d722ba648) @@ -126,6 +126,7 @@ MSG_ID_DD_VOLTAGES_DATA = 0x68 MSG_ID_DD_RINSE_PUMP_DATA = 0x69 MSG_ID_DD_PISTON_PUMP_CONTROL_DATA = 0xF0 + MSG_ID_DD_DRY_BICART_FILL_DATA = 0xF1 MSG_ID_TD_TESTER_LOGIN_REQUEST = 0x8000 MSG_ID_TD_SOFTWARE_RESET_REQUEST = 0x8001 @@ -281,6 +282,9 @@ MSG_ID_DD_VOLTAGE_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA051 MSG_ID_DD_MONITORED_VOLTAGE_OVERRIDE_REQUEST = 0xA052 MSG_ID_DD_RINSE_PUMP_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA053 + MSG_ID_DD_DRY_BICART_DATA_PUBLISH_OVERRIDE_REQUEST = 0xA054 + MSG_ID_DD_DRY_BICART_MAX_FILL_CYCLE_COUNT_OVERRIDE_REQUEST = 0xA055 + MSG_ID_DD_DRY_BICART_START_STOP_OVERRIDE_REQUEST = 0xA056 # Placeholder messages MSG_ID_DD_ALARM_STATE_OVERRIDE_REQUEST = 0xAF03 Index: leahi_dialin/dd/modules/balancing_chamber.py =================================================================== diff -u -rec8a2600b9e8cf6fe7e02c200a1c24221ca86863 -r0e852e50782a638367a1139f8c56cd8d722ba648 --- leahi_dialin/dd/modules/balancing_chamber.py (.../balancing_chamber.py) (revision ec8a2600b9e8cf6fe7e02c200a1c24221ca86863) +++ leahi_dialin/dd/modules/balancing_chamber.py (.../balancing_chamber.py) (revision 0e852e50782a638367a1139f8c56cd8d722ba648) @@ -81,7 +81,7 @@ self.switching_period = struct.unpack('I', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] self.bal_chamber_fill_in_progress = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_6]))[0] + message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] self.current_bal_chamber_switching_counter = struct.unpack('I', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] self.is_pressure_stabilized_during_fill = struct.unpack('I', bytearray( Index: leahi_dialin/dd/modules/drybicart.py =================================================================== diff -u --- leahi_dialin/dd/modules/drybicart.py (revision 0) +++ leahi_dialin/dd/modules/drybicart.py (revision 0e852e50782a638367a1139f8c56cd8d722ba648) @@ -0,0 +1,176 @@ +########################################################################### +# +# Copyright (c) 2025-2026 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 drybicart.py +# +# @author (last) Sameer Poyil +# @date (last) 19-Nov-2025 +# @author (original) Sameer Poyil +# @date (original) 19-Nov-2025 +# +############################################################################ +import struct +from enum import unique +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 DDBDryBicart(AbstractSubSystem): + """ + DryBicart + + Dialysate Delivery (DD) Dialin API sub-class for Dry Bicart 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_dry_bicart_data = MsgIds.MSG_ID_DD_DRY_BICART_FILL_DATA.value + self.can_interface.register_receiving_publication_function(channel_id, self.msg_id_dd_dry_bicart_data, + self._handler_dry_bicart_sync) + + self.execution_state = 0 + self.dry_bicart_max_fill_cycle_count = 0 + self.dry_bicart_fill_request = 0 + self.dd_dry_bicart_timestamp = 0 + + + @publish(["msg_id_dd_dry_bicart_data", + "execution_state", "dry_bicart_max_fill_cycle_count", + "dry_bicart_fill_request"]) + def _handler_dry_bicart_sync(self, message, timestamp=0.0): + """ + Handles published dry bicart data messages. + + @param message: published dry bicart 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.dry_bicart_max_fill_cycle_count = struct.unpack('I', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] + self.dry_bicart_fill_request = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] + + + self.dd_dry_bicart_timestamp = timestamp + + def cmd_dry_bicart_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the dry bicart data broadcast 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_DRY_BICART_DATA_PUBLISH_OVERRIDE_REQUEST.value, + payload=payload) + + self.logger.debug("override DD Dry Bicart data broadcast 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_bicart_max_fill_cycle_count_override(self, count: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the dry bicart max cycle count override command + Constraints: + Must be logged into DD. + + @param count: int - count value to override max fill cycle count + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + + """ + cycle_count = integer_to_bytearray(count) + reset_byte_array = integer_to_bytearray(reset) + payload = reset_byte_array + cycle_count + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_DRY_BICART_MAX_FILL_CYCLE_COUNT_OVERRIDE_REQUEST.value, + payload=payload) + + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(cycle_count) + self.logger.debug("override max fill cycle count " + ": " + str_res) + + # 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_dry_bicart_fill_request_override(self, start_stop: bool) -> int: + """ + Constructs and sends the dry bicart fill request override command + Constraints: + Must be logged into DD. + + @param start_stop: bool - value to start or stop switch ( start = 1, stop = 0 + @return: 1 if successful, zero otherwise + + """ + + sts = integer_to_bytearray(start_stop) + payload = sts + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_DRY_BICART_START_STOP_OVERRIDE_REQUEST.value, + payload=payload) + + # 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