Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -r2138d06d100fdcf23f2e9069f35ee2fdee62008f -r9a9f63852d6f00feabda7a5ef672f8c81ae9b7e4 --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 2138d06d100fdcf23f2e9069f35ee2fdee62008f) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 9a9f63852d6f00feabda7a5ef672f8c81ae9b7e4) @@ -68,7 +68,15 @@ MSG_ID_RO_ALARM_INFO_DATA= 0x2D MSG_ID_DD_BAL_CHAMBER_DATA = 0x2E MSG_ID_DD_GEN_DIALYSATE_MODE_DATA = 0x2F - MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA = 0x30 + MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA = 0x30 + MSG_ID_RO_VALVES_STATES_DATA = 0x31 + MSG_ID_RO_PUMP_DATA = 0x32 + MSG_ID_RO_OP_MODE_DATA = 0x33 + MSG_ID_RO_PRESSURES_DATA = 0x34 + MSG_ID_RO_LEVEL_DATA = 0x35 + MSG_ID_RO_FLOW_DATA = 0x36 + MSG_ID_RO_CONDUCTIVITY_DATA = 0x37 + MSG_ID_DD_RO_START_STOP_CMD_REQUEST = 0x38 MSG_ID_TESTER_LOGIN_REQUEST = 0x8000 Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -rb493554a035402b243926b114fa26fa1255fd422 -r9a9f63852d6f00feabda7a5ef672f8c81ae9b7e4 --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision b493554a035402b243926b114fa26fa1255fd422) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 9a9f63852d6f00feabda7a5ef672f8c81ae9b7e4) @@ -24,6 +24,9 @@ from .modules.temperature_sensors import DDTemperatureSensors from .modules.valves import DDValves +from .proxies.ro_proxy import ROProxy +from .proxies.td_proxy import TDProxy + from ..common.msg_defs import MsgIds, MsgFieldPositions from ..common.dd_defs import DDOpModes from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels @@ -115,7 +118,10 @@ self.temperature_sensors = DDTemperatureSensors(self.can_interface, self.logger) self.valves = DDValves(self.can_interface, self.logger) + self.ro_proxy = ROProxy(self.can_interface, self.logger) + self.td_proxy = TDProxy(self.can_interface, self.logger) + @publish(["dd_debug_events_timestamp","dd_debug_events"]) def _handler_dd_debug_event_sync(self, message, timestamp = 0.0): Index: leahi_dialin/dd/proxies/ro_proxy.py =================================================================== diff -u --- leahi_dialin/dd/proxies/ro_proxy.py (revision 0) +++ leahi_dialin/dd/proxies/ro_proxy.py (revision 9a9f63852d6f00feabda7a5ef672f8c81ae9b7e4) @@ -0,0 +1,62 @@ +########################################################################### +# +# Copyright (c) 2020-2024 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 buttons.py +# +# @author (last) Micahel Garthwaite +# @date (last) 18-Aug-2023 +# @author (original) Peter Lucia +# @date (original) 02-Apr-2020 +# +############################################################################ +import struct +from logging import Logger + +from leahi_dialin import float_to_bytearray +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels +from leahi_dialin.utils.base import AbstractSubSystem, publish +from leahi_dialin.utils.conversions import integer_to_bytearray, byte_to_bytearray + + +class ROProxy(AbstractSubSystem): + """ + Dialysate Delivery (DD) Dialin API sub-class for RO proxy ( injection ) related commands. + """ + + def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): + """ + HD_Buttons constructor + + @param can_interface: the Denali CAN interface object + """ + + super().__init__() + self.can_interface = can_interface + self.logger = logger + + # no current registered call back methods + + def cmd_dd_send_ro_start_stop_request(self, start: bool = 0, ro_rate: float = 0): + """ + Constructs and sends a DG command response to the HD. + + @param: cmd_id: The DG command ID + @param: rejected: 0 for acceptance, 1 for rejection + @param: rejection_code: The rejection reason. + @return: none + """ + stt = integer_to_bytearray(start) + rtt = float_to_bytearray(ro_rate) + payload = rtt + stt + message = DenaliMessage.build_message(channel_id=DenaliChannels.dd_to_ro_ch_id, + message_id=MsgIds.MSG_ID_DD_RO_START_STOP_CMD_REQUEST.value, + payload=payload) + + self.logger.debug("Sending DD start stop request to RO.") + self.can_interface.send(message, 0) + Index: leahi_dialin/dd/proxies/td_proxy.py =================================================================== diff -u -rfd7a25d8f068bcba594c01410a02a03f6afbcd59 -r9a9f63852d6f00feabda7a5ef672f8c81ae9b7e4 --- leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision fd7a25d8f068bcba594c01410a02a03f6afbcd59) +++ leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision 9a9f63852d6f00feabda7a5ef672f8c81ae9b7e4) @@ -1 +1,79 @@ +########################################################################### +# +# Copyright (c) 2020-2024 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 buttons.py +# +# @author (last) Micahel Garthwaite +# @date (last) 18-Aug-2023 +# @author (original) Peter Lucia +# @date (original) 02-Apr-2020 +# +############################################################################ +import struct +from logging import Logger + +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels +from leahi_dialin.utils.base import AbstractSubSystem, publish +from leahi_dialin.utils.conversions import integer_to_bytearray, byte_to_bytearray, float_to_bytearray + + +class TDProxy(AbstractSubSystem): + """ + Dialysate Delivery (DD) Dialin API sub-class for TD proxy ( injection ) related commands. + """ + + def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): + """ + HD_Buttons constructor + + @param can_interface: the Denali CAN interface object + """ + + super().__init__() + self.can_interface = can_interface + self.logger = logger + + if self.can_interface is not None: + channel_id = DenaliChannels.td_to_dd_ch_id + msg_id = MsgIds.MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA.value + self.can_interface.register_receiving_publication_function(channel_id, msg_id, + self._handler_dialysate_delivery_request_response) + + self.dialysate_delivery_request_start = 0 + self.dialysate_delivery_request_dial_rate = 0.0 + self.dialysate_delivery_request_uf_rate = 0.0 + self.dialysate_delivery_request_dial_temp = 0.0 + self.dialysate_delivery_request_bypass = 0 + self.dialysate_delivery_request_acid = 0 + self.dialysate_delivery_request_bicarb = 0 + self.dd_td_to_dd_request_response_timestamp = 0.0 + + @publish(["dd_td_to_dd_request_response_timestamp", + "dialysate_delivery_request_start","dialysate_delivery_request_dial_rate", + "dialysate_delivery_request_uf_rate","dialysate_delivery_request_dial_temp", + "dialysate_delivery_request_bypass","dialysate_delivery_request_acid", + "dialysate_delivery_request_bicarb", + ]) + def _handler_dialysate_delivery_request_response(self, message, timestamp=0.0): + self.dialysate_delivery_request_start = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] + self.dialysate_delivery_request_dial_rate = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] + self.dialysate_delivery_request_uf_rate = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] + self.dialysate_delivery_request_dial_temp = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] + self.dialysate_delivery_request_bypass = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] + self.dialysate_delivery_request_acid = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] + self.dialysate_delivery_request_bicarb = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] + + self.dd_td_to_dd_request_response_timestamp = timestamp +