Exemplo n.º 1
0
    def create_GUI(self):
        self.pbtn_step_activate = create_Toggle_button("Disabled")
        self.qled_step_size = QtWid.QLineEdit("1.0",alignment=
                                              QtCore.Qt.AlignRight)
        self.qled_step_size.setFixedWidth(70)

        grid_sub = QtWid.QGridLayout()
        grid_sub.addWidget(self.pbtn_step_activate  , 0, 0, 1, 3)
        grid_sub.addWidget(QtWid.QLabel("Step size"), 1, 0)
        grid_sub.addWidget(self.qled_step_size      , 1, 1)
        grid_sub.addWidget(QtWid.QLabel("mm")       , 1, 2)

        font_1 = QtGui.QFont("", 20)
        font_2 = QtGui.QFont("", 30)
        p1 = {'font': font_1, 'enabled': False}
        p2 = {'font': font_2, 'enabled': False}
        self.pbtn_step_up = QtWid.QPushButton(chr(0x25B2), **p1)
        self.pbtn_step_up.setFixedSize(50, 50)
        self.pbtn_step_down = QtWid.QPushButton(chr(0x25BC), **p1)
        self.pbtn_step_down.setFixedSize(50, 50)
        self.pbtn_step_left = QtWid.QPushButton(chr(0x25c0), **p2)
        self.pbtn_step_left.setFixedSize(50, 50)
        self.pbtn_step_right = QtWid.QPushButton(chr(0x25B6), **p2)
        self.pbtn_step_right.setFixedSize(50, 50)

        self.pted_focus_trap = QtWid.QPlainTextEdit('', enabled=False)
        self.pted_focus_trap.setFixedSize(0, 0)

        grid = QtWid.QGridLayout()
        grid.addLayout(grid_sub               , 0, 0, 1, 4)
        grid.addItem(QtWid.QSpacerItem(1, 12) , 1, 0)
        grid.addWidget(self.pbtn_step_up      , 2, 1, QtCore.Qt.AlignHCenter)
        grid.addWidget(self.pbtn_step_left    , 3, 0, QtCore.Qt.AlignHCenter)
        grid.addWidget(self.pbtn_step_right   , 3, 2, QtCore.Qt.AlignHCenter)
        grid.addWidget(self.pbtn_step_down    , 4, 1, QtCore.Qt.AlignHCenter)
        grid.addWidget(self.pted_focus_trap   , 5, 1, QtCore.Qt.AlignHCenter)

        self.grpb = QtWid.QGroupBox("Move single step")
        self.grpb.eventFilter = self.eventFilter
        self.grpb.installEventFilter(self.grpb)
        self.grpb.setStyleSheet(SS_GROUP)
        self.grpb.setLayout(grid)
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent, **kwargs)

        self.setGeometry(20, 60, 1200, 900)
        self.setWindowTitle("Calibration thermistors")

        # ----------------------------------------------------------------------
        #   Top frame
        # ----------------------------------------------------------------------

        # Left box
        vbox_left = QtWid.QVBoxLayout()
        vbox_left.addStretch(1)

        # Middle box
        self.lbl_title = QtWid.QLabel(text="Calibration thermistors",
                                      font=QtGui.QFont("Verdana", 12),
                                      minimumHeight=40)
        self.lbl_title.setStyleSheet(SS_TITLE)
        self.lbl_title.setAlignment(QtCore.Qt.AlignCenter)

        self.str_cur_date_time = QtWid.QLabel("00-00-0000    00:00:00")
        self.str_cur_date_time.setAlignment(QtCore.Qt.AlignCenter)

        self.qpbt_record = create_Toggle_button(
            "Click to start recording to file", minimumHeight=40)
        self.qpbt_record.setMinimumWidth(500)

        vbox_middle = QtWid.QVBoxLayout()
        vbox_middle.addWidget(self.lbl_title)
        vbox_middle.addWidget(self.str_cur_date_time)
        vbox_middle.addWidget(self.qpbt_record)

        # Right box
        self.qpbt_exit = QtWid.QPushButton("Exit")
        self.qpbt_exit.clicked.connect(self.close)
        self.qpbt_exit.setMinimumHeight(30)

        vbox_right = QtWid.QVBoxLayout()
        vbox_right.addWidget(self.qpbt_exit, stretch=0)
        vbox_right.addStretch(1)

        # Round up top frame
        hbox_top = QtWid.QHBoxLayout()
        hbox_top.addLayout(vbox_left, stretch=0)
        hbox_top.addStretch(1)
        hbox_top.addLayout(vbox_middle, stretch=0)
        hbox_top.addStretch(1)
        hbox_top.addLayout(vbox_right, stretch=0)

        # ----------------------------------------------------------------------
        #   Chart: Mux readings
        # ----------------------------------------------------------------------

        # GraphicsWindow
        self.gw_mux = pg.GraphicsWindow()
        self.gw_mux.setBackground([20, 20, 20])

        # PlotItem
        self.pi_mux = self.gw_mux.addPlot()
        self.pi_mux.setTitle(
            '<span style="font-size:12pt">Mux readings</span>')
        self.pi_mux.setLabel(
            'bottom', '<span style="font-size:12pt">history (min)</span>')
        self.pi_mux.setLabel(
            'left', '<span style="font-size:12pt">misc. units</span>')
        self.pi_mux.showGrid(x=1, y=1)
        self.pi_mux.setMenuEnabled(True)
        self.pi_mux.enableAutoRange(axis=pg.ViewBox.XAxis, enable=False)
        self.pi_mux.enableAutoRange(axis=pg.ViewBox.YAxis, enable=True)
        self.pi_mux.setAutoVisible(y=True)

        # Viewbox properties for the legend
        vb = self.gw_mux.addViewBox(enableMenu=False)
        vb.setMaximumWidth(80)

        # Legend
        self.legend = pg.LegendItem()
        self.legend.setParentItem(vb)
        self.legend.anchor((0, 0), (0, 0), offset=(1, 10))
        self.legend.setFixedWidth(75)
        self.legend.setScale(1)

        # ----------------------------------------------------------------------
        #   Show curves selection
        # ----------------------------------------------------------------------

        grpb_show_curves = QtWid.QGroupBox("Show")
        grpb_show_curves.setStyleSheet(SS_GROUP)

        self.grid_show_curves = QtWid.QGridLayout()
        self.grid_show_curves.setVerticalSpacing(0)

        grpb_show_curves.setLayout(self.grid_show_curves)

        # ----------------------------------------------------------------------
        #   Chart history time range selection
        # ----------------------------------------------------------------------

        grpb_history = QtWid.QGroupBox("History")
        grpb_history.setStyleSheet(SS_GROUP)

        p = {'maximumWidth': 70}
        self.qpbt_history_1 = QtWid.QPushButton("00:30", **p)
        self.qpbt_history_2 = QtWid.QPushButton("01:00", **p)
        self.qpbt_history_3 = QtWid.QPushButton("03:00", **p)
        self.qpbt_history_4 = QtWid.QPushButton("05:00", **p)
        self.qpbt_history_5 = QtWid.QPushButton("10:00", **p)
        self.qpbt_history_6 = QtWid.QPushButton("30:00", **p)

        self.qpbt_history_clear = QtWid.QPushButton("clear", **p)
        self.qpbt_history_clear.clicked.connect(self.clear_all_charts)

        grid = QtWid.QGridLayout()
        grid.setVerticalSpacing(0)
        grid.addWidget(self.qpbt_history_1, 0, 0)
        grid.addWidget(self.qpbt_history_2, 1, 0)
        grid.addWidget(self.qpbt_history_3, 2, 0)
        grid.addWidget(self.qpbt_history_4, 3, 0)
        grid.addWidget(self.qpbt_history_5, 4, 0)
        grid.addWidget(self.qpbt_history_6, 5, 0)
        grid.addWidget(self.qpbt_history_clear, 6, 0)

        grpb_history.setLayout(grid)

        # ----------------------------------------------------------------------
        #   Multiplexer grid
        # ----------------------------------------------------------------------

        vbox1 = QtWid.QVBoxLayout()
        vbox1.addWidget(grpb_show_curves,
                        stretch=0,
                        alignment=QtCore.Qt.AlignTop)
        vbox1.addWidget(grpb_history, stretch=0, alignment=QtCore.Qt.AlignTop)
        vbox1.addStretch(1)

        hbox_mux = QtWid.QHBoxLayout()
        hbox_mux.addWidget(mux_pyqt.qgrp,
                           stretch=0,
                           alignment=QtCore.Qt.AlignTop)
        hbox_mux.addWidget(self.gw_mux, stretch=1)
        hbox_mux.addLayout(vbox1)

        # ----------------------------------------------------------------------
        #   Chart: Bath temperatures
        # ----------------------------------------------------------------------

        # GraphicsWindow
        self.gw_bath = pg.GraphicsWindow()
        self.gw_bath.setBackground([20, 20, 20])

        # PlotItem
        self.pi_bath = self.gw_bath.addPlot()
        self.pi_bath.setTitle(
            '<span style="font-size:12pt">Temperatures</span>')
        self.pi_bath.setLabel(
            'bottom', '<span style="font-size:12pt">history (min)</span>')
        self.pi_bath.setLabel(
            'left', '<span style="font-size:12pt">(%sC)</span>' % chr(176))
        self.pi_bath.showGrid(x=1, y=1)
        self.pi_bath.setMenuEnabled(True)
        self.pi_bath.enableAutoRange(axis=pg.ViewBox.XAxis, enable=False)
        self.pi_bath.enableAutoRange(axis=pg.ViewBox.YAxis, enable=True)
        self.pi_bath.setAutoVisible(y=True)

        pen1 = pg.mkPen(color=[255, 0, 0], width=2)
        pen2 = pg.mkPen(color=[255, 255, 0], width=2)
        pen3 = pg.mkPen(color=[0, 128, 255], width=2)
        self.CH_P1_temp = ChartHistory(CH_SAMPLES_MUX,
                                       self.pi_bath.plot(pen=pen1))
        self.CH_P2_temp = ChartHistory(CH_SAMPLES_MUX,
                                       self.pi_bath.plot(pen=pen2))
        self.CH_PT104_ch1_T = ChartHistory(CH_SAMPLES_MUX,
                                           self.pi_bath.plot(pen=pen3))

        # ----------------------------------------------------------------------
        #   Group: Bath temperatures
        # ----------------------------------------------------------------------

        grpb_bath = QtWid.QGroupBox("Polyscience bath")
        grpb_bath.setStyleSheet(SS_GROUP)

        self.qled_P1_temp = QtWid.QLineEdit("nan")
        self.qled_P2_temp = QtWid.QLineEdit("nan")

        grid = QtWid.QGridLayout()
        grid.setVerticalSpacing(4)
        grid.addWidget(QtWid.QLabel("P1 (red)"), 0, 0)
        grid.addWidget(QtWid.QLabel("P2 (yel)"), 1, 0)
        grid.addWidget(self.qled_P1_temp, 0, 1)
        grid.addWidget(self.qled_P2_temp, 1, 1)
        grid.addWidget(QtWid.QLabel("%sC" % chr(176)), 0, 2)
        grid.addWidget(QtWid.QLabel("%sC" % chr(176)), 1, 2)

        grpb_bath.setLayout(grid)

        # ----------------------------------------------------------------------
        #   Polyscience and PT104
        # ----------------------------------------------------------------------

        vbox_tmp = QtWid.QVBoxLayout()
        vbox_tmp.addWidget(grpb_bath, stretch=0)
        vbox_tmp.addWidget(pt104_pyqt.qgrp, stretch=0)
        vbox_tmp.addStretch(1)

        hbox_bath = QtWid.QHBoxLayout()
        hbox_bath.addLayout(vbox_tmp)
        hbox_bath.addWidget(self.gw_bath, stretch=1)

        # ----------------------------------------------------------------------
        #   Round up full window
        # ----------------------------------------------------------------------

        vbox = QtWid.QVBoxLayout(self)
        vbox.addLayout(hbox_top)
        vbox.addLayout(hbox_mux)
        vbox.addLayout(hbox_bath)
        vbox.addStretch(1)
