Index: dialin/common/hd_defs.py =================================================================== diff -u -r57b7159edd44ae10a59545530f6623e4c87eedf0 -r9fd0e3390bdb0e8d7fcce0722d1e94cb029e629c --- dialin/common/hd_defs.py (.../hd_defs.py) (revision 57b7159edd44ae10a59545530f6623e4c87eedf0) +++ dialin/common/hd_defs.py (.../hd_defs.py) (revision 9fd0e3390bdb0e8d7fcce0722d1e94cb029e629c) @@ -47,6 +47,14 @@ SAMPLE_WATER_STATE = 1 # Sample water state of the sample water sub-mode state machine NUM_OF_SAMPLE_WATER_STATES = 2 # Number of sample water sub-mode states +class HD_Pre_Treatment_Consumable_Self_Test_States(DialinEnum): + CONSUMABLE_SELF_TESTS_INSTALL_STATE = 0 # Consumable self-tests install state + CONSUMABLE_SELF_TESTS_WATER_QUALITY_CHECK_STATE = 1 # Consumable self-tests water quality check state + CONSUMABLE_SELF_TESTS_BICARB_PUMP_CHECK_STATE = 2 # Consumable self-tests bicarbonate concentrate pump check state + CONSUMABLE_SELF_TESTS_ACID_PUMP_CHECK_STATE = 3 # Consumable self-tests acid concentrate pump check state + CONSUMABLE_SELF_TESTS_COMPLETE_STATE = 4 # Consumable self-tests complete state + NUM_OF_CONSUMABLE_SELF_TESTS_STATES = 5 # Number of consumable install sub-mode states + class HD_Pre_Treatment_No_Cart_Self_Tests_States(DialinEnum): NO_CART_SELF_TESTS_START_STATE = 0 # No cartridge self-tests starting state. NO_CART_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE = 1 # Wait for door to be closed before running self-tests. Index: dialin/common/msg_defs.py =================================================================== diff -u -r4923706568f2f70f48c12401bff2039b01513ca9 -r9fd0e3390bdb0e8d7fcce0722d1e94cb029e629c --- dialin/common/msg_defs.py (.../msg_defs.py) (revision 4923706568f2f70f48c12401bff2039b01513ca9) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision 9fd0e3390bdb0e8d7fcce0722d1e94cb029e629c) @@ -112,9 +112,9 @@ 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_HD_SELF_TEST_NO_CART_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_HD_SELF_TEST_DRY_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 Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r57b7159edd44ae10a59545530f6623e4c87eedf0 -r9fd0e3390bdb0e8d7fcce0722d1e94cb029e629c --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 57b7159edd44ae10a59545530f6623e4c87eedf0) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 9fd0e3390bdb0e8d7fcce0722d1e94cb029e629c) @@ -203,18 +203,18 @@ if self.can_interface is not None: channel_id = DenaliChannels.ui_to_hd_ch_id - self.can_interface.register_receiving_publication_function(channel_id, - MsgIds.MSG_ID_UI_START_TREATMENT.value, - self._handler_ui_start_treatment) - self.can_interface.register_receiving_publication_function(channel_id, - MsgIds.MSG_ID_UI_PRE_TREATMENT_UF_REQUEST.value, - self._handler_ui_pre_treatment_uf_request) - self.can_interface.register_receiving_publication_function(channel_id, - MsgIds.MSG_ID_UI_NEW_TREATMENT_PARAMS.value, - self._handler_ui_validate_parameters) - 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_START_TREATMENT.value, + # self._handler_ui_start_treatment) + # self.can_interface.register_receiving_publication_function(channel_id, + # MsgIds.MSG_ID_UI_PRE_TREATMENT_UF_REQUEST.value, + # self._handler_ui_pre_treatment_uf_request) + # self.can_interface.register_receiving_publication_function(channel_id, + # MsgIds.MSG_ID_UI_NEW_TREATMENT_PARAMS.value, + # self._handler_ui_validate_parameters) + # self.can_interface.register_receiving_publication_function(channel_id, + # MsgIds.MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS.value, + # self._handler_ui_confirm_treatment) self.alarms_simulator = HDAlarmsSimulator(self.can_interface, self.logger) self.treatment_parameter_rejections = TreatmentParameterRejections() @@ -329,53 +329,35 @@ self.can_interface.send(message, 0) - def cmd_send_priming_time_remaining(self, state, seconds_remaining, seconds_total): - """ - Broadcasts the number of seconds remaining in priming to the UI + # def _handler_ui_confirm_treatment(self, message): + # """ + # Handler function to detect when a treatment is confirmed + # + # @param message: the confirm treatment message + # @return: None + # """ + # START_POS = DenaliMessage.PAYLOAD_START_INDEX + # END_POS = START_POS + 4 + # + # request = struct.unpack('i', bytearray( + # message['message'][START_POS:END_POS]))[0] + # + # if request == 0: + # self.logger.debug("Received UI cancel confirmation of Treatment Parameters. ") + # return + # + # self.logger.debug("Received UI confirmation of Treatment Parameters. ") + # + # self.logger.debug("Priming ...") + # state = 0 + # total_seconds = 100 + # for seconds_remaining in range(total_seconds, -1, -1): + # if seconds_remaining % (total_seconds // 3) == 0: + # state += 1 + # self.cmd_send_priming_time_remaining(state, seconds_remaining, total_seconds) + # sleep(0.05) + # self.logger.debug("Finished priming.") - @return: None - """ - - payload = bytearray() - payload += integer_to_bytearray(state) - payload += integer_to_bytearray(seconds_remaining) - payload += integer_to_bytearray(seconds_total) - - message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, - message_id=MsgIds.MSG_ID_DG_PRIMING_STATUS_DATA.value, - payload=payload) - - self.can_interface.send(message, 0) - - def _handler_ui_confirm_treatment(self, message): - """ - Handler function to detect when a treatment is confirmed - - @param message: the confirm treatment message - @return: None - """ - START_POS = DenaliMessage.PAYLOAD_START_INDEX - END_POS = START_POS + 4 - - request = struct.unpack('i', bytearray( - message['message'][START_POS:END_POS]))[0] - - if request == 0: - self.logger.debug("Received UI cancel confirmation of Treatment Parameters. ") - return - - self.logger.debug("Received UI confirmation of Treatment Parameters. ") - - self.logger.debug("Priming ...") - state = 0 - total_seconds = 100 - for seconds_remaining in range(total_seconds, -1, -1): - if seconds_remaining % (total_seconds // 3) == 0: - state += 1 - self.cmd_send_priming_time_remaining(state, seconds_remaining, total_seconds) - sleep(0.05) - self.logger.debug("Finished priming.") - def _handler_ui_pre_treatment_uf_request(self, message): """ Handles the ui pre treatment uf request and sends a response @@ -813,7 +795,7 @@ :param dialysate_flow_rate: (int) Dialysate Flow Rate :return: None """ - + if not isinstance(accepted, int): accepted = int(accepted) if not isinstance(reason, int): @@ -1848,6 +1830,7 @@ def cmd_send_pre_treatment_state_data(self, sub_mode, water_sample_state, + consumables_self_test_state, no_cartridge_self_test_state, installation_state, dry_self_test_state, @@ -1858,6 +1841,7 @@ 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 consumables_self_test_state : (U32) consumables self test 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 @@ -1868,6 +1852,7 @@ """ payload = integer_to_bytearray(sub_mode) payload += integer_to_bytearray(water_sample_state) + payload += integer_to_bytearray(consumables_self_test_state) payload += integer_to_bytearray(no_cartridge_self_test_state) payload += integer_to_bytearray(installation_state) payload += integer_to_bytearray(dry_self_test_state) @@ -1881,22 +1866,6 @@ 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 @@ -1913,23 +1882,23 @@ self.can_interface.send(message, 0) - def cmd_send_pre_treatment_filter_flush_progress_data(self, total, countdown): + def cmd_send_pre_treatment_water_sample_response(self, accepted, reason ): """ - send the pretreatment filter flush progress data - :param accepted: (U32) Total time in second - :param reason: (U32) count down time in second + send the pretreatment water sample response + :param accepted: (U32) accept or reject + :param reason: (U32) rejection reason :return: None """ - payload = integer_to_bytearray(total) - payload += integer_to_bytearray(countdown) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) - message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, - message_id=MsgIds.MSG_ID_DG_FILTER_FLUSH_PROGRESS.value, + 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_no_cartridge_self_test_progress_data(self, total, countdown): + def cmd_send_pre_treatment_self_test_no_cartridge_progress_data(self, total, countdown): """ send the pretreatment no cartridge self-tests progress data :param accepted: (U32) Total time in second @@ -1939,13 +1908,13 @@ 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, + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_SELF_TEST_NO_CART_PROGRESS.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_pre_treatment_dry_self_tests_progress_data(self, total, countdown): + def cmd_send_pre_treatment_self_test_dry_progress_data(self, total, countdown): """ send the pretreatment dry self-tests progress data :param accepted: (U32) Total time in second @@ -1955,12 +1924,29 @@ 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, + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_SELF_TEST_DRY_PROGRESS.value, payload=payload) self.can_interface.send(message, 0) + def cmd_send_pre_treatment_disposables_prime_progress_data(self, timeout, countdown): + """ + Broadcasts the progress time data of pre-treatment disposables priming to the UI + :param timeout : (int) the total progress time timeout in seconds + :param countdown: (int) the remaining time in seconds + :return: None + """ + payload = bytearray() + payload += integer_to_bytearray(timeout) + payload += integer_to_bytearray(countdown) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, + message_id=MsgIds.MSG_ID_DG_PRIMING_STATUS_DATA.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