Module matisse_controller.gui.dialogs.configuration_dialog

Source code
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import *

import matisse_controller.config as cfg
import matisse_controller.config.tooltips as tooltips
import matisse_controller.matisse as matisse
from matisse_controller.shamrock_ple.ccd import CCD


class ConfigurationDialog(QDialog):
    """A dialog for displaying and modifying selected configurable options that affect the behavior of the program."""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowTitle('Configuration')
        self.resize(1000, 550)
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        self.add_options()
        self.set_current_values_from_config()
        self.add_buttons()

    def add_options(self):
        general_options = self.create_general_options()
        gui_options = self.create_gui_options()
        ple_options = self.create_ple_options()
        scan_options = self.create_scan_options()
        locking_options = self.create_locking_options()
        self.set_tooltips()

        form = QWidget()
        form_layout = QHBoxLayout()
        form.setLayout(form_layout)
        column_1 = QVBoxLayout()
        column_1.addWidget(general_options)
        column_1.addWidget(gui_options)
        column_1.addWidget(ple_options)
        form_layout.addLayout(column_1)
        form_layout.addWidget(scan_options)
        form_layout.addWidget(locking_options)
        self.layout.addWidget(form)

    def create_general_options(self):
        general_options = QGroupBox('General')
        general_layout = QFormLayout()
        general_options.setLayout(general_layout)
        self.matisse_device_id_field = QLineEdit()
        general_layout.addRow('Matisse device ID: ', self.matisse_device_id_field)
        self.wavemeter_port_field = QLineEdit()
        general_layout.addRow('Wavemeter port: ', self.wavemeter_port_field)
        self.wavemeter_precision_field = QSpinBox()
        self.wavemeter_precision_field.setMinimum(0)
        general_layout.addRow('Wavemeter precision: ', self.wavemeter_precision_field)
        self.wavemeter_measurement_delay_field = QDoubleSpinBox()
        self.wavemeter_measurement_delay_field.setMinimum(0)
        self.wavemeter_measurement_delay_field.setSingleStep(0.1)
        general_layout.addRow('Wavemeter measurement delay: ', self.wavemeter_measurement_delay_field)
        self.component_limit_offset_field = QDoubleSpinBox()
        self.component_limit_offset_field.setMinimum(0)
        self.component_limit_offset_field.setDecimals(3)
        general_layout.addRow('Component limit offset: ', self.component_limit_offset_field)
        self.wavelength_lower_limit_field = QDoubleSpinBox()
        self.wavelength_lower_limit_field.setMinimum(0)
        self.wavelength_lower_limit_field.setMaximum(2000)
        general_layout.addRow('Wavelength lower limit: ', self.wavelength_lower_limit_field)
        self.wavelength_upper_limit_field = QDoubleSpinBox()
        self.wavelength_upper_limit_field.setMinimum(0)
        self.wavelength_upper_limit_field.setMaximum(2000)
        general_layout.addRow('Wavelength upper limit: ', self.wavelength_upper_limit_field)
        self.bifi_reset_pos_field = QSpinBox()
        self.bifi_reset_pos_field.setMinimum(matisse.BIREFRINGENT_FILTER_LOWER_LIMIT)
        self.bifi_reset_pos_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT)
        general_layout.addRow('BiFi reset position: ', self.bifi_reset_pos_field)
        self.thin_eta_reset_pos_field = QSpinBox()
        self.thin_eta_reset_pos_field.setMinimum(matisse.THIN_ETALON_LOWER_LIMIT)
        self.thin_eta_reset_pos_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT)
        general_layout.addRow('Thin etalon reset position: ', self.thin_eta_reset_pos_field)
        self.thin_eta_rand_range_field = QSpinBox()
        self.thin_eta_rand_range_field.setMinimum(0)
        self.thin_eta_rand_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 2)
        general_layout.addRow('Thin etalon randomization range: ', self.thin_eta_rand_range_field)
        self.report_events_field = QCheckBox()
        general_layout.addRow('Report events? ', self.report_events_field)
        return general_options

    def create_gui_options(self):
        gui_options = QGroupBox('GUI')
        gui_layout = QFormLayout()
        gui_options.setLayout(gui_layout)
        self.status_monitor_delay_field = QDoubleSpinBox()
        self.status_monitor_delay_field.setMinimum(0)
        gui_layout.addRow('Status monitor update delay: ', self.status_monitor_delay_field)
        self.status_monitor_font_size_field = QSpinBox()
        self.status_monitor_font_size_field.setMinimum(0)
        gui_layout.addRow('Status monitor font size: ', self.status_monitor_font_size_field)
        return gui_options

    def create_ple_options(self):
        ple_options = QGroupBox('PLE')
        ple_layout = QFormLayout()
        ple_options.setLayout(ple_layout)
        self.target_temperature_field = QSpinBox()
        self.target_temperature_field.setMinimum(CCD.MIN_TEMP)
        self.target_temperature_field.setMaximum(CCD.MAX_TEMP)
        ple_layout.addRow('Default target CCD temperature: ', self.target_temperature_field)
        self.temperature_tolerance_field = QDoubleSpinBox()
        self.temperature_tolerance_field.setMinimum(3)
        ple_layout.addRow('CCD temperature tolerance: ', self.temperature_tolerance_field)
        return ple_options

    def create_scan_options(self):
        scan_options = QGroupBox('Scanning')
        scan_layout = QFormLayout()
        scan_options.setLayout(scan_layout)
        self.scan_limit_field = QSpinBox()
        self.scan_limit_field.setMinimum(0)
        scan_layout.addRow('Number of scans before retry: ', self.scan_limit_field)
        self.bifi_scan_range_field = QSpinBox()
        self.bifi_scan_range_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT / 2)
        scan_layout.addRow('BiFi normal scan range:', self.bifi_scan_range_field)
        self.bifi_small_scan_range_field = QSpinBox()
        self.bifi_small_scan_range_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT / 4)
        scan_layout.addRow('BiFi small scan range:', self.bifi_small_scan_range_field)
        self.bifi_scan_step_field = QSpinBox()
        scan_layout.addRow('BiFi scan step:', self.bifi_scan_step_field)
        self.bifi_scan_show_plots_field = QCheckBox()
        scan_layout.addRow('Show BiFi scan plots? ', self.bifi_scan_show_plots_field)
        self.bifi_smoothing_window_field = QSpinBox()
        self.bifi_smoothing_window_field.setMinimum(1)
        self.bifi_smoothing_window_field.setSingleStep(2)
        self.bifi_smoothing_window_field.valueChanged.connect(self.ensure_odd_value)
        scan_layout.addRow('BiFi smoothing filter window: ', self.bifi_smoothing_window_field)
        self.bifi_smoothing_polyorder_field = QSpinBox()
        self.bifi_smoothing_polyorder_field.setMinimum(1)
        scan_layout.addRow('BiFi smoothing filter polyorder: ', self.bifi_smoothing_polyorder_field)
        self.thin_eta_scan_range_field = QSpinBox()
        self.thin_eta_scan_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 2)
        scan_layout.addRow('Thin etalon normal scan range:', self.thin_eta_scan_range_field)
        self.thin_eta_small_scan_range_field = QSpinBox()
        self.thin_eta_small_scan_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 4)
        scan_layout.addRow('Thin etalon small scan range:', self.thin_eta_small_scan_range_field)
        self.thin_eta_scan_step_field = QSpinBox()
        scan_layout.addRow('Thin etalon scan step:', self.thin_eta_scan_step_field)
        self.thin_eta_nudge_field = QSpinBox()
        scan_layout.addRow('Thin etalon scan nudge:', self.thin_eta_nudge_field)
        self.thin_eta_scan_show_plots_field = QCheckBox()
        scan_layout.addRow('Show thin etalon scan plots? ', self.thin_eta_scan_show_plots_field)
        self.thin_eta_smoothing_window_field = QSpinBox()
        self.thin_eta_smoothing_window_field.setMinimum(1)
        self.thin_eta_smoothing_window_field.setSingleStep(2)
        self.thin_eta_smoothing_window_field.valueChanged.connect(self.ensure_odd_value)
        scan_layout.addRow('Thin etalon smoothing filter window: ', self.thin_eta_smoothing_window_field)
        self.thin_eta_smoothing_polyorder_field = QSpinBox()
        self.thin_eta_smoothing_polyorder_field.setMinimum(1)
        scan_layout.addRow('Thin etalon smoothing filter polyorder: ', self.thin_eta_smoothing_polyorder_field)
        self.thin_eta_max_allowed_stddev_field = QDoubleSpinBox()
        self.thin_eta_max_allowed_stddev_field.setMinimum(0)
        scan_layout.addRow('Thin etalon max allowed stddev: ', self.thin_eta_max_allowed_stddev_field)
        self.refcell_rising_speed_field = QDoubleSpinBox()
        self.refcell_rising_speed_field.setDecimals(3)
        self.refcell_rising_speed_field.setSingleStep(0.001)
        self.refcell_rising_speed_field.setMinimum(0)
        self.refcell_rising_speed_field.setMaximum(0.1)
        scan_layout.addRow('RefCell scan rising speed: ', self.refcell_rising_speed_field)
        self.refcell_falling_speed_field = QDoubleSpinBox()
        self.refcell_falling_speed_field.setDecimals(3)
        self.refcell_falling_speed_field.setSingleStep(0.001)
        self.refcell_falling_speed_field.setMinimum(0)
        self.refcell_falling_speed_field.setMaximum(0.1)
        scan_layout.addRow('RefCell scan falling speed: ', self.refcell_falling_speed_field)
        self.large_wavelength_drift_field = QDoubleSpinBox()
        scan_layout.addRow('Large wavelength drift: ', self.large_wavelength_drift_field)
        self.medium_wavelength_drift_field = QDoubleSpinBox()
        scan_layout.addRow('Medium wavelength drift: ', self.medium_wavelength_drift_field)
        self.small_wavelength_drift_field = QDoubleSpinBox()
        scan_layout.addRow('Small wavelength drift: ', self.small_wavelength_drift_field)
        return scan_options

    def create_locking_options(self):
        locking_options = QGroupBox('Locking/Stabilization')
        locking_layout = QFormLayout()
        locking_options.setLayout(locking_layout)
        self.locking_timeout_field = QDoubleSpinBox()
        self.locking_timeout_field.setMinimum(0)
        locking_layout.addRow('Locking timeout: ', self.locking_timeout_field)
        self.fast_pz_setpoint_lower_limit_field = QDoubleSpinBox()
        self.fast_pz_setpoint_lower_limit_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.fast_pz_setpoint_lower_limit_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('Fast piezo setpoint scan lower limit: ', self.fast_pz_setpoint_lower_limit_field)
        self.fast_pz_setpoint_upper_limit_field = QDoubleSpinBox()
        self.fast_pz_setpoint_upper_limit_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.fast_pz_setpoint_upper_limit_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('Fast piezo setpoint scan upper limit: ', self.fast_pz_setpoint_upper_limit_field)
        self.fast_pz_setpoint_num_points_field = QSpinBox()
        self.fast_pz_setpoint_num_points_field.setMinimum(32)
        self.fast_pz_setpoint_num_points_field.setMaximum(512)
        locking_layout.addRow('Fast piezo setpoint scan sample: ', self.fast_pz_setpoint_num_points_field)
        self.fast_pz_setpoint_num_scans_field = QSpinBox()
        self.fast_pz_setpoint_num_scans_field.setMinimum(1)
        locking_layout.addRow('Fast piezo setpoint number of scans: ', self.fast_pz_setpoint_num_scans_field)
        self.auto_correction_limit_field = QSpinBox()
        self.auto_correction_limit_field.setMinimum(1)
        locking_layout.addRow('Number of auto-corrections before retry: ', self.auto_correction_limit_field)
        self.pz_eta_upper_correction_pos_field = QDoubleSpinBox()
        self.pz_eta_upper_correction_pos_field.setSingleStep(0.01)
        self.pz_eta_upper_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
        self.pz_eta_upper_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
        locking_layout.addRow('Piezo etalon upper correction pos: ', self.pz_eta_upper_correction_pos_field)
        self.slow_pz_upper_correction_pos_field = QDoubleSpinBox()
        self.slow_pz_upper_correction_pos_field.setSingleStep(0.01)
        self.slow_pz_upper_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
        self.slow_pz_upper_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
        locking_layout.addRow('Slow piezo upper correction pos: ', self.slow_pz_upper_correction_pos_field)
        self.refcell_upper_correction_pos_field = QDoubleSpinBox()
        self.refcell_upper_correction_pos_field.setSingleStep(0.01)
        self.refcell_upper_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.refcell_upper_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('RefCell upper correction pos: ', self.refcell_upper_correction_pos_field)
        self.pz_eta_mid_correction_pos_field = QDoubleSpinBox()
        self.pz_eta_mid_correction_pos_field.setSingleStep(0.01)
        self.pz_eta_mid_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
        self.pz_eta_mid_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
        locking_layout.addRow('Piezo etalon mid correction pos: ', self.pz_eta_mid_correction_pos_field)
        self.slow_pz_mid_correction_pos_field = QDoubleSpinBox()
        self.slow_pz_mid_correction_pos_field.setSingleStep(0.01)
        self.slow_pz_mid_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
        self.slow_pz_mid_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
        locking_layout.addRow('Slow piezo mid correction pos: ', self.slow_pz_mid_correction_pos_field)
        self.refcell_mid_correction_pos_field = QDoubleSpinBox()
        self.refcell_mid_correction_pos_field.setSingleStep(0.01)
        self.refcell_mid_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.refcell_mid_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('RefCell mid correction pos: ', self.refcell_mid_correction_pos_field)
        self.pz_eta_lower_correction_pos_field = QDoubleSpinBox()
        self.pz_eta_lower_correction_pos_field.setSingleStep(0.01)
        self.pz_eta_lower_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
        self.pz_eta_lower_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
        locking_layout.addRow('Piezo etalon lower correction pos: ', self.pz_eta_lower_correction_pos_field)
        self.slow_pz_lower_correction_pos_field = QDoubleSpinBox()
        self.slow_pz_lower_correction_pos_field.setSingleStep(0.01)
        self.slow_pz_lower_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
        self.slow_pz_lower_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
        locking_layout.addRow('Slow piezo lower correction pos: ', self.slow_pz_lower_correction_pos_field)
        self.refcell_lower_correction_pos_field = QDoubleSpinBox()
        self.refcell_lower_correction_pos_field.setSingleStep(0.01)
        self.refcell_lower_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.refcell_lower_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('RefCell lower correction pos: ', self.refcell_lower_correction_pos_field)
        self.stabilization_rising_speed_field = QDoubleSpinBox()
        self.stabilization_rising_speed_field.setDecimals(3)
        self.stabilization_rising_speed_field.setSingleStep(0.001)
        self.stabilization_rising_speed_field.setMinimum(0)
        self.stabilization_rising_speed_field.setMaximum(0.1)
        locking_layout.addRow('Auto-stabilization rising speed: ', self.stabilization_rising_speed_field)
        self.stabilization_falling_speed_field = QDoubleSpinBox()
        self.stabilization_falling_speed_field.setDecimals(3)
        self.stabilization_falling_speed_field.setSingleStep(0.001)
        self.stabilization_falling_speed_field.setMinimum(0)
        self.stabilization_falling_speed_field.setMaximum(0.1)
        locking_layout.addRow('Auto-stabilization falling speed: ', self.stabilization_falling_speed_field)
        self.stabilization_delay_field = QDoubleSpinBox()
        self.stabilization_delay_field.setMinimum(0.1)
        locking_layout.addRow('Auto-stabilization delay: ', self.stabilization_delay_field)
        self.stabilization_tolerance_field = QDoubleSpinBox()
        self.stabilization_tolerance_field.setDecimals(4)
        self.stabilization_tolerance_field.setSingleStep(0.0001)
        self.stabilization_tolerance_field.setMinimum(0.0001)
        locking_layout.addRow('Auto-stabilization tolerance: ', self.stabilization_tolerance_field)
        return locking_options

    def set_tooltips(self):
        self.matisse_device_id_field.setToolTip(tooltips.MATISSE_DEVICE_ID)
        self.wavemeter_port_field.setToolTip(tooltips.WAVEMETER_PORT)
        self.wavemeter_precision_field.setToolTip(tooltips.WAVEMETER_PRECISION)
        self.wavemeter_measurement_delay_field.setToolTip(tooltips.WAVEMETER_MEASUREMENT_DELAY)

        self.status_monitor_delay_field.setToolTip(tooltips.STATUS_MONITOR_DELAY)
        self.status_monitor_font_size_field.setToolTip(tooltips.STATUS_MONITOR_FONT_SIZE)

        self.bifi_reset_pos_field.setToolTip(tooltips.BIFI_RESET_POS)
        self.thin_eta_reset_pos_field.setToolTip(tooltips.THIN_ETA_RESET_POS)
        self.thin_eta_rand_range_field.setToolTip(tooltips.THIN_ETA_RAND_RANGE)

        self.report_events_field.setToolTip(tooltips.REPORT_EVENTS)

        self.component_limit_offset_field.setToolTip(tooltips.COMPONENT_LIMIT_OFFSET)

        self.wavelength_lower_limit_field.setToolTip(tooltips.WAVELENGTH_LOWER_LIMIT)
        self.wavelength_upper_limit_field.setToolTip(tooltips.WAVELENGTH_UPPER_LIMIT)

        self.scan_limit_field.setToolTip(tooltips.SCAN_LIMIT)

        self.bifi_scan_range_field.setToolTip(tooltips.BIFI_SCAN_RANGE)
        self.bifi_small_scan_range_field.setToolTip(tooltips.BIFI_SCAN_RANGE_SMALL)
        self.bifi_scan_step_field.setToolTip(tooltips.BIFI_SCAN_STEP)
        self.bifi_scan_show_plots_field.setToolTip(tooltips.BIFI_SCAN_SHOW_PLOTS)
        self.bifi_smoothing_window_field.setToolTip(tooltips.BIFI_SMOOTHING_FILTER_WINDOW)
        self.bifi_smoothing_polyorder_field.setToolTip(tooltips.BIFI_SMOOTHING_FILTER_POLYORDER)

        self.thin_eta_scan_range_field.setToolTip(tooltips.THIN_ETA_SCAN_RANGE)
        self.thin_eta_small_scan_range_field.setToolTip(tooltips.THIN_ETA_SCAN_RANGE_SMALL)
        self.thin_eta_scan_step_field.setToolTip(tooltips.THIN_ETA_SCAN_STEP)
        self.thin_eta_nudge_field.setToolTip(tooltips.THIN_ETA_NUDGE)
        self.thin_eta_scan_show_plots_field.setToolTip(tooltips.THIN_ETA_SHOW_PLOTS)
        self.thin_eta_smoothing_window_field.setToolTip(tooltips.THIN_ETA_SMOOTHING_FILTER_WINDOW)
        self.thin_eta_smoothing_polyorder_field.setToolTip(tooltips.THIN_ETA_SMOOTHING_FILTER_POLYORDER)
        self.thin_eta_max_allowed_stddev_field.setToolTip(tooltips.THIN_ETA_MAX_ALLOWED_STDDEV)

        self.refcell_rising_speed_field.setToolTip(tooltips.REFCELL_SCAN_RISING_SPEED)
        self.refcell_falling_speed_field.setToolTip(tooltips.REFCELL_SCAN_FALLING_SPEED)

        self.large_wavelength_drift_field.setToolTip(tooltips.LARGE_WAVELENGTH_DRIFT)
        self.medium_wavelength_drift_field.setToolTip(tooltips.MEDIUM_WAVELENGTH_DRIFT)
        self.small_wavelength_drift_field.setToolTip(tooltips.SMALL_WAVELENGTH_DRIFT)

        self.locking_timeout_field.setToolTip(tooltips.LOCKING_TIMEOUT)
        self.fast_pz_setpoint_lower_limit_field.setToolTip(tooltips.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT)
        self.fast_pz_setpoint_upper_limit_field.setToolTip(tooltips.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT)
        self.fast_pz_setpoint_num_points_field.setToolTip(tooltips.FAST_PZ_SETPOINT_NUM_POINTS)
        self.fast_pz_setpoint_num_scans_field.setToolTip(tooltips.FAST_PZ_SETPOINT_NUM_SCANS)

        self.stabilization_rising_speed_field.setToolTip(tooltips.STABILIZATION_RISING_SPEED)
        self.stabilization_falling_speed_field.setToolTip(tooltips.STABILIZATION_FALLING_SPEED)
        self.stabilization_delay_field.setToolTip(tooltips.STABILIZATION_DELAY)
        self.stabilization_tolerance_field.setToolTip(tooltips.STABILIZATION_TOLERANCE)

        self.auto_correction_limit_field.setToolTip(tooltips.CORRECTION_LIMIT)

        self.target_temperature_field.setToolTip(tooltips.PLE_TARGET_TEMPERATURE)
        self.temperature_tolerance_field.setToolTip(tooltips.PLE_TEMPERATURE_TOLERANCE)

    def set_current_values_from_config(self):
        self.matisse_device_id_field.setText(cfg.get(cfg.MATISSE_DEVICE_ID))
        self.wavemeter_port_field.setText(cfg.get(cfg.WAVEMETER_PORT))
        self.wavemeter_precision_field.setValue(cfg.get(cfg.WAVEMETER_PRECISION))
        self.wavemeter_measurement_delay_field.setValue(cfg.get(cfg.WAVEMETER_MEASUREMENT_DELAY))

        self.status_monitor_delay_field.setValue(cfg.get(cfg.STATUS_MONITOR_DELAY))
        self.status_monitor_font_size_field.setValue(cfg.get(cfg.STATUS_MONITOR_FONT_SIZE))

        self.component_limit_offset_field.setValue(cfg.get(cfg.COMPONENT_LIMIT_OFFSET))
        self.wavelength_lower_limit_field.setValue(cfg.get(cfg.WAVELENGTH_LOWER_LIMIT))
        self.wavelength_upper_limit_field.setValue(cfg.get(cfg.WAVELENGTH_UPPER_LIMIT))
        self.bifi_reset_pos_field.setValue(cfg.get(cfg.BIFI_RESET_POS))
        self.thin_eta_reset_pos_field.setValue(cfg.get(cfg.THIN_ETA_RESET_POS))
        self.thin_eta_rand_range_field.setValue(cfg.get(cfg.THIN_ETA_RAND_RANGE))

        self.report_events_field.setChecked(cfg.get(cfg.REPORT_EVENTS))

        self.scan_limit_field.setValue(cfg.get(cfg.SCAN_LIMIT))

        self.bifi_scan_range_field.setValue(cfg.get(cfg.BIFI_SCAN_RANGE))
        self.bifi_small_scan_range_field.setValue(cfg.get(cfg.BIFI_SCAN_RANGE_SMALL))
        self.bifi_scan_step_field.setValue(cfg.get(cfg.BIFI_SCAN_STEP))
        self.bifi_scan_show_plots_field.setChecked(cfg.get(cfg.BIFI_SCAN_SHOW_PLOTS))
        self.bifi_smoothing_window_field.setValue(cfg.get(cfg.BIFI_SMOOTHING_FILTER_WINDOW))
        self.bifi_smoothing_polyorder_field.setValue(cfg.get(cfg.BIFI_SMOOTHING_FILTER_POLYORDER))

        self.thin_eta_scan_range_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_RANGE))
        self.thin_eta_small_scan_range_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_RANGE_SMALL))
        self.thin_eta_scan_step_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_STEP))
        self.thin_eta_nudge_field.setValue(cfg.get(cfg.THIN_ETA_NUDGE))
        self.thin_eta_scan_show_plots_field.setChecked(cfg.get(cfg.THIN_ETA_SHOW_PLOTS))
        self.thin_eta_smoothing_window_field.setValue(cfg.get(cfg.THIN_ETA_SMOOTHING_FILTER_WINDOW))
        self.thin_eta_smoothing_polyorder_field.setValue(cfg.get(cfg.THIN_ETA_SMOOTHING_FILTER_POLYORDER))
        self.thin_eta_max_allowed_stddev_field.setValue(cfg.get(cfg.THIN_ETA_MAX_ALLOWED_STDDEV))

        self.refcell_rising_speed_field.setValue(cfg.get(cfg.REFCELL_SCAN_RISING_SPEED))
        self.refcell_falling_speed_field.setValue(cfg.get(cfg.REFCELL_SCAN_FALLING_SPEED))

        self.large_wavelength_drift_field.setValue(cfg.get(cfg.LARGE_WAVELENGTH_DRIFT))
        self.medium_wavelength_drift_field.setValue(cfg.get(cfg.MEDIUM_WAVELENGTH_DRIFT))
        self.small_wavelength_drift_field.setValue(cfg.get(cfg.SMALL_WAVELENGTH_DRIFT))

        self.locking_timeout_field.setValue(cfg.get(cfg.LOCKING_TIMEOUT))
        self.fast_pz_setpoint_lower_limit_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT))
        self.fast_pz_setpoint_upper_limit_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT))
        self.fast_pz_setpoint_num_points_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_NUM_POINTS))
        self.fast_pz_setpoint_num_scans_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_NUM_SCANS))

        self.stabilization_rising_speed_field.setValue(cfg.get(cfg.STABILIZATION_RISING_SPEED))
        self.stabilization_falling_speed_field.setValue(cfg.get(cfg.STABILIZATION_FALLING_SPEED))
        self.stabilization_delay_field.setValue(cfg.get(cfg.STABILIZATION_DELAY))
        self.stabilization_tolerance_field.setValue(cfg.get(cfg.STABILIZATION_TOLERANCE))

        self.auto_correction_limit_field.setValue(cfg.get(cfg.CORRECTION_LIMIT))

        self.pz_eta_upper_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_UPPER_CORRECTION_POS))
        self.slow_pz_upper_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_UPPER_CORRECTION_POS))
        self.refcell_upper_correction_pos_field.setValue(cfg.get(cfg.REFCELL_UPPER_CORRECTION_POS))
        self.pz_eta_mid_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_MID_CORRECTION_POS))
        self.slow_pz_mid_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_MID_CORRECTION_POS))
        self.refcell_mid_correction_pos_field.setValue(cfg.get(cfg.REFCELL_MID_CORRECTION_POS))
        self.pz_eta_lower_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_LOWER_CORRECTION_POS))
        self.slow_pz_lower_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_LOWER_CORRECTION_POS))
        self.refcell_lower_correction_pos_field.setValue(cfg.get(cfg.REFCELL_LOWER_CORRECTION_POS))

        self.target_temperature_field.setValue(cfg.get(cfg.PLE_TARGET_TEMPERATURE))
        self.temperature_tolerance_field.setValue(cfg.get(cfg.PLE_TEMPERATURE_TOLERANCE))

    def add_buttons(self):
        button_box = QDialogButtonBox(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Save |
                                      QDialogButtonBox.Cancel)
        button_box.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore_defaults)
        button_box.button(QDialogButtonBox.Save).clicked.connect(self.save_configuration)
        button_box.button(QDialogButtonBox.Cancel).clicked.connect(self.cancel)
        self.layout.addWidget(button_box)

    @pyqtSlot(bool)
    def restore_defaults(self, checked):
        cfg.restore_defaults()
        self.set_current_values_from_config()

    @pyqtSlot(bool)
    def save_configuration(self, checked):
        print('Saving configuration.')
        cfg.set(cfg.MATISSE_DEVICE_ID, self.matisse_device_id_field.text())
        cfg.set(cfg.WAVEMETER_PORT, self.wavemeter_port_field.text())
        cfg.set(cfg.WAVEMETER_PRECISION, self.wavemeter_precision_field.value())
        cfg.set(cfg.WAVEMETER_MEASUREMENT_DELAY, self.wavemeter_measurement_delay_field.value())

        cfg.set(cfg.STATUS_MONITOR_DELAY, self.status_monitor_delay_field.value())
        cfg.set(cfg.STATUS_MONITOR_FONT_SIZE, self.status_monitor_font_size_field.value())

        cfg.set(cfg.COMPONENT_LIMIT_OFFSET, self.component_limit_offset_field.value())
        cfg.set(cfg.WAVELENGTH_LOWER_LIMIT, self.wavelength_lower_limit_field.value())
        cfg.set(cfg.WAVELENGTH_UPPER_LIMIT, self.wavelength_upper_limit_field.value())
        cfg.set(cfg.BIFI_RESET_POS, self.bifi_reset_pos_field.value())
        cfg.set(cfg.THIN_ETA_RESET_POS, self.thin_eta_reset_pos_field.value())
        cfg.set(cfg.THIN_ETA_RAND_RANGE, self.thin_eta_rand_range_field.value())

        cfg.set(cfg.REPORT_EVENTS, self.report_events_field.isChecked())

        cfg.set(cfg.SCAN_LIMIT, self.scan_limit_field.value())

        cfg.set(cfg.BIFI_SCAN_RANGE, self.bifi_scan_range_field.value())
        cfg.set(cfg.BIFI_SCAN_RANGE_SMALL, self.bifi_small_scan_range_field.value())
        cfg.set(cfg.BIFI_SCAN_STEP, self.bifi_scan_step_field.value())
        cfg.set(cfg.BIFI_SCAN_SHOW_PLOTS, self.bifi_scan_show_plots_field.isChecked())
        cfg.set(cfg.BIFI_SMOOTHING_FILTER_WINDOW, self.bifi_smoothing_window_field.value())
        cfg.set(cfg.BIFI_SMOOTHING_FILTER_POLYORDER, self.bifi_smoothing_polyorder_field.value())

        cfg.set(cfg.THIN_ETA_SCAN_RANGE, self.thin_eta_scan_range_field.value())
        cfg.set(cfg.THIN_ETA_SCAN_RANGE_SMALL, self.thin_eta_small_scan_range_field.value())
        cfg.set(cfg.THIN_ETA_SCAN_STEP, self.thin_eta_scan_step_field.value())
        cfg.set(cfg.THIN_ETA_NUDGE, self.thin_eta_nudge_field.value())
        cfg.set(cfg.THIN_ETA_SHOW_PLOTS, self.thin_eta_scan_show_plots_field.isChecked())
        cfg.set(cfg.THIN_ETA_SMOOTHING_FILTER_WINDOW, self.thin_eta_smoothing_window_field.value())
        cfg.set(cfg.THIN_ETA_SMOOTHING_FILTER_POLYORDER, self.thin_eta_smoothing_polyorder_field.value())
        cfg.set(cfg.THIN_ETA_MAX_ALLOWED_STDDEV, self.thin_eta_max_allowed_stddev_field.value())

        cfg.set(cfg.REFCELL_SCAN_RISING_SPEED, self.refcell_rising_speed_field.value())
        cfg.set(cfg.REFCELL_SCAN_FALLING_SPEED, self.refcell_falling_speed_field.value())

        cfg.set(cfg.LARGE_WAVELENGTH_DRIFT, self.large_wavelength_drift_field.value())
        cfg.set(cfg.MEDIUM_WAVELENGTH_DRIFT, self.medium_wavelength_drift_field.value())
        cfg.set(cfg.SMALL_WAVELENGTH_DRIFT, self.small_wavelength_drift_field.value())

        cfg.set(cfg.LOCKING_TIMEOUT, self.locking_timeout_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT, self.fast_pz_setpoint_lower_limit_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT, self.fast_pz_setpoint_upper_limit_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_NUM_POINTS, self.fast_pz_setpoint_num_points_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_NUM_SCANS, self.fast_pz_setpoint_num_scans_field.value())

        cfg.set(cfg.STABILIZATION_RISING_SPEED, self.stabilization_rising_speed_field.value())
        cfg.set(cfg.STABILIZATION_FALLING_SPEED, self.stabilization_falling_speed_field.value())
        cfg.set(cfg.STABILIZATION_DELAY, self.stabilization_delay_field.value())
        cfg.set(cfg.STABILIZATION_TOLERANCE, self.stabilization_tolerance_field.value())

        cfg.set(cfg.CORRECTION_LIMIT, self.auto_correction_limit_field.value())

        cfg.set(cfg.PIEZO_ETA_UPPER_CORRECTION_POS, self.pz_eta_upper_correction_pos_field.value())
        cfg.set(cfg.SLOW_PIEZO_UPPER_CORRECTION_POS, self.slow_pz_upper_correction_pos_field.value())
        cfg.set(cfg.REFCELL_UPPER_CORRECTION_POS, self.refcell_upper_correction_pos_field.value())
        cfg.set(cfg.PIEZO_ETA_MID_CORRECTION_POS, self.pz_eta_mid_correction_pos_field.value())
        cfg.set(cfg.SLOW_PIEZO_MID_CORRECTION_POS, self.slow_pz_mid_correction_pos_field.value())
        cfg.set(cfg.REFCELL_MID_CORRECTION_POS, self.refcell_mid_correction_pos_field.value())
        cfg.set(cfg.PIEZO_ETA_LOWER_CORRECTION_POS, self.pz_eta_lower_correction_pos_field.value())
        cfg.set(cfg.SLOW_PIEZO_LOWER_CORRECTION_POS, self.slow_pz_lower_correction_pos_field.value())
        cfg.set(cfg.REFCELL_LOWER_CORRECTION_POS, self.refcell_lower_correction_pos_field.value())

        cfg.set(cfg.PLE_TARGET_TEMPERATURE, self.target_temperature_field.value())
        cfg.set(cfg.PLE_TEMPERATURE_TOLERANCE, self.temperature_tolerance_field.value())

        cfg.save()
        self.close()

    @pyqtSlot(bool)
    def cancel(self, checked):
        self.close()

    @pyqtSlot(int)
    def ensure_odd_value(self, value):
        field: QSpinBox = self.sender()
        if value % 2 == 0:
            field.setValue(value - 1)


