########################################################################### # # 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.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 DDProxy(AbstractSubSystem): """ Treatment Delivery (DD) Dialin API sub-class for DD proxy ( injection ) related commands. """ def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): """ DDProxy 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)