Exemplo n.º 1
0
    def _create_inh_control(self, name, parent, layout, col):
        # Create a label for the inhibit switch
        label = QLabel(name, parent)
        label.setAlignment(Qt.AlignCenter)
        font = label.font()
        font.setPointSize(7)
        font.setBold(True)
        label.setFont(font)
        layout.addWidget(label, 0, col)

        # Add an indicator to show inhibit state
        ind = Indicator(parent, QColor(255, 120, 0))
        ind.setFixedSize(20, 20)
        layout.addWidget(ind, 1, col)
        layout.setAlignment(ind, Qt.AlignCenter)

        # Add a switch to control the inhibit state
        check = QCheckBox(parent)
        check.setFixedSize(20, 20)
        check.setStyleSheet(
            'QCheckBox::indicator{subcontrol-position:center;}')
        layout.addWidget(check, 2, col)
        layout.setAlignment(check, Qt.AlignCenter)
        layout.setColumnMinimumWidth(col, 25)

        self._inh_switches.append(check)
        self._inh_inds.append(ind)
Exemplo n.º 2
0
    def _create_stop_cond(self, label_text, name, layout, col):
        # Create an indicator to show stop status
        ind = Indicator(self, QColor(255, 0, 0))
        ind.setFixedSize(25, 20)
        layout.addWidget(ind, 0, col)
        layout.setAlignment(ind, Qt.AlignCenter)
        self._stop_inds[name] = ind

        # Add a switch to control the stop control state
        check = QCheckBox(self)
        check.setFixedSize(20, 20)
        check.setStyleSheet(
            'QCheckBox::indicator{subcontrol-position:center;}')
        layout.addWidget(check, 1, col)
        layout.setAlignment(check, Qt.AlignCenter)
        check.stateChanged.connect(self._set_stop_conds)
        self._stop_switches[name] = check

        # Create a label for the inhibit switch
        label = QLabel(label_text, self)
        label.setAlignment(Qt.AlignCenter)
        font = label.font()
        font.setPointSize(7)
        font.setBold(True)
        label.setFont(font)
        label_height = 2 if '\n' in label_text else 1
        layout.addWidget(label, 2, col, label_height, 1)
        layout.setAlignment(label, Qt.AlignCenter | Qt.AlignTop)
Exemplo n.º 3
0
    def _create_alarm(self, name, color, layout, col):
        # Create an indicator to show alarm status
        ind = Indicator(self, color)
        ind.setFixedSize(25, 20)
        layout.addWidget(ind, 1, col)
        layout.setAlignment(ind, Qt.AlignCenter)
        self._alarm_inds[name.lower()] = ind

        # Create a label for the indicator
        label = self._create_label(name, self)
        layout.addWidget(label, 0, col, 1, 1)
        layout.setAlignment(label, Qt.AlignCenter | Qt.AlignTop)
Exemplo n.º 4
0
    def _create_status_light(self, name, parent, layout, col):
        label = QLabel(name, parent)
        label.setAlignment(Qt.AlignCenter)
        font = label.font()
        font.setPointSize(7)
        font.setBold(True)
        label.setFont(font)
        layout.addWidget(label, 1, col)

        # Add an indicator to show inhibit state
        ind = Indicator(parent, QColor(255, 0, 0))
        ind.setFixedSize(20, 20)
        layout.addWidget(ind, 2, col)
        layout.setAlignment(ind, Qt.AlignCenter)

        return ind
