Index: leahi_dialin/td/proxies/dd_proxy.py =================================================================== diff -u -r2138d06d100fdcf23f2e9069f35ee2fdee62008f -rbd45f04f6e4f66ec2b121f496bc8db20ca00a6b8 --- leahi_dialin/td/proxies/dd_proxy.py (.../dd_proxy.py) (revision 2138d06d100fdcf23f2e9069f35ee2fdee62008f) +++ leahi_dialin/td/proxies/dd_proxy.py (.../dd_proxy.py) (revision bd45f04f6e4f66ec2b121f496bc8db20ca00a6b8) @@ -1 +1,63 @@ +########################################################################### +# +# 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 +# +############################################################################ +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 DDProxy(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_td_send_dd_gen_dialysate_request(self, start: bool = 0, dial_rate: float = 0, uf_rate: float = 0, + dial_temp: float = 0, bypass: int = 0, acid: int = 0, bicarb: int = 0): + """ + Constructs and sends a TD gen dialysate request to the DD. + + @return: none + """ + stt = integer_to_bytearray(start) + dial = float_to_bytearray(dial_rate) + uf = float_to_bytearray(uf_rate) + temp = float_to_bytearray(dial_temp) + byp = integer_to_bytearray(bypass) + acd = integer_to_bytearray(acid) + bic = integer_to_bytearray(bicarb) + payload = bic +acd + byp + temp + uf + dial + stt + message = DenaliMessage.build_message(channel_id=DenaliChannels.td_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA.value, + payload=payload) + + self.logger.debug("Sending TD gen dialysate data request to DD.") + self.can_interface.send(message, 0) \ No newline at end of file Index: leahi_dialin/td/treatment_delivery.py =================================================================== diff -u -rcd4a454309e537e52d2e5c064611ebf986cbe359 -rbd45f04f6e4f66ec2b121f496bc8db20ca00a6b8 --- leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision cd4a454309e537e52d2e5c064611ebf986cbe359) +++ leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision bd45f04f6e4f66ec2b121f496bc8db20ca00a6b8) @@ -25,6 +25,9 @@ from .modules.switches import TDSwitches from .modules.valves import TDValves from .modules.voltages import TDVoltages + +from .proxies.dd_proxy import DDProxy + from ..common.msg_defs import MsgIds, MsgFieldPositions from ..common.td_defs import TDOpModes from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels @@ -122,6 +125,8 @@ self.valves = TDValves(self.can_interface, self.logger) self.voltages = TDVoltages(self.can_interface, self.logger) + self.dd_proxy = DDProxy(self.can_interface, self.logger) + @publish(["td_debug_events_timestamp","td_debug_events"]) def _handler_td_debug_event_sync(self, message, timestamp = 0.0):