Exemplo n.º 1
0
    def extract_params(self) -> List[Scale.Limit]:
        try:
            scales = []
            for row_idx in range(self.ui.limits_table.rowCount()):
                limit = utils.parse_input(
                    self.ui.limits_table.item(
                        row_idx, ScaleLimitsDialog.Column.LIMIT).text())
                device_class = self.ui.limits_table.cellWidget(
                    row_idx, ScaleLimitsDialog.Column.CLASS).value()
                signal_type = \
                    self.ui.limits_table.cellWidget(row_idx, ScaleLimitsDialog.Column.SIGNAL_TYPE).currentIndex()
                frequency = \
                    self.ui.limits_table.cellWidget(row_idx, ScaleLimitsDialog.Column.FREQUENCY).get_frequency_text()
                limit_id = int(
                    self.ui.limits_table.item(
                        row_idx, ScaleLimitsDialog.Column.ID).text())

                scales.append(
                    Scale.Limit(a_id=limit_id,
                                a_limit=limit,
                                a_device_class=device_class,
                                a_signal_type=clb.SignalType(signal_type),
                                a_frequency=frequency))
            return scales
        except Exception as err:
            utils.exception_handler(err)
Exemplo n.º 2
0
    def signal_type_changed(self, a_idx):
        try:
            sender_table_row = self.ui.limits_table.currentRow()
            row_limit_item = self.ui.limits_table.item(
                sender_table_row, ScaleLimitsDialog.Column.LIMIT)

            value_f = utils.parse_input(row_limit_item.text())
            signal_type = clb.SignalType(a_idx)
            units = clb.signal_type_to_units[signal_type]

            value_str = utils.value_to_user_with_units(units)(value_f)
            row_limit_item.setText(value_str)
        except Exception as err:
            utils.exception_handler(err)
Exemplo n.º 3
0
    def save_params(self):
        limit = utils.parse_input(self.ui.limit_edit.text())
        if limit != 0:
            if self.case.limit != limit:
                # Это сбрасывает точки шкалы в таблице
                self.case.scale_coef = 0

            self.case.limit = limit
            self.case.minimal_discrete = utils.parse_input(self.ui.minimal_discrete_edit.text())
            self.case.signal_type = clb.SignalType(self.ui.signal_type_combobox.currentIndex())
            self.case.device_class = self.ui.device_class_spinbox.value()

            self.accept()
        else:
            QtWidgets.QMessageBox.critical(self, "Ошибка", "Предел не может быть равен нулю",
                                           QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
Exemplo n.º 4
0
    def set_value_to_user(self, a_item: QtWidgets.QTableWidgetItem):
        self.ui.limits_table.blockSignals(True)
        try:
            if a_item.column() == ScaleLimitsDialog.Column.LIMIT:
                value_f = utils.parse_input(a_item.text())
                signal_type = clb.SignalType(
                    self.ui.limits_table.cellWidget(
                        a_item.row(),
                        ScaleLimitsDialog.Column.SIGNAL_TYPE).currentIndex())
                units = clb.signal_type_to_units[signal_type]
                value_f = clb.bound_amplitude(value_f, signal_type)
                value_str = utils.value_to_user_with_units(units)(value_f)

                a_item.setText(value_str)
                a_item.setData(QtCore.Qt.UserRole, value_str)

        except ValueError:
            a_item.setText(a_item.data(QtCore.Qt.UserRole))
        self.ui.limits_table.blockSignals(False)
Exemplo n.º 5
0
 def signal_type_changed(self, a_signal_type: int):
     self.case.signal_type = clb.SignalType(a_signal_type)
     self.normalize_edit_value(self.ui.limit_edit)
     self.normalize_edit_value(self.ui.minimal_discrete_edit)