########################################################################### # # 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 ro_proxy.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): """ ROProxy 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_set_start_stop_override_request(self, signal: int = 0): """ Constructs and sends a set start-stop override request to the FP to generate permeate. @param: signal: 0 to request stop and go to standby or 1 to start generate permeate via pre-generate @return: none """ sig = integer_to_bytearray(signal) payload = sig message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, message_id=MsgIds.MSG_ID_FP_SET_START_STOP_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("Sending start-stop request to FP.") self.can_interface.send(message, 0)