def recover_config(self, a_cell_config: CellConfig):
        self.signal_type_to_radio[self.signal_type].setChecked(True)

        self.ui.measure_delay_spinbox.setValue(a_cell_config.measure_delay)
        self.ui.measure_time_spinbox.setValue(a_cell_config.measure_time)
        self.ui.coefficient_edit.setText(
            utils.float_to_string(a_cell_config.coefficient, a_precision=20))

        self.ui.coefficient_edit.setReadOnly(
            a_cell_config.auto_calc_coefficient)
        self.ui.auto_coefficient_checkbox.setChecked(
            a_cell_config.auto_calc_coefficient)

        self.ui.meter_config_edit.setText(a_cell_config.meter_config_string)

        self.ui.consider_output_value_checkbox.setChecked(
            a_cell_config.consider_output_value)

        self.coil_to_radio[a_cell_config.coil].setChecked(True)
        self.divider_to_radio[a_cell_config.divider].setChecked(True)
        self.meter_to_radio[a_cell_config.meter].setChecked(True)

        for extra_parameter in a_cell_config.extra_parameters:
            qt_utils.qtablewidget_append_row(
                self.ui.extra_variables_table,
                (extra_parameter.name, str(extra_parameter.index),
                 str(extra_parameter.bit_index), extra_parameter.type,
                 utils.float_to_string(extra_parameter.work_value),
                 utils.float_to_string(extra_parameter.default_value)))
    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid() or (self.rowCount() < index.row()) or \
                (role != Qt.DisplayRole and role != Qt.EditRole and role != Qt.BackgroundRole):
            return QVariant()
        if role == Qt.BackgroundRole:
            return QVariant(QtGui.QBrush(self.__get_cell_color(index)))
        else:
            cell_value = self.__values[index.row()][index.column()]

            if index.row() == CorrectionTableModel.HEADER_ROW and index.column(
            ) == CorrectionTableModel.HEADER_COLUMN:
                return ""

            if index.row() == CorrectionTableModel.HEADER_ROW:
                units = ""
                # units = " " + CorrectionTableModel.HZ_UNITS
            else:
                units = ""
                # units = " " + self.__signal_type_units

            if role == Qt.DisplayRole:
                value = utils.float_to_string(
                    cell_value,
                    a_precision=CorrectionTableModel.DISPLAY_DATA_PRECISION)
            else:
                value = utils.float_to_string(
                    cell_value,
                    a_precision=CorrectionTableModel.EDIT_DATA_PRECISION)

            str_value = f"{value}{units}"
            return str_value
    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid() or (self.rowCount() < index.row()) or \
                (role != Qt.DisplayRole and role != Qt.EditRole and role != Qt.BackgroundRole
                 and role != Qt.ToolTipRole and role != Qt.UserRole):
            return QVariant()
        if role == Qt.BackgroundRole:
            return QVariant(QtGui.QBrush(self.__get_cell_color(index)))
        elif role == Qt.ToolTipRole:
            if not self.__is_cell_header(index.row(), index.column()):
                return self.get_cell_tool_tip(index.row(), index.column())
            else:
                return QVariant()
        elif role == Qt.UserRole:
            if not self.__is_cell_header(index.row(), index.column()):
                cell_config = self.__cells[index.row()][index.column()].config
                # Уот так уот
                return cell_config.coil * 10 + cell_config.divider
            else:
                return 0
        else:
            cell_data = self.__cells[index.row()][index.column()]

            if not cell_data.has_value() or \
                    index.row() == MeasureDataModel.HEADER_ROW and index.column() == MeasureDataModel.HEADER_COLUMN:
                return ""

            if index.row() == MeasureDataModel.HEADER_ROW:
                displayed_data = CellData.GetDataType.MEASURED
                if self.__signal_type_is_ac:
                    units = " " + MeasureDataModel.HZ_UNITS
                else:
                    units = ""
            elif index.column() == MeasureDataModel.HEADER_COLUMN:
                displayed_data = CellData.GetDataType.MEASURED
                units = " " + self.__signal_type_units
            elif self.__displayed_data == CellData.GetDataType.MEASURED:
                displayed_data = self.__displayed_data
                units = " " + self.__signal_type_units
            else:
                displayed_data = self.__displayed_data
                units = ""

            if role == Qt.DisplayRole:
                cell_value = cell_data.get_value(displayed_data)
                value = utils.float_to_string(
                    cell_value,
                    self.get_display_precision(
                        cell_value, self.__settings.display_data_precision))
            else:
                # role == Qt.EditRole
                value = utils.float_to_string(
                    cell_data.get_value(displayed_data),
                    a_precision=self.__settings.edit_data_precision)

            str_value = f"{value}{units}"

            return str_value
Beispiel #4
0
    def recover_parameters(self, a_measure_parameters: MeasureParameters):
        self.signal_type_to_radio[a_measure_parameters.signal_type].setChecked(
            True)
        self.ui.flash_after_finish_checkbox.setChecked(
            a_measure_parameters.flash_after_finish)
        self.ui.enable_correction_checkbox.setChecked(
            a_measure_parameters.enable_correction)

        for flash_row in a_measure_parameters.flash_table:
            qt_utils.qtablewidget_append_row(
                self.ui.flash_table,
                (str(flash_row.number), str(
                    flash_row.eeprom_offset), str(flash_row.size),
                 utils.float_to_string(flash_row.start_value),
                 utils.float_to_string(flash_row.end_value)))
 def normalize_edit_value(self, edit: QtWidgets.QLineEdit):
     try:
         value = utils.parse_input(edit.text(), a_precision=20)
         edit.setText(utils.float_to_string(value, a_precision=20))
     except ValueError:
         edit.setText("0")
     self.update_edit_color(edit)
    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid() or (self.rowCount() < index.row()) or (
                role != Qt.DisplayRole and role != Qt.EditRole):
            return QVariant()

        cell_value = self.__values[index.row()][index.column()]

        if role == Qt.DisplayRole:
            str_value = utils.float_to_string(
                cell_value,
                a_precision=DeviceCoefficientsModel.DISPLAY_DATA_PRECISION)
        else:
            str_value = utils.float_to_string(
                cell_value,
                a_precision=DeviceCoefficientsModel.EDIT_DATA_PRECISION)

        return str_value
Beispiel #7
0
 def set_float_edit_param(self):
     edit = self.sender()
     object_field, type_ = self.get_parameter_name_type(edit)
     try:
         value = utils.parse_input(edit.text())
         edit.setText(utils.float_to_string(value))
         setattr(self.__variables_owner, object_field, type_(value))
     except ValueError:
         edit.setText("0")
         setattr(self.__variables_owner, object_field, type_(0.))
    def auto_coefficient_checkbox_toggled(self, a_enable):
        if a_enable:
            coil, divider, _ = self.__get_scheme()
            coefficient = CellConfig.calculate_coefficient(
                coil, divider, self.frequency, self.shared_parameters)
        else:
            coefficient = self.init_coefficient

        self.ui.coefficient_edit.setText(
            utils.float_to_string(coefficient, a_precision=20))
        self.ui.coefficient_edit.setReadOnly(a_enable)
Beispiel #9
0
    def log_measure_info(self):
        signal_type = self.current_measure_parameters.signal_type
        frequency = utils.float_to_string(self.current_frequency)
        frequency_str = f"Частота: {frequency} Гц" if clb.is_ac_signal[
            signal_type] else f"Y: {frequency}"

        logging.info(
            f"Параметры текущего измерения ({self.current_cell_position.measure_name}). "
            f"Сигнал: {clb.signal_type_to_text_short[signal_type]} ({clb.signal_type_to_text[signal_type]}). "
            f"Амплитуда: {utils.float_to_string(self.current_amplitude)} "
            f"{clb.signal_type_to_units[signal_type]}. {frequency_str}. "
            f"Катушка: {self.current_config.coil.name}, "
            f"делитель: {self.current_config.divider.name}, "
            f"измеритель: {self.current_config.meter.name}")
Beispiel #10
0
    def read_variables(self):
        self.ui.variables_table.blockSignals(True)

        try:
            if self.netvars.connected():
                for visual_row in range(self.ui.variables_table.rowCount()):
                    row = int(
                        self.ui.variables_table.item(
                            visual_row, self.Column.NUMBER).text())

                    value = self.netvars.read_variable(row)
                    self.ui.variables_table.item(visual_row,
                                                 self.Column.VALUE).setText(
                                                     utils.float_to_string(
                                                         round(value, 7)))

                self.update_graph_variables_data()
        except Exception as err:
            logging.debug(utils.exception_handler(err))

        self.ui.variables_table.blockSignals(False)
    def copy_cell_value(self):
        data_model = self.ui.correction_table_view.model()

        if data_model is not None:
            selected_indices = sorted(self.ui.correction_table_view.
                                      selectionModel().selectedIndexes())
            if selected_indices:
                copy_str = ""
                prev_row = selected_indices[0].row()
                for num, cell_idx in enumerate(selected_indices):
                    if prev_row != cell_idx.row():
                        prev_row = cell_idx.row()
                        copy_str += "\n"
                    elif num != 0:
                        copy_str += "\t"

                    cell_value = data_model.get_cell_value(
                        cell_idx.row(), cell_idx.column())
                    value_str = utils.float_to_string(
                        cell_value,
                        a_precision=15) if cell_value is not None else "0"
                    copy_str += f"{value_str}"

                QtWidgets.QApplication.clipboard().setText(copy_str)
Beispiel #12
0
 def set_number_to_table(self, a_row: int, a_column: int, a_value: float):
     self.ui.parameters_table.item(a_row, a_column).setText(
         utils.float_to_string(a_value, a_precision=15))
Beispiel #13
0
    def add_float_edit_param(self, a_name, a_object_field, a_value):
        edit = QEditDoubleClick(self.__settings_table)
        edit.setText(utils.float_to_string(a_value))

        self.add_parameter_to_table(a_name, a_object_field, edit, float)
        edit.editingFinished.connect(self.set_float_edit_param)
Beispiel #14
0
 def process_input(self, a_input: str):
     value = float(a_input.replace(",", "."))
     value = self.bound_input(value)
     return utils.float_to_string(value)