def main():
    app = QApplication([])
    d = ConfigurationDialog()
    d.exec()
    app.exit()


if __name__ == '__main__':
    main()

Functions

def main()
Source code
def main():
    app = QApplication([])
    d = ConfigurationDialog()
    d.exec()
    app.exit()

Classes

class ConfigurationDialog (*args, **kwargs)

A dialog for displaying and modifying selected configurable options that affect the behavior of the program.

Source code
class ConfigurationDialog(QDialog):
    """A dialog for displaying and modifying selected configurable options that affect the behavior of the program."""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowTitle('Configuration')
        self.resize(1000, 550)
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        self.add_options()
        self.set_current_values_from_config()
        self.add_buttons()

    def add_options(self):
        general_options = self.create_general_options()
        gui_options = self.create_gui_options()
        ple_options = self.create_ple_options()
        scan_options = self.create_scan_options()
        locking_options = self.create_locking_options()
        self.set_tooltips()

        form = QWidget()
        form_layout = QHBoxLayout()
        form.setLayout(form_layout)
        column_1 = QVBoxLayout()
        column_1.addWidget(general_options)
        column_1.addWidget(gui_options)
        column_1.addWidget(ple_options)
        form_layout.addLayout(column_1)
        form_layout.addWidget(scan_options)
        form_layout.addWidget(locking_options)
        self.layout.addWidget(form)

    def create_general_options(self):
        general_options = QGroupBox('General')
        general_layout = QFormLayout()
        general_options.setLayout(general_layout)
        self.matisse_device_id_field = QLineEdit()
        general_layout.addRow('Matisse device ID: ', self.matisse_device_id_field)
        self.wavemeter_port_field = QLineEdit()
        general_layout.addRow('Wavemeter port: ', self.wavemeter_port_field)
        self.wavemeter_precision_field = QSpinBox()
        self.wavemeter_precision_field.setMinimum(0)
        general_layout.addRow('Wavemeter precision: ', self.wavemeter_precision_field)
        self.wavemeter_measurement_delay_field = QDoubleSpinBox()
        self.wavemeter_measurement_delay_field.setMinimum(0)
        self.wavemeter_measurement_delay_field.setSingleStep(0.1)
        general_layout.addRow('Wavemeter measurement delay: ', self.wavemeter_measurement_delay_field)
        self.component_limit_offset_field = QDoubleSpinBox()
        self.component_limit_offset_field.setMinimum(0)
        self.component_limit_offset_field.setDecimals(3)
        general_layout.addRow('Component limit offset: ', self.component_limit_offset_field)
        self.wavelength_lower_limit_field = QDoubleSpinBox()
        self.wavelength_lower_limit_field.setMinimum(0)
        self.wavelength_lower_limit_field.setMaximum(2000)
        general_layout.addRow('Wavelength lower limit: ', self.wavelength_lower_limit_field)
        self.wavelength_upper_limit_field = QDoubleSpinBox()
        self.wavelength_upper_limit_field.setMinimum(0)
        self.wavelength_upper_limit_field.setMaximum(2000)
        general_layout.addRow('Wavelength upper limit: ', self.wavelength_upper_limit_field)
        self.bifi_reset_pos_field = QSpinBox()
        self.bifi_reset_pos_field.setMinimum(matisse.BIREFRINGENT_FILTER_LOWER_LIMIT)
        self.bifi_reset_pos_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT)
        general_layout.addRow('BiFi reset position: ', self.bifi_reset_pos_field)
        self.thin_eta_reset_pos_field = QSpinBox()
        self.thin_eta_reset_pos_field.setMinimum(matisse.THIN_ETALON_LOWER_LIMIT)
        self.thin_eta_reset_pos_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT)
        general_layout.addRow('Thin etalon reset position: ', self.thin_eta_reset_pos_field)
        self.thin_eta_rand_range_field = QSpinBox()
        self.thin_eta_rand_range_field.setMinimum(0)
        self.thin_eta_rand_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 2)
        general_layout.addRow('Thin etalon randomization range: ', self.thin_eta_rand_range_field)
        self.report_events_field = QCheckBox()
        general_layout.addRow('Report events? ', self.report_events_field)
        return general_options

    def create_gui_options(self):
        gui_options = QGroupBox('GUI')
        gui_layout = QFormLayout()
        gui_options.setLayout(gui_layout)
        self.status_monitor_delay_field = QDoubleSpinBox()
        self.status_monitor_delay_field.setMinimum(0)
        gui_layout.addRow('Status monitor update delay: ', self.status_monitor_delay_field)
        self.status_monitor_font_size_field = QSpinBox()
        self.status_monitor_font_size_field.setMinimum(0)
        gui_layout.addRow('Status monitor font size: ', self.status_monitor_font_size_field)
        return gui_options

    def create_ple_options(self):
        ple_options = QGroupBox('PLE')
        ple_layout = QFormLayout()
        ple_options.setLayout(ple_layout)
        self.target_temperature_field = QSpinBox()
        self.target_temperature_field.setMinimum(CCD.MIN_TEMP)
        self.target_temperature_field.setMaximum(CCD.MAX_TEMP)
        ple_layout.addRow('Default target CCD temperature: ', self.target_temperature_field)
        self.temperature_tolerance_field = QDoubleSpinBox()
        self.temperature_tolerance_field.setMinimum(3)
        ple_layout.addRow('CCD temperature tolerance: ', self.temperature_tolerance_field)
        return ple_options

    def create_scan_options(self):
        scan_options = QGroupBox('Scanning')
        scan_layout = QFormLayout()
        scan_options.setLayout(scan_layout)
        self.scan_limit_field = QSpinBox()
        self.scan_limit_field.setMinimum(0)
        scan_layout.addRow('Number of scans before retry: ', self.scan_limit_field)
        self.bifi_scan_range_field = QSpinBox()
        self.bifi_scan_range_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT / 2)
        scan_layout.addRow('BiFi normal scan range:', self.bifi_scan_range_field)
        self.bifi_small_scan_range_field = QSpinBox()
        self.bifi_small_scan_range_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT / 4)
        scan_layout.addRow('BiFi small scan range:', self.bifi_small_scan_range_field)
        self.bifi_scan_step_field = QSpinBox()
        scan_layout.addRow('BiFi scan step:', self.bifi_scan_step_field)
        self.bifi_scan_show_plots_field = QCheckBox()
        scan_layout.addRow('Show BiFi scan plots? ', self.bifi_scan_show_plots_field)
        self.bifi_smoothing_window_field = QSpinBox()
        self.bifi_smoothing_window_field.setMinimum(1)
        self.bifi_smoothing_window_field.setSingleStep(2)
        self.bifi_smoothing_window_field.valueChanged.connect(self.ensure_odd_value)
        scan_layout.addRow('BiFi smoothing filter window: ', self.bifi_smoothing_window_field)
        self.bifi_smoothing_polyorder_field = QSpinBox()
        self.bifi_smoothing_polyorder_field.setMinimum(1)
        scan_layout.addRow('BiFi smoothing filter polyorder: ', self.bifi_smoothing_polyorder_field)
        self.thin_eta_scan_range_field = QSpinBox()
        self.thin_eta_scan_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 2)
        scan_layout.addRow('Thin etalon normal scan range:', self.thin_eta_scan_range_field)
        self.thin_eta_small_scan_range_field = QSpinBox()
        self.thin_eta_small_scan_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 4)
        scan_layout.addRow('Thin etalon small scan range:', self.thin_eta_small_scan_range_field)
        self.thin_eta_scan_step_field = QSpinBox()
        scan_layout.addRow('Thin etalon scan step:', self.thin_eta_scan_step_field)
        self.thin_eta_nudge_field = QSpinBox()
        scan_layout.addRow('Thin etalon scan nudge:', self.thin_eta_nudge_field)
        self.thin_eta_scan_show_plots_field = QCheckBox()
        scan_layout.addRow('Show thin etalon scan plots? ', self.thin_eta_scan_show_plots_field)
        self.thin_eta_smoothing_window_field = QSpinBox()
        self.thin_eta_smoothing_window_field.setMinimum(1)
        self.thin_eta_smoothing_window_field.setSingleStep(2)
        self.thin_eta_smoothing_window_field.valueChanged.connect(self.ensure_odd_value)
        scan_layout.addRow('Thin etalon smoothing filter window: ', self.thin_eta_smoothing_window_field)
        self.thin_eta_smoothing_polyorder_field = QSpinBox()
        self.thin_eta_smoothing_polyorder_field.setMinimum(1)
        scan_layout.addRow('Thin etalon smoothing filter polyorder: ', self.thin_eta_smoothing_polyorder_field)
        self.thin_eta_max_allowed_stddev_field = QDoubleSpinBox()
        self.thin_eta_max_allowed_stddev_field.setMinimum(0)
        scan_layout.addRow('Thin etalon max allowed stddev: ', self.thin_eta_max_allowed_stddev_field)
        self.refcell_rising_speed_field = QDoubleSpinBox()
        self.refcell_rising_speed_field.setDecimals(3)
        self.refcell_rising_speed_field.setSingleStep(0.001)
        self.refcell_rising_speed_field.setMinimum(0)
        self.refcell_rising_speed_field.setMaximum(0.1)
        scan_layout.addRow('RefCell scan rising speed: ', self.refcell_rising_speed_field)
        self.refcell_falling_speed_field = QDoubleSpinBox()
        self.refcell_falling_speed_field.setDecimals(3)
        self.refcell_falling_speed_field.setSingleStep(0.001)
        self.refcell_falling_speed_field.setMinimum(0)
        self.refcell_falling_speed_field.setMaximum(0.1)
        scan_layout.addRow('RefCell scan falling speed: ', self.refcell_falling_speed_field)
        self.large_wavelength_drift_field = QDoubleSpinBox()
        scan_layout.addRow('Large wavelength drift: ', self.large_wavelength_drift_field)
        self.medium_wavelength_drift_field = QDoubleSpinBox()
        scan_layout.addRow('Medium wavelength drift: ', self.medium_wavelength_drift_field)
        self.small_wavelength_drift_field = QDoubleSpinBox()
        scan_layout.addRow('Small wavelength drift: ', self.small_wavelength_drift_field)
        return scan_options

    def create_locking_options(self):
        locking_options = QGroupBox('Locking/Stabilization')
        locking_layout = QFormLayout()
        locking_options.setLayout(locking_layout)
        self.locking_timeout_field = QDoubleSpinBox()
        self.locking_timeout_field.setMinimum(0)
        locking_layout.addRow('Locking timeout: ', self.locking_timeout_field)
        self.fast_pz_setpoint_lower_limit_field = QDoubleSpinBox()
        self.fast_pz_setpoint_lower_limit_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.fast_pz_setpoint_lower_limit_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('Fast piezo setpoint scan lower limit: ', self.fast_pz_setpoint_lower_limit_field)
        self.fast_pz_setpoint_upper_limit_field = QDoubleSpinBox()
        self.fast_pz_setpoint_upper_limit_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.fast_pz_setpoint_upper_limit_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('Fast piezo setpoint scan upper limit: ', self.fast_pz_setpoint_upper_limit_field)
        self.fast_pz_setpoint_num_points_field = QSpinBox()
        self.fast_pz_setpoint_num_points_field.setMinimum(32)
        self.fast_pz_setpoint_num_points_field.setMaximum(512)
        locking_layout.addRow('Fast piezo setpoint scan sample: ', self.fast_pz_setpoint_num_points_field)
        self.fast_pz_setpoint_num_scans_field = QSpinBox()
        self.fast_pz_setpoint_num_scans_field.setMinimum(1)
        locking_layout.addRow('Fast piezo setpoint number of scans: ', self.fast_pz_setpoint_num_scans_field)
        self.auto_correction_limit_field = QSpinBox()
        self.auto_correction_limit_field.setMinimum(1)
        locking_layout.addRow('Number of auto-corrections before retry: ', self.auto_correction_limit_field)
        self.pz_eta_upper_correction_pos_field = QDoubleSpinBox()
        self.pz_eta_upper_correction_pos_field.setSingleStep(0.01)
        self.pz_eta_upper_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
        self.pz_eta_upper_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
        locking_layout.addRow('Piezo etalon upper correction pos: ', self.pz_eta_upper_correction_pos_field)
        self.slow_pz_upper_correction_pos_field = QDoubleSpinBox()
        self.slow_pz_upper_correction_pos_field.setSingleStep(0.01)
        self.slow_pz_upper_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
        self.slow_pz_upper_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
        locking_layout.addRow('Slow piezo upper correction pos: ', self.slow_pz_upper_correction_pos_field)
        self.refcell_upper_correction_pos_field = QDoubleSpinBox()
        self.refcell_upper_correction_pos_field.setSingleStep(0.01)
        self.refcell_upper_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.refcell_upper_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('RefCell upper correction pos: ', self.refcell_upper_correction_pos_field)
        self.pz_eta_mid_correction_pos_field = QDoubleSpinBox()
        self.pz_eta_mid_correction_pos_field.setSingleStep(0.01)
        self.pz_eta_mid_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
        self.pz_eta_mid_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
        locking_layout.addRow('Piezo etalon mid correction pos: ', self.pz_eta_mid_correction_pos_field)
        self.slow_pz_mid_correction_pos_field = QDoubleSpinBox()
        self.slow_pz_mid_correction_pos_field.setSingleStep(0.01)
        self.slow_pz_mid_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
        self.slow_pz_mid_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
        locking_layout.addRow('Slow piezo mid correction pos: ', self.slow_pz_mid_correction_pos_field)
        self.refcell_mid_correction_pos_field = QDoubleSpinBox()
        self.refcell_mid_correction_pos_field.setSingleStep(0.01)
        self.refcell_mid_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.refcell_mid_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('RefCell mid correction pos: ', self.refcell_mid_correction_pos_field)
        self.pz_eta_lower_correction_pos_field = QDoubleSpinBox()
        self.pz_eta_lower_correction_pos_field.setSingleStep(0.01)
        self.pz_eta_lower_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
        self.pz_eta_lower_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
        locking_layout.addRow('Piezo etalon lower correction pos: ', self.pz_eta_lower_correction_pos_field)
        self.slow_pz_lower_correction_pos_field = QDoubleSpinBox()
        self.slow_pz_lower_correction_pos_field.setSingleStep(0.01)
        self.slow_pz_lower_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
        self.slow_pz_lower_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
        locking_layout.addRow('Slow piezo lower correction pos: ', self.slow_pz_lower_correction_pos_field)
        self.refcell_lower_correction_pos_field = QDoubleSpinBox()
        self.refcell_lower_correction_pos_field.setSingleStep(0.01)
        self.refcell_lower_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
        self.refcell_lower_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
        locking_layout.addRow('RefCell lower correction pos: ', self.refcell_lower_correction_pos_field)
        self.stabilization_rising_speed_field = QDoubleSpinBox()
        self.stabilization_rising_speed_field.setDecimals(3)
        self.stabilization_rising_speed_field.setSingleStep(0.001)
        self.stabilization_rising_speed_field.setMinimum(0)
        self.stabilization_rising_speed_field.setMaximum(0.1)
        locking_layout.addRow('Auto-stabilization rising speed: ', self.stabilization_rising_speed_field)
        self.stabilization_falling_speed_field = QDoubleSpinBox()
        self.stabilization_falling_speed_field.setDecimals(3)
        self.stabilization_falling_speed_field.setSingleStep(0.001)
        self.stabilization_falling_speed_field.setMinimum(0)
        self.stabilization_falling_speed_field.setMaximum(0.1)
        locking_layout.addRow('Auto-stabilization falling speed: ', self.stabilization_falling_speed_field)
        self.stabilization_delay_field = QDoubleSpinBox()
        self.stabilization_delay_field.setMinimum(0.1)
        locking_layout.addRow('Auto-stabilization delay: ', self.stabilization_delay_field)
        self.stabilization_tolerance_field = QDoubleSpinBox()
        self.stabilization_tolerance_field.setDecimals(4)
        self.stabilization_tolerance_field.setSingleStep(0.0001)
        self.stabilization_tolerance_field.setMinimum(0.0001)
        locking_layout.addRow('Auto-stabilization tolerance: ', self.stabilization_tolerance_field)
        return locking_options

    def set_tooltips(self):
        self.matisse_device_id_field.setToolTip(tooltips.MATISSE_DEVICE_ID)
        self.wavemeter_port_field.setToolTip(tooltips.WAVEMETER_PORT)
        self.wavemeter_precision_field.setToolTip(tooltips.WAVEMETER_PRECISION)
        self.wavemeter_measurement_delay_field.setToolTip(tooltips.WAVEMETER_MEASUREMENT_DELAY)

        self.status_monitor_delay_field.setToolTip(tooltips.STATUS_MONITOR_DELAY)
        self.status_monitor_font_size_field.setToolTip(tooltips.STATUS_MONITOR_FONT_SIZE)

        self.bifi_reset_pos_field.setToolTip(tooltips.BIFI_RESET_POS)
        self.thin_eta_reset_pos_field.setToolTip(tooltips.THIN_ETA_RESET_POS)
        self.thin_eta_rand_range_field.setToolTip(tooltips.THIN_ETA_RAND_RANGE)

        self.report_events_field.setToolTip(tooltips.REPORT_EVENTS)

        self.component_limit_offset_field.setToolTip(tooltips.COMPONENT_LIMIT_OFFSET)

        self.wavelength_lower_limit_field.setToolTip(tooltips.WAVELENGTH_LOWER_LIMIT)
        self.wavelength_upper_limit_field.setToolTip(tooltips.WAVELENGTH_UPPER_LIMIT)

        self.scan_limit_field.setToolTip(tooltips.SCAN_LIMIT)

        self.bifi_scan_range_field.setToolTip(tooltips.BIFI_SCAN_RANGE)
        self.bifi_small_scan_range_field.setToolTip(tooltips.BIFI_SCAN_RANGE_SMALL)
        self.bifi_scan_step_field.setToolTip(tooltips.BIFI_SCAN_STEP)
        self.bifi_scan_show_plots_field.setToolTip(tooltips.BIFI_SCAN_SHOW_PLOTS)
        self.bifi_smoothing_window_field.setToolTip(tooltips.BIFI_SMOOTHING_FILTER_WINDOW)
        self.bifi_smoothing_polyorder_field.setToolTip(tooltips.BIFI_SMOOTHING_FILTER_POLYORDER)

        self.thin_eta_scan_range_field.setToolTip(tooltips.THIN_ETA_SCAN_RANGE)
        self.thin_eta_small_scan_range_field.setToolTip(tooltips.THIN_ETA_SCAN_RANGE_SMALL)
        self.thin_eta_scan_step_field.setToolTip(tooltips.THIN_ETA_SCAN_STEP)
        self.thin_eta_nudge_field.setToolTip(tooltips.THIN_ETA_NUDGE)
        self.thin_eta_scan_show_plots_field.setToolTip(tooltips.THIN_ETA_SHOW_PLOTS)
        self.thin_eta_smoothing_window_field.setToolTip(tooltips.THIN_ETA_SMOOTHING_FILTER_WINDOW)
        self.thin_eta_smoothing_polyorder_field.setToolTip(tooltips.THIN_ETA_SMOOTHING_FILTER_POLYORDER)
        self.thin_eta_max_allowed_stddev_field.setToolTip(tooltips.THIN_ETA_MAX_ALLOWED_STDDEV)

        self.refcell_rising_speed_field.setToolTip(tooltips.REFCELL_SCAN_RISING_SPEED)
        self.refcell_falling_speed_field.setToolTip(tooltips.REFCELL_SCAN_FALLING_SPEED)

        self.large_wavelength_drift_field.setToolTip(tooltips.LARGE_WAVELENGTH_DRIFT)
        self.medium_wavelength_drift_field.setToolTip(tooltips.MEDIUM_WAVELENGTH_DRIFT)
        self.small_wavelength_drift_field.setToolTip(tooltips.SMALL_WAVELENGTH_DRIFT)

        self.locking_timeout_field.setToolTip(tooltips.LOCKING_TIMEOUT)
        self.fast_pz_setpoint_lower_limit_field.setToolTip(tooltips.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT)
        self.fast_pz_setpoint_upper_limit_field.setToolTip(tooltips.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT)
        self.fast_pz_setpoint_num_points_field.setToolTip(tooltips.FAST_PZ_SETPOINT_NUM_POINTS)
        self.fast_pz_setpoint_num_scans_field.setToolTip(tooltips.FAST_PZ_SETPOINT_NUM_SCANS)

        self.stabilization_rising_speed_field.setToolTip(tooltips.STABILIZATION_RISING_SPEED)
        self.stabilization_falling_speed_field.setToolTip(tooltips.STABILIZATION_FALLING_SPEED)
        self.stabilization_delay_field.setToolTip(tooltips.STABILIZATION_DELAY)
        self.stabilization_tolerance_field.setToolTip(tooltips.STABILIZATION_TOLERANCE)

        self.auto_correction_limit_field.setToolTip(tooltips.CORRECTION_LIMIT)

        self.target_temperature_field.setToolTip(tooltips.PLE_TARGET_TEMPERATURE)
        self.temperature_tolerance_field.setToolTip(tooltips.PLE_TEMPERATURE_TOLERANCE)

    def set_current_values_from_config(self):
        self.matisse_device_id_field.setText(cfg.get(cfg.MATISSE_DEVICE_ID))
        self.wavemeter_port_field.setText(cfg.get(cfg.WAVEMETER_PORT))
        self.wavemeter_precision_field.setValue(cfg.get(cfg.WAVEMETER_PRECISION))
        self.wavemeter_measurement_delay_field.setValue(cfg.get(cfg.WAVEMETER_MEASUREMENT_DELAY))

        self.status_monitor_delay_field.setValue(cfg.get(cfg.STATUS_MONITOR_DELAY))
        self.status_monitor_font_size_field.setValue(cfg.get(cfg.STATUS_MONITOR_FONT_SIZE))

        self.component_limit_offset_field.setValue(cfg.get(cfg.COMPONENT_LIMIT_OFFSET))
        self.wavelength_lower_limit_field.setValue(cfg.get(cfg.WAVELENGTH_LOWER_LIMIT))
        self.wavelength_upper_limit_field.setValue(cfg.get(cfg.WAVELENGTH_UPPER_LIMIT))
        self.bifi_reset_pos_field.setValue(cfg.get(cfg.BIFI_RESET_POS))
        self.thin_eta_reset_pos_field.setValue(cfg.get(cfg.THIN_ETA_RESET_POS))
        self.thin_eta_rand_range_field.setValue(cfg.get(cfg.THIN_ETA_RAND_RANGE))

        self.report_events_field.setChecked(cfg.get(cfg.REPORT_EVENTS))

        self.scan_limit_field.setValue(cfg.get(cfg.SCAN_LIMIT))

        self.bifi_scan_range_field.setValue(cfg.get(cfg.BIFI_SCAN_RANGE))
        self.bifi_small_scan_range_field.setValue(cfg.get(cfg.BIFI_SCAN_RANGE_SMALL))
        self.bifi_scan_step_field.setValue(cfg.get(cfg.BIFI_SCAN_STEP))
        self.bifi_scan_show_plots_field.setChecked(cfg.get(cfg.BIFI_SCAN_SHOW_PLOTS))
        self.bifi_smoothing_window_field.setValue(cfg.get(cfg.BIFI_SMOOTHING_FILTER_WINDOW))
        self.bifi_smoothing_polyorder_field.setValue(cfg.get(cfg.BIFI_SMOOTHING_FILTER_POLYORDER))

        self.thin_eta_scan_range_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_RANGE))
        self.thin_eta_small_scan_range_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_RANGE_SMALL))
        self.thin_eta_scan_step_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_STEP))
        self.thin_eta_nudge_field.setValue(cfg.get(cfg.THIN_ETA_NUDGE))
        self.thin_eta_scan_show_plots_field.setChecked(cfg.get(cfg.THIN_ETA_SHOW_PLOTS))
        self.thin_eta_smoothing_window_field.setValue(cfg.get(cfg.THIN_ETA_SMOOTHING_FILTER_WINDOW))
        self.thin_eta_smoothing_polyorder_field.setValue(cfg.get(cfg.THIN_ETA_SMOOTHING_FILTER_POLYORDER))
        self.thin_eta_max_allowed_stddev_field.setValue(cfg.get(cfg.THIN_ETA_MAX_ALLOWED_STDDEV))

        self.refcell_rising_speed_field.setValue(cfg.get(cfg.REFCELL_SCAN_RISING_SPEED))
        self.refcell_falling_speed_field.setValue(cfg.get(cfg.REFCELL_SCAN_FALLING_SPEED))

        self.large_wavelength_drift_field.setValue(cfg.get(cfg.LARGE_WAVELENGTH_DRIFT))
        self.medium_wavelength_drift_field.setValue(cfg.get(cfg.MEDIUM_WAVELENGTH_DRIFT))
        self.small_wavelength_drift_field.setValue(cfg.get(cfg.SMALL_WAVELENGTH_DRIFT))

        self.locking_timeout_field.setValue(cfg.get(cfg.LOCKING_TIMEOUT))
        self.fast_pz_setpoint_lower_limit_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT))
        self.fast_pz_setpoint_upper_limit_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT))
        self.fast_pz_setpoint_num_points_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_NUM_POINTS))
        self.fast_pz_setpoint_num_scans_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_NUM_SCANS))

        self.stabilization_rising_speed_field.setValue(cfg.get(cfg.STABILIZATION_RISING_SPEED))
        self.stabilization_falling_speed_field.setValue(cfg.get(cfg.STABILIZATION_FALLING_SPEED))
        self.stabilization_delay_field.setValue(cfg.get(cfg.STABILIZATION_DELAY))
        self.stabilization_tolerance_field.setValue(cfg.get(cfg.STABILIZATION_TOLERANCE))

        self.auto_correction_limit_field.setValue(cfg.get(cfg.CORRECTION_LIMIT))

        self.pz_eta_upper_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_UPPER_CORRECTION_POS))
        self.slow_pz_upper_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_UPPER_CORRECTION_POS))
        self.refcell_upper_correction_pos_field.setValue(cfg.get(cfg.REFCELL_UPPER_CORRECTION_POS))
        self.pz_eta_mid_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_MID_CORRECTION_POS))
        self.slow_pz_mid_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_MID_CORRECTION_POS))
        self.refcell_mid_correction_pos_field.setValue(cfg.get(cfg.REFCELL_MID_CORRECTION_POS))
        self.pz_eta_lower_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_LOWER_CORRECTION_POS))
        self.slow_pz_lower_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_LOWER_CORRECTION_POS))
        self.refcell_lower_correction_pos_field.setValue(cfg.get(cfg.REFCELL_LOWER_CORRECTION_POS))

        self.target_temperature_field.setValue(cfg.get(cfg.PLE_TARGET_TEMPERATURE))
        self.temperature_tolerance_field.setValue(cfg.get(cfg.PLE_TEMPERATURE_TOLERANCE))

    def add_buttons(self):
        button_box = QDialogButtonBox(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Save |
                                      QDialogButtonBox.Cancel)
        button_box.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore_defaults)
        button_box.button(QDialogButtonBox.Save).clicked.connect(self.save_configuration)
        button_box.button(QDialogButtonBox.Cancel).clicked.connect(self.cancel)
        self.layout.addWidget(button_box)

    @pyqtSlot(bool)
    def restore_defaults(self, checked):
        cfg.restore_defaults()
        self.set_current_values_from_config()

    @pyqtSlot(bool)
    def save_configuration(self, checked):
        print('Saving configuration.')
        cfg.set(cfg.MATISSE_DEVICE_ID, self.matisse_device_id_field.text())
        cfg.set(cfg.WAVEMETER_PORT, self.wavemeter_port_field.text())
        cfg.set(cfg.WAVEMETER_PRECISION, self.wavemeter_precision_field.value())
        cfg.set(cfg.WAVEMETER_MEASUREMENT_DELAY, self.wavemeter_measurement_delay_field.value())

        cfg.set(cfg.STATUS_MONITOR_DELAY, self.status_monitor_delay_field.value())
        cfg.set(cfg.STATUS_MONITOR_FONT_SIZE, self.status_monitor_font_size_field.value())

        cfg.set(cfg.COMPONENT_LIMIT_OFFSET, self.component_limit_offset_field.value())
        cfg.set(cfg.WAVELENGTH_LOWER_LIMIT, self.wavelength_lower_limit_field.value())
        cfg.set(cfg.WAVELENGTH_UPPER_LIMIT, self.wavelength_upper_limit_field.value())
        cfg.set(cfg.BIFI_RESET_POS, self.bifi_reset_pos_field.value())
        cfg.set(cfg.THIN_ETA_RESET_POS, self.thin_eta_reset_pos_field.value())
        cfg.set(cfg.THIN_ETA_RAND_RANGE, self.thin_eta_rand_range_field.value())

        cfg.set(cfg.REPORT_EVENTS, self.report_events_field.isChecked())

        cfg.set(cfg.SCAN_LIMIT, self.scan_limit_field.value())

        cfg.set(cfg.BIFI_SCAN_RANGE, self.bifi_scan_range_field.value())
        cfg.set(cfg.BIFI_SCAN_RANGE_SMALL, self.bifi_small_scan_range_field.value())
        cfg.set(cfg.BIFI_SCAN_STEP, self.bifi_scan_step_field.value())
        cfg.set(cfg.BIFI_SCAN_SHOW_PLOTS, self.bifi_scan_show_plots_field.isChecked())
        cfg.set(cfg.BIFI_SMOOTHING_FILTER_WINDOW, self.bifi_smoothing_window_field.value())
        cfg.set(cfg.BIFI_SMOOTHING_FILTER_POLYORDER, self.bifi_smoothing_polyorder_field.value())

        cfg.set(cfg.THIN_ETA_SCAN_RANGE, self.thin_eta_scan_range_field.value())
        cfg.set(cfg.THIN_ETA_SCAN_RANGE_SMALL, self.thin_eta_small_scan_range_field.value())
        cfg.set(cfg.THIN_ETA_SCAN_STEP, self.thin_eta_scan_step_field.value())
        cfg.set(cfg.THIN_ETA_NUDGE, self.thin_eta_nudge_field.value())
        cfg.set(cfg.THIN_ETA_SHOW_PLOTS, self.thin_eta_scan_show_plots_field.isChecked())
        cfg.set(cfg.THIN_ETA_SMOOTHING_FILTER_WINDOW, self.thin_eta_smoothing_window_field.value())
        cfg.set(cfg.THIN_ETA_SMOOTHING_FILTER_POLYORDER, self.thin_eta_smoothing_polyorder_field.value())
        cfg.set(cfg.THIN_ETA_MAX_ALLOWED_STDDEV, self.thin_eta_max_allowed_stddev_field.value())

        cfg.set(cfg.REFCELL_SCAN_RISING_SPEED, self.refcell_rising_speed_field.value())
        cfg.set(cfg.REFCELL_SCAN_FALLING_SPEED, self.refcell_falling_speed_field.value())

        cfg.set(cfg.LARGE_WAVELENGTH_DRIFT, self.large_wavelength_drift_field.value())
        cfg.set(cfg.MEDIUM_WAVELENGTH_DRIFT, self.medium_wavelength_drift_field.value())
        cfg.set(cfg.SMALL_WAVELENGTH_DRIFT, self.small_wavelength_drift_field.value())

        cfg.set(cfg.LOCKING_TIMEOUT, self.locking_timeout_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT, self.fast_pz_setpoint_lower_limit_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT, self.fast_pz_setpoint_upper_limit_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_NUM_POINTS, self.fast_pz_setpoint_num_points_field.value())
        cfg.set(cfg.FAST_PZ_SETPOINT_NUM_SCANS, self.fast_pz_setpoint_num_scans_field.value())

        cfg.set(cfg.STABILIZATION_RISING_SPEED, self.stabilization_rising_speed_field.value())
        cfg.set(cfg.STABILIZATION_FALLING_SPEED, self.stabilization_falling_speed_field.value())
        cfg.set(cfg.STABILIZATION_DELAY, self.stabilization_delay_field.value())
        cfg.set(cfg.STABILIZATION_TOLERANCE, self.stabilization_tolerance_field.value())

        cfg.set(cfg.CORRECTION_LIMIT, self.auto_correction_limit_field.value())

        cfg.set(cfg.PIEZO_ETA_UPPER_CORRECTION_POS, self.pz_eta_upper_correction_pos_field.value())
        cfg.set(cfg.SLOW_PIEZO_UPPER_CORRECTION_POS, self.slow_pz_upper_correction_pos_field.value())
        cfg.set(cfg.REFCELL_UPPER_CORRECTION_POS, self.refcell_upper_correction_pos_field.value())
        cfg.set(cfg.PIEZO_ETA_MID_CORRECTION_POS, self.pz_eta_mid_correction_pos_field.value())
        cfg.set(cfg.SLOW_PIEZO_MID_CORRECTION_POS, self.slow_pz_mid_correction_pos_field.value())
        cfg.set(cfg.REFCELL_MID_CORRECTION_POS, self.refcell_mid_correction_pos_field.value())
        cfg.set(cfg.PIEZO_ETA_LOWER_CORRECTION_POS, self.pz_eta_lower_correction_pos_field.value())
        cfg.set(cfg.SLOW_PIEZO_LOWER_CORRECTION_POS, self.slow_pz_lower_correction_pos_field.value())
        cfg.set(cfg.REFCELL_LOWER_CORRECTION_POS, self.refcell_lower_correction_pos_field.value())

        cfg.set(cfg.PLE_TARGET_TEMPERATURE, self.target_temperature_field.value())
        cfg.set(cfg.PLE_TEMPERATURE_TOLERANCE, self.temperature_tolerance_field.value())

        cfg.save()
        self.close()

    @pyqtSlot(bool)
    def cancel(self, checked):
        self.close()

    @pyqtSlot(int)
    def ensure_odd_value(self, value):
        field: QSpinBox = self.sender()
        if value % 2 == 0:
            field.setValue(value - 1)

