""" The Heparin 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 simulator.interface import SimulationInterface from dialin.ui.hd_simulator import TXStates # plugin specific # -- none -- class Loader(DynamicLoader): """ The Saline Bolus ui loader class """ btnAccept: QtWidgets.QPushButton btnReject: QtWidgets.QPushButton lblAction: QtWidgets.QLabel spnRejectReason: QtWidgets.QSpinBox sldTarget: QtWidgets.QSlider sldCurrent: QtWidgets.QSlider sldRate: QtWidgets.QSlider sldTimeoutTotal: QtWidgets.QSlider sldTimeoutCountDown: QtWidgets.QSlider requested_state: TXStates def __init__(self, interface: SimulationInterface): super().__init__(os.path.dirname(__file__), interface) self.requested_state = TXStates.RINSEBACK_STOP_INIT_STATE def _init_loader(self): """ finds and creates widgets :return: none """ # rinseback adjustment self.btnAccept = self.find_button('btnAccept') self.btnReject = self.find_button('btnReject') self.lblAction = self.find_label('lblAction') self.spnRejectReason = self.find_spinbox('spnRejectReason') # rinseback data self.sldTarget = self.find_slider('sldTarget') self.sldCurrent = self.find_slider('sldCurrent') self.sldRate = self.find_slider('sldRate') self.sldTimeoutTotal = self.find_slider('sldTimeoutTotal') self.sldTimeoutCountDown = self.find_slider('sldTimeoutCountDown') def _init_widgets(self): """ initializes the widgets' properties :return: none """ pass def _init_connections(self): """ initializes the widgets connections :return: """ # rinseback adjustment self.btnAccept.clicked.connect(self.do_accept) self.btnReject.clicked.connect(self.do_reject) # rinseback data self.sldTarget.valueChanged.connect(self.do_data) self.sldCurrent.valueChanged.connect(self.do_data) self.sldRate.valueChanged.connect(self.do_data) self.sldTimeoutTotal.valueChanged.connect(self.do_data) self.sldTimeoutCountDown.valueChanged.connect(self.do_data) @Slot() def do_accept(self): """ the slot for accept button :return: none """ self.interface.hd.cmd_send_treatment_adjust_rinseback_response(True, 0) self.lblAction.setText('Accepted ') @Slot() def do_reject(self): """ the slot for accept saline bolus button :return: none """ reason = self.spnRejectReason.value() self.interface.hd.cmd_send_treatment_adjust_rinseback_response(False, reason) self.lblAction.setText('Rejected ' + "{}".format(reason)) @Slot() def do_data(self): """ the slot which is called to send the data by calling the denaliMessage API cmd_send_treatment_rinseback_data :return: none """ target = self.sldTarget.value() current = self.sldCurrent.value() rate = self.sldRate.value() timeout_total = self.sldTimeoutTotal.value() timeout_countdown = self.sldTimeoutCountDown.value() self.interface.hd.cmd_send_treatment_rinseback_data(target, current, rate, timeout_total, timeout_countdown)