-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from linien-org/feature/fix-psd-algorithm-sel…
…ection Fix PSD algorithm selection
- Loading branch information
Showing
5 changed files
with
56 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Copyright 2018-2022 Benjamin Wiegand <[email protected]> | ||
# Copyright 2021-2022 Bastian Leykauf <[email protected]> | ||
# Copyright 2021-2024 Bastian Leykauf <[email protected]> | ||
# | ||
# This file is part of Linien and based on redpid. | ||
# | ||
|
@@ -212,7 +212,9 @@ def show_cursor_position(self, show): | |
self.cursor_label.setVisible(show) | ||
|
||
def leaveEvent(self, QEvent): | ||
"""This method is called when the mouse used to hover the plot and | ||
not left. In this case, we hide crosshair and cursor label.""" | ||
""" | ||
This method is called when the mouse used to hover the plot and not left. In | ||
this case, we hide crosshair and cursor label. | ||
""" | ||
super().leaveEvent(QEvent) | ||
self.show_cursor_position(False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Copyright 2018-2022 Benjamin Wiegand <[email protected]> | ||
# Copyright 2021-2022 Bastian Leykauf <[email protected]> | ||
# Copyright 2021-2024 Bastian Leykauf <[email protected]> | ||
# | ||
# This file is part of Linien and based on redpid. | ||
# | ||
|
@@ -23,6 +23,8 @@ | |
from linien_common.common import PSDAlgorithm | ||
from linien_gui.config import UI_PATH | ||
from linien_gui.dialogs import error_dialog | ||
from linien_gui.ui.psd_plot_widget import PSDPlotWidget | ||
from linien_gui.ui.psd_table_widget import PSDTableWidget | ||
from linien_gui.utils import ( | ||
RandomColorChoser, | ||
get_linien_app_instance, | ||
|
@@ -33,6 +35,18 @@ | |
|
||
|
||
class PSDWindow(QtWidgets.QMainWindow): | ||
PSDPlot: PSDPlotWidget | ||
curveTable: PSDTableWidget | ||
maxMeasurementTimeComboBox: QtWidgets.QComboBox | ||
PSDAlgorithmComboBox: QtWidgets.QComboBox | ||
startPSDPushButton: QtWidgets.QPushButton | ||
stopPSDPushButton: QtWidgets.QPushButton | ||
exportPSDPushButton: QtWidgets.QPushButton | ||
importPSDPushButton: QtWidgets.QPushButton | ||
deleteCurveButton: QtWidgets.QPushButton | ||
PSDRunningContainer: QtWidgets.QWidget | ||
PSDNotRunningContainer: QtWidgets.QGroupBox | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(PSDWindow, self).__init__(*args, **kwargs) | ||
uic.loadUi(UI_PATH / "psd_window.ui", self) | ||
|
@@ -46,21 +60,19 @@ def __init__(self, *args, **kwargs): | |
self.data = {} | ||
self.complete_uids = [] | ||
|
||
self.start_psd_button.clicked.connect(self.start_psd) | ||
self.stop_psd_button.clicked.connect(self.stop_psd) | ||
self.startPSDPushButton.clicked.connect(self.start_psd) | ||
self.stopPSDPushButton.clicked.connect(self.stop_psd) | ||
|
||
self.curve_table.show_or_hide_curve.connect( | ||
self.psd_plot_widget.show_or_hide_curve | ||
) | ||
self.delete_curve_button.clicked.connect(self.delete_curve) | ||
self.export_psd_button.clicked.connect(self.export_psd) | ||
self.import_psd_button.clicked.connect(self.import_psd) | ||
self.curveTable.show_or_hide_curve.connect(self.PSDPlot.show_or_hide_curve) | ||
self.deleteCurveButton.clicked.connect(self.delete_curve) | ||
self.exportPSDPushButton.clicked.connect(self.export_psd) | ||
self.importPSDPushButton.clicked.connect(self.import_psd) | ||
|
||
self.maximum_measurement_time.currentIndexChanged.connect( | ||
self.change_maximum_measurement_time | ||
self.maxMeasurementTimeComboBox.currentIndexChanged.connect( | ||
self.on_maximum_measurement_time_changed | ||
) | ||
|
||
self.psd_algorithm.currentIndexChanged.connect(self.change_psd_algorithm) | ||
self.PSDAlgorithmComboBox.currentIndexChanged.connect(self.change_psd_algorithm) | ||
|
||
def on_connection_established(self): | ||
self.parameters = self.app.parameters | ||
|
@@ -75,19 +87,19 @@ def on_connection_established(self): | |
|
||
param2ui( | ||
self.parameters.psd_acquisition_max_decimation, | ||
self.maximum_measurement_time, | ||
self.maxMeasurementTimeComboBox, | ||
lambda max_decimation: max_decimation - 12, | ||
) | ||
param2ui(self.parameters.psd_algorithm, self.psd_algorithm) | ||
param2ui(self.parameters.psd_algorithm, self.PSDAlgorithmComboBox) | ||
|
||
def update_status(_): | ||
psd_running = self.parameters.psd_acquisition_running.value | ||
if psd_running: | ||
self.container_psd_running.show() | ||
self.container_psd_not_running.hide() | ||
self.PSDRunningContainer.show() | ||
self.PSDNotRunningContainer.hide() | ||
else: | ||
self.container_psd_running.hide() | ||
self.container_psd_not_running.show() | ||
self.PSDRunningContainer.hide() | ||
self.PSDNotRunningContainer.show() | ||
|
||
self.parameters.psd_acquisition_running.add_callback(update_status) | ||
|
||
|
@@ -97,13 +109,11 @@ def closeEvent(self, event, *args, **kwargs): | |
event.ignore() | ||
self.hide() | ||
|
||
def change_maximum_measurement_time(self, index): | ||
def on_maximum_measurement_time_changed(self, index): | ||
self.parameters.psd_acquisition_max_decimation.value = 12 + index | ||
|
||
def change_psd_algorithm(self, index): | ||
self.parameters.psd_algorithm.value = [PSDAlgorithm.LPSD, PSDAlgorithm.WELCH][ | ||
index | ||
] | ||
def change_psd_algorithm(self, index: int) -> None: | ||
self.parameters.psd_algorithm.value = list(PSDAlgorithm)[index] | ||
|
||
def psd_data_received(self, data_pickled): | ||
if data_pickled is None: | ||
|
@@ -130,8 +140,8 @@ def psd_data_received(self, data_pickled): | |
else: | ||
color = self.colors[curve_uuid] | ||
|
||
self.psd_plot_widget.plot_curve(curve_uuid, data["psds"], color) | ||
self.curve_table.add_curve(curve_uuid, data, color) | ||
self.PSDPlot.plot_curve(curve_uuid, data["psds"], color) | ||
self.curveTable.add_curve(curve_uuid, data, color) | ||
|
||
self.data[curve_uuid] = data | ||
|
||
|
@@ -150,9 +160,9 @@ def start_pid_optimization(self): | |
self.control.start_pid_optimization() | ||
|
||
def delete_curve(self): | ||
uuid = self.curve_table.delete_selected_curve() | ||
uuid = self.curveTable.delete_selected_curve() | ||
if uuid is not None: | ||
self.psd_plot_widget.delete_curve(uuid) | ||
self.PSDPlot.delete_curve(uuid) | ||
del self.data[uuid] | ||
|
||
def export_psd(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters