""" The Ultrafiltration ui loader """ # 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 Ultrafiltration ui loader """ tbSend: QtWidgets.QToolButton tbReset: QtWidgets.QToolButton tblSubMode: QtWidgets.QTableWidget tblUFStates: QtWidgets.QTableWidget tblSalineStates: QtWidgets.QTableWidget tblHeparinStates: QtWidgets.QTableWidget tblRinsebackStates: QtWidgets.QTableWidget tblRecirculateStates: QtWidgets.QTableWidget tblBloodPrimeStates: QtWidgets.QTableWidget tblTreatmentEndStates: QtWidgets.QTableWidget tblTreatmentStopStates: QtWidgets.QTableWidget def __init__(self, interface: SimulationInterface): super().__init__(os.path.dirname(__file__), interface) def _init_loader(self): """ finds and creates widgets :return: none """ self.tbSend = self.find_tool_button('tbSend') self.tbReset = self.find_tool_button('tbReset') self.tblSubMode = self.find_table_widget('tblSubMode') self.tblUFStates = self.find_table_widget('tblUFStates') self.tblSalineStates = self.find_table_widget('tblSalineStates') self.tblHeparinStates = self.find_table_widget('tblHeparinStates') self.tblRinsebackStates = self.find_table_widget('tblRinsebackStates') self.tblRecirculateStates = self.find_table_widget('tblRecirculateStates') self.tblBloodPrimeStates = self.find_table_widget('tblBloodPrimeStates') self.tblTreatmentEndStates = self.find_table_widget('tblTreatmentEndStates') self.tblTreatmentStopStates = self.find_table_widget('tblTreatmentStopStates') def _init_connections(self): """ initializes the widgets connections :return: none """ self.tbReset.clicked.connect(self._init_widgets) self.tbSend.clicked.connect(self.do_treatment_states) self.tblSubMode.currentCellChanged.connect(self.do_treatment_states) self.tblUFStates.currentCellChanged.connect(self.do_treatment_states) self.tblSalineStates.currentCellChanged.connect(self.do_treatment_states) self.tblHeparinStates.currentCellChanged.connect(self.do_treatment_states) self.tblRinsebackStates.currentCellChanged.connect(self.do_treatment_states) self.tblRecirculateStates.currentCellChanged.connect(self.do_treatment_states) self.tblBloodPrimeStates.currentCellChanged.connect(self.do_treatment_states) self.tblTreatmentEndStates.currentCellChanged.connect(self.do_treatment_states) self.tblTreatmentStopStates.currentCellChanged.connect(self.do_treatment_states) # apply/send the initial states # self.do_treatment_states() @Slot() def _init_widgets(self): """ initializes the widgets' properties :return: none """ self.tblSubMode.setCurrentCell(TXStates.TREATMENT_START_STATE, 0) self.tblUFStates.setCurrentCell(TXStates.UF_RUNNING_STATE, 0) self.tblSalineStates.setCurrentCell(TXStates.SALINE_BOLUS_STATE_IDLE, 0) self.tblHeparinStates.setCurrentCell(TXStates.HEPARIN_STATE_OFF, 0) self.tblRinsebackStates.setCurrentCell(TXStates.RINSEBACK_STOP_INIT_STATE, 0) self.tblRecirculateStates.setCurrentCell(TXStates.TREATMENT_RECIRC_RECIRC_STATE, 0) self.tblBloodPrimeStates.setCurrentCell(TXStates.BLOOD_PRIME_RAMP_STATE, 0) self.tblTreatmentEndStates.setCurrentCell(TXStates.TREATMENT_END_WAIT_FOR_RINSEBACK_STATE, 0) self.tblTreatmentStopStates.setCurrentCell(TXStates.TREATMENT_STOP_RECIRC_STATE, 0) @Slot() def do_treatment_states(self): """ the slot for saline bolus state change :return: none """ sub_mode = int(self.tblSubMode.verticalHeaderItem(self.tblSubMode.currentRow()).text()) uf_state = int(self.tblUFStates.verticalHeaderItem(self.tblUFStates.currentRow()).text()) saline = int(self.tblSalineStates.verticalHeaderItem(self.tblSalineStates.currentRow()).text()) heparin = int(self.tblHeparinStates.verticalHeaderItem(self.tblHeparinStates.currentRow()).text()) rinseback = int(self.tblRinsebackStates.verticalHeaderItem(self.tblRinsebackStates.currentRow()).text()) recirculate = int(self.tblRecirculateStates.verticalHeaderItem(self.tblRecirculateStates.currentRow()).text()) blood_prime = int(self.tblBloodPrimeStates.verticalHeaderItem(self.tblBloodPrimeStates.currentRow()).text()) treatment_end = int(self.tblTreatmentEndStates.verticalHeaderItem(self.tblTreatmentEndStates.currentRow()).text()) treatment_stop = int(self.tblTreatmentStopStates.verticalHeaderItem(self.tblTreatmentStopStates.currentRow()).text()) self.interface.hd.cmd_set_treatment_states_data( sub_mode, uf_state, saline, heparin, rinseback, recirculate, blood_prime, treatment_end, treatment_stop )