""" The Disposable Prime 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 # plugin specific # -- none -- class Loader(DynamicLoader): """ The Saline Bolus ui loader class """ rbHD: QtWidgets.QRadioButton rbDG: QtWidgets.QRadioButton leMessageID: QtWidgets.QLineEdit leTargetMax: QtWidgets.QLineEdit sldTimeout: QtWidgets.QSlider sldCountdown: QtWidgets.QSlider 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.rbHD = self.find_radio_button('rbHD') self.rbDG = self.find_radio_button('rbDG') self.leMessageID = self.find_line_edit('leMessageID') self.leTargetMax = self.find_line_edit('leTargetMax') self.sldTimeout = self.find_slider('sldTimeout') self.sldCountdown = self.find_slider('sldCountdown') def _init_widgets(self): """ initializes the widgets' properties :return: none """ pass def _init_connections(self): """ initializes the widgets connections :return: """ self.leTargetMax.textChanged.connect(self.do_set_target_maximum) self.sldTimeout.valueChanged.connect(self.do_data) self.sldCountdown.valueChanged.connect(self.do_data) @Slot() def do_set_target_maximum(self, value): """ sets the target slider maximum to the value of value :return: none """ self.sldTimeout.setMaximum(int(value)) self.sldCountdown.setMaximum(int(value)) @Slot() def do_data(self): """ the slot which is called to send the data by calling the denaliMessage API cmd_send_treatment_blood_prime_data :return: none """ message_id = self.leMessageID.text() timeout = self.sldTimeout.value() countdown = self.sldCountdown.value() if self.rbHD.isChecked(): self.hd_simulator.cmd_send_general_hd_progress_data(int(message_id), timeout, countdown) else: self.hd_simulator.cmd_send_general_dg_progress_data(int(message_id), timeout, countdown)