Index: dialin/ui/hd_simulator.py =================================================================== diff -u -rca3fa85c69d78a574e43e3706a3fb6b2732ee6b8 -r565745de835f2efabbcc458aea51ced88fc63162 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision ca3fa85c69d78a574e43e3706a3fb6b2732ee6b8) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 565745de835f2efabbcc458aea51ced88fc63162) @@ -290,7 +290,7 @@ self.demoSelection = 0 # setup event to change state on demoTimer self.demoCount = 0 - elif (msg_id == MsgIds.MSG_ID_UI_CONFIRMATION_RESULT_RESPONSE.value) and \ + if (msg_id == MsgIds.MSG_ID_UI_CONFIRMATION_RESULT_RESPONSE.value) and \ (params.data_int[0] == 98): rsp_id = MsgIds.MSG_ID_HD_UI_CONFIRMATION_REQUEST rsp_payload = integer_to_bytearray(98) # TBD! Use const for 99 @@ -310,15 +310,15 @@ self.rinseback_volume_all_ml = self.rinseback_volume_out_ml # INITIATE A NEW TREATMENT SETUP ---------------------------------- - elif msg_id == MsgIds.MSG_ID_UI_INITIATE_TREATMENT_REQUEST.value: + if msg_id == MsgIds.MSG_ID_UI_INITIATE_TREATMENT_REQUEST.value: rsp_id = MsgIds.MSG_ID_HD_OP_MODE_DATA if params.data_int[0] == EResponse.Accepted: rsp_payload = integer_to_bytearray(HDOpModes.MODE_TPAR.value) else: rsp_payload = integer_to_bytearray(HDOpModes.MODE_STAN.value) rsp_payload += integer_to_bytearray(0) - elif msg_id == MsgIds.MSG_ID_UI_NEW_TREATMENT_PARAMS_REQUEST.value: + if msg_id == MsgIds.MSG_ID_UI_NEW_TREATMENT_PARAMS_REQUEST.value: rsp_id = MsgIds.MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE rsp_payload = struct.pack("<" + str(TreatmentParameters.NUM_OF_TREATMENT_PARAMS.value + 1) + "i", 1, @@ -365,20 +365,8 @@ # else: # self.demoSpeed = 1 - elif msg_id == MsgIds.MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS_REQUEST.value: - if params.data_int[0] == EResponse.Accepted: ## TBD!!! FOLLOWING IS FUTILE ATTEMPT TO SET UF MAX - calc_max_uf_volume = min(int(self.MAX_UF_RATE_ML_PER_SEC * self.treatment_time_sec/100.0)*100.0, self.MAX_UF_ML_PER_TX) - self.cmd_set_treatment_parameter_ranges(min_treatment_duration=0, max_treatment_duration=480, - min_uf_volume=0.0, - max_uf_volume=calc_max_uf_volume, - min_dialysate_flow_rate=100, max_dialysate_flow_rate=600) - ## TBD!!! Does this work? - self.cmd_send_uf_treatment_response(accepted=EResponse.Accepted, - reason=RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value, - volume=calc_max_uf_volume) - ## TBD!! Is this needed to clear UI from presenting old data? - self.cmd_set_treatment_saline_bolus_data(target=self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_SALINE_BOLUS_VOLUME_ML.value], - cumulative=0.0, delivered=0.0) + if msg_id == MsgIds.MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS_REQUEST.value: + if params.data_int[0] == EResponse.Accepted: self.salineVolume_ml = 0.0 self.salineVolCum_ml = 0.0 self.cmd_send_hd_operation_mode(HDOpModes.MODE_PRET.value,0) @@ -407,8 +395,14 @@ rsp_payload += integer_to_bytearray(0) # WATER SAMPLING -------------------------------------------------- - elif msg_id == MsgIds.MSG_ID_UI_SAMPLE_WATER_RESULT.value: # sample water completed, prime filter... + if msg_id == MsgIds.MSG_ID_UI_SAMPLE_WATER_RESULT.value: # sample water completed, prime filter... if params.data_int[0] == EResponse.Accepted: + ## TBD!!! FOLLOWING IS FUTILE ATTEMPT TO SET UF MAX + calc_max_uf_volume = min(int(self.MAX_UF_RATE_ML_PER_SEC * self.treatment_time_sec/100.0)*100.0, self.MAX_UF_ML_PER_TX) + self.cmd_set_treatment_parameter_ranges(min_treatment_duration=0, max_treatment_duration=480, + min_uf_volume=0.0, + max_uf_volume=calc_max_uf_volume, + min_dialysate_flow_rate=100, max_dialysate_flow_rate=600) self.demoTimedIncValue = PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_INSTALL_STATE.value rsp_id = MsgIds.MSG_ID_PRE_TREATMENT_STATE_DATA rsp_payload = struct.pack( @@ -446,15 +440,23 @@ self.demoSelection = 0 # Wait for user # PRETREATMENT INSTALL AND TESTS --------------------------------- - elif msg_id == MsgIds.MSG_ID_UI_CONSUMABLE_INSTALL_CONFIRM_REQUEST.value: + if msg_id == MsgIds.MSG_ID_UI_CONSUMABLE_INSTALL_CONFIRM_REQUEST.value: + ## TBD!!! Does this work? + self.cmd_send_uf_treatment_response(accepted=EResponse.Accepted, + reason=RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value, + volume=calc_max_uf_volume) # assuming everything is setup in preceding MSG_ID_UI_SAMPLE_WATER_RESULT handling self.demoSelection = 6 # TBD setup event to change to self.demoCounter = self.demoCount # next tick self.demoCount = 3 # TBD redundant with above? self.demoCounter = self.demoCount # immediate self.demoTimedIncValue = PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_PRIME_STATE.value # 1. TBD Note: this will be skipped as an output - elif msg_id == MsgIds.MSG_ID_UI_INSTALLATION_CONFIRM_REQUEST.value: + if msg_id == MsgIds.MSG_ID_UI_INSTALLATION_CONFIRM_REQUEST.value: + ## TBD!! Is this needed to clear UI from presenting old data? + self.cmd_set_treatment_saline_bolus_data(target=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_SALINE_BOLUS_VOLUME_ML.value], + cumulative=0.0, delivered=0.0) self.demoTimedIncValue = PreTreatmentDrySelfTestsStates.DRY_SELF_TESTS_START_STATE.value self.demoSelection = 9 # TBD setup event to change to test completions self.demoCount = 4 # 4 timer ticks each for 12-16 TBD?? @@ -465,15 +467,15 @@ self.demoGroupCounter = -self.demoCounter # start displayed timer progressing with the Counter self.demoGroupCount = PreTreatmentDrySelfTestsStates.NUM_OF_DRY_SELF_TESTS_STATES.value * self.demoCount # aggregate counter TBD! calc the 13 - elif msg_id == MsgIds.MSG_ID_UI_START_PRIME_REQUEST.value: # _60 x3C 'Start Prime' + if msg_id == MsgIds.MSG_ID_UI_START_PRIME_REQUEST.value: # _60 x3C 'Start Prime' self.demoSelection = 10 # continue on, picking up from previous state setup by selection 9 self.demoCount = 5 self.demoCounter = self.demoCount # TBD! creates illusion of starting self.demoGroupCount = PreTreatmentPrimeStates.NUM_OF_HD_PRIME_STATES.value * self.demoCount # aggregate counter self.demoGroupCounter = 0 # aggregate counter TBD SHOULD be handled by previous group end logic (?) # TREATMENT: PATIENT CONNECT -------------------------------------- - elif msg_id == MsgIds.MSG_ID_UI_PATIENT_CONNECTION_BEGIN_REQUEST.value: # 100 x64 'Continue' Priming Complete + if msg_id == MsgIds.MSG_ID_UI_PATIENT_CONNECTION_BEGIN_REQUEST.value: # 100 x64 'Continue' Priming Complete # TBD!!! Setup UF Range before this rsp_id = MsgIds.MSG_ID_PRE_TREATMENT_STATE_DATA rsp_payload = struct.pack( @@ -491,7 +493,7 @@ ) self.demoSelection = 0 # Wait for user - elif msg_id == MsgIds.MSG_ID_UI_SET_UF_VOLUME_PARAMETER_REQUEST.value: # _79 x4F + if msg_id == MsgIds.MSG_ID_UI_SET_UF_VOLUME_PARAMETER_REQUEST.value: # _79 x4F rsp_id = MsgIds.MSG_ID_HD_SET_UF_VOLUME_PARAMETER_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) @@ -503,21 +505,21 @@ self.uf_rate_l_per_sec = 0 self.demoSelection = 0 # Wait for user - elif msg_id == MsgIds.MSG_ID_UI_PATIENT_CONNECTION_CONFIRM_REQUEST.value: # 102 x66 + if msg_id == MsgIds.MSG_ID_UI_PATIENT_CONNECTION_CONFIRM_REQUEST.value: # 102 x66 rsp_id = MsgIds.MSG_ID_HD_PATIENT_CONNECTION_CONFIRM_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) self.demoSelection = 0 # Wait for user - elif msg_id == MsgIds.MSG_ID_UI_START_TREATMENT_REQUEST.value: # 113 x71 + if msg_id == MsgIds.MSG_ID_UI_START_TREATMENT_REQUEST.value: # 113 x71 rsp_id = MsgIds.MSG_ID_HD_START_TREATMENT_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) self.demoSelection = 20 # Start Treatment self.demoCount = 0 # immediately # DIALYSIS --------------------------------------------------- - elif msg_id == MsgIds.MSG_ID_USER_TREATMENT_TIME_CHANGE_REQUEST.value: # _22 x16 + if msg_id == MsgIds.MSG_ID_USER_TREATMENT_TIME_CHANGE_REQUEST.value: # _22 x16 rsp_id = MsgIds.MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE if params.data_int[0] is not None: if params.data_int[0] == 4 * 60 + 30: # 'secret' means to force end if 0 duration is unavailable @@ -531,7 +533,7 @@ rsp_payload += integer_to_bytearray(int(self.treatment_time_sec / 60)) rsp_payload += float_to_bytearray(self.uf_volume_set_l * 1000.0) - elif msg_id == MsgIds.MSG_ID_USER_SALINE_BOLUS_REQUEST.value: # _18 x12 + if msg_id == MsgIds.MSG_ID_USER_SALINE_BOLUS_REQUEST.value: # _18 x12 rsp_id = MsgIds.MSG_ID_USER_SALINE_BOLUS_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) @@ -542,7 +544,7 @@ else: self.demoSelection = 33 # Bolus Stop request - elif msg_id == MsgIds.MSG_ID_UI_HEPARIN_PAUSE_RESUME_REQUEST.value: # _.. x4B + if msg_id == MsgIds.MSG_ID_UI_HEPARIN_PAUSE_RESUME_REQUEST.value: # _.. x4B rsp_id = MsgIds.MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) @@ -551,7 +553,7 @@ else: self.heparin_pause = False # Heparin Resume - elif msg_id == MsgIds.MSG_ID_UI_PRESSURE_LIMITS_CHANGE_REQUEST.value: # _70 x46 + if msg_id == MsgIds.MSG_ID_UI_PRESSURE_LIMITS_CHANGE_REQUEST.value: # _70 x46 rsp_id = MsgIds.MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) @@ -566,7 +568,7 @@ rsp_payload += integer_to_bytearray(params.data_int[1]) rsp_payload += integer_to_bytearray(params.data_int[2]) - elif msg_id == MsgIds.MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_REQUEST.value: # _70 x46 + if msg_id == MsgIds.MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_REQUEST.value: # _70 x46 rsp_id = MsgIds.MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) @@ -581,7 +583,7 @@ rsp_payload += integer_to_bytearray(params.data_int[0]) # RINSEBACK ------------------------- - elif msg_id == MsgIds.MSG_ID_UI_RINSEBACK_CMD_REQUEST.value: # _82 x52 + if msg_id == MsgIds.MSG_ID_UI_RINSEBACK_CMD_REQUEST.value: # _82 x52 rsp_id = MsgIds.MSG_ID_HD_RINSEBACK_CMD_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) @@ -617,19 +619,19 @@ elif params.data_int[0] == 9: # TBD!! Additional not implemented 9 = return to treatment rsp_payload = integer_to_bytearray(EResponse.Rejected) - elif msg_id == MsgIds.MSG_ID_UI_PATIENT_DISCONNECTION_CONFIRM_REQUEST.value or \ + if msg_id == MsgIds.MSG_ID_UI_PATIENT_DISCONNECTION_CONFIRM_REQUEST.value or \ msg_id == MsgIds.MSG_ID_UI_TREATMENT_LOG_DATA_REQUEST.value: # _74 x4A # rsp_id = MsgIds.MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE self._send_treatment_log() - elif msg_id == MsgIds.MSG_ID_UI_DISPOSABLE_REMOVAL_CONFIRM_REQUEST.value: # 115 x73 + if msg_id == MsgIds.MSG_ID_UI_DISPOSABLE_REMOVAL_CONFIRM_REQUEST.value: # 115 x73 rsp_id = MsgIds.MSG_ID_HD_DISPOSABLE_REMOVAL_CONFIRM_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value) self.demoSelection = 1 # Reset to beginning (rather than Disinfect choices '= 50') self.demoCount = 0 # immediately - elif msg_id == MsgIds.MSG_ID_UI_POST_TX_NEXT_REQUEST.value: # 0x6 + if msg_id == MsgIds.MSG_ID_UI_POST_TX_NEXT_REQUEST.value: # 0x6 rsp_id = MsgIds.MSG_ID_HD_POST_TX_NEXT_CMD_RESPONSE rsp_payload = integer_to_bytearray(EResponse.Accepted) rsp_payload += integer_to_bytearray(RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value)