Exemplo n.º 5
0
    def _create_reg(self, ind_list, name, width, color):
        # Create a widget to hold the register's bits
        reg_widget = QWidget(self)
        reg_layout = QVBoxLayout(reg_widget)
        reg_widget.setLayout(reg_layout)
        reg_layout.setSpacing(0)
        reg_layout.setMargin(0)

        # Create a widget to hold the register's label and value textbox
        label_value = QWidget(reg_widget)
        lv_layout = QHBoxLayout(label_value)
        label_value.setLayout(lv_layout)
        lv_layout.setSpacing(1)
        lv_layout.setMargin(0)
        reg_layout.addWidget(label_value)

        # Create a label to show the register's name
        reg_label = QLabel(name, label_value)
        reg_label.setAlignment(Qt.AlignCenter)
        font = reg_label.font()
        font.setPointSize(8)
        reg_label.setFont(font)
        lv_layout.addWidget(reg_label)

        # Create a textbox to show the register's value in octal
        n_digits = int((width + 2) / 3)
        if n_digits == 1:
            value_width = 25
        elif n_digits == 2:
            value_width = 30
        else:
            value_width = 45

        reg_value = QLineEdit(label_value)
        reg_value.setReadOnly(True)
        reg_value.setMaximumSize(value_width, 32)
        reg_value.setText(n_digits * '0')
        font = QFont('Monospace')
        font.setStyleHint(QFont.TypeWriter)
        font.setPointSize(10)
        reg_value.setFont(font)
        reg_value.setAlignment(Qt.AlignCenter)
        lv_layout.addWidget(reg_value)

        # Create a frame to hold the register's bits
        bit_frame = QFrame(reg_widget)
        bit_layout = QHBoxLayout(bit_frame)
        bit_layout.setSpacing(1)
        bit_layout.setMargin(0)
        bit_frame.setLayout(bit_layout)
        bit_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)

        # Add indicators for each bit in the register, from MSB to LSB
        for i in range(width, 0, -1):
            ind = Indicator(bit_frame, color)
            ind.setFixedSize(20, 32)
            bit_layout.addWidget(ind)
            ind_list.insert(0, ind)

            # Add separators between each group of 3 bits
            if (i > 1) and ((i % 3) == 1):
                sep = QFrame(bit_frame)
                sep.setFrameStyle(QFrame.VLine | QFrame.Raised)
                bit_layout.addWidget(sep)

        reg_layout.addWidget(bit_frame)

        return reg_widget, reg_value
Exemplo n.º 6
0
    def _setup_ui(self, name, color):
        # Set up the overall horizontal layout
        layout = QHBoxLayout(self)
        self.setLayout(layout)
        layout.setSpacing(3)
        layout.setMargin(1)

        # Construct a frame to hold the 16 indicators
        bit_frame = QFrame(self)
        bit_layout = QHBoxLayout(bit_frame)
        bit_layout.setSpacing(1)
        bit_layout.setMargin(0)
        bit_frame.setLayout(bit_layout)
        bit_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)

        layout.addWidget(bit_frame)

        # Add the 16 bit indicators to the frame, from 16 to 1.
        for i in range(16, 0, -1):
            ind = Indicator(bit_frame, color)
            ind.setFixedSize(20, 32)
            bit_layout.addWidget(ind)
            self._indicators.insert(0, ind)

            # Add separators between every group of 3 bits (except between
            # bits 15 and 16).
            if (i < 16) and (i > 1) and ((i % 3) == 1):
                sep = QFrame(bit_frame)
                sep.setFrameStyle(QFrame.VLine | QFrame.Raised)
                bit_layout.addWidget(sep)

        # Add sensed and generated parity bits, if this register has them
        if self._has_parity:
            sep = QFrame(bit_frame)
            sep.setFrameStyle(QFrame.VLine | QFrame.Raised)
            bit_layout.addWidget(sep)

            for i in range(2, 0, -1):
                ind = Indicator(bit_frame, QColor(220, 240, 0))
                ind.setFixedSize(20, 32)
                bit_layout.addWidget(ind)
                self._parity_inds.insert(0, ind)

        # Add a box to display the octal decoded value in
        self._value_box = QLineEdit()
        self._value_box.setMaximumSize(52, 32)
        self._value_box.setReadOnly(True)
        self._value_box.setAlignment(Qt.AlignCenter)
        self._value_box.setText('00000')

        font = QFont('Monospace')
        font.setStyleHint(QFont.TypeWriter)
        font.setPointSize(10)
        self._value_box.setFont(font)

        layout.addWidget(self._value_box)

        # Add a label showing the name of the register
        label = QLabel(name, self)
        font = label.font()
        font.setPointSize(14)
        font.setBold(True)
        label.setFont(font)
        label.setMinimumWidth(20)

        layout.addWidget(label)

        # If parity was not included, fill up the equivalent space
        if not self._has_parity:
            layout.addSpacing(62)
        else:
            layout.addSpacing(17)