Ancestors

  • PyQt5.QtWidgets.QDialog
  • PyQt5.QtWidgets.QWidget
  • PyQt5.QtCore.QObject
  • sip.wrapper
  • PyQt5.QtGui.QPaintDevice
  • sip.simplewrapper

Methods

def add_buttons(self)
Source code
def add_buttons(self):
    button_box = QDialogButtonBox(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Save |
                                  QDialogButtonBox.Cancel)
    button_box.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore_defaults)
    button_box.button(QDialogButtonBox.Save).clicked.connect(self.save_configuration)
    button_box.button(QDialogButtonBox.Cancel).clicked.connect(self.cancel)
    self.layout.addWidget(button_box)
def add_options(self)
Source code
def add_options(self):
    general_options = self.create_general_options()
    gui_options = self.create_gui_options()
    ple_options = self.create_ple_options()
    scan_options = self.create_scan_options()
    locking_options = self.create_locking_options()
    self.set_tooltips()

    form = QWidget()
    form_layout = QHBoxLayout()
    form.setLayout(form_layout)
    column_1 = QVBoxLayout()
    column_1.addWidget(general_options)
    column_1.addWidget(gui_options)
    column_1.addWidget(ple_options)
    form_layout.addLayout(column_1)
    form_layout.addWidget(scan_options)
    form_layout.addWidget(locking_options)
    self.layout.addWidget(form)