Exemplo n.º 3
0
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent, **kwargs)

        self.setGeometry(600, 120, 1200, 600)
        self.setWindowTitle("Keysight 3497xA control")

        # ----------------------------------------------------------------------
        #   Top grid
        # ----------------------------------------------------------------------

        self.qlbl_title = QtWid.QLabel("Keysight 3497xA control",
                                       font=QtGui.QFont(
                                           "Palatino",
                                           14,
                                           weight=QtGui.QFont.Bold))
        self.qlbl_cur_date_time = QtWid.QLabel("00-00-0000    00:00:00")
        self.qpbt_record = create_Toggle_button(
            "Click to start recording to file", minimumHeight=40)
        self.qpbt_record.setMinimumWidth(400)

        self.qpbt_exit = QtWid.QPushButton("Exit")
        self.qpbt_exit.clicked.connect(self.close)
        self.qpbt_exit.setMinimumHeight(30)

        grid_top = QtWid.QGridLayout()
        grid_top.addWidget(self.qlbl_title, 0, 0, QtCore.Qt.AlignCenter)
        grid_top.addWidget(self.qpbt_exit, 0, 2, QtCore.Qt.AlignRight)
        grid_top.addWidget(self.qlbl_cur_date_time, 1, 0,
                           QtCore.Qt.AlignCenter)
        grid_top.addWidget(self.qpbt_record, 2, 0, QtCore.Qt.AlignCenter)
        grid_top.setColumnMinimumWidth(0, 420)
        grid_top.setColumnStretch(1, 1)

        # ----------------------------------------------------------------------
        #   Chart: Mux readings
        # ----------------------------------------------------------------------

        # GraphicsWindow
        self.gw_mux = pg.GraphicsWindow()
        self.gw_mux.setBackground([20, 20, 20])

        # PlotItem
        self.pi_mux = self.gw_mux.addPlot()
        self.pi_mux.setTitle(
            '<span style="font-size:12pt">Mux readings</span>')
        self.pi_mux.setLabel(
            'bottom', '<span style="font-size:12pt">history (min)</span>')
        self.pi_mux.setLabel(
            'left', '<span style="font-size:12pt">misc. units</span>')
        self.pi_mux.showGrid(x=1, y=1)
        self.pi_mux.setMenuEnabled(True)
        self.pi_mux.enableAutoRange(axis=pg.ViewBox.XAxis, enable=False)
        self.pi_mux.enableAutoRange(axis=pg.ViewBox.YAxis, enable=True)
        self.pi_mux.setAutoVisible(y=True)

        # Viewbox properties for the legend
        vb = self.gw_mux.addViewBox(enableMenu=False)
        vb.setMaximumWidth(80)

        # Legend
        self.legend = pg.LegendItem()
        self.legend.setParentItem(vb)
        self.legend.anchor((0, 0), (0, 0), offset=(1, 10))
        self.legend.setFixedWidth(75)
        self.legend.setScale(1)

        # ----------------------------------------------------------------------
        #   Show curves selection
        # ----------------------------------------------------------------------

        qgrp_show_curves = QtWid.QGroupBox("Show")
        qgrp_show_curves.setStyleSheet(SS_GROUP)
        self.grid_show_curves = QtWid.QGridLayout()
        self.grid_show_curves.setVerticalSpacing(0)
        qgrp_show_curves.setLayout(self.grid_show_curves)

        # ----------------------------------------------------------------------
        #   Chart history time range selection
        # ----------------------------------------------------------------------

        p = {'maximumWidth': 70}
        self.qpbt_history_1 = QtWid.QPushButton("00:30", **p)
        self.qpbt_history_2 = QtWid.QPushButton("01:00", **p)
        self.qpbt_history_3 = QtWid.QPushButton("03:00", **p)
        self.qpbt_history_4 = QtWid.QPushButton("05:00", **p)
        self.qpbt_history_5 = QtWid.QPushButton("10:00", **p)
        self.qpbt_history_6 = QtWid.QPushButton("30:00", **p)

        self.qpbt_history_clear = QtWid.QPushButton("clear", **p)
        self.qpbt_history_clear.clicked.connect(self.clear_all_charts)

        grid = QtWid.QGridLayout()
        grid.setVerticalSpacing(0)
        grid.addWidget(self.qpbt_history_1, 0, 0)
        grid.addWidget(self.qpbt_history_2, 1, 0)
        grid.addWidget(self.qpbt_history_3, 2, 0)
        grid.addWidget(self.qpbt_history_4, 3, 0)
        grid.addWidget(self.qpbt_history_5, 4, 0)
        grid.addWidget(self.qpbt_history_6, 5, 0)
        grid.addWidget(self.qpbt_history_clear, 6, 0)

        qgrp_history = QtWid.QGroupBox("History")
        qgrp_history.setStyleSheet(SS_GROUP)
        qgrp_history.setLayout(grid)

        # ----------------------------------------------------------------------
        #   Bottom grid
        # ----------------------------------------------------------------------

        vbox1 = QtWid.QVBoxLayout()
        vbox1.addWidget(qgrp_show_curves,
                        stretch=0,
                        alignment=QtCore.Qt.AlignTop)
        vbox1.addWidget(qgrp_history, stretch=0, alignment=QtCore.Qt.AlignTop)
        vbox1.addStretch(1)

        hbox1 = QtWid.QHBoxLayout()
        hbox1.addWidget(mux_pyqt.qgrp, stretch=0, alignment=QtCore.Qt.AlignTop)
        hbox1.addWidget(self.gw_mux, stretch=1)
        hbox1.addLayout(vbox1)

        # ----------------------------------------------------------------------
        #   Round up full window
        # ----------------------------------------------------------------------

        vbox = QtWid.QVBoxLayout(self)
        vbox.addLayout(grid_top)
        vbox.addLayout(hbox1)
        vbox.addStretch(1)
    def create_GUI(self):
        # Groupbox "Alarm values"
        # -----------------------
        p = {
            'alignment': QtCore.Qt.AlignRight,
            'minimumWidth': 50,
            'maximumWidth': 30,
            'readOnly': True
        }
        self.LO_flow = QtWid.QLineEdit(**p)
        self.HI_flow = QtWid.QLineEdit(**p)
        self.LO_pres = QtWid.QLineEdit(**p)
        self.HI_pres = QtWid.QLineEdit(**p)
        self.LO_temp = QtWid.QLineEdit(**p)
        self.HI_temp = QtWid.QLineEdit(**p)
        self.pbtn_read_alarm_values = QtWid.QPushButton("Read")
        self.pbtn_read_alarm_values.setMinimumSize(50, 30)

        p = {'alignment': QtCore.Qt.AlignCenter}
        grid = QtWid.QGridLayout()
        grid.addWidget(
            QtWid.QLabel("Values can be set in the chiller's menu", **p), 0, 0,
            1, 4)
        grid.addWidget(QtWid.QLabel("LO"), 1, 1)
        grid.addWidget(QtWid.QLabel("HI"), 1, 2)
        grid.addWidget(QtWid.QLabel("Flow rate"), 2, 0)
        grid.addWidget(self.LO_flow, 2, 1)
        grid.addWidget(self.HI_flow, 2, 2)
        grid.addWidget(QtWid.QLabel("LPM"), 2, 3)
        grid.addWidget(QtWid.QLabel("Pressure"), 3, 0)
        grid.addWidget(self.LO_pres, 3, 1)
        grid.addWidget(self.HI_pres, 3, 2)
        grid.addWidget(QtWid.QLabel("bar"), 3, 3)
        grid.addWidget(QtWid.QLabel("Temperature"), 4, 0)
        grid.addWidget(self.LO_temp, 4, 1)
        grid.addWidget(self.HI_temp, 4, 2)
        grid.addWidget(QtWid.QLabel(CHAR_DEG_C), 4, 3)
        grid.addWidget(self.pbtn_read_alarm_values, 5, 0)

        self.grpb_alarms = QtWid.QGroupBox("Alarm values")
        self.grpb_alarms.setStyleSheet(SS_GROUP)
        self.grpb_alarms.setLayout(grid)

        # Groupbox "PID feedback"
        # -----------------------
        p = {
            'alignment': QtCore.Qt.AlignRight,
            'minimumWidth': 50,
            'maximumWidth': 30,
            'readOnly': True
        }
        self.PID_P = QtWid.QLineEdit(**p)
        self.PID_I = QtWid.QLineEdit(**p)
        self.PID_D = QtWid.QLineEdit(**p)
        self.pbtn_read_PID_values = QtWid.QPushButton("Read")
        self.pbtn_read_PID_values.setMinimumSize(50, 30)

        p = {'alignment': QtCore.Qt.AlignCenter}
        grid = QtWid.QGridLayout()
        grid.addWidget(
            QtWid.QLabel("Values can be set in the chiller's menu", **p), 0, 0,
            1, 3)
        grid.addWidget(QtWid.QLabel("P", **p), 1, 0)
        grid.addWidget(self.PID_P, 1, 1)
        grid.addWidget(QtWid.QLabel("% span of 100" + CHAR_DEG_C), 1, 2)
        grid.addWidget(QtWid.QLabel("I", **p), 2, 0)
        grid.addWidget(self.PID_I, 2, 1)
        grid.addWidget(QtWid.QLabel("repeats/minute"), 2, 2)
        grid.addWidget(QtWid.QLabel("D", **p), 3, 0)
        grid.addWidget(self.PID_D, 3, 1)
        grid.addWidget(QtWid.QLabel("minutes"), 3, 2)
        grid.addWidget(self.pbtn_read_PID_values, 4, 0)

        self.grpb_PID = QtWid.QGroupBox("PID feedback")
        self.grpb_PID.setStyleSheet(SS_GROUP)
        self.grpb_PID.setLayout(grid)

        # Groupbox "Status bits"
        # ----------------------
        self.SB_tripped = create_error_LED()
        self.SB_tripped.setText("No faults")
        self.SB_high_temp_fixed = create_tiny_error_LED()
        self.SB_low_temp_fixed = create_tiny_error_LED()
        self.SB_high_temp = create_tiny_error_LED()
        self.SB_low_temp = create_tiny_error_LED()
        self.SB_high_pressure = create_tiny_error_LED()
        self.SB_low_pressure = create_tiny_error_LED()
        self.SB_drip_pan = create_tiny_error_LED()
        self.SB_high_level = create_tiny_error_LED()
        self.SB_phase_monitor = create_tiny_error_LED()
        self.SB_motor_overload = create_tiny_error_LED()
        self.SB_LPC = create_tiny_error_LED()
        self.SB_HPC = create_tiny_error_LED()
        self.SB_external_EMO = create_tiny_error_LED()
        self.SB_local_EMO = create_tiny_error_LED()
        self.SB_low_flow = create_tiny_error_LED()
        self.SB_low_level = create_tiny_error_LED()
        self.SB_sense_5V = create_tiny_error_LED()
        self.SB_invalid_level = create_tiny_error_LED()
        self.SB_low_fixed_flow_warning = create_tiny_error_LED()
        self.SB_high_pressure_factory = create_tiny_error_LED()
        self.SB_low_pressure_factory = create_tiny_error_LED()

        p = {'alignment': QtCore.Qt.AlignRight}
        grid = QtWid.QGridLayout()
        grid.addWidget(self.SB_tripped, 0, 0, 1, 2)
        grid.addItem(QtWid.QSpacerItem(1, 12), 1, 0)
        grid.addWidget(QtWid.QLabel("high temp fixed fault", **p), 2, 0)
        grid.addWidget(self.SB_high_temp_fixed, 2, 1)
        grid.addWidget(QtWid.QLabel("low temp fixed fault", **p), 3, 0)
        grid.addWidget(self.SB_low_temp_fixed, 3, 1)
        grid.addWidget(QtWid.QLabel("high temp fault/warning", **p), 4, 0)
        grid.addWidget(self.SB_high_temp, 4, 1)
        grid.addWidget(QtWid.QLabel("low temp fault/warning", **p), 5, 0)
        grid.addWidget(self.SB_low_temp, 5, 1)
        grid.addWidget(QtWid.QLabel("high pressure fault/warning", **p), 6, 0)
        grid.addWidget(self.SB_high_pressure, 6, 1)
        grid.addWidget(QtWid.QLabel("low pressure fault/warning", **p), 7, 0)
        grid.addWidget(self.SB_low_pressure, 7, 1)
        grid.addWidget(QtWid.QLabel("drip pan fault", **p), 8, 0)
        grid.addWidget(self.SB_drip_pan, 8, 1)
        grid.addWidget(QtWid.QLabel("high level fault", **p), 9, 0)
        grid.addWidget(self.SB_high_level, 9, 1)
        grid.addWidget(QtWid.QLabel("phase monitor fault", **p), 10, 0)
        grid.addWidget(self.SB_phase_monitor, 10, 1)
        grid.addWidget(QtWid.QLabel("motor overload fault", **p), 11, 0)
        grid.addWidget(self.SB_motor_overload, 11, 1)
        grid.addWidget(QtWid.QLabel("LPC fault", **p), 12, 0)
        grid.addWidget(self.SB_LPC, 12, 1)
        grid.addWidget(QtWid.QLabel("HPC fault", **p), 13, 0)
        grid.addWidget(self.SB_HPC, 13, 1)
        grid.addWidget(QtWid.QLabel("external EMO fault", **p), 14, 0)
        grid.addWidget(self.SB_external_EMO, 14, 1)
        grid.addWidget(QtWid.QLabel("local EMO fault", **p), 15, 0)
        grid.addWidget(self.SB_local_EMO, 15, 1)
        grid.addWidget(QtWid.QLabel("low flow fault", **p), 16, 0)
        grid.addWidget(self.SB_low_flow, 16, 1)
        grid.addWidget(QtWid.QLabel("low level fault", **p), 17, 0)
        grid.addWidget(self.SB_low_level, 17, 1)
        grid.addWidget(QtWid.QLabel("sense 5V fault", **p), 18, 0)
        grid.addWidget(self.SB_sense_5V, 18, 1)
        grid.addWidget(QtWid.QLabel("invalid level fault", **p), 19, 0)
        grid.addWidget(self.SB_invalid_level, 19, 1)
        grid.addWidget(QtWid.QLabel("low fixed flow warning", **p), 20, 0)
        grid.addWidget(self.SB_low_fixed_flow_warning, 20, 1)
        grid.addWidget(QtWid.QLabel("high pressure factory fault", **p), 21, 0)
        grid.addWidget(self.SB_high_pressure_factory, 21, 1)
        grid.addWidget(QtWid.QLabel("low pressure factory fault", **p), 22, 0)
        grid.addWidget(self.SB_low_pressure_factory, 22, 1)

        self.grpb_SBs = QtWid.QGroupBox("Status bits")
        self.grpb_SBs.setStyleSheet(SS_GROUP)
        self.grpb_SBs.setLayout(grid)

        # Groupbox "Control"
        # ------------------
        p = {
            'alignment': QtCore.Qt.AlignRight,
            'minimumWidth': 50,
            'maximumWidth': 30
        }

        self.lbl_offline = QtWid.QLabel("OFFLINE",
                                        visible=False,
                                        font=QtGui.QFont(
                                            "Palatino",
                                            14,
                                            weight=QtGui.QFont.Bold),
                                        alignment=QtCore.Qt.AlignCenter)
        self.pbtn_on = create_Toggle_button("Off")
        self.powering_down = create_tiny_error_LED()
        self.send_setpoint = QtWid.QLineEdit(**p)
        self.read_setpoint = QtWid.QLineEdit(**p, readOnly=True)
        self.read_temp = QtWid.QLineEdit(**p, readOnly=True)
        self.read_flow = QtWid.QLineEdit(**p, readOnly=True)
        self.read_supply = QtWid.QLineEdit(**p, readOnly=True)
        self.read_suction = QtWid.QLineEdit(**p, readOnly=True)
        self.lbl_update_counter = QtWid.QLabel("0")

        grid = QtWid.QGridLayout()
        grid.addWidget(self.lbl_offline, 0, 0, 1, 3)
        grid.addWidget(self.pbtn_on, 1, 0, 1, 3)
        grid.addWidget(
            QtWid.QLabel("Is powering up/down?",
                         alignment=QtCore.Qt.AlignRight), 2, 0, 1, 2)
        grid.addWidget(self.powering_down, 2, 2)
        grid.addItem(QtWid.QSpacerItem(1, 12), 3, 0)
        grid.addWidget(QtWid.QLabel("Send setpoint"), 4, 0)
        grid.addWidget(QtWid.QLabel("Read setpoint"), 5, 0)
        grid.addWidget(self.send_setpoint, 4, 1)
        grid.addWidget(self.read_setpoint, 5, 1)
        grid.addWidget(QtWid.QLabel(CHAR_DEG_C), 4, 2)
        grid.addWidget(QtWid.QLabel(CHAR_DEG_C), 5, 2)
        grid.addItem(QtWid.QSpacerItem(1, 12), 6, 0)
        grid.addWidget(QtWid.QLabel("Read temp"), 7, 0)
        grid.addWidget(self.read_temp, 7, 1)
        grid.addWidget(QtWid.QLabel(CHAR_DEG_C), 7, 2)
        grid.addWidget(QtWid.QLabel("Read flow"), 8, 0)
        grid.addWidget(self.read_flow, 8, 1)
        grid.addWidget(QtWid.QLabel("LPM"), 8, 2)
        grid.addWidget(QtWid.QLabel("Read supply"), 9, 0)
        grid.addWidget(self.read_supply, 9, 1)
        grid.addWidget(QtWid.QLabel("bar"), 9, 2)
        grid.addWidget(QtWid.QLabel("Read suction"), 10, 0)
        grid.addWidget(self.read_suction, 10, 1)
        grid.addWidget(QtWid.QLabel("bar"), 10, 2)

        grid.addItem(QtWid.QSpacerItem(1, 12), 11, 0)
        grid.addWidget(QtWid.QLabel("Nominal values @ 15-02-2018:"), 12, 0, 1,
                       3)
        grid.addWidget(QtWid.QLabel("Read flow"), 13, 0)
        grid.addWidget(QtWid.QLabel("80  ", alignment=QtCore.Qt.AlignRight),
                       13, 1)
        grid.addWidget(QtWid.QLabel("LPM"), 13, 2)
        grid.addWidget(QtWid.QLabel("Read supply"), 14, 0)
        grid.addWidget(QtWid.QLabel("2.9  ", alignment=QtCore.Qt.AlignRight),
                       14, 1)
        grid.addWidget(QtWid.QLabel("bar"), 14, 2)
        grid.addWidget(QtWid.QLabel("Read suction"), 15, 0)
        grid.addWidget(QtWid.QLabel("40  ", alignment=QtCore.Qt.AlignRight),
                       15, 1)
        grid.addWidget(QtWid.QLabel("bar"), 15, 2)
        grid.addWidget(self.lbl_update_counter, 16, 0, 1, 2)

        self.grpb_control = QtWid.QGroupBox("Control")
        self.grpb_control.setStyleSheet(SS_GROUP)
        self.grpb_control.setLayout(grid)

        # --------------------------------------
        #   Round up final QtWid.QHBoxLayout()
        # --------------------------------------

        vbox = QtWid.QVBoxLayout()
        vbox.addWidget(self.grpb_alarms)
        vbox.addWidget(self.grpb_PID)
        vbox.setAlignment(self.grpb_alarms, QtCore.Qt.AlignTop)
        vbox.setAlignment(self.grpb_PID, QtCore.Qt.AlignTop)
        vbox.setAlignment(QtCore.Qt.AlignTop)

        self.hbly_GUI = QtWid.QHBoxLayout()
        self.hbly_GUI.addLayout(vbox)
        self.hbly_GUI.addWidget(self.grpb_SBs)
        self.hbly_GUI.addWidget(self.grpb_control)
        self.hbly_GUI.addStretch(1)
        self.hbly_GUI.setAlignment(self.grpb_SBs, QtCore.Qt.AlignTop)
        self.hbly_GUI.setAlignment(self.grpb_control, QtCore.Qt.AlignTop)
        self.hbly_GUI.setAlignment(QtCore.Qt.AlignTop)
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent, **kwargs)

        self.setGeometry(50, 50, 1000, 660)
        self.setWindowTitle("AxTorque - Torque Measurement")

        # -------------------------
        #   Top frame
        # -------------------------

        # Left box
        self.qlbl_update_counter = QtWid.QLabel("Samples: 0")
        self.qlbl_Axeltext = QtWid.QLabel("Axel Johansson 2019")
        self.qlbl_DAQ_rate = QtWid.QLabel("DAQ: 0 Hz")
        self.qlbl_DAQ_rate.setMinimumWidth(100)

        vbox_left = QtWid.QVBoxLayout()
        vbox_left.addWidget(self.qlbl_Axeltext, stretch=0)
        vbox_left.addStretch(1)
        vbox_left.addWidget(self.qlbl_update_counter, stretch=0)
        vbox_left.addWidget(self.qlbl_DAQ_rate, stretch=0)

        # Middle box
        self.qlbl_title = QtWid.QLabel("AxTorque - Torque Measurement",
                                       font=QtGui.QFont(
                                           "Palatino",
                                           14,
                                           weight=QtGui.QFont.Bold))
        self.qlbl_title.setAlignment(QtCore.Qt.AlignCenter)
        self.qlbl_cur_date_time = QtWid.QLabel("00-00-0000    00:00:00")
        self.qlbl_cur_date_time.setAlignment(QtCore.Qt.AlignCenter)
        self.qpbt_record = create_Toggle_button(
            "Click to start recording to file", minimumHeight=40)
        self.qpbt_record.clicked.connect(self.process_qpbt_record)

        vbox_middle = QtWid.QVBoxLayout()
        vbox_middle.addWidget(self.qlbl_title)
        vbox_middle.addWidget(self.qlbl_cur_date_time)
        vbox_middle.addWidget(self.qpbt_record)

        # Right box
        self.qpbt_exit = QtWid.QPushButton("Exit")
        self.qpbt_exit.clicked.connect(self.close)
        self.qpbt_exit.setMinimumHeight(30)

        vbox_right = QtWid.QVBoxLayout()
        vbox_right.addWidget(self.qpbt_exit, stretch=0)
        vbox_right.addStretch(1)

        # Round up top frame
        hbox_top = QtWid.QHBoxLayout()
        hbox_top.addLayout(vbox_left, stretch=0)
        hbox_top.addStretch(1)
        hbox_top.addLayout(vbox_middle, stretch=0)
        hbox_top.addStretch(1)
        hbox_top.addLayout(vbox_right, stretch=0)

        # -------------------------
        #   Bottom frame
        # -------------------------

        # Create PlotItem
        self.gw_chart = pg.GraphicsWindow()
        self.gw_chart.setBackground([20, 20, 20])
        self.pi_chart = self.gw_chart.addPlot()
        self.gw_chart2 = pg.GraphicsWindow()
        self.gw_chart2.setMaximumWidth(300)
        self.gw_chart2.setBackground([10, 10, 10])
        self.pi_chart2 = self.gw_chart2.addPlot()

        p = {'color': '#BBB', 'font-size': '10pt'}
        self.pi_chart.showGrid(x=1, y=1)
        self.pi_chart.setTitle('Torque Measurements', **p)
        self.pi_chart.setLabel('bottom', text='Time [s]', **p)
        self.pi_chart.setLabel('left', text='Torque [Nm]', **p)
        self.pi_chart.setRange(
            xRange=[-1.04 * CHART_HISTORY_TIME, CHART_HISTORY_TIME * 0.04])  #,
        #yRange=[-1.1, 1.1])#,
        #disableAutoRange=True)

        p = {'color': '#BBB', 'font-size': '10pt'}
        self.pi_chart2.showGrid(x=1, y=1)
        self.pi_chart2.setTitle('Yaw, Pitch, Roll', **p)
        self.pi_chart2.setLabel('bottom', text='Time [s]', **p)
        self.pi_chart2.setLabel('left', text='Orientation', **p)
        self.pi_chart2.setRange(
            xRange=[-1.04 * CHART_HISTORY_TIME, CHART_HISTORY_TIME * 0.04])

        # Create ChartHistory and PlotDataItem and link them together
        PEN_01 = pg.mkPen(color=[200, 200, 200], width=3)
        PEN_yaw = pg.mkPen(color=[200, 0, 0], width=3)
        PEN_pitch = pg.mkPen(color=[0, 200, 0], width=3)
        PEN_roll = pg.mkPen(color=[0, 0, 200], width=3)

        num_samples = round(CHART_HISTORY_TIME * 1e3 / UPDATE_INTERVAL_ARDUINO)
        self.CH_1 = ChartHistory(num_samples, self.pi_chart.plot(pen=PEN_01))
        self.CH_yaw = ChartHistory(num_samples,
                                   self.pi_chart2.plot(pen=PEN_yaw))
        self.CH_pitch = ChartHistory(num_samples,
                                     self.pi_chart2.plot(pen=PEN_pitch))
        self.CH_roll = ChartHistory(num_samples,
                                    self.pi_chart2.plot(pen=PEN_roll))

        self.CH_1.x_axis_divisor = 1000  # From [ms] to [s]
        self.CH_yaw.x_axis_divisor = 1000  # From [ms] to [s]
        self.CH_pitch.x_axis_divisor = 1000  # From [ms] to [s]
        self.CH_roll.x_axis_divisor = 1000  # From [ms] to [s]

        # 'Readings'
        p = {'readOnly': True}
        self.qlin_reading_t = QtWid.QLineEdit(**p)
        self.qlin_reading_1 = QtWid.QLineEdit(**p)

        grid = QtWid.QGridLayout()
        grid.addWidget(QtWid.QLabel("time"), 0, 0)
        grid.addWidget(self.qlin_reading_t, 0, 1)
        grid.addWidget(QtWid.QLabel("Torque [Nm]"), 1, 0)
        grid.addWidget(self.qlin_reading_1, 1, 1)
        grid.setAlignment(QtCore.Qt.AlignTop)

        qgrp_readings = QtWid.QGroupBox("Readings")
        qgrp_readings.setStyleSheet(SS_GROUP)
        qgrp_readings.setLayout(grid)

        # 'Wave type'
        self.qpbt_wave_sine = QtWid.QPushButton("Tare Strain gauges")
        self.qpbt_wave_sine.clicked.connect(self.process_qpbt_wave_sine)
        self.qpbt_wave_square = QtWid.QPushButton("Reset orientation")
        self.qpbt_wave_square.clicked.connect(self.process_qpbt_wave_square)
        #self.qpbt_wave_sawtooth = QtWid.QComboBox()
        #self.qpbt_wave_sawtooth.addItem("port")
        #self.qpbt_wave_sawtooth.stateChanged.connect(lambda:self.btnstate(self.qpbt_wave_sawtooth))
        #self.qpbt_wave_sawtooth.clicked.connect(self.process_qpbt_wave_sawtooth)

        grid = QtWid.QGridLayout()
        grid.addWidget(self.qpbt_wave_sine, 0, 0)
        grid.addWidget(self.qpbt_wave_square, 1, 0)
        #grid.addWidget(self.qpbt_wave_sawtooth, 2, 0)
        grid.setAlignment(QtCore.Qt.AlignTop)

        qgrp_wave_type = QtWid.QGroupBox("Tools")
        qgrp_wave_type.setStyleSheet(SS_GROUP)
        qgrp_wave_type.setLayout(grid)

        # 'Chart'
        self.qpbt_clear_chart = QtWid.QPushButton("Clear")
        self.qpbt_clear_chart.clicked.connect(self.process_qpbt_clear_chart)

        grid = QtWid.QGridLayout()
        grid.addWidget(self.qpbt_clear_chart, 0, 0)
        grid.setAlignment(QtCore.Qt.AlignTop)

        qgrp_chart = QtWid.QGroupBox("Chart")
        qgrp_chart.setStyleSheet(SS_GROUP)
        qgrp_chart.setLayout(grid)

        vbox = QtWid.QVBoxLayout()

        vbox.addWidget(qgrp_readings)
        vbox.addWidget(qgrp_wave_type)
        vbox.addWidget(qgrp_chart)
        vbox.addWidget(self.gw_chart2, 1)
        vbox.addStretch()

        # Round up bottom frame
        hbox_bot = QtWid.QHBoxLayout()
        hbox_bot.addWidget(self.gw_chart, 1)
        hbox_bot.addLayout(vbox, 0)

        # -------------------------
        #   Round up full window
        # -------------------------

        vbox = QtWid.QVBoxLayout(self)
        vbox.addLayout(hbox_top, stretch=0)
        vbox.addSpacerItem(QtWid.QSpacerItem(0, 20))
        vbox.addLayout(hbox_bot, stretch=1)
    def create_GUI(self):
        # Measure
        p = {'alignment': QtCore.Qt.AlignRight, 'font': FONT_MONOSPACE}
        self.V_meas = QtWid.QLabel("0.00  V   ", **p)
        self.I_meas = QtWid.QLabel("0.000 A   ", **p)
        self.P_meas = QtWid.QLabel("0.00  W   ", **p)

        # Source
        p = {'maximumWidth': 60, 'alignment': QtCore.Qt.AlignRight}
        self.pbtn_ENA_output = create_Toggle_button("Output OFF")
        self.V_source = QtWid.QLineEdit("0.00", **p)
        self.I_source = QtWid.QLineEdit("0.000", **p)
        self.P_source = QtWid.QLineEdit("0.00", **p)
        self.pbtn_ENA_PID = create_Toggle_button("OFF", minimumHeight=24)
        self.pbtn_ENA_PID.setMinimumWidth(60)

        # Protection
        self.OVP_level = QtWid.QLineEdit("0.000", **p)
        self.pbtn_ENA_OCP = create_Toggle_button("OFF", minimumHeight=24)
        self.pbtn_ENA_OCP.setMinimumWidth(60)

        # Questionable condition status registers
        self.status_QC_OV = create_tiny_error_LED()
        self.status_QC_OC = create_tiny_error_LED()
        self.status_QC_PF = create_tiny_error_LED()
        self.status_QC_OT = create_tiny_error_LED()
        self.status_QC_INH = create_tiny_error_LED()
        self.status_QC_UNR = create_tiny_error_LED()

        # Operation condition status registers
        self.status_OC_WTG = create_tiny_error_LED()
        self.status_OC_CV = create_tiny_error_LED()
        self.status_OC_CC = create_tiny_error_LED()

        # Final elements
        self.errors = QtWid.QLineEdit('')
        self.errors.setStyleSheet(SS_TEXTBOX_ERRORS)
        self.pbtn_ackn_errors = QtWid.QPushButton("Acknowledge errors")
        self.pbtn_reinit = QtWid.QPushButton("Reinitialize")
        self.pbtn_save_defaults = QtWid.QPushButton("Save")
        self.pbtn_debug_test = QtWid.QPushButton("Debug test")
        self.lbl_update_counter = QtWid.QLabel("0")

        i = 0
        p = {'alignment': QtCore.Qt.AlignLeft + QtCore.Qt.AlignVCenter}

        grid = QtWid.QGridLayout()
        grid.setVerticalSpacing(0)
        grid.addWidget(self.V_meas, i, 0, 1, 4)
        i += 1
        grid.addWidget(self.I_meas, i, 0, 1, 4)
        i += 1
        grid.addWidget(self.P_meas, i, 0, 1, 4)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 8), i, 0)
        i += 1
        grid.addWidget(self.pbtn_ENA_output, i, 0, 1, 4)
        i += 1

        grid.addItem(QtWid.QSpacerItem(1, 10), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("Source:"), i, 0, 1, 4)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 4), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("Voltage"), i, 0, 1, 2)
        grid.addWidget(self.V_source, i, 2)
        grid.addWidget(QtWid.QLabel("V", **p), i, 3)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 2), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("Current"), i, 0, 1, 2)
        grid.addWidget(self.I_source, i, 2)
        grid.addWidget(QtWid.QLabel("A", **p), i, 3)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 2), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("Power PID"), i, 0, 1, 2)
        grid.addWidget(self.pbtn_ENA_PID, i, 2, QtCore.Qt.AlignLeft)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 2), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("Power"), i, 0, 1, 2)
        grid.addWidget(self.P_source, i, 2)
        grid.addWidget(QtWid.QLabel("W", **p), i, 3)
        i += 1

        grid.addItem(QtWid.QSpacerItem(1, 10), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("Protection:"), i, 0, 1, 4)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 4), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("OVP"), i, 0, 1, 2)
        grid.addWidget(self.OVP_level, i, 2)
        grid.addWidget(QtWid.QLabel("V", **p), i, 3)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 2), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("OCP"), i, 0, 1, 2)
        grid.addWidget(self.pbtn_ENA_OCP, i, 2, QtCore.Qt.AlignLeft)
        i += 1

        grid.addItem(QtWid.QSpacerItem(1, 10), i, 0)
        i += 1
        grid.addWidget(self.status_QC_OV, i, 0)
        grid.addWidget(QtWid.QLabel("OV"), i, 1)
        grid.addWidget(QtWid.QLabel("| over-voltage"), i, 2, 1, 2)
        i += 1
        grid.addWidget(self.status_QC_OC, i, 0)
        grid.addWidget(QtWid.QLabel("OC"), i, 1)
        grid.addWidget(QtWid.QLabel("| over-current"), i, 2, 1, 2)
        i += 1
        grid.addWidget(self.status_QC_PF, i, 0)
        grid.addWidget(QtWid.QLabel("PF"), i, 1)
        grid.addWidget(QtWid.QLabel("| AC power failure"), i, 2, 1, 2)
        i += 1
        grid.addWidget(self.status_QC_OT, i, 0)
        grid.addWidget(QtWid.QLabel("OT"), i, 1)
        grid.addWidget(QtWid.QLabel("| over-temperature"), i, 2, 1, 2)
        i += 1
        grid.addWidget(self.status_QC_INH, i, 0)
        grid.addWidget(QtWid.QLabel("INH"), i, 1)
        grid.addWidget(QtWid.QLabel("| output inhibited"), i, 2, 1, 2)
        i += 1
        grid.addWidget(self.status_QC_UNR, i, 0)
        grid.addWidget(QtWid.QLabel("UNR"), i, 1)
        grid.addWidget(QtWid.QLabel("| unregulated"), i, 2, 1, 2)
        i += 1

        grid.addItem(QtWid.QSpacerItem(1, 10), i, 0)
        i += 1
        grid.addWidget(self.status_OC_WTG, i, 0)
        grid.addWidget(QtWid.QLabel("WTG"), i, 1)
        grid.addWidget(QtWid.QLabel("| waiting for trigger"), i, 2, 1, 2)
        i += 1
        grid.addWidget(self.status_OC_CV, i, 0)
        grid.addWidget(QtWid.QLabel("CV"), i, 1)
        grid.addWidget(QtWid.QLabel("| constant voltage"), i, 2, 1, 2)
        i += 1
        grid.addWidget(self.status_OC_CC, i, 0)
        grid.addWidget(QtWid.QLabel("CC"), i, 1)
        grid.addWidget(QtWid.QLabel("| constant current"), i, 2, 1, 2)
        i += 1

        grid.addItem(QtWid.QSpacerItem(1, 10), i, 0)
        i += 1
        grid.addWidget(QtWid.QLabel("Errors"), i, 0, 1, 2)
        grid.addWidget(self.errors, i, 2, 1, 2)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 4), i, 0)
        i += 1
        grid.addWidget(self.pbtn_ackn_errors, i, 0, 1, 4)
        i += 1

        hbox = QtWid.QHBoxLayout()
        hbox.addWidget(self.pbtn_save_defaults)
        hbox.addWidget(self.pbtn_reinit)
        grid.addLayout(hbox, i, 0, 1, 4)
        i += 1
        grid.addItem(QtWid.QSpacerItem(1, 4), i, 0)
        i += 1
        grid.addWidget(self.lbl_update_counter, i, 0, 1, 4)
        i += 1
        #grid.addWidget(self.pbtn_debug_test              , i, 0, 1, 4); i+=1

        grid.setColumnStretch(0, 0)
        grid.setColumnStretch(1, 0)
        grid.setColumnStretch(2, 0)
        grid.setColumnStretch(3, 1)
        grid.setAlignment(QtCore.Qt.AlignTop)
        #grid.setAlignment(QtCore.Qt.AlignLeft)
        self.grid = grid

        self.grpb = QtWid.QGroupBox("%s" % self.dev.name)
        self.grpb.setStyleSheet(SS_GROUP)
        self.grpb.setLayout(self.grid)
    def create_GUI(self):
        p = {'alignment': QtCore.Qt.AlignCenter, 'font': FONT_MONOSPACE}
        p2 = {'alignment': QtCore.Qt.AlignCenter + QtCore.Qt.AlignVCenter}
        #self.qlbl_mux = QtWid.QLabel("Keysight 34972a", **p2)
        self.qlbl_mux_state = QtWid.QLabel("Offline", **p)
        self.qpbt_start_scan = create_Toggle_button("Start scan")

        self.qpte_SCPI_commands = QtWid.QPlainTextEdit('', readOnly=True,
                                                       lineWrapMode=False)
        self.qpte_SCPI_commands.setStyleSheet(SS_TEXTBOX_READ_ONLY)
        self.qpte_SCPI_commands.setMaximumHeight(152)
        self.qpte_SCPI_commands.setMinimumWidth(200)
        self.qpte_SCPI_commands.setFont(FONT_MONOSPACE_SMALL)

        p = {'alignment': QtCore.Qt.AlignRight, 'readOnly': True}
        self.qled_scanning_interval_ms = QtWid.QLineEdit("", **p)
        self.qled_obtained_interval_ms = QtWid.QLineEdit("", **p)

        self.qpte_errors = QtWid.QPlainTextEdit('', lineWrapMode=False)
        self.qpte_errors.setStyleSheet(SS_TEXTBOX_ERRORS)
        self.qpte_errors.setMaximumHeight(90)

        self.qpbt_ackn_errors    = QtWid.QPushButton("Acknowledge errors")
        self.qpbt_reinit         = QtWid.QPushButton("Reinitialize")
        self.qlbl_update_counter = QtWid.QLabel("0")
        self.qpbt_debug_test     = QtWid.QPushButton("Debug test")

        self.qpbt_start_scan.clicked.connect(self.process_qpbt_start_scan)
        self.qpbt_ackn_errors.clicked.connect(self.process_qpbt_ackn_errors)
        self.qpbt_reinit.clicked.connect(self.process_qpbt_reinit)
        self.qpbt_debug_test.clicked.connect(self.process_qpbt_debug_test)

        i = 0
        p = {'alignment': QtCore.Qt.AlignLeft + QtCore.Qt.AlignVCenter}

        grid = QtWid.QGridLayout()
        grid.setVerticalSpacing(4)
        #grid.addWidget(self.qlbl_mux                      , i, 0, 1, 3); i+=1
        grid.addWidget(QtWid.QLabel("Only scan when necessary.", **p2)
                                                          , i, 0, 1, 2); i+=1
        grid.addWidget(QtWid.QLabel("It wears down the multiplexer.", **p2)
                                                          , i, 0, 1, 2); i+=1
        grid.addItem(QtWid.QSpacerItem(1, 3)              , i, 0)      ; i+=1
        grid.addWidget(self.qlbl_mux_state                , i, 0, 1, 2); i+=1
        grid.addItem(QtWid.QSpacerItem(1, 3)              , i, 0)      ; i+=1
        grid.addWidget(self.qpbt_start_scan               , i, 0, 1, 2); i+=1
        grid.addItem(QtWid.QSpacerItem(1, 4)              , i, 0)      ; i+=1
        grid.addWidget(QtWid.QLabel("SCPI scan commands:"), i, 0, 1, 2); i+=1
        grid.addWidget(self.qpte_SCPI_commands            , i, 0, 1, 2); i+=1
        grid.addWidget(QtWid.QLabel("Scanning interval [ms]"), i, 0)
        grid.addWidget(self.qled_scanning_interval_ms     , i, 1)      ; i+=1
        grid.addWidget(QtWid.QLabel("Obtained [ms]")      , i, 0)
        grid.addWidget(self.qled_obtained_interval_ms     , i, 1)      ; i+=1
        grid.addWidget(self.qpbt_reinit                   , i, 0, 1, 2); i+=1
        grid.addItem(QtWid.QSpacerItem(1, 12)             , i, 0)      ; i+=1
        grid.addWidget(QtWid.QLabel("Errors:")            , i, 0, 1, 2); i+=1
        grid.addWidget(self.qpte_errors                   , i, 0, 1, 2); i+=1
        grid.addWidget(self.qpbt_ackn_errors              , i, 0, 1, 2); i+=1
        grid.addWidget(self.qlbl_update_counter           , i, 0, 1, 2); i+=1
        #grid.addWidget(self.qpbt_debug_test               , i, 0, 1, 2); i+=1

        #  Table widget containing the readings of the current scan cycle
        # ----------------------------------------------------------------
        self.qtbl_readings = QtWid.QTableWidget(columnCount=1)
        self.qtbl_readings.setHorizontalHeaderLabels(["Readings"])
        self.qtbl_readings.horizontalHeaderItem(0).setFont(FONT_MONOSPACE_SMALL)
        self.qtbl_readings.verticalHeader().setFont(FONT_MONOSPACE_SMALL)
        self.qtbl_readings.verticalHeader().setDefaultSectionSize(24);
        self.qtbl_readings.setFont(FONT_MONOSPACE_SMALL)
        #self.qtbl_readings.setMinimumHeight(600)
        self.qtbl_readings.setFixedWidth(180)
        self.qtbl_readings.setColumnWidth(0, 100)

        grid.addWidget(self.qtbl_readings, 0, 2, i, 1)

        self.qgrp = QtWid.QGroupBox("%s" % self.dev.name)
        self.qgrp.setStyleSheet(SS_GROUP)
        self.qgrp.setLayout(grid)