########################################################################### # # 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 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)