Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r2a98d3c2f9b7cc7ef136729725ba3d83249230ae -rac368c6deb78514ddde757cd885eff812b73cd1a --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 2a98d3c2f9b7cc7ef136729725ba3d83249230ae) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision ac368c6deb78514ddde757cd885eff812b73cd1a) @@ -57,7 +57,7 @@ NUM_TREATMENT_PARAMETERS = 19 instance_count = 0 - MAX_UF_RATE_ML_PER_HR = 1000.0 + MAX_UF_RATE_ML_PER_HR = 2500.0 MAX_UF_RATE_ML_PER_SEC = MAX_UF_RATE_ML_PER_HR / 3600 MAX_UF_ML_PER_TX = 7000.0 @@ -606,53 +606,16 @@ rsp_payload += integer_to_bytearray(0) self.demoSelection = 0 # Complete Treatment self.demoCount = 0 # immediately + # rsp_id = MsgIds.MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE + self._send_treatment_log() # TBD! pre-sending prior to final transition to better assure receipt(?) 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.value or \ - msg_id == MsgIds.MSG_ID_UI_TREATMENT_LOG_DATA_REQUEST: # _74 x4A + msg_id == MsgIds.MSG_ID_UI_TREATMENT_LOG_DATA_REQUEST.value: # _74 x4A # rsp_id = MsgIds.MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE - tx_time_s = self.treatment_stop_time_s-self.treatment_start_time_s - self.cmd_send_post_treatment_log_response( - accepted = EResponse.Accepted, # bool - reason = RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value, # int, - blood_flow_rate= self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_BLOOD_FLOW_RATE_ML_MIN.value], # int - dialysate_flow_rate = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_DIALYSATE_FLOW_RATE_ML_MIN.value], # int - treatment_duration = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_TREATMENT_DURATION_MIN.value] * 60, # int - actual_treatment_duration = int(tx_time_s), # int - acid_concentrate_type = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_ACID_CONCENTRATE.value], # int - bicarbonate_concentrate_type = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_BICARB_CONCENTRATE.value], # int - potassium_concentration = 1000, # int - calcium_concentration = 2500, # int - bicarbonate_concentration = 33000, # int - sodium_concentration = 137000, # int - dialysate_temperature = self.demo_treatment_params.data_float[TreatmentParameters.TREATMENT_PARAM_DIALYSATE_TEMPERATURE_C.value], # float - dialyzer_type = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_DIALYZER_TYPE.value], # int - treatment_start_date_time = int(self.treatment_start_time_s), # int - treatment_end_date_time = int(self.treatment_stop_time_s), # int - average_blood_flow = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_BLOOD_FLOW_RATE_ML_MIN.value], # float - average_dialysate_flow = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_DIALYSATE_FLOW_RATE_ML_MIN.value], # float - dialysate_volume_used = (self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_DIALYSATE_FLOW_RATE_ML_MIN.value] * tx_time_s / 60.0), # float - average_dialysate_temp = self.demo_treatment_params.data_float[TreatmentParameters.TREATMENT_PARAM_DIALYSATE_TEMPERATURE_C.value], # float - origin_uf_volume = self.uf_volume_set_l, # float - target_uf_volume = self.uf_volume_set_l, # float - actual_uf_volume = self.uf_volume_out_l, # float - origin_uf_rate = self.uf_volume_set_l / self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_TREATMENT_DURATION_MIN.value], # float - target_uf_rate = self.uf_volume_set_l / self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_TREATMENT_DURATION_MIN.value], # float - actual_uf_rate = self.uf_volume_out_l / tx_time_s * 60.0, # float - saline_bolus_volume = int(self.salineVolCum_ml), # int - heparin_bolus_volume = self.heparin_bolus_ml, # float - heparin_dispense_rate = self.heparin_rate_ml_per_hr, # float - heparin_pre_stop = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_HEPARIN_PRESTOP_MIN.value], # int - heparin_delivered_volume = self.heparin_out_ml, # float - heparin_type = self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_HEPARIN_TYPE.value], # int - average_arterial_pressure = self.arterial_pressure_mid_mmHg, # float - average_venous_pressure = self.venous_pressure_mid_mmHg, # float - device_id = 101, # int - water_sample_test_result = EResponse.Accepted # int - ) - pass + self._send_treatment_log() elif msg_id == MsgIds.MSG_ID_UI_DISPOSABLE_REMOVAL_CONFIRM.value: # 115 x73 rsp_id = MsgIds.MSG_ID_HD_DISPOSABLE_REMOVAL_CONFIRM_RESPONSE @@ -1244,6 +1207,67 @@ self.can_interface.send(tmr_message, 0) self.demoSemaphore.release() + def _send_treatment_log(self) -> None: + """ + Handles a UI request to set the HD RTC + @param message: (dict) the message containing the request + @return: None + """ + tx_time_s = self.treatment_stop_time_s - self.treatment_start_time_s + self.cmd_send_post_treatment_log_response( + accepted=EResponse.Accepted, # bool + reason=RequestRejectReasons.REQUEST_REJECT_REASON_NONE.value, # int, + blood_flow_rate=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_BLOOD_FLOW_RATE_ML_MIN.value], # int + dialysate_flow_rate=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_DIALYSATE_FLOW_RATE_ML_MIN.value], # int + treatment_duration=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_TREATMENT_DURATION_MIN.value] * 60, # int + actual_treatment_duration=int(tx_time_s), # int + acid_concentrate_type=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_ACID_CONCENTRATE.value], # int + bicarbonate_concentrate_type=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_BICARB_CONCENTRATE.value], # int + potassium_concentration=1000, # int + calcium_concentration=2500, # int + bicarbonate_concentration=33000, # int + sodium_concentration=137000, # int + dialysate_temperature=self.demo_treatment_params.data_float[ + TreatmentParameters.TREATMENT_PARAM_DIALYSATE_TEMPERATURE_C.value], # float + dialyzer_type=self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_DIALYZER_TYPE.value], + # int + treatment_start_date_time=int(self.treatment_start_time_s), # int + treatment_end_date_time=int(self.treatment_stop_time_s), # int + average_blood_flow=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_BLOOD_FLOW_RATE_ML_MIN.value], # float + average_dialysate_flow=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_DIALYSATE_FLOW_RATE_ML_MIN.value], # float + dialysate_volume_used=(self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_DIALYSATE_FLOW_RATE_ML_MIN.value] * tx_time_s / 60.0 / 1000.0), + # float + average_dialysate_temp=self.demo_treatment_params.data_float[ + TreatmentParameters.TREATMENT_PARAM_DIALYSATE_TEMPERATURE_C.value], # float + origin_uf_volume=self.uf_volume_set_l, # float + target_uf_volume=self.uf_volume_set_l, # float + actual_uf_volume=self.uf_volume_out_l, # float + origin_uf_rate=self.uf_volume_set_l / self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_TREATMENT_DURATION_MIN.value], # float + target_uf_rate=self.uf_volume_set_l / self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_TREATMENT_DURATION_MIN.value], # float + actual_uf_rate=self.uf_volume_out_l / tx_time_s * 60.0, # float + saline_bolus_volume=int(self.salineVolCum_ml), # int + heparin_bolus_volume=self.heparin_bolus_ml, # float + heparin_dispense_rate=self.heparin_rate_ml_per_hr, # float + heparin_pre_stop=self.demo_treatment_params.data_int[ + TreatmentParameters.TREATMENT_PARAM_HEPARIN_PRESTOP_MIN.value], # int + heparin_delivered_volume=self.heparin_out_ml, # float + heparin_type=self.demo_treatment_params.data_int[TreatmentParameters.TREATMENT_PARAM_HEPARIN_TYPE.value], # int + average_arterial_pressure=self.arterial_pressure_mid_mmHg, # float + average_venous_pressure=self.venous_pressure_mid_mmHg, # float + device_id=101, # int + water_sample_test_result=EResponse.Accepted # int + ) + def _handler_set_rtc_request(self, message: dict) -> None: """ Handles a UI request to set the HD RTC