Index: dialin/common/msg_ids.py =================================================================== diff -u -r410627f2a7a611e5c8c0115a1dafaed44e4df57b -r39a6a491a48545b1dd6c39a72a13d8ca55f941cf --- dialin/common/msg_ids.py (.../msg_ids.py) (revision 410627f2a7a611e5c8c0115a1dafaed44e4df57b) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision 39a6a491a48545b1dd6c39a72a13d8ca55f941cf) @@ -396,6 +396,7 @@ MSG_ID_DG_SET_SW_CONFIG_RECORD = 0xA04B MSG_ID_DG_SEND_SW_CONFIG_RECORD = 0xA04C MSG_ID_DG_FANS_DUTY_CYCLE_OVERRIDE = 0xA04D + MSG_ID_DG_HD_COMMUNICATION_STATUS_OVERRIDE = 0xA04E MSG_ID_HD_DEBUG_EVENT = 0xFFF1 MSG_ID_DG_DEBUG_EVENT = 0xFFF2 Index: dialin/dg/hd_proxy.py =================================================================== diff -u -r3a70bfb451b74106348c064c34f19934aadd9119 -r39a6a491a48545b1dd6c39a72a13d8ca55f941cf --- dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision 3a70bfb451b74106348c064c34f19934aadd9119) +++ dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision 39a6a491a48545b1dd6c39a72a13d8ca55f941cf) @@ -19,6 +19,7 @@ from ..protocols.CAN import DenaliMessage, DenaliChannels from ..utils.base import AbstractSubSystem from ..utils.conversions import integer_to_bytearray, float_to_bytearray +from ..dg import NO_RESET, RESET class DGHDProxy(AbstractSubSystem): @@ -333,3 +334,40 @@ else: self.logger.debug("Timeout!!!!") return False + + def cmd_hd_communication_status_override(self, reset: int = NO_RESET) -> int: + """ + Constructs and sends the HD communication status override command. + Constraints: + Must be logged into DG. + + Method only sets HD Communication status to True on NO_RESET. Therefore, when this message + is called when the HD and DG are communicating, there will be no noticeable effect. + + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + reset_byte_array = integer_to_bytearray(reset) + payload = reset_byte_array + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id=MsgIds.MSG_ID_DG_HD_COMMUNICATION_OVERRIDE.value, + payload=payload) + + self.logger.debug("Overriding DG HD communication Status.") + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + if reset == RESET: + str_res = "Reset " + else: + str_res = "Set " + self.logger.debug("HD Communication status overridden to " + str_res + + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False \ No newline at end of file Index: dialin/hd/post_treatment.py =================================================================== diff -u --- dialin/hd/post_treatment.py (revision 0) +++ dialin/hd/post_treatment.py (revision 39a6a491a48545b1dd6c39a72a13d8ca55f941cf) @@ -0,0 +1,62 @@ +########################################################################### +# +# Copyright (c) 2020-2022 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 post_treatment.py +# +# @author (last) Michael Garthwaite +# @date (last) 22-Feb-2022 +# @author (original) Michael Garthwaite +# @date (original) 22-Feb-2022 +# +############################################################################ +import struct +from logging import Logger + +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliChannels +from ..utils.base import AbstractSubSystem, publish + + +class HDPostTreatment(AbstractSubSystem): + """ + + Hemodialysis Delivery (HD) Dialin API sub-class for post treatment related commands. + + """ + + def __init__(self, can_interface, logger: Logger): + """ + HDPostTreatment constructor + """ + + super().__init__() + self.can_interface = can_interface + self.logger = logger + + if self.can_interface is not None: + self.can_interface.register_receiving_publication_function(DenaliChannels.hd_sync_broadcast_ch_id, + MsgIds.MSG_ID_HD_POST_TREATMENT_STATE.value, + self._handler_post_treatment_sub_mode_sync) + + self.post_treatment_sub_mode = 0 + + def get_post_treatment_sub_mode(self) -> int: + """ + Returns post treatment submode (in int) + """ + return self.post_treatment_sub_mode + + @publish(["post_treatment_sub_mode"]) + def _handler_post_treatment_sub_mode_sync(self, message): + """ + Handles published post treatment sub mode data messages. Sub mode data is also captured for reference. + + @param message: published post treatment sub mode broadcast message + @return: none + """ + self.post_treatment_sub_mode = struct.unpack('