diff --git a/src/nqrduck_broadband/controller.py b/src/nqrduck_broadband/controller.py index 5ae50a7..33364b8 100644 --- a/src/nqrduck_broadband/controller.py +++ b/src/nqrduck_broadband/controller.py @@ -34,11 +34,19 @@ class BroadbandController(ModuleController): self.set_averages_failure.emit() # receive LUT data elif key == "LUT_finished": - logger.debug("Received LUT data.") - self.module.model.LUT = value - self.change_start_frequency(self.module.model.LUT.start_frequency) - self.change_stop_frequency(self.module.model.LUT.stop_frequency) - self.change_frequency_step(self.module.model.LUT.frequency_step) + self.received_LUT(value) + + def received_LUT(self, LUT : Measurement) -> None: + """This slot is called when the LUT data is received from the nqrduck module. + + Args: + LUT (Measurement): LUT data. + """ + logger.debug("Received LUT data.") + self.module.model.LUT = LUT + self.change_start_frequency(self.module.model.LUT.start_frequency) + self.change_stop_frequency(self.module.model.LUT.stop_frequency) + self.change_frequency_step(self.module.model.LUT.frequency_step) @pyqtSlot(str) def set_frequency(self, value : str) -> None: @@ -131,6 +139,11 @@ class BroadbandController(ModuleController): else: self.module.view.add_info_text("Broadband measurement finished.") + @pyqtSlot() + def delete_LUT(self) -> None: + """This slot is called when the LUT is deleted.""" + self.module.model.LUT = None + def start_single_measurement(self, frequency : float) -> None: """Starts a single measurement. @@ -139,5 +152,8 @@ class BroadbandController(ModuleController): """ logger.debug("Starting single measurement.") self.module.view.add_info_text("Starting measurement at frequency: " + str(frequency)) + # First set the frequency of the spectrometer self.module.nqrduck_signal.emit("set_frequency", str(frequency)) + # If there is a LUT available, send the tune and match values as signal + self.module.nqrduck_signal.emit("start_measurement", None) \ No newline at end of file diff --git a/src/nqrduck_broadband/resources/broadband_widget.ui b/src/nqrduck_broadband/resources/broadband_widget.ui index 7e6874f..e028417 100644 --- a/src/nqrduck_broadband/resources/broadband_widget.ui +++ b/src/nqrduck_broadband/resources/broadband_widget.ui @@ -157,7 +157,7 @@ - + @@ -177,9 +177,27 @@ - + + + + + Active LUT: + + + + + + + None + + + + + + + - + Delete LUT @@ -218,7 +236,7 @@ 0 0 271 - 719 + 677 diff --git a/src/nqrduck_broadband/view.py b/src/nqrduck_broadband/view.py index debda48..248cacb 100644 --- a/src/nqrduck_broadband/view.py +++ b/src/nqrduck_broadband/view.py @@ -65,6 +65,9 @@ class BroadbandView(ModuleView): # LUT data self.module.model.LUT_changed.connect(self.on_LUT_changed) + # On deleteLUTButton clicked + self._ui_form.deleteLUTButton.clicked.connect(self.module.controller.delete_LUT) + @pyqtSlot() def start_measurement_clicked(self) -> None: """This method is called when the start measurement button is clicked. @@ -229,7 +232,17 @@ class BroadbandView(ModuleView): def on_LUT_changed(self) -> None: """This method is called when the LUT data is changed.""" logger.debug("Updating LUT fields.") - # LUT type here + # If lut is not None disable the start- stop step frequency fields and update the LUT type label + if self.module.model.LUT is not None: + self._ui_form.start_frequencyField.setEnabled(False) + self._ui_form.stop_frequencyField.setEnabled(False) + self._ui_form.frequencystepEdit.setEnabled(False) + self._ui_form.activeLUTLabel.setText("Test") + else: + self._ui_form.start_frequencyField.setEnabled(True) + self._ui_form.stop_frequencyField.setEnabled(True) + self._ui_form.frequencystepEdit.setEnabled(True) + self._ui_form.activeLUTLabel.setText("None") def add_info_text(self, text : str) -> None: """Add a text to the info box with a timestamp. diff --git a/src/nqrduck_broadband/widget.py b/src/nqrduck_broadband/widget.py index 5a89a9b..cbfd09a 100644 --- a/src/nqrduck_broadband/widget.py +++ b/src/nqrduck_broadband/widget.py @@ -101,10 +101,18 @@ class Ui_Form(object): self.label_10.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.label_10.setObjectName("label_10") self.verticalLayout_3.addWidget(self.label_10) - self.file_pathLabel = QtWidgets.QLabel(parent=Form) - self.file_pathLabel.setText("") - self.file_pathLabel.setObjectName("file_pathLabel") - self.verticalLayout_3.addWidget(self.file_pathLabel) + self.gridLayout = QtWidgets.QGridLayout() + self.gridLayout.setObjectName("gridLayout") + self.label_11 = QtWidgets.QLabel(parent=Form) + self.label_11.setObjectName("label_11") + self.gridLayout.addWidget(self.label_11, 0, 0, 1, 1) + self.activeLUTLabel = QtWidgets.QLabel(parent=Form) + self.activeLUTLabel.setObjectName("activeLUTLabel") + self.gridLayout.addWidget(self.activeLUTLabel, 0, 1, 1, 1) + self.verticalLayout_3.addLayout(self.gridLayout) + self.deleteLUTButton = QtWidgets.QPushButton(parent=Form) + self.deleteLUTButton.setObjectName("deleteLUTButton") + self.verticalLayout_3.addWidget(self.deleteLUTButton) self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.label_9 = QtWidgets.QLabel(parent=Form) @@ -122,7 +130,7 @@ class Ui_Form(object): self.infoBox.setWidgetResizable(True) self.infoBox.setObjectName("infoBox") self.scrollAreaWidgetContents = QtWidgets.QWidget() - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 271, 719)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 271, 677)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -133,7 +141,7 @@ class Ui_Form(object): self.verticalLayout_2.addWidget(self.infoBox) self.verticalLayout_2.setStretch(2, 1) self.verticalLayout_3.addLayout(self.verticalLayout_2) - self.verticalLayout_3.setStretch(2, 1) + self.verticalLayout_3.setStretch(3, 1) self.verticalLayout_4.addLayout(self.verticalLayout_3) self.verticalLayout_4.setStretch(1, 1) self.horizontalLayout_6.addLayout(self.verticalLayout_4) @@ -186,5 +194,8 @@ class Ui_Form(object): self.label_7.setText(_translate("Form", "Averages:")) self.start_measurementButton.setText(_translate("Form", "Start Measurement")) self.label_10.setText(_translate("Form", "Sequence Settings:")) + self.label_11.setText(_translate("Form", "Active LUT:")) + self.activeLUTLabel.setText(_translate("Form", "None")) + self.deleteLUTButton.setText(_translate("Form", "Delete LUT")) self.label_9.setText(_translate("Form", "Info Box:")) from nqrduck.contrib.mplwidget import MplWidget