mirror of
https://github.com/nqrduck/nqrduck-measurement.git
synced 2024-11-13 21:41:54 +00:00
Implemented frequency and averages setting.
This commit is contained in:
parent
de4d4fcad6
commit
ada6b7ad4e
4 changed files with 72 additions and 19 deletions
|
@ -1,14 +1,29 @@
|
||||||
import logging
|
import logging
|
||||||
from PyQt6.QtCore import pyqtSlot
|
from PyQt6.QtCore import pyqtSlot, pyqtSignal
|
||||||
|
from PyQt6.QtWidgets import QWidget
|
||||||
from nqrduck.module.module_controller import ModuleController
|
from nqrduck.module.module_controller import ModuleController
|
||||||
from nqrduck_spectrometer.measurement import Measurement
|
from nqrduck_spectrometer.measurement import Measurement
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class MeasurementController(ModuleController):
|
class MeasurementController(ModuleController):
|
||||||
|
|
||||||
|
set_frequency_failure = pyqtSignal()
|
||||||
|
set_averages_failure = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
super().__init__(module)
|
super().__init__(module)
|
||||||
|
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def set_frequency(self, value):
|
||||||
|
logger.debug("Setting frequency to: " + value)
|
||||||
|
self.module.nqrduck_signal.emit("set_frequency", value)
|
||||||
|
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def set_averages(self, value):
|
||||||
|
logger.debug("Setting averages to: " + value)
|
||||||
|
self.module.nqrduck_signal.emit("set_averages", value)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def change_view_mode(self):
|
def change_view_mode(self):
|
||||||
logger.debug("Changing view mode.")
|
logger.debug("Changing view mode.")
|
||||||
|
@ -37,3 +52,11 @@ class MeasurementController(ModuleController):
|
||||||
logger.debug("Received measurement error.")
|
logger.debug("Received measurement error.")
|
||||||
self.module.view.measurement_dialog.hide()
|
self.module.view.measurement_dialog.hide()
|
||||||
self.module.nqrduck_signal.emit("notification", ["Error", "Error during measurement."])
|
self.module.nqrduck_signal.emit("notification", ["Error", "Error during measurement."])
|
||||||
|
|
||||||
|
elif key == "failure" and value[0] == "set_frequency" and self.module.view._ui_form.frequencyEdit.text() == value[1]:
|
||||||
|
logger.debug("Received set frequency failure.")
|
||||||
|
self.set_frequency_failure.emit()
|
||||||
|
|
||||||
|
elif key == "failure" and value[0] == "set_averages" and self.module.view._ui_form.averagesEdit.text() == value[1]:
|
||||||
|
logger.debug("Received set averages failure.")
|
||||||
|
self.set_averages_failure.emit()
|
||||||
|
|
|
@ -51,24 +51,24 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="frequencyLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Target Frequency</string>
|
<string>Target Frequency</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
<widget class="QLineEdit" name="averagesEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="averagesLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Averages</string>
|
<string>Averages</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit"/>
|
<widget class="QLineEdit" name="frequencyEdit"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -52,6 +52,15 @@ class MeasurementView(ModuleView):
|
||||||
self._ui_form.buttonStart.clicked.connect(self.on_measurement_start_button_clicked)
|
self._ui_form.buttonStart.clicked.connect(self.on_measurement_start_button_clicked)
|
||||||
self._ui_form.fftButton.clicked.connect(self.module.controller.change_view_mode)
|
self._ui_form.fftButton.clicked.connect(self.module.controller.change_view_mode)
|
||||||
|
|
||||||
|
self._ui_form.frequencyEdit.editingFinished.connect(lambda: self.on_editing_finished(self._ui_form.frequencyEdit.text()))
|
||||||
|
self._ui_form.averagesEdit.editingFinished.connect(lambda: self.on_editing_finished(self._ui_form.averagesEdit.text()))
|
||||||
|
|
||||||
|
self.module.controller.set_frequency_failure.connect(self.on_set_frequency_failure)
|
||||||
|
self.module.controller.set_averages_failure.connect(self.on_set_averages_failure)
|
||||||
|
|
||||||
|
# Call validator for buttonStart
|
||||||
|
|
||||||
|
|
||||||
def init_plotter(self):
|
def init_plotter(self):
|
||||||
plotter = self._ui_form.plotter
|
plotter = self._ui_form.plotter
|
||||||
plotter.canvas.ax.clear()
|
plotter.canvas.ax.clear()
|
||||||
|
@ -105,6 +114,27 @@ class MeasurementView(ModuleView):
|
||||||
logger.debug("Measurement start button clicked.")
|
logger.debug("Measurement start button clicked.")
|
||||||
self.module.controller.start_measurement()
|
self.module.controller.start_measurement()
|
||||||
|
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def on_editing_finished(self, value):
|
||||||
|
logger.debug("Editing finished.")
|
||||||
|
self.sender().setStyleSheet("")
|
||||||
|
if self.sender() == self._ui_form.frequencyEdit:
|
||||||
|
self.module.controller.set_frequency(value)
|
||||||
|
elif self.sender() == self._ui_form.averagesEdit:
|
||||||
|
self.module.controller.set_averages(value)
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def on_set_frequency_failure(self):
|
||||||
|
"""Slot for when the set frequency signal fails."""
|
||||||
|
logger.debug("Set frequency failure.")
|
||||||
|
self._ui_form.frequencyEdit.setStyleSheet("border: 1px solid red;")
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def on_set_averages_failure(self):
|
||||||
|
"""Slot for when the set averages signal fails."""
|
||||||
|
logger.debug("Set averages failure.")
|
||||||
|
self._ui_form.averagesEdit.setStyleSheet("border: 1px solid red;")
|
||||||
|
|
||||||
class MeasurementDialog(QDialog):
|
class MeasurementDialog(QDialog):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
|
@ -39,18 +39,18 @@ class Ui_Form(object):
|
||||||
self.settingsLayout.addLayout(self.spectrometerLayout)
|
self.settingsLayout.addLayout(self.spectrometerLayout)
|
||||||
self.gridLayout = QtWidgets.QGridLayout()
|
self.gridLayout = QtWidgets.QGridLayout()
|
||||||
self.gridLayout.setObjectName("gridLayout")
|
self.gridLayout.setObjectName("gridLayout")
|
||||||
self.label = QtWidgets.QLabel(parent=Form)
|
self.frequencyLabel = QtWidgets.QLabel(parent=Form)
|
||||||
self.label.setObjectName("label")
|
self.frequencyLabel.setObjectName("frequencyLabel")
|
||||||
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
|
self.gridLayout.addWidget(self.frequencyLabel, 0, 0, 1, 1)
|
||||||
self.lineEdit_2 = QtWidgets.QLineEdit(parent=Form)
|
self.averagesEdit = QtWidgets.QLineEdit(parent=Form)
|
||||||
self.lineEdit_2.setObjectName("lineEdit_2")
|
self.averagesEdit.setObjectName("averagesEdit")
|
||||||
self.gridLayout.addWidget(self.lineEdit_2, 1, 1, 1, 1)
|
self.gridLayout.addWidget(self.averagesEdit, 1, 1, 1, 1)
|
||||||
self.label_2 = QtWidgets.QLabel(parent=Form)
|
self.averagesLabel = QtWidgets.QLabel(parent=Form)
|
||||||
self.label_2.setObjectName("label_2")
|
self.averagesLabel.setObjectName("averagesLabel")
|
||||||
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
|
self.gridLayout.addWidget(self.averagesLabel, 1, 0, 1, 1)
|
||||||
self.lineEdit = QtWidgets.QLineEdit(parent=Form)
|
self.frequencyEdit = QtWidgets.QLineEdit(parent=Form)
|
||||||
self.lineEdit.setObjectName("lineEdit")
|
self.frequencyEdit.setObjectName("frequencyEdit")
|
||||||
self.gridLayout.addWidget(self.lineEdit, 0, 1, 1, 1)
|
self.gridLayout.addWidget(self.frequencyEdit, 0, 1, 1, 1)
|
||||||
self.settingsLayout.addLayout(self.gridLayout)
|
self.settingsLayout.addLayout(self.gridLayout)
|
||||||
self.buttonStart = QtWidgets.QPushButton(parent=Form)
|
self.buttonStart = QtWidgets.QPushButton(parent=Form)
|
||||||
self.buttonStart.setObjectName("buttonStart")
|
self.buttonStart.setObjectName("buttonStart")
|
||||||
|
@ -95,8 +95,8 @@ class Ui_Form(object):
|
||||||
Form.setWindowTitle(_translate("Form", "Form"))
|
Form.setWindowTitle(_translate("Form", "Form"))
|
||||||
self.titleLable.setText(_translate("Form", "Single Frequency Measurement: "))
|
self.titleLable.setText(_translate("Form", "Single Frequency Measurement: "))
|
||||||
self.spectrometerLabel.setText(_translate("Form", "Spectrometer:"))
|
self.spectrometerLabel.setText(_translate("Form", "Spectrometer:"))
|
||||||
self.label.setText(_translate("Form", "Target Frequency"))
|
self.frequencyLabel.setText(_translate("Form", "Target Frequency"))
|
||||||
self.label_2.setText(_translate("Form", "Averages"))
|
self.averagesLabel.setText(_translate("Form", "Averages"))
|
||||||
self.buttonStart.setText(_translate("Form", "Start Measurement"))
|
self.buttonStart.setText(_translate("Form", "Start Measurement"))
|
||||||
self.fftButton.setText(_translate("Form", "FFT"))
|
self.fftButton.setText(_translate("Form", "FFT"))
|
||||||
from nqrduck.contrib.mplwidget import MplWidget
|
from nqrduck.contrib.mplwidget import MplWidget
|
||||||
|
|
Loading…
Reference in a new issue