def cancel(self, checked)
Source code
@pyqtSlot(bool)
def cancel(self, checked):
    self.close()
def create_general_options(self)
Source code
def create_general_options(self):
    general_options = QGroupBox('General')
    general_layout = QFormLayout()
    general_options.setLayout(general_layout)
    self.matisse_device_id_field = QLineEdit()
    general_layout.addRow('Matisse device ID: ', self.matisse_device_id_field)
    self.wavemeter_port_field = QLineEdit()
    general_layout.addRow('Wavemeter port: ', self.wavemeter_port_field)
    self.wavemeter_precision_field = QSpinBox()
    self.wavemeter_precision_field.setMinimum(0)
    general_layout.addRow('Wavemeter precision: ', self.wavemeter_precision_field)
    self.wavemeter_measurement_delay_field = QDoubleSpinBox()
    self.wavemeter_measurement_delay_field.setMinimum(0)
    self.wavemeter_measurement_delay_field.setSingleStep(0.1)
    general_layout.addRow('Wavemeter measurement delay: ', self.wavemeter_measurement_delay_field)
    self.component_limit_offset_field = QDoubleSpinBox()
    self.component_limit_offset_field.setMinimum(0)
    self.component_limit_offset_field.setDecimals(3)
    general_layout.addRow('Component limit offset: ', self.component_limit_offset_field)
    self.wavelength_lower_limit_field = QDoubleSpinBox()
    self.wavelength_lower_limit_field.setMinimum(0)
    self.wavelength_lower_limit_field.setMaximum(2000)
    general_layout.addRow('Wavelength lower limit: ', self.wavelength_lower_limit_field)
    self.wavelength_upper_limit_field = QDoubleSpinBox()
    self.wavelength_upper_limit_field.setMinimum(0)
    self.wavelength_upper_limit_field.setMaximum(2000)
    general_layout.addRow('Wavelength upper limit: ', self.wavelength_upper_limit_field)
    self.bifi_reset_pos_field = QSpinBox()
    self.bifi_reset_pos_field.setMinimum(matisse.BIREFRINGENT_FILTER_LOWER_LIMIT)
    self.bifi_reset_pos_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT)
    general_layout.addRow('BiFi reset position: ', self.bifi_reset_pos_field)
    self.thin_eta_reset_pos_field = QSpinBox()
    self.thin_eta_reset_pos_field.setMinimum(matisse.THIN_ETALON_LOWER_LIMIT)
    self.thin_eta_reset_pos_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT)
    general_layout.addRow('Thin etalon reset position: ', self.thin_eta_reset_pos_field)
    self.thin_eta_rand_range_field = QSpinBox()
    self.thin_eta_rand_range_field.setMinimum(0)
    self.thin_eta_rand_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 2)
    general_layout.addRow('Thin etalon randomization range: ', self.thin_eta_rand_range_field)
    self.report_events_field = QCheckBox()
    general_layout.addRow('Report events? ', self.report_events_field)
    return general_options
