Index: dialin/hd/ui_proxy.py =================================================================== diff -u -r2dbb3b03c9e63d2cda582facc6cef28710252a8a -rb81eef238382df5e2006b62623d84cf5b3bc86f7 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 2dbb3b03c9e63d2cda582facc6cef28710252a8a) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision b81eef238382df5e2006b62623d84cf5b3bc86f7) @@ -7,8 +7,8 @@ # # @file ui_proxy.py # -# @author (last) Dara Navaei -# @date (last) 27-Apr-2023 +# @author (last) Micahel Garthwaite +# @date (last) 16-May-2023 # @author (original) Sean # @date (original) 15-Apr-2020 # @@ -159,7 +159,10 @@ MsgIds.MSG_ID_HD_DISINFECT_STANDBY_DATA.value, self._handler_disinfects_data_publish) + self.can_interface.register_receiving_publication_function(DenaliChannels.hd_to_ui_ch_id, MsgIds.MSG_ID_HD_ACTIVE_ALARMS_LIST_REQUEST_RESPONSE.value, + self.handler_active_alarm_list_response) + self.hd_uf_settings_change_res_timestamp = 0.0 self.hd_uf_settings_change_confirm_res_timestamp = 0.0 self.hd_treatment_time_change_res_timestamp = 0.0 @@ -174,6 +177,7 @@ self.hd_recirc_res_timestamp = 0.0 self.hd_tx_end_cmd_res_timestamp = 0.0 self.hd_disinfection_standby_timestamp = 0.0 + self.hd_active_alarm_list_timestamp = 0.0 # initialize variables that will be populated by HD version response self.hd_version = None self.fpga_version = None @@ -222,6 +226,10 @@ # initialize variables that will be populated by response to treatment end command self.treatment_end_cmd_succeeded = False self.treatment_end_cmd_reject_reason = 0 + # initialize variables that will be populated by response to active alarm list cmd + self.active_alarm_list_succeeded = False + self.active_alarm_list_reject_reason = 0 + self.alarm_list_response = () self.reject_reasons = OrderedDict() for attr in RequestRejectReasons: @@ -459,6 +467,14 @@ """ return self.saline_bolus_request_bolus_volume + def get_active_alarm_list(self): + """ + Gets the HD alarm list. + + @return : the alarm list as a tuple + """ + return self.alarm_list_response + @publish([ "hd_version_res_timestamp" "hd_version", @@ -1040,6 +1056,43 @@ self.treatment_end_cmd_reject_reason = RequestRejectReasons(rea[0]) self.hd_tx_end_cmd_res_timestamp = timestamp + @publish([ + "hd_active_alarm_list_timestamp", + "active_alarm_list_succeeded", + "active_alarm_list_reject_reason", + "alarm_list_response", + ]) + def handler_active_alarm_list_response(self, message: dict, timestamp=0.0) -> None: + rsp = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] + rea = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] + al1 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] + al2 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] + al3 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] + al4 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] + al5 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] + al6 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] + al7 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9]))[0] + al8 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_10:MsgFieldPositions.END_POS_FIELD_10]))[0] + al9 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11]))[0] + al10 = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_12:MsgFieldPositions.END_POS_FIELD_12]))[0] + + self.active_alarm_list_succeeded = rsp + self.active_alarm_list_reject_reason = rea + self.alarm_list_response = (al1, al2, al3, al4, al5, al6, al7, al8, al9, al10) + self.hd_active_alarm_list_timestamp = timestamp + def cmd_ui_checkin_with_hd(self) -> None: """ Constructs and sends the ui check-in message @@ -1767,3 +1820,16 @@ self.disinfects_hd_submode = hd_state self.disinfects_dg_mode = dg_submode self.hd_disinfection_standby_timestamp = timestamp + + def cmd_ui_send_alarm_list_request(self) -> None: + """ + Constructs and sends a ui message to request the HD active alarm list. + + @return: none + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_hd_ch_id, + message_id=MsgIds.MSG_ID_UI_ACTIVE_ALARMS_LIST_REQUEST.value) + + self.logger.debug("Sending active alarm list request msg to HD.") + self.can_interface.send(message, 0) \ No newline at end of file