""" The ui loader class """ # Python import os # Qt from PySide2 import QtWidgets from PySide2.QtCore import Slot # parent from simulator.dynamicloader import DynamicLoader # hd Simulator from dialin.ui.hd_simulator import HDSimulator from dialin.ui.hd_simulator import RequestRejectReasons from dialin.utils.conversions import unsigned_to_bytearray, float_to_bytearray # plugin specific # -- None -- class Loader(DynamicLoader): """ The ui loader class """ btnAcceptDisposableConfirm: QtWidgets.QPushButton btnRejectDisposableConfirm: QtWidgets.QPushButton spnReasonDisposableConfirm: QtWidgets.QSpinBox lblActionDisposableConfirm: QtWidgets.QLabel btnAcceptTxLog: QtWidgets.QPushButton btnRejectTxLog: QtWidgets.QPushButton spnReasonTxLog: QtWidgets.QSpinBox lblActionTxLog: QtWidgets.QLabel leBloodFlowRate: QtWidgets.QLineEdit leDialysateFlowRate: QtWidgets.QLineEdit leTreatmentDuration: QtWidgets.QLineEdit leActualTreatmentDuration: QtWidgets.QLineEdit leAcidConcentrateType: QtWidgets.QLineEdit leBicarbonateConcentrateType: QtWidgets.QLineEdit lePotassiumConcentration: QtWidgets.QLineEdit leCalciumConcentration: QtWidgets.QLineEdit leBicarbonateConcentration: QtWidgets.QLineEdit leSodiumConcentration: QtWidgets.QLineEdit leDialysateTemperature: QtWidgets.QLineEdit leDialyzerType: QtWidgets.QLineEdit leTreatmentDateTime: QtWidgets.QLineEdit leAverageBloodFlow: QtWidgets.QLineEdit leAverageDialysateFlow: QtWidgets.QLineEdit leDialysateVolumeUsed: QtWidgets.QLineEdit leAverageDialysateTemp: QtWidgets.QLineEdit leTargetUFVolume: QtWidgets.QLineEdit leActualUFVolume: QtWidgets.QLineEdit leTargetUFRate: QtWidgets.QLineEdit leActualUFRate: QtWidgets.QLineEdit leSalineBolusVolume: QtWidgets.QLineEdit leHeparinType: QtWidgets.QLineEdit leHeparinConcentration: QtWidgets.QLineEdit leHeparinBolusVolume: QtWidgets.QLineEdit leHeparinDispenseRate: QtWidgets.QLineEdit leHeparinPreStop: QtWidgets.QLineEdit leHeparinDeliveredVolume: QtWidgets.QLineEdit leAverageArterialPressure: QtWidgets.QLineEdit leAverageVenousPressure: QtWidgets.QLineEdit leEndTreatmentEarlyAlarm: QtWidgets.QLineEdit leDeviceID: QtWidgets.QLineEdit leWaterSampleTestResult: QtWidgets.QLineEdit btnTxLogDataSend: QtWidgets.QPushButton leTxLogDataBloodFlowRate: QtWidgets.QLineEdit leTxLogDataDialysateFlowRate: QtWidgets.QLineEdit leTxLogDataUFRate: QtWidgets.QLineEdit leTxLogDataArterialPressure: QtWidgets.QLineEdit leTxLogDataVenousPressure: QtWidgets.QLineEdit btnTxLogAlarmSend: QtWidgets.QPushButton leTxLogAlarmID: QtWidgets.QLineEdit leTxLogAlarmP1: QtWidgets.QLineEdit leTxLogAlarmP2: QtWidgets.QLineEdit btnTxLogEventSend: QtWidgets.QPushButton leTxLogEventID: QtWidgets.QLineEdit leTxLogEventOld: QtWidgets.QLineEdit leTxLogEventNew: QtWidgets.QLineEdit def __init__(self, hd_simulator: HDSimulator): super().__init__(os.path.dirname(__file__), hd_simulator) def _init_loader(self): """ finds and creates widgets :return: none """ self.btnAcceptDisposableConfirm = self.find_button('btnAcceptDisposableConfirm') self.btnRejectDisposableConfirm = self.find_button('btnRejectDisposableConfirm') self.spnReasonDisposableConfirm = self.find_spinbox('spnReasonDisposableConfirm') self.lblActionDisposableConfirm = self.find_label('lblActionDisposableConfirm') self.btnAcceptTxLog = self.find_button('btnAcceptTxLog') self.btnRejectTxLog = self.find_button('btnRejectTxLog') self.spnReasonTxLog = self.find_spinbox('spnReasonTxLog') self.lblActionTxLog = self.find_label('lblActionTxLog') self.leBloodFlowRate = self.find_line_edit('leBloodFlowRate') self.leDialysateFlowRate = self.find_line_edit('leDialysateFlowRate') self.leTreatmentDuration = self.find_line_edit('leTreatmentDuration') self.leActualTreatmentDuration = self.find_line_edit('leActualTreatmentDuration') self.leAcidConcentrateType = self.find_line_edit('leAcidConcentrateType') self.leBicarbonateConcentrateType = self.find_line_edit('leBicarbonateConcentrateType') self.lePotassiumConcentration = self.find_line_edit('lePotassiumConcentration') self.leCalciumConcentration = self.find_line_edit('leCalciumConcentration') self.leBicarbonateConcentration = self.find_line_edit('leBicarbonateConcentration') self.leSodiumConcentration = self.find_line_edit('leSodiumConcentration') self.leDialysateTemperature = self.find_line_edit('leDialysateTemperature') self.leDialyzerType = self.find_line_edit('leDialyzerType') self.leTreatmentDateTime = self.find_line_edit('leTreatmentDateTime') self.leAverageBloodFlow = self.find_line_edit('leAverageBloodFlow') self.leAverageDialysateFlow = self.find_line_edit('leAverageDialysateFlow') self.leDialysateVolumeUsed = self.find_line_edit('leDialysateVolumeUsed') self.leAverageDialysateTemp = self.find_line_edit('leAverageDialysateTemp') self.leTargetUFVolume = self.find_line_edit('leTargetUFVolume') self.leActualUFVolume = self.find_line_edit('leActualUFVolume') self.leTargetUFRate = self.find_line_edit('leTargetUFRate') self.leActualUFRate = self.find_line_edit('leActualUFRate') self.leSalineBolusVolume = self.find_line_edit('leSalineBolusVolume') self.leHeparinType = self.find_line_edit('leHeparinType') self.leHeparinConcentration = self.find_line_edit('leHeparinConcentration') self.leHeparinBolusVolume = self.find_line_edit('leHeparinBolusVolume') self.leHeparinDispenseRate = self.find_line_edit('leHeparinDispenseRate') self.leHeparinPreStop = self.find_line_edit('leHeparinPreStop') self.leHeparinDeliveredVolume = self.find_line_edit('leHeparinDeliveredVolume') self.leAverageArterialPressure = self.find_line_edit('leAverageArterialPressure') self.leAverageVenousPressure = self.find_line_edit('leAverageVenousPressure') self.leEndTreatmentEarlyAlarm = self.find_line_edit('leEndTreatmentEarlyAlarm') self.leDeviceID = self.find_line_edit('leDeviceID') self.leWaterSampleTestResult = self.find_line_edit('leWaterSampleTestResult') self.btnTxLogDataSend = self.find_button('btnTxLogDataSend') self.leTxLogDataBloodFlowRate = self.find_line_edit('leTxLogDataBloodFlowRate') self.leTxLogDataDialysateFlowRate = self.find_line_edit('leTxLogDataDialysateFlowRate') self.leTxLogDataUFRate = self.find_line_edit('leTxLogDataUFRate') self.leTxLogDataArterialPressure = self.find_line_edit('leTxLogDataArterialPressure') self.leTxLogDataVenousPressure = self.find_line_edit('leTxLogDataVenousPressure') self.btnTxLogAlarmSend = self.find_button('btnTxLogAlarmSend') self.leTxLogAlarmID = self.find_line_edit('leTxLogAlarmID') self.leTxLogAlarmP1 = self.find_line_edit('leTxLogAlarmP1') self.leTxLogAlarmP2 = self.find_line_edit('leTxLogAlarmP2') self.btnTxLogEventSend = self.find_button('btnTxLogEventSend') self.leTxLogEventID = self.find_line_edit('leTxLogEventID') self.leTxLogEventOld = self.find_line_edit('leTxLogEventOld') self.leTxLogEventNew = self.find_line_edit('leTxLogEventNew') def _init_widgets(self): """ initializes the widgets' properties :return: none """ pass def _init_connections(self): """ initializes the widgets connections :return: """ self.btnAcceptDisposableConfirm.clicked.connect(self.do_accept_disposable_confirm) self.btnRejectDisposableConfirm.clicked.connect(self.do_reject_disposable_confirm) self.btnTxLogDataSend.clicked.connect(self.do_send_tx_log_data) self.btnTxLogAlarmSend.clicked.connect(self.do_send_tx_log_alarm) self.btnTxLogEventSend.clicked.connect(self.do_send_tx_log_event) self.btnAcceptTxLog.clicked.connect(self.do_accept_tx_log) self.btnRejectTxLog.clicked.connect(self.do_reject_tx_log) @Slot() def do_send_tx_log_data(self): """ sends the treatment log data (Average 30 min) values :return: """ tx_log_data_blood_flow_rate = int(self.leTxLogDataBloodFlowRate.text()) tx_log_data_dialysate_flow_rate = int(self.leTxLogDataDialysateFlowRate.text()) tx_log_data_uf_rate = float(self.leTxLogDataUFRate.text()) tx_log_data_arterial_pressure = float(self.leTxLogDataArterialPressure.text()) tx_log_data_venous_pressure = float(self.leTxLogDataVenousPressure.text()) self.hd_simulator.cmd_send_treatment_log_data(tx_log_data_blood_flow_rate, tx_log_data_dialysate_flow_rate, tx_log_data_uf_rate, tx_log_data_arterial_pressure, tx_log_data_venous_pressure) @Slot() def do_send_tx_log_alarm(self): """ sends the treatment log alarm list of values :return: """ tx_log_alarm_id = int(self.leTxLogAlarmID.text()) tx_log_alarm_parameter1 = int(self.leTxLogAlarmP1.text()) tx_log_alarm_parameter2 = int(self.leTxLogAlarmP2.text()) self.hd_simulator.cmd_send_treatment_log_alarm(tx_log_alarm_id, tx_log_alarm_parameter1, tx_log_alarm_parameter2) @Slot() def do_send_tx_log_event(self): """ sends the treatment log event list of values :return: """ tx_log_event_id = int(self.leTxLogEventID.text()) tx_log_event_old_value = float(self.leTxLogEventOld.text()) tx_log_event_new_value = float(self.leTxLogEventNew.text()) self.hd_simulator.cmd_send_treatment_log_event(tx_log_event_id, tx_log_event_old_value, tx_log_event_new_value) @Slot() def do_accept_disposable_confirm(self): """ the slot for accept button :return: none """ self.hd_simulator.cmd_send_post_treatment_disposable_removal_confirm_response(True, 0) self.lblActionDisposableConfirm.setText('Accepted') @Slot() def do_reject_disposable_confirm(self): """ the slot for reject button :return: none """ reason = self.spnReasonDisposableConfirm.value() self.hd_simulator.cmd_send_post_treatment_disposable_removal_confirm_response(False, reason) self.lblActionDisposableConfirm.setText('Rejected ' + "{}".format(reason)) @Slot() def do_accept_tx_log(self): """ the slot for accept button :return: none """ parameters = [ # column 1 unsigned_to_bytearray(int(self.leBloodFlowRate.text())), unsigned_to_bytearray(int(self.leDialysateFlowRate.text())), unsigned_to_bytearray(int(self.leTreatmentDuration.text())), unsigned_to_bytearray(int(self.leActualTreatmentDuration.text())), unsigned_to_bytearray(int(self.leAcidConcentrateType.text())), unsigned_to_bytearray(int(self.leBicarbonateConcentrateType.text())), unsigned_to_bytearray(int(self.lePotassiumConcentration.text())), unsigned_to_bytearray(int(self.leCalciumConcentration.text())), unsigned_to_bytearray(int(self.leBicarbonateConcentration.text())), unsigned_to_bytearray(int(self.leSodiumConcentration.text())), float_to_bytearray(float(self.leDialysateTemperature.text())), unsigned_to_bytearray(int(self.leDialyzerType.text())), unsigned_to_bytearray(int(self.leTreatmentDateTime.text())), float_to_bytearray(float(self.leAverageBloodFlow.text())), float_to_bytearray(float(self.leAverageDialysateFlow.text())), float_to_bytearray(float(self.leDialysateVolumeUsed.text())), float_to_bytearray(float(self.leAverageDialysateTemp.text())), # column 2 float_to_bytearray(float(self.leTargetUFVolume.text())), float_to_bytearray(float(self.leActualUFVolume.text())), float_to_bytearray(float(self.leTargetUFRate.text())), float_to_bytearray(float(self.leActualUFRate.text())), unsigned_to_bytearray(int(self.leSalineBolusVolume.text())), unsigned_to_bytearray(int(self.leHeparinType.text())), unsigned_to_bytearray(int(self.leHeparinConcentration.text())), float_to_bytearray(float(self.leHeparinBolusVolume.text())), float_to_bytearray(float(self.leHeparinDispenseRate.text())), unsigned_to_bytearray(int(self.leHeparinPreStop.text())), float_to_bytearray(float(self.leHeparinDeliveredVolume.text())), float_to_bytearray(float(self.leAverageArterialPressure.text())), float_to_bytearray(float(self.leAverageVenousPressure.text())), unsigned_to_bytearray(int(self.leEndTreatmentEarlyAlarm.text())), unsigned_to_bytearray(int(self.leDeviceID.text())), unsigned_to_bytearray(int(self.leWaterSampleTestResult.text())) ] self.hd_simulator.cmd_send_post_treatment_log_response(True, 0, parameters) self.lblActionTxLog.setText('Accepted ') @Slot() def do_reject_tx_log(self): """ the slot for reject button :return: none """ parameters = [ # column 1 unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), float_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), # column 2 float_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), unsigned_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), float_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0), unsigned_to_bytearray(0) ] reason = self.spnReasonTxLog.value() self.hd_simulator.cmd_send_post_treatment_log_response(False, reason, parameters) self.lblActionTxLog.setText('Rejected ' + "{}".format(reason))