Index: dialin/common/msg_defs.py =================================================================== diff -u -r96006d22aa13f0287e2697a7cac7604201633263 -r4923706568f2f70f48c12401bff2039b01513ca9 --- dialin/common/msg_defs.py (.../msg_defs.py) (revision 96006d22aa13f0287e2697a7cac7604201633263) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision 4923706568f2f70f48c12401bff2039b01513ca9) @@ -78,8 +78,8 @@ MSG_ID_HD_START_TREATMENT_RESPONSE = 0x39 # HD response to user request to initiate a treatment MSG_ID_HD_VALVES_DATA = 0x3A # HD broadcast of valves data MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS = 0x3B # UI user confirmation of treatment parameters - MSG_ID_UI_TREATMENT_END_REQUEST = 0x3C # UI user treatment end request - MSG_ID_HD_TREATMENT_END_RESPONSE = 0x3D # HD response to user request to end treatment + MSG_ID_UI_START_PRIME_REQUEST = 0x3C # UI user has requested to start priming + MSG_ID_HD_START_PRIME_RESPONSE = 0x3D # HD response to user request to start priming MSG_ID_HD_AIR_TRAP_DATA = 0x003E # HD broadcast of air trap data MSG_ID_ALARM_CONDITION_CLEARED = 0x3F # Broadcast that the alarm condition has been cleared MSG_ID_UI_ALARM_USER_ACTION = 0x40 # UI user has requested an alarm action @@ -107,6 +107,19 @@ MSG_ID_UI_TX_END_CMD = 0x57 # UI end treatment sub-mode user request MSG_ID_HD_TX_END_CMD_RESPONSE = 0x58 # HD end treatment sub-mode user request response + MSG_ID_PRE_TREATMENT_STATE = 0x5C # HD broadcast of pre-treatment state + MSG_ID_UI_SAMPLE_WATER_CMD = 0x5D # UI sample water sub-mode user request + MSG_ID_HD_SAMPLE_WATER_CMD_RESPONSE = 0x5E # HD sample water sub-mode request response + MSG_ID_UI_SAMPLE_WATER_RESULT = 0x5F # UI sample water result message + MSG_ID_DG_FILTER_FLUSH_PROGRESS = 0x60 # DG broadcast of filter flush progress + MSG_ID_HD_NO_CART_SELF_TEST_PROGRESS = 0x61 # HD broadcast of no cartridge self-tests progress + MSG_ID_UI_INSTALLATION_CONFIRM = 0x62 # UI disposable installation user confirmation + MSG_ID_HD_DRY_SELF_TEST_PROGRESS = 0x63 # HD broadcast of dry self-tests progress + MSG_ID_UI_CONTINUE_TO_TREATMENT_REQUEST = 0x64 # UI user has requested to continue to treatment + MSG_ID_HD_CONTINUE_TO_TREATMENT_RESPONSE = 0x65 # HD response to user request to continue to treatment + MSG_ID_UI_PATIENT_CONNECTION_CONFIRM = 0x66 # UI user has confirmed patient connection completed + MSG_ID_HD_PATIENT_CONNECTION_CONFIRM_RESPONSE = 0x67 # HD response to user confirmation of patient connection + MSG_ID_CAN_ERROR_COUNT = 0x999 # test code in support of EMC testing # service/test CAN messages @@ -257,6 +270,12 @@ REQUEST_REJECT_REASON_SALINE_BOLUS_NOT_IN_PROGRESS = 22 NUM_OF_REQUEST_REJECT_REASONS = 23 + REQUEST_REJECT_REASON_INVALID_COMMAND = 25 # Requested user action invalid + REQUEST_REJECT_REASON_TREATMENT_IS_COMPLETED = 26 # The treatment has been completed + REQUEST_REJECT_REASON_RINSEBACK_MAX_VOLUME_REACHED = 27 # Rinseback volume maximum has been reached - no more additional rinsebacks allowed + REQUEST_REJECT_REASON_UF_VOLUME_NOT_SET = 28 # Ultrafiltration volume is not set yet + REQUEST_REJECT_REASON_NO_PATIENT_CONNECTION_CONFIRM = 29 # The user has not confirmed patient connection + class MsgFieldPositions: # Generic response msg field byte positions (where 32-bit data fields are used) START_POS_FIELD_1 = 6 # Hardcoded for now to avoid cyclic import issue. See protocols.CAN.DenaliMessage class Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r0f311aec036eb4508cfa7dd4090c579101c348b1 -r4923706568f2f70f48c12401bff2039b01513ca9 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 0f311aec036eb4508cfa7dd4090c579101c348b1) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 4923706568f2f70f48c12401bff2039b01513ca9) @@ -215,14 +215,15 @@ self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS.value, self._handler_ui_confirm_treatment) - self.can_interface.register_receiving_publication_function(channel_id, - MsgIds.MSG_ID_UI_TREATMENT_END_REQUEST.value, - self._handler_ui_end_treatment) self.alarms_simulator = HDAlarmsSimulator(self.can_interface, self.logger) self.treatment_parameter_rejections = TreatmentParameterRejections() - def alarm(self) : + def alarm(self): + """ + the alarm simulator object getter + :return: HDAlarmsSimulator : alarm simulator object + """ return self.alarms_simulator def cmd_send_treatment_parameter_validation_response(self, rejections: List[RequestRejectReasons]): @@ -1843,3 +1844,164 @@ payload=payload) self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_state_data(self, + sub_mode, + water_sample_state, + no_cartridge_self_test_state, + installation_state, + dry_self_test_state, + prime_state, + patient_connection_state): + """ + sends the broadcast message of the pre-treatment states + :param sub_mode : (U32) the main pre treatment state + :param water_sample_state : (U32) water sample state + :param no_cartridge_self_test_state : (U32) no cartridge self-test state + :param installation_state : (U32) installation state + :param dry_self_test_state : (U32) dry self-test state + :param prime_state : (U32) prime state + :param patient_connection_state : (U32) patient connection state + :return: + """ + payload = integer_to_bytearray(sub_mode) + payload += integer_to_bytearray(water_sample_state) + payload += integer_to_bytearray(no_cartridge_self_test_state) + payload += integer_to_bytearray(installation_state) + payload += integer_to_bytearray(dry_self_test_state) + payload += integer_to_bytearray(prime_state) + payload += integer_to_bytearray(patient_connection_state) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, + message_id=MsgIds.MSG_ID_PRE_TREATMENT_STATE.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_water_sample_response(self, accepted, reason ): + """ + send the pretreatment water sample response + :param accepted: (U32) accept or reject + :param reason: (U32) rejection reason + :return: None + """ + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_SAMPLE_WATER_CMD_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_filter_flush_progress_data(self, total, countdown): + """ + send the pretreatment filter flush progress data + :param accepted: (U32) Total time in second + :param reason: (U32) count down time in second + :return: None + """ + payload = integer_to_bytearray(total) + payload += integer_to_bytearray(countdown) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIds.MSG_ID_DG_FILTER_FLUSH_PROGRESS.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_filter_flush_progress_data(self, total, countdown): + """ + send the pretreatment filter flush progress data + :param accepted: (U32) Total time in second + :param reason: (U32) count down time in second + :return: None + """ + payload = integer_to_bytearray(total) + payload += integer_to_bytearray(countdown) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIds.MSG_ID_DG_FILTER_FLUSH_PROGRESS.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_no_cartridge_self_test_progress_data(self, total, countdown): + """ + send the pretreatment no cartridge self-tests progress data + :param accepted: (U32) Total time in second + :param reason: (U32) count down time in second + :return: None + """ + payload = integer_to_bytearray(total) + payload += integer_to_bytearray(countdown) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_NO_CART_SELF_TEST_PROGRESS.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_dry_self_tests_progress_data(self, total, countdown): + """ + send the pretreatment dry self-tests progress data + :param accepted: (U32) Total time in second + :param reason: (U32) count down time in second + :return: None + """ + payload = integer_to_bytearray(total) + payload += integer_to_bytearray(countdown) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_DRY_SELF_TEST_PROGRESS.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_prime_start_response(self, accepted, reason ): + """ + send the pretreatment prime start response + :param accepted: (U32) accept or reject + :param reason: (U32) rejection reason + :return: None + """ + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_START_PRIME_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_continue_to_treament_response(self, accepted, reason ): + """ + send the pretreatment continue to treatment response + :param accepted: (U32) accept or reject + :param reason: (U32) rejection reason + :return: None + """ + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_CONTINUE_TO_TREATMENT_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_pre_treatment_patient_connection_confirm_response(self, accepted, reason ): + """ + send the pretreatment patient connection confirm response + :param accepted: (U32) accept or reject + :param reason: (U32) rejection reason + :return: None + """ + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_PATIENT_CONNECTION_CONFIRM_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0)