Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r89df6a25e4845ad234c1ffc71fb484b73d125b4c -r41588662a7894a2748b65bdad8e14e70a09d38c1 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 89df6a25e4845ad234c1ffc71fb484b73d125b4c) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 41588662a7894a2748b65bdad8e14e70a09d38c1) @@ -24,7 +24,7 @@ class HDSimulator(AbstractSubSystem): - NUM_TREATMENT_PARAMETERS = 18 + NUM_TREATMENT_PARAMETERS = 19 instance_count = 0 # UI version message field positions @@ -55,6 +55,7 @@ HDSimulator.instance_count = HDSimulator.instance_count + 1 self.checked_in = False + self.checked_in_last = 0 self._log_manager = LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") self.logger = self._log_manager.logger self.console_out = console_out @@ -67,6 +68,7 @@ if self.can_interface is not None: channel_id = DenaliChannels.ui_to_hd_ch_id + if auto_response: self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_CHECK_IN.value, @@ -314,15 +316,25 @@ @param message: the check-in message @return: None """ + now = time.time() + # if the application is not checking-in (the simulatoe ) within 2 sec it means it has been stopped, + # so do the check-in again. + print("check-in: ", now, now - self.checked_in_last) + if now - self.checked_in_last > 5: + self.checked_in = False + + self.checked_in_last = now + if self.checked_in: return print("_handler_ui_first_check_in") + self.cmd_send_power_on_self_test_version_request() for i in range(20): self.cmd_send_hd_post(i, True, False) sleep(0.1) self.cmd_send_hd_post(0, True, True) - self.cmd_send_hd_operation_mode(3, 0) + self.cmd_send_hd_operation_mode(4, 0) self.checked_in = True def _handler_ui_initiate_treatment(self, message): @@ -1692,15 +1704,18 @@ average_dialysate_flow: float, dialysate_volume_used: float, average_dialysate_temp: float, + origin_uf_volume: float, target_uf_volume: float, actual_uf_volume: float, + origin_uf_rate: float, target_uf_rate: float, actual_uf_rate: float, saline_bolus_volume: int, heparin_bolus_volume: float, heparin_dispense_rate: float, heparin_pre_stop: int, heparin_delivered_volume: float, + heparin_type: int, average_arterial_pressure: float, average_venous_pressure: float, device_id: int, @@ -1728,15 +1743,18 @@ @param average_dialysate_flow: average dialysate flow @param dialysate_volume_used: dialysate volume used @param average_dialysate_temp: average dialysate temp + @param origin_uf_volume: origin uf volume @param target_uf_volume: target uf volume @param actual_uf_volume: actual uf volume + @param origin_uf_rate: origin uf rate @param target_uf_rate: target uf rate @param actual_uf_rate: actual uf rate @param saline_bolus_volume: saline bolus volume @param heparin_bolus_volume: heparin bolus volume @param heparin_dispense_rate: heparin dispense rate @param heparin_pre_stop: heparin pre stop @param heparin_delivered_volume: heparin delivered volume + @param heparin_type: heparin type @param average_arterial_pressure: average arterial pressure @param average_venous_pressure: average venous pressure @param device_id: device id @@ -1764,15 +1782,18 @@ payload += float_to_bytearray(float(average_dialysate_flow)) payload += float_to_bytearray(float(dialysate_volume_used)) payload += float_to_bytearray(float(average_dialysate_temp)) + payload += float_to_bytearray(float(origin_uf_volume)) payload += float_to_bytearray(float(target_uf_volume)) payload += float_to_bytearray(float(actual_uf_volume)) + payload += float_to_bytearray(float(origin_uf_rate)) payload += float_to_bytearray(float(target_uf_rate)) payload += float_to_bytearray(float(actual_uf_rate)) payload += unsigned_to_bytearray(int(saline_bolus_volume)) payload += float_to_bytearray(float(heparin_bolus_volume)) payload += float_to_bytearray(float(heparin_dispense_rate)) payload += unsigned_to_bytearray(int(heparin_pre_stop)) payload += float_to_bytearray(float(heparin_delivered_volume)) + payload += unsigned_to_bytearray(int(heparin_type)) payload += float_to_bytearray(float(average_arterial_pressure)) payload += float_to_bytearray(float(average_venous_pressure)) payload += unsigned_to_bytearray(int(device_id)) @@ -1979,6 +2000,7 @@ def cmd_send_hd_general_progress_data(self, message_id: int, total: int, countdown: int) -> None: """ + ~~~~ a general method t send any standard progress data message, by it's id @param message_id: the id of the message @param total: the total value of the progress data @@ -2013,8 +2035,8 @@ """ payload = bytearray() - message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, - message_id=MsgIds.MSG_ID_HD_UI_VERSION_INFO_REQUEST.value, + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIdsDialin.MSG_DIALIN_ID_HD_VERSION_REQUEST.value, payload=payload) self.can_interface.send(message, 0)