Index: dialin/common/msg_ids.py =================================================================== diff -u -rd832b9ec145bf0c8bf3bf0bdc4844d146a60e600 -rd50fb22ae4b013ec67356cbcd058f219de22a67a --- dialin/common/msg_ids.py (.../msg_ids.py) (revision d832b9ec145bf0c8bf3bf0bdc4844d146a60e600) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision d50fb22ae4b013ec67356cbcd058f219de22a67a) @@ -247,8 +247,8 @@ MSG_ID_HD_AIR_TRAP_SEND_INTERVAL_OVERRIDE = 0X8032 MSG_ID_HD_AIR_TRAP_LEVEL_SENSOR_OVERRIDE = 0X8033 MSG_ID_HD_SOFTWARE_RESET_REQUEST = 0X8034 - MSG_ID_HD_GET_SW_CONFIG_RECORD = 0x8035 - MSG_ID_HD_SET_SW_CONFIG_RECORD = 0x8036 + MSG_ID_HD_GET_SW_CONFIG_RECORD = 0X8035 + MSG_ID_HD_SET_SW_CONFIG_RECORD = 0X8036 MSG_ID_BLOOD_PUMP_HOME_CMD = 0X8037 MSG_ID_DIAL_IN_PUMP_HOME_CMD = 0X8038 MSG_ID_DIAL_OUT_PUMP_HOME_CMD = 0X8039 @@ -315,6 +315,8 @@ MSG_ID_HD_SYRINGE_PUMP_FORCE_SENSOR_DAC_CALIBRATE = 0x8077 MSG_ID_HD_STOP_RTC_CLOCK = 0x8078 MSG_ID_HD_FANS_DUTY_CYCLE_OVERRIDE = 0x8079 + MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS = 0X8080 + MSG_ID_HD_RES_CURRENT_TREATMENT_PARAMETERS = 0X8081 MSG_ID_DG_TESTER_LOGIN_REQUEST = 0XA000 MSG_ID_DG_ALARM_STATE_OVERRIDE = 0XA001 Index: dialin/hd/treatment.py =================================================================== diff -u -r9dcbb4f172b53560d8bae26363a16b906a1ba135 -rd50fb22ae4b013ec67356cbcd058f219de22a67a --- dialin/hd/treatment.py (.../treatment.py) (revision 9dcbb4f172b53560d8bae26363a16b906a1ba135) +++ dialin/hd/treatment.py (.../treatment.py) (revision d50fb22ae4b013ec67356cbcd058f219de22a67a) @@ -110,6 +110,10 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_treatment_stop_timer_data_sync) + msg_id = MsgIds.MSG_ID_HD_RES_CURRENT_TREATMENT_PARAMETERS.value + self.can_interface.register_receiving_publication_function(DenaliChannels.hd_to_dialin_ch_id, msg_id, + self._handler_treatment_current_parameters) + # treatment duration data self.treatment_time_prescribed = 0 self.treatment_time_elapsed = 0 @@ -144,6 +148,27 @@ self.treatment_stop_timeout_secs = 0 self.treatment_stop_timeout_coundown_secs = 0 + self.current_treatment_param_dict = {} + self.current_blood_flow = 0 + self.current_dialysate_flow = 0 + self.current_treatment_duration = 0 + self.current_heparin_pre_stop = 0 + self.current_saline_bolus_volume = 0 + self.current_acid_concentrate = 0 + self.current_bicarb_concentrate = 0 + self.current_dialyzer_type = 0 + self.current_heparin_type = 0 + self.current_blood_pressure_measurement_interval = 0 + self.current_rinseback_flow_rate = 0 + self.current_arterial_low = 0 + self.current_arterial_high = 0 + self.current_venous_low = 0 + self.current_venous_high = 0 + self.current_heparin_bolus = 0 + self.current_heparin_dispense = 0 + self.current_dialysate_temp = 0 + self.current_uf_volume = 0 + def reset(self) -> None: """ Reset all treatment variables @@ -383,6 +408,37 @@ """ return self.recirc_countdown_secs + def get_current_treatment_parameters(self) -> dict: + """ + Returns current treatment parameters in a dictionary + + @return: self.current_treatment_param_dict + """ + self.current_treatment_param_dict = { + "blood_flow": self.current_blood_flow, + "dialysate_flow" : self.current_dialysate_flow, + "treatment_duration" : self.current_treatment_duration, + "heparin_pre_stop" : self.current_heparin_pre_stop, + "saline_bolus" : self.current_saline_bolus_volume, + "acid_concentrate" : self.current_acid_concentrate, + "bicarb_concetrate" : self.current_bicarb_concentrate, + "dialyzer_type" : self.current_dialyzer_type, + "heparin_type" : self.current_heparin_type, + "blood_pressure_interval" : self.current_blood_pressure_measurement_interval, + "rinseback_flow_rate" : self.current_rinseback_flow_rate, + "arterial_low" : self.current_arterial_low, + "arterial_high" : self.current_arterial_high, + "venous_low" : self.current_venous_low, + "venous_high" : self.current_venous_high, + "heparin_bolus" : self.current_heparin_bolus, + "heparin_dispense" : self.current_heparin_dispense, + "dialysate_temp" : self.current_dialysate_temp, + "uf_volume" : self.current_uf_volume + } + + return self.current_treatment_param_dict + + @publish([ "treatment_time_prescribed", "treatment_time_elapsed", @@ -582,6 +638,82 @@ self.treatment_stop_timeout_secs = tmo[0] self.treatment_stop_timeout_coundown_secs = cnd[0] + @publish(["accepted", "current_blood_flow", "current_dialysate_flow", + "current_treatment_duration", "current_heparin_pre_stop", "current_saline_bolus_volume", + "current_acid_concentrate", "current_bicarb_concentrate", "current_dialyzer_type", + "current_heparin_type", "current_blood_pressure_measurement_interval", "current_rinseback_flow_rate", + "current_arterial_low", "current_arterial_high", "current_venous_low", + "current_venous_high", "current_heparin_bolus", "current_heparin_dispense", + "current_dialysate_temp", "current_uf_volume"]) + def _handler_treatment_current_parameters(self, message) -> None: + """ + Handles published current treatment parameters messages. + + @param message: published current treatment parameters data message. + @return: None + """ + accepted = struct.unpack(' int: """ Constructs and sends the set blood flow rate treatment parameter command. @@ -1550,3 +1682,27 @@ self.logger.debug("Timeout!!!!") return False + def cmd_request_current_treatment_parameters(self): + """ + Constructs and sends the current treatment parameters request message + Constraints: + Must be logged into HD. + + @return: 1 if successful, zero otherwise + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS.value) + + self.logger.debug("Requesting current Treatment Parameters from HD.") + + # Send message + received_message = self.can_interface.send(message) + # If there is content... + if received_message is not None: + self.logger.debug("Current Treatment Parameter Request recieved.") + # response payload is OK or not OK + return True + else: + self.logger.debug("Timeout!!!!") + return False