Index: dialin/hd/ui_proxy.py =================================================================== diff -u -r300931344a107d7f4848808b4f78a50985c64cd8 -r615811771f562ec677f10f1c91bb15733fc7b209 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 300931344a107d7f4848808b4f78a50985c64cd8) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 615811771f562ec677f10f1c91bb15733fc7b209) @@ -410,6 +410,168 @@ """ return self.target_dialysate_flow_rate + def get_treatment_parameters_valid(self): + """ + Gets the T/F flag for whether treatment parameters + are considered valid by HD. + + @return: True if treatment parameters are valid, False if not + """ + return self.treatment_parameters_valid + + def get_blood_flow_rate_reject_reason(self): + """ + Gets the reject reason code for the blood flow rate + treatment parameter. + + @return: The reject reason code for the blood flow rate + """ + return self.blood_flow_rate_reject_reason + + def get_dialysate_flow_rate_reject_reason(self): + """ + Gets the reject reason code for the dialysate flow rate + treatment parameter. + + @return: The reject reason code for the dialysate flow rate + """ + return self.dialysate_flow_rate_reject_reason + + def get_treatment_duration_reject_reason(self): + """ + Gets the reject reason code for the treatment duration + treatment parameter. + + @return: The reject reason code for the treatment duration + """ + return self.treatment_duration_reject_reason + + def get_heparin_pre_stop_time_reject_reason(self): + """ + Gets the reject reason code for the Heparin pre-stop + time treatment parameter. + + @return: The reject reason code for the Heparin pre-stop time + """ + return self.heparin_pre_stop_time_reject_reason + + def get_saline_bolus_volume_reject_reason(self): + """ + Gets the reject reason code for the saline bolus volume + treatment parameter. + + @return: The reject reason code for the saline bolus volume + """ + return self.saline_bolus_volume_reject_reason + + def get_acid_concentrate_reject_reason(self): + """ + Gets the reject reason code for the acid concentrate + treatment parameter. + + @return: The reject reason code for the acid concentrate + """ + return self.acid_concentrate_reject_reason + + def get_bicarb_concentrate_reject_reason(self): + """ + Gets the reject reason code for the bicarbonate + concentrate treatment parameter. + + @return: The reject reason code for the bicarbonate concentrate + """ + return self.bicarb_concentrate_reject_reason + + def get_dialyzer_type_reject_reason(self): + """ + Gets the reject reason code for the dialyzer type treatment + parameter. + + @return: The reject reason code for the dialyzer type + """ + return self.dialyzer_type_reject_reason + + def get_blood_pressure_meas_interval_reject_reason(self): + """ + Gets the reject reason code for the BP measurement interval + treatment parameter. + + @return: The reject reason code for the BP measurement interval + """ + return self.blood_pressure_meas_interval_reject_reason + + def get_rinseback_flow_rate_reject_reason(self): + """ + Gets the reject reason code for the rinseback flow rate + treatment parameter. + + @return: The reject reason code for the rinseback flow rate + """ + return self.rinseback_flow_rate_reject_reason + + def get_arterial_pressure_low_alarm_limit_reject_reason(self): + """ + Gets the reject reason code for the arterial pressure low alarm + limit treatment parameter. + + @return: The reject reason code for the arterial pressure low alarm limit + """ + return self.arterial_pressure_low_alarm_limit_reject_reason + + def get_arterial_pressure_high_alarm_limit_reject_reason(self): + """ + Gets the reject reason code for the arterial pressure high alarm + limit treatment parameter. + + @return: The reject reason code for the arterial pressure high alarm limit + """ + return self.arterial_pressure_high_alarm_limit_reject_reason + + def get_venous_pressure_low_alarm_limit_reject_reason(self): + """ + Gets the reject reason code for the venous pressure low alarm + limit treatment parameter. + + @return: The reject reason code for the venous pressure low alarm limit + """ + return self.venous_pressure_low_alarm_limit_reject_reason + + def get_venous_pressure_high_alarm_limit_reject_reason(self): + """ + Gets the reject reason code for the venous pressure high alarm + limit treatment parameter. + + @return: The reject reason code for the venous pressure high alarm limit + """ + return self.venous_pressure_high_alarm_limit_reject_reason + + def get_heparin_dispense_rate_reject_reason(self): + """ + Gets the reject reason code for the Heparin dispense rate + treatment parameter. + + @return: The reject reason code for the Heparin dispense rate + """ + return self.heparin_dispense_rate_reject_reason + + def get_heparin_bolus_volume_reject_reason(self): + """ + Gets the reject reason code for the Heparin bolus volume + treatment parameter. + + @return: The reject reason code for the Heparin bolus volume + """ + return self.heparin_bolus_volume_reject_reason + + def get_dialysate_temperature_reject_reason(self): + """ + Gets the reject reason code for the dialysate temperature + treatment parameter. + + @return: The reject reason code for dialysate temperature + """ + return self.dialysate_temperature_reject_reason + @_publish([ "hd_version" ]) @@ -440,46 +602,109 @@ return self.hd_version @_publish([ - "min_treatment_duration_min", - "max_treatment_duration_min", - "min_uf_volume_ml", - "max_uf_volume_ml", - "min_dialysate_flow_rate_ml_min", - "max_dialysate_flow_rate_ml_min" + "treatment_parameters_valid", + "blood_flow_rate_reject_reason", + "dialysate_flow_rate_reject_reason", + "treatment_duration_reject_reason", + "heparin_pre_stop_time_reject_reason", + "saline_bolus_volume_reject_reason", + "acid_concentrate_reject_reason", + "bicarb_concentrate_reject_reason", + "dialyzer_type_reject_reason", + "blood_pressure_meas_interval_reject_reason", + "rinseback_flow_rate_reject_reason", + "arterial_pressure_low_alarm_limit_reject_reason", + "arterial_pressure_high_alarm_limit_reject_reason", + "venous_pressure_low_alarm_limit_reject_reason", + "venous_pressure_high_alarm_limit_reject_reason", + "heparin_dispense_rate_reject_reason", + "heparin_bolus_volume_reject_reason", + "dialysate_temperature_reject_reason" ]) def _handler_treatment_param_settings(self, message): """ Handler for response from HD regarding validation of treatment parameters. @param message: response message from HD regarding validity of provided treatment parameters.\n - U32 Minimum treatment duration setting (in min.). \n - U32 Maximum treatment duration setting (in min.). \n - F32 Minimum ultrafiltration volume (in mL). \n - F32 Maximum ultrafiltration volume (in mL). \n - U32 Minimum dialysate flow rate (in mL/min). \n - U32 Maximum dialysate flow rate (in mL/min). + U32 0=Treatment parameters are valid, 1=Treatment parameters are invalid. \n + U32 Reject reason code for blood flow rate (0=valid). \n + U32 Reject reason code for dialysate flow rate (0=valid). \n + U32 Reject reason code for treatment duration (0=valid). \n + U32 Reject reason code for Heparin pre-stop time (0=valid). \n + U32 Reject reason code for saline bolus volume (0=valid). \n + U32 Reject reason code for acid concentrate (0=valid). \n + U32 Reject reason code for bicarb concentrate (0=valid). \n + U32 Reject reason code for dialyzer type (0=valid). \n + U32 Reject reason code for BP measurement interval (0=valid). \n + U32 Reject reason code for rinseback flow rate (0=valid). \n + U32 Reject reason code for arterial pressure low alarm limit (0=valid). \n + U32 Reject reason code for arterial pressure high alarm limit (0=valid). \n + U32 Reject reason code for venous pressure low alarm limit (0=valid). \n + U32 Reject reason code for venous pressure high alarm limit (0=valid). \n + U32 Reject reason code for Heparin dispense rate (0=valid). \n + U32 Reject reason code for Heparin bolus volume (0=valid). \n + U32 Reject reason code for dialysate temperature (0=valid). \n @return: none """ - mintime = struct.unpack('i', bytearray( - message['message'][self.START_POS_MIN_TREAT_TIME:self.END_POS_MIN_TREAT_TIME])) - maxtime = struct.unpack('i', bytearray( - message['message'][self.START_POS_MAX_TREAT_TIME:self.END_POS_MAX_TREAT_TIME])) - minufvol = struct.unpack('f', bytearray( - message['message'][self.START_POS_MIN_UF_VOL:self.END_POS_MIN_UF_VOL])) - maxufvol = struct.unpack('f', bytearray( - message['message'][self.START_POS_MAX_UF_VOL:self.END_POS_MAX_UF_VOL])) - mindialrt = struct.unpack('i', bytearray( - message['message'][self.START_POS_MIN_DIAL_RATE:self.END_POS_MIN_DIAL_RATE])) - maxdialrt = struct.unpack('i', bytearray( - message['message'][self.START_POS_MAX_DIAL_RATE:self.END_POS_MAX_DIAL_RATE])) + p = DenaliMessage.PAYLOAD_START_INDEX + val = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + bld = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + dia = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + dur = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + sto = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + sal = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + acd = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + bic = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + dlz = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + bpi = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + rbf = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + apl = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + aph = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + vpl = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + vph = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + hdr = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + hbv = struct.unpack('i', bytearray(message['message'][p:p+4])) + p += 4 + tmp = struct.unpack('i', bytearray(message['message'][p:p+4])) - self.min_treatment_duration_min = mintime[0] - self.max_treatment_duration_min = maxtime[0] - self.min_uf_volume_ml = minufvol[0] - self.max_uf_volume_ml = maxufvol[0] - self.min_dialysate_flow_rate_ml_min = mindialrt[0] - self.max_dialysate_flow_rate_ml_min = maxdialrt[0] + if val[0] == 1: + self.treatment_parameters_valid = True + else: + self.treatment_parameters_valid = False + self.blood_flow_rate_reject_reason = bld[0] + self.dialysate_flow_rate_reject_reason = dia[0] + self.treatment_duration_reject_reason = dur[0] + self.heparin_pre_stop_time_reject_reason = sto[0] + self.saline_bolus_volume_reject_reason = sal[0] + self.acid_concentrate_reject_reason = acd[0] + self.bicarb_concentrate_reject_reason = bic[0] + self.dialyzer_type_reject_reason = dlz[0] + self.blood_pressure_meas_interval_reject_reason = bpi[0] + self.rinseback_flow_rate_reject_reason = rbf[0] + self.arterial_pressure_low_alarm_limit_reject_reason = apl[0] + self.arterial_pressure_high_alarm_limit_reject_reason = aph[0] + self.venous_pressure_low_alarm_limit_reject_reason = vpl[0] + self.venous_pressure_high_alarm_limit_reject_reason = vph[0] + self.heparin_dispense_rate_reject_reason = hdr[0] + self.heparin_bolus_volume_reject_reason = hbv[0] + self.dialysate_temperature_reject_reason = tmp[0] @_publish([ "min_treatment_duration_min", @@ -639,10 +864,8 @@ self.uf_change_succeeded = resp self.uf_change_reject_reason = rea[0] - self.uf_change_volume_ml = vol[0] / self.LITER_TO_ML_CONVERSION_FACTOR + self.uf_change_volume_ml = vol[0] #/ self.LITER_TO_ML_CONVERSION_FACTOR - #self.uf_change_volume_ml = vol[0] In the staging branch commented out - self.uf_change_time_min = tim[0] self.uf_change_time_diff = tmd[0] self.uf_change_rate_ml_min = rat[0] @@ -747,7 +970,7 @@ """ # reset response to this command so we can tell when response is received - self.UFChangeResponse = None + #self.UFChangeResponse = None # build command message volume = float_to_bytearray(vol * self.LITER_TO_ML_CONVERSION_FACTOR) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, @@ -771,7 +994,7 @@ """ # reset response to this command so we can tell when response is received - self.UFChangeResponse = None + #self.UFChangeResponse = None # build command message volume = float_to_bytearray(vol * self.LITER_TO_ML_CONVERSION_FACTOR) @@ -884,22 +1107,6 @@ return 0 - def cmd_ui_confirm_treatment_parameters(self): - """ - Constructs and sends a ui confirm treatment parameters message - - @return: none - """ - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=self.MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS) - - print("Sending confirm treatment parameters messge.") - - self.can_interface.send(message, 0) - - return 0 - def set_treatment_parameters(self, bld_flow, dia_flow, duration, hep_rate, hep_bol, hep_stop, sal_bol, acid, bicarb, dialyzer, dia_temp, art_low, art_high, ven_low, ven_high, bp_intvl, rb_flow): @@ -931,40 +1138,40 @@ self.blood_flow_rate = bld_flow self.dialysate_flow_rate = dia_flow self.treatment_duration = duration - self.heparin_dispense_rate = hep_rate - self.heparin_bolus_volume = hep_bol self.heparin_pre_stop_time = hep_stop self.saline_bolus_volume = sal_bol self.acid_concentrate = acid self.bicarb_concentrate = bicarb self.dialyzer_type = dialyzer - self.dialysate_temperature = dia_temp + self.blood_pressure_meas_interval = bp_intvl + self.rinseback_flow_rate = rb_flow self.arterial_pressure_low_alarm_limit = art_low self.arterial_pressure_high_alarm_limit = art_high self.venous_pressure_low_alarm_limit = ven_low self.venous_pressure_high_alarm_limit = ven_high - self.blood_pressure_meas_interval = bp_intvl - self.rinseback_flow_rate = rb_flow + self.heparin_dispense_rate = hep_rate + self.heparin_bolus_volume = hep_bol + self.dialysate_temperature = dia_temp bld = integer_to_bytearray(bld_flow) dia = integer_to_bytearray(dia_flow) dur = integer_to_bytearray(duration) - hdr = float_to_bytearray(hep_rate) - hbv = float_to_bytearray(hep_bol) hps = integer_to_bytearray(hep_stop) sal = integer_to_bytearray(sal_bol) acc = integer_to_bytearray(acid) bic = integer_to_bytearray(bicarb) dzr = integer_to_bytearray(dialyzer) - tmp = float_to_bytearray(dia_temp) + bpi = integer_to_bytearray(bp_intvl) + rbf = integer_to_bytearray(rb_flow) apl = integer_to_bytearray(art_low) aph = integer_to_bytearray(art_high) vpl = integer_to_bytearray(ven_low) vph = integer_to_bytearray(ven_high) - bpi = integer_to_bytearray(bp_intvl) - rbf = integer_to_bytearray(rb_flow) + hdr = float_to_bytearray(hep_rate) + hbv = float_to_bytearray(hep_bol) + tmp = float_to_bytearray(dia_temp) - payload = bld+dia+dur+hdr+hbv+hps+sal+acc+bic+dzr+tmp+apl+aph+vpl+vph+bpi+rbf + payload = bld+dia+dur+hps+sal+acc+bic+dzr+bpi+rbf+apl+aph+vpl+vph+hdr+hbv+tmp message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_UI_NEW_TREATMENT_PARAMS, payload=payload) @@ -974,3 +1181,19 @@ self.can_interface.send(message, 0) return 0 + + def cmd_ui_confirm_treatment_parameters(self): + """ + Constructs and sends a ui confirm treatment parameters message + + @return: none + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=self.MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS) + + print("Sending confirm treatment parameters messge.") + + self.can_interface.send(message, 0) + + return 0