def create_gui_options(self)
Source code
def create_gui_options(self):
    gui_options = QGroupBox('GUI')
    gui_layout = QFormLayout()
    gui_options.setLayout(gui_layout)
    self.status_monitor_delay_field = QDoubleSpinBox()
    self.status_monitor_delay_field.setMinimum(0)
    gui_layout.addRow('Status monitor update delay: ', self.status_monitor_delay_field)
    self.status_monitor_font_size_field = QSpinBox()
    self.status_monitor_font_size_field.setMinimum(0)
    gui_layout.addRow('Status monitor font size: ', self.status_monitor_font_size_field)
    return gui_options
def create_locking_options(self)
Source code
def create_locking_options(self):
    locking_options = QGroupBox('Locking/Stabilization')
    locking_layout = QFormLayout()
    locking_options.setLayout(locking_layout)
    self.locking_timeout_field = QDoubleSpinBox()
    self.locking_timeout_field.setMinimum(0)
    locking_layout.addRow('Locking timeout: ', self.locking_timeout_field)
    self.fast_pz_setpoint_lower_limit_field = QDoubleSpinBox()
    self.fast_pz_setpoint_lower_limit_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
    self.fast_pz_setpoint_lower_limit_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
    locking_layout.addRow('Fast piezo setpoint scan lower limit: ', self.fast_pz_setpoint_lower_limit_field)
    self.fast_pz_setpoint_upper_limit_field = QDoubleSpinBox()
    self.fast_pz_setpoint_upper_limit_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
    self.fast_pz_setpoint_upper_limit_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
    locking_layout.addRow('Fast piezo setpoint scan upper limit: ', self.fast_pz_setpoint_upper_limit_field)
    self.fast_pz_setpoint_num_points_field = QSpinBox()
    self.fast_pz_setpoint_num_points_field.setMinimum(32)
    self.fast_pz_setpoint_num_points_field.setMaximum(512)
    locking_layout.addRow('Fast piezo setpoint scan sample: ', self.fast_pz_setpoint_num_points_field)
    self.fast_pz_setpoint_num_scans_field = QSpinBox()
    self.fast_pz_setpoint_num_scans_field.setMinimum(1)
    locking_layout.addRow('Fast piezo setpoint number of scans: ', self.fast_pz_setpoint_num_scans_field)
    self.auto_correction_limit_field = QSpinBox()
    self.auto_correction_limit_field.setMinimum(1)
    locking_layout.addRow('Number of auto-corrections before retry: ', self.auto_correction_limit_field)
    self.pz_eta_upper_correction_pos_field = QDoubleSpinBox()
    self.pz_eta_upper_correction_pos_field.setSingleStep(0.01)
    self.pz_eta_upper_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
    self.pz_eta_upper_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
    locking_layout.addRow('Piezo etalon upper correction pos: ', self.pz_eta_upper_correction_pos_field)
    self.slow_pz_upper_correction_pos_field = QDoubleSpinBox()
    self.slow_pz_upper_correction_pos_field.setSingleStep(0.01)
    self.slow_pz_upper_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
    self.slow_pz_upper_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
    locking_layout.addRow('Slow piezo upper correction pos: ', self.slow_pz_upper_correction_pos_field)
    self.refcell_upper_correction_pos_field = QDoubleSpinBox()
    self.refcell_upper_correction_pos_field.setSingleStep(0.01)
    self.refcell_upper_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
    self.refcell_upper_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
    locking_layout.addRow('RefCell upper correction pos: ', self.refcell_upper_correction_pos_field)
    self.pz_eta_mid_correction_pos_field = QDoubleSpinBox()
    self.pz_eta_mid_correction_pos_field.setSingleStep(0.01)
    self.pz_eta_mid_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
    self.pz_eta_mid_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
    locking_layout.addRow('Piezo etalon mid correction pos: ', self.pz_eta_mid_correction_pos_field)
    self.slow_pz_mid_correction_pos_field = QDoubleSpinBox()
    self.slow_pz_mid_correction_pos_field.setSingleStep(0.01)
    self.slow_pz_mid_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
    self.slow_pz_mid_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
    locking_layout.addRow('Slow piezo mid correction pos: ', self.slow_pz_mid_correction_pos_field)
    self.refcell_mid_correction_pos_field = QDoubleSpinBox()
    self.refcell_mid_correction_pos_field.setSingleStep(0.01)
    self.refcell_mid_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
    self.refcell_mid_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
    locking_layout.addRow('RefCell mid correction pos: ', self.refcell_mid_correction_pos_field)
    self.pz_eta_lower_correction_pos_field = QDoubleSpinBox()
    self.pz_eta_lower_correction_pos_field.setSingleStep(0.01)
    self.pz_eta_lower_correction_pos_field.setMinimum(matisse.PIEZO_ETALON_LOWER_LIMIT)
    self.pz_eta_lower_correction_pos_field.setMaximum(matisse.PIEZO_ETALON_UPPER_LIMIT)
    locking_layout.addRow('Piezo etalon lower correction pos: ', self.pz_eta_lower_correction_pos_field)
    self.slow_pz_lower_correction_pos_field = QDoubleSpinBox()
    self.slow_pz_lower_correction_pos_field.setSingleStep(0.01)
    self.slow_pz_lower_correction_pos_field.setMinimum(matisse.SLOW_PIEZO_LOWER_LIMIT)
    self.slow_pz_lower_correction_pos_field.setMaximum(matisse.SLOW_PIEZO_UPPER_LIMIT)
    locking_layout.addRow('Slow piezo lower correction pos: ', self.slow_pz_lower_correction_pos_field)
    self.refcell_lower_correction_pos_field = QDoubleSpinBox()
    self.refcell_lower_correction_pos_field.setSingleStep(0.01)
    self.refcell_lower_correction_pos_field.setMinimum(matisse.REFERENCE_CELL_LOWER_LIMIT)
    self.refcell_lower_correction_pos_field.setMaximum(matisse.REFERENCE_CELL_UPPER_LIMIT)
    locking_layout.addRow('RefCell lower correction pos: ', self.refcell_lower_correction_pos_field)
    self.stabilization_rising_speed_field = QDoubleSpinBox()
    self.stabilization_rising_speed_field.setDecimals(3)
    self.stabilization_rising_speed_field.setSingleStep(0.001)
    self.stabilization_rising_speed_field.setMinimum(0)
    self.stabilization_rising_speed_field.setMaximum(0.1)
    locking_layout.addRow('Auto-stabilization rising speed: ', self.stabilization_rising_speed_field)
    self.stabilization_falling_speed_field = QDoubleSpinBox()
    self.stabilization_falling_speed_field.setDecimals(3)
    self.stabilization_falling_speed_field.setSingleStep(0.001)
    self.stabilization_falling_speed_field.setMinimum(0)
    self.stabilization_falling_speed_field.setMaximum(0.1)
    locking_layout.addRow('Auto-stabilization falling speed: ', self.stabilization_falling_speed_field)
    self.stabilization_delay_field = QDoubleSpinBox()
    self.stabilization_delay_field.setMinimum(0.1)
    locking_layout.addRow('Auto-stabilization delay: ', self.stabilization_delay_field)
    self.stabilization_tolerance_field = QDoubleSpinBox()
    self.stabilization_tolerance_field.setDecimals(4)
    self.stabilization_tolerance_field.setSingleStep(0.0001)
    self.stabilization_tolerance_field.setMinimum(0.0001)
    locking_layout.addRow('Auto-stabilization tolerance: ', self.stabilization_tolerance_field)
    return locking_options
def create_ple_options(self)
Source code
def create_ple_options(self):
    ple_options = QGroupBox('PLE')
    ple_layout = QFormLayout()
    ple_options.setLayout(ple_layout)
    self.target_temperature_field = QSpinBox()
    self.target_temperature_field.setMinimum(CCD.MIN_TEMP)
    self.target_temperature_field.setMaximum(CCD.MAX_TEMP)
    ple_layout.addRow('Default target CCD temperature: ', self.target_temperature_field)
    self.temperature_tolerance_field = QDoubleSpinBox()
    self.temperature_tolerance_field.setMinimum(3)
    ple_layout.addRow('CCD temperature tolerance: ', self.temperature_tolerance_field)
    return ple_options
def create_scan_options(self)
Source code
def create_scan_options(self):
    scan_options = QGroupBox('Scanning')
    scan_layout = QFormLayout()
    scan_options.setLayout(scan_layout)
    self.scan_limit_field = QSpinBox()
    self.scan_limit_field.setMinimum(0)
    scan_layout.addRow('Number of scans before retry: ', self.scan_limit_field)
    self.bifi_scan_range_field = QSpinBox()
    self.bifi_scan_range_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT / 2)
    scan_layout.addRow('BiFi normal scan range:', self.bifi_scan_range_field)
    self.bifi_small_scan_range_field = QSpinBox()
    self.bifi_small_scan_range_field.setMaximum(matisse.BIREFRINGENT_FILTER_UPPER_LIMIT / 4)
    scan_layout.addRow('BiFi small scan range:', self.bifi_small_scan_range_field)
    self.bifi_scan_step_field = QSpinBox()
    scan_layout.addRow('BiFi scan step:', self.bifi_scan_step_field)
    self.bifi_scan_show_plots_field = QCheckBox()
    scan_layout.addRow('Show BiFi scan plots? ', self.bifi_scan_show_plots_field)
    self.bifi_smoothing_window_field = QSpinBox()
    self.bifi_smoothing_window_field.setMinimum(1)
    self.bifi_smoothing_window_field.setSingleStep(2)
    self.bifi_smoothing_window_field.valueChanged.connect(self.ensure_odd_value)
    scan_layout.addRow('BiFi smoothing filter window: ', self.bifi_smoothing_window_field)
    self.bifi_smoothing_polyorder_field = QSpinBox()
    self.bifi_smoothing_polyorder_field.setMinimum(1)
    scan_layout.addRow('BiFi smoothing filter polyorder: ', self.bifi_smoothing_polyorder_field)
    self.thin_eta_scan_range_field = QSpinBox()
    self.thin_eta_scan_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 2)
    scan_layout.addRow('Thin etalon normal scan range:', self.thin_eta_scan_range_field)
    self.thin_eta_small_scan_range_field = QSpinBox()
    self.thin_eta_small_scan_range_field.setMaximum(matisse.THIN_ETALON_UPPER_LIMIT / 4)
    scan_layout.addRow('Thin etalon small scan range:', self.thin_eta_small_scan_range_field)
    self.thin_eta_scan_step_field = QSpinBox()
    scan_layout.addRow('Thin etalon scan step:', self.thin_eta_scan_step_field)
    self.thin_eta_nudge_field = QSpinBox()
    scan_layout.addRow('Thin etalon scan nudge:', self.thin_eta_nudge_field)
    self.thin_eta_scan_show_plots_field = QCheckBox()
    scan_layout.addRow('Show thin etalon scan plots? ', self.thin_eta_scan_show_plots_field)
    self.thin_eta_smoothing_window_field = QSpinBox()
    self.thin_eta_smoothing_window_field.setMinimum(1)
    self.thin_eta_smoothing_window_field.setSingleStep(2)
    self.thin_eta_smoothing_window_field.valueChanged.connect(self.ensure_odd_value)
    scan_layout.addRow('Thin etalon smoothing filter window: ', self.thin_eta_smoothing_window_field)
    self.thin_eta_smoothing_polyorder_field = QSpinBox()
    self.thin_eta_smoothing_polyorder_field.setMinimum(1)
    scan_layout.addRow('Thin etalon smoothing filter polyorder: ', self.thin_eta_smoothing_polyorder_field)
    self.thin_eta_max_allowed_stddev_field = QDoubleSpinBox()
    self.thin_eta_max_allowed_stddev_field.setMinimum(0)
    scan_layout.addRow('Thin etalon max allowed stddev: ', self.thin_eta_max_allowed_stddev_field)
    self.refcell_rising_speed_field = QDoubleSpinBox()
    self.refcell_rising_speed_field.setDecimals(3)
    self.refcell_rising_speed_field.setSingleStep(0.001)
    self.refcell_rising_speed_field.setMinimum(0)
    self.refcell_rising_speed_field.setMaximum(0.1)
    scan_layout.addRow('RefCell scan rising speed: ', self.refcell_rising_speed_field)
    self.refcell_falling_speed_field = QDoubleSpinBox()
    self.refcell_falling_speed_field.setDecimals(3)
    self.refcell_falling_speed_field.setSingleStep(0.001)
    self.refcell_falling_speed_field.setMinimum(0)
    self.refcell_falling_speed_field.setMaximum(0.1)
    scan_layout.addRow('RefCell scan falling speed: ', self.refcell_falling_speed_field)
    self.large_wavelength_drift_field = QDoubleSpinBox()
    scan_layout.addRow('Large wavelength drift: ', self.large_wavelength_drift_field)
    self.medium_wavelength_drift_field = QDoubleSpinBox()
    scan_layout.addRow('Medium wavelength drift: ', self.medium_wavelength_drift_field)
    self.small_wavelength_drift_field = QDoubleSpinBox()
    scan_layout.addRow('Small wavelength drift: ', self.small_wavelength_drift_field)
    return scan_options
def ensure_odd_value(self, value)
Source code
@pyqtSlot(int)
def ensure_odd_value(self, value):
    field: QSpinBox = self.sender()
    if value % 2 == 0:
        field.setValue(value - 1)
def restore_defaults(self, checked)
Source code
@pyqtSlot(bool)
def restore_defaults(self, checked):
    cfg.restore_defaults()
    self.set_current_values_from_config()
def save_configuration(self, checked)
Source code
@pyqtSlot(bool)
def save_configuration(self, checked):
    print('Saving configuration.')
    cfg.set(cfg.MATISSE_DEVICE_ID, self.matisse_device_id_field.text())
    cfg.set(cfg.WAVEMETER_PORT, self.wavemeter_port_field.text())
    cfg.set(cfg.WAVEMETER_PRECISION, self.wavemeter_precision_field.value())
    cfg.set(cfg.WAVEMETER_MEASUREMENT_DELAY, self.wavemeter_measurement_delay_field.value())

    cfg.set(cfg.STATUS_MONITOR_DELAY, self.status_monitor_delay_field.value())
    cfg.set(cfg.STATUS_MONITOR_FONT_SIZE, self.status_monitor_font_size_field.value())

    cfg.set(cfg.COMPONENT_LIMIT_OFFSET, self.component_limit_offset_field.value())
    cfg.set(cfg.WAVELENGTH_LOWER_LIMIT, self.wavelength_lower_limit_field.value())
    cfg.set(cfg.WAVELENGTH_UPPER_LIMIT, self.wavelength_upper_limit_field.value())
    cfg.set(cfg.BIFI_RESET_POS, self.bifi_reset_pos_field.value())
    cfg.set(cfg.THIN_ETA_RESET_POS, self.thin_eta_reset_pos_field.value())
    cfg.set(cfg.THIN_ETA_RAND_RANGE, self.thin_eta_rand_range_field.value())

    cfg.set(cfg.REPORT_EVENTS, self.report_events_field.isChecked())

    cfg.set(cfg.SCAN_LIMIT, self.scan_limit_field.value())

    cfg.set(cfg.BIFI_SCAN_RANGE, self.bifi_scan_range_field.value())
    cfg.set(cfg.BIFI_SCAN_RANGE_SMALL, self.bifi_small_scan_range_field.value())
    cfg.set(cfg.BIFI_SCAN_STEP, self.bifi_scan_step_field.value())
    cfg.set(cfg.BIFI_SCAN_SHOW_PLOTS, self.bifi_scan_show_plots_field.isChecked())
    cfg.set(cfg.BIFI_SMOOTHING_FILTER_WINDOW, self.bifi_smoothing_window_field.value())
    cfg.set(cfg.BIFI_SMOOTHING_FILTER_POLYORDER, self.bifi_smoothing_polyorder_field.value())

    cfg.set(cfg.THIN_ETA_SCAN_RANGE, self.thin_eta_scan_range_field.value())
    cfg.set(cfg.THIN_ETA_SCAN_RANGE_SMALL, self.thin_eta_small_scan_range_field.value())
    cfg.set(cfg.THIN_ETA_SCAN_STEP, self.thin_eta_scan_step_field.value())
    cfg.set(cfg.THIN_ETA_NUDGE, self.thin_eta_nudge_field.value())
    cfg.set(cfg.THIN_ETA_SHOW_PLOTS, self.thin_eta_scan_show_plots_field.isChecked())
    cfg.set(cfg.THIN_ETA_SMOOTHING_FILTER_WINDOW, self.thin_eta_smoothing_window_field.value())
    cfg.set(cfg.THIN_ETA_SMOOTHING_FILTER_POLYORDER, self.thin_eta_smoothing_polyorder_field.value())
    cfg.set(cfg.THIN_ETA_MAX_ALLOWED_STDDEV, self.thin_eta_max_allowed_stddev_field.value())

    cfg.set(cfg.REFCELL_SCAN_RISING_SPEED, self.refcell_rising_speed_field.value())
    cfg.set(cfg.REFCELL_SCAN_FALLING_SPEED, self.refcell_falling_speed_field.value())

    cfg.set(cfg.LARGE_WAVELENGTH_DRIFT, self.large_wavelength_drift_field.value())
    cfg.set(cfg.MEDIUM_WAVELENGTH_DRIFT, self.medium_wavelength_drift_field.value())
    cfg.set(cfg.SMALL_WAVELENGTH_DRIFT, self.small_wavelength_drift_field.value())

    cfg.set(cfg.LOCKING_TIMEOUT, self.locking_timeout_field.value())
    cfg.set(cfg.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT, self.fast_pz_setpoint_lower_limit_field.value())
    cfg.set(cfg.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT, self.fast_pz_setpoint_upper_limit_field.value())
    cfg.set(cfg.FAST_PZ_SETPOINT_NUM_POINTS, self.fast_pz_setpoint_num_points_field.value())
    cfg.set(cfg.FAST_PZ_SETPOINT_NUM_SCANS, self.fast_pz_setpoint_num_scans_field.value())

    cfg.set(cfg.STABILIZATION_RISING_SPEED, self.stabilization_rising_speed_field.value())
    cfg.set(cfg.STABILIZATION_FALLING_SPEED, self.stabilization_falling_speed_field.value())
    cfg.set(cfg.STABILIZATION_DELAY, self.stabilization_delay_field.value())
    cfg.set(cfg.STABILIZATION_TOLERANCE, self.stabilization_tolerance_field.value())

    cfg.set(cfg.CORRECTION_LIMIT, self.auto_correction_limit_field.value())

    cfg.set(cfg.PIEZO_ETA_UPPER_CORRECTION_POS, self.pz_eta_upper_correction_pos_field.value())
    cfg.set(cfg.SLOW_PIEZO_UPPER_CORRECTION_POS, self.slow_pz_upper_correction_pos_field.value())
    cfg.set(cfg.REFCELL_UPPER_CORRECTION_POS, self.refcell_upper_correction_pos_field.value())
    cfg.set(cfg.PIEZO_ETA_MID_CORRECTION_POS, self.pz_eta_mid_correction_pos_field.value())
    cfg.set(cfg.SLOW_PIEZO_MID_CORRECTION_POS, self.slow_pz_mid_correction_pos_field.value())
    cfg.set(cfg.REFCELL_MID_CORRECTION_POS, self.refcell_mid_correction_pos_field.value())
    cfg.set(cfg.PIEZO_ETA_LOWER_CORRECTION_POS, self.pz_eta_lower_correction_pos_field.value())
    cfg.set(cfg.SLOW_PIEZO_LOWER_CORRECTION_POS, self.slow_pz_lower_correction_pos_field.value())
    cfg.set(cfg.REFCELL_LOWER_CORRECTION_POS, self.refcell_lower_correction_pos_field.value())

    cfg.set(cfg.PLE_TARGET_TEMPERATURE, self.target_temperature_field.value())
    cfg.set(cfg.PLE_TEMPERATURE_TOLERANCE, self.temperature_tolerance_field.value())

    cfg.save()
    self.close()
def set_current_values_from_config(self)
Source code
def set_current_values_from_config(self):
    self.matisse_device_id_field.setText(cfg.get(cfg.MATISSE_DEVICE_ID))
    self.wavemeter_port_field.setText(cfg.get(cfg.WAVEMETER_PORT))
    self.wavemeter_precision_field.setValue(cfg.get(cfg.WAVEMETER_PRECISION))
    self.wavemeter_measurement_delay_field.setValue(cfg.get(cfg.WAVEMETER_MEASUREMENT_DELAY))

    self.status_monitor_delay_field.setValue(cfg.get(cfg.STATUS_MONITOR_DELAY))
    self.status_monitor_font_size_field.setValue(cfg.get(cfg.STATUS_MONITOR_FONT_SIZE))

    self.component_limit_offset_field.setValue(cfg.get(cfg.COMPONENT_LIMIT_OFFSET))
    self.wavelength_lower_limit_field.setValue(cfg.get(cfg.WAVELENGTH_LOWER_LIMIT))
    self.wavelength_upper_limit_field.setValue(cfg.get(cfg.WAVELENGTH_UPPER_LIMIT))
    self.bifi_reset_pos_field.setValue(cfg.get(cfg.BIFI_RESET_POS))
    self.thin_eta_reset_pos_field.setValue(cfg.get(cfg.THIN_ETA_RESET_POS))
    self.thin_eta_rand_range_field.setValue(cfg.get(cfg.THIN_ETA_RAND_RANGE))

    self.report_events_field.setChecked(cfg.get(cfg.REPORT_EVENTS))

    self.scan_limit_field.setValue(cfg.get(cfg.SCAN_LIMIT))

    self.bifi_scan_range_field.setValue(cfg.get(cfg.BIFI_SCAN_RANGE))
    self.bifi_small_scan_range_field.setValue(cfg.get(cfg.BIFI_SCAN_RANGE_SMALL))
    self.bifi_scan_step_field.setValue(cfg.get(cfg.BIFI_SCAN_STEP))
    self.bifi_scan_show_plots_field.setChecked(cfg.get(cfg.BIFI_SCAN_SHOW_PLOTS))
    self.bifi_smoothing_window_field.setValue(cfg.get(cfg.BIFI_SMOOTHING_FILTER_WINDOW))
    self.bifi_smoothing_polyorder_field.setValue(cfg.get(cfg.BIFI_SMOOTHING_FILTER_POLYORDER))

    self.thin_eta_scan_range_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_RANGE))
    self.thin_eta_small_scan_range_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_RANGE_SMALL))
    self.thin_eta_scan_step_field.setValue(cfg.get(cfg.THIN_ETA_SCAN_STEP))
    self.thin_eta_nudge_field.setValue(cfg.get(cfg.THIN_ETA_NUDGE))
    self.thin_eta_scan_show_plots_field.setChecked(cfg.get(cfg.THIN_ETA_SHOW_PLOTS))
    self.thin_eta_smoothing_window_field.setValue(cfg.get(cfg.THIN_ETA_SMOOTHING_FILTER_WINDOW))
    self.thin_eta_smoothing_polyorder_field.setValue(cfg.get(cfg.THIN_ETA_SMOOTHING_FILTER_POLYORDER))
    self.thin_eta_max_allowed_stddev_field.setValue(cfg.get(cfg.THIN_ETA_MAX_ALLOWED_STDDEV))

    self.refcell_rising_speed_field.setValue(cfg.get(cfg.REFCELL_SCAN_RISING_SPEED))
    self.refcell_falling_speed_field.setValue(cfg.get(cfg.REFCELL_SCAN_FALLING_SPEED))

    self.large_wavelength_drift_field.setValue(cfg.get(cfg.LARGE_WAVELENGTH_DRIFT))
    self.medium_wavelength_drift_field.setValue(cfg.get(cfg.MEDIUM_WAVELENGTH_DRIFT))
    self.small_wavelength_drift_field.setValue(cfg.get(cfg.SMALL_WAVELENGTH_DRIFT))

    self.locking_timeout_field.setValue(cfg.get(cfg.LOCKING_TIMEOUT))
    self.fast_pz_setpoint_lower_limit_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT))
    self.fast_pz_setpoint_upper_limit_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT))
    self.fast_pz_setpoint_num_points_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_NUM_POINTS))
    self.fast_pz_setpoint_num_scans_field.setValue(cfg.get(cfg.FAST_PZ_SETPOINT_NUM_SCANS))

    self.stabilization_rising_speed_field.setValue(cfg.get(cfg.STABILIZATION_RISING_SPEED))
    self.stabilization_falling_speed_field.setValue(cfg.get(cfg.STABILIZATION_FALLING_SPEED))
    self.stabilization_delay_field.setValue(cfg.get(cfg.STABILIZATION_DELAY))
    self.stabilization_tolerance_field.setValue(cfg.get(cfg.STABILIZATION_TOLERANCE))

    self.auto_correction_limit_field.setValue(cfg.get(cfg.CORRECTION_LIMIT))

    self.pz_eta_upper_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_UPPER_CORRECTION_POS))
    self.slow_pz_upper_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_UPPER_CORRECTION_POS))
    self.refcell_upper_correction_pos_field.setValue(cfg.get(cfg.REFCELL_UPPER_CORRECTION_POS))
    self.pz_eta_mid_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_MID_CORRECTION_POS))
    self.slow_pz_mid_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_MID_CORRECTION_POS))
    self.refcell_mid_correction_pos_field.setValue(cfg.get(cfg.REFCELL_MID_CORRECTION_POS))
    self.pz_eta_lower_correction_pos_field.setValue(cfg.get(cfg.PIEZO_ETA_LOWER_CORRECTION_POS))
    self.slow_pz_lower_correction_pos_field.setValue(cfg.get(cfg.SLOW_PIEZO_LOWER_CORRECTION_POS))
    self.refcell_lower_correction_pos_field.setValue(cfg.get(cfg.REFCELL_LOWER_CORRECTION_POS))

    self.target_temperature_field.setValue(cfg.get(cfg.PLE_TARGET_TEMPERATURE))
    self.temperature_tolerance_field.setValue(cfg.get(cfg.PLE_TEMPERATURE_TOLERANCE))
def set_tooltips(self)
Source code
def set_tooltips(self):
    self.matisse_device_id_field.setToolTip(tooltips.MATISSE_DEVICE_ID)
    self.wavemeter_port_field.setToolTip(tooltips.WAVEMETER_PORT)
    self.wavemeter_precision_field.setToolTip(tooltips.WAVEMETER_PRECISION)
    self.wavemeter_measurement_delay_field.setToolTip(tooltips.WAVEMETER_MEASUREMENT_DELAY)

    self.status_monitor_delay_field.setToolTip(tooltips.STATUS_MONITOR_DELAY)
    self.status_monitor_font_size_field.setToolTip(tooltips.STATUS_MONITOR_FONT_SIZE)

    self.bifi_reset_pos_field.setToolTip(tooltips.BIFI_RESET_POS)
    self.thin_eta_reset_pos_field.setToolTip(tooltips.THIN_ETA_RESET_POS)
    self.thin_eta_rand_range_field.setToolTip(tooltips.THIN_ETA_RAND_RANGE)

    self.report_events_field.setToolTip(tooltips.REPORT_EVENTS)

    self.component_limit_offset_field.setToolTip(tooltips.COMPONENT_LIMIT_OFFSET)

    self.wavelength_lower_limit_field.setToolTip(tooltips.WAVELENGTH_LOWER_LIMIT)
    self.wavelength_upper_limit_field.setToolTip(tooltips.WAVELENGTH_UPPER_LIMIT)

    self.scan_limit_field.setToolTip(tooltips.SCAN_LIMIT)

    self.bifi_scan_range_field.setToolTip(tooltips.BIFI_SCAN_RANGE)
    self.bifi_small_scan_range_field.setToolTip(tooltips.BIFI_SCAN_RANGE_SMALL)
    self.bifi_scan_step_field.setToolTip(tooltips.BIFI_SCAN_STEP)
    self.bifi_scan_show_plots_field.setToolTip(tooltips.BIFI_SCAN_SHOW_PLOTS)
    self.bifi_smoothing_window_field.setToolTip(tooltips.BIFI_SMOOTHING_FILTER_WINDOW)
    self.bifi_smoothing_polyorder_field.setToolTip(tooltips.BIFI_SMOOTHING_FILTER_POLYORDER)

    self.thin_eta_scan_range_field.setToolTip(tooltips.THIN_ETA_SCAN_RANGE)
    self.thin_eta_small_scan_range_field.setToolTip(tooltips.THIN_ETA_SCAN_RANGE_SMALL)
    self.thin_eta_scan_step_field.setToolTip(tooltips.THIN_ETA_SCAN_STEP)
    self.thin_eta_nudge_field.setToolTip(tooltips.THIN_ETA_NUDGE)
    self.thin_eta_scan_show_plots_field.setToolTip(tooltips.THIN_ETA_SHOW_PLOTS)
    self.thin_eta_smoothing_window_field.setToolTip(tooltips.THIN_ETA_SMOOTHING_FILTER_WINDOW)
    self.thin_eta_smoothing_polyorder_field.setToolTip(tooltips.THIN_ETA_SMOOTHING_FILTER_POLYORDER)
    self.thin_eta_max_allowed_stddev_field.setToolTip(tooltips.THIN_ETA_MAX_ALLOWED_STDDEV)

    self.refcell_rising_speed_field.setToolTip(tooltips.REFCELL_SCAN_RISING_SPEED)
    self.refcell_falling_speed_field.setToolTip(tooltips.REFCELL_SCAN_FALLING_SPEED)

    self.large_wavelength_drift_field.setToolTip(tooltips.LARGE_WAVELENGTH_DRIFT)
    self.medium_wavelength_drift_field.setToolTip(tooltips.MEDIUM_WAVELENGTH_DRIFT)
    self.small_wavelength_drift_field.setToolTip(tooltips.SMALL_WAVELENGTH_DRIFT)

    self.locking_timeout_field.setToolTip(tooltips.LOCKING_TIMEOUT)
    self.fast_pz_setpoint_lower_limit_field.setToolTip(tooltips.FAST_PZ_SETPOINT_SCAN_LOWER_LIMIT)
    self.fast_pz_setpoint_upper_limit_field.setToolTip(tooltips.FAST_PZ_SETPOINT_SCAN_UPPER_LIMIT)
    self.fast_pz_setpoint_num_points_field.setToolTip(tooltips.FAST_PZ_SETPOINT_NUM_POINTS)
    self.fast_pz_setpoint_num_scans_field.setToolTip(tooltips.FAST_PZ_SETPOINT_NUM_SCANS)

    self.stabilization_rising_speed_field.setToolTip(tooltips.STABILIZATION_RISING_SPEED)
    self.stabilization_falling_speed_field.setToolTip(tooltips.STABILIZATION_FALLING_SPEED)
    self.stabilization_delay_field.setToolTip(tooltips.STABILIZATION_DELAY)
    self.stabilization_tolerance_field.setToolTip(tooltips.STABILIZATION_TOLERANCE)

    self.auto_correction_limit_field.setToolTip(tooltips.CORRECTION_LIMIT)

    self.target_temperature_field.setToolTip(tooltips.PLE_TARGET_TEMPERATURE)
    self.temperature_tolerance_field.setToolTip(tooltips.PLE_TEMPERATURE_TOLERANCE)