From 7dbf01017f3452ecf31bd5eb78a4357a05e4cc07 Mon Sep 17 00:00:00 2001 From: jupfi Date: Tue, 12 Dec 2023 16:24:45 +0100 Subject: [PATCH] Implemented testing of LUT. --- src/nqrduck_autotm/controller.py | 10 ++++++++ src/nqrduck_autotm/view.py | 39 ++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/nqrduck_autotm/controller.py b/src/nqrduck_autotm/controller.py index f947f55..5c31154 100644 --- a/src/nqrduck_autotm/controller.py +++ b/src/nqrduck_autotm/controller.py @@ -963,6 +963,16 @@ class AutoTMController(ModuleController): self.module.model.LUT = LUT # self.module.view.create_mech_LUT_spinner_dialog() + def go_to_position(self, tuning_position : int, matching_position : int) -> None: + """Go to the specified position. + + Args: + position (SavedPosition): The position to go to. + """ + confirmation = self.on_absolute_move(tuning_position, self.module.model.tuning_stepper) + if confirmation: + self.on_absolute_move(matching_position, self.module.model.matching_stepper) + # This method isn't used anymore but it might be useful in the future so I'll keep it here def read_reflection(self, frequency) -> tuple: diff --git a/src/nqrduck_autotm/view.py b/src/nqrduck_autotm/view.py index fafae94..32a71d9 100644 --- a/src/nqrduck_autotm/view.py +++ b/src/nqrduck_autotm/view.py @@ -585,6 +585,9 @@ class AutoTMView(ModuleView): self.setParent(parent) self.setWindowTitle("LUT") + # Set size + self.resize(800, 800) + # Add vertical main layout main_layout = QVBoxLayout() @@ -592,7 +595,12 @@ class AutoTMView(ModuleView): # Create table widget self.table_widget = QTableWidget() - self.table_widget.setColumnCount(3) + self.table_widget.setColumnCount(4) + self.table_widget.setColumnWidth(0, 150) + self.table_widget.setColumnWidth(1, 200) + self.table_widget.setColumnWidth(2, 200) + self.table_widget.setColumnWidth(3, 100) + if LUT.TYPE == "Mechanical": self.table_widget.setHorizontalHeaderLabels( ["Frequency (MHz)", "Tuning Position", "Matching Position"] @@ -612,14 +620,31 @@ class AutoTMView(ModuleView): row, 2, QTableWidgetItem(str(LUT.data[frequency][1])) ) + # Button to test the specific entry in the LUT + test_button = QPushButton("Test") + # For electrical probe coils the matching voltage is the first entry in the LUT + if LUT.TYPE == "Electrical": + tuning_voltage = str(LUT.data[frequency][1]) + matching_voltage = str(LUT.data[frequency][0]) + test_button.clicked.connect( + lambda _, tuning_voltage=tuning_voltage, matching_voltage=matching_voltage: self.module.controller.set_voltages( + tuning_voltage, matching_voltage + ) + ) + # For mechanical probe coils the tuning voltage is the first entry in the LUT + elif LUT.TYPE == "Mechanical": + tuning_position = str(LUT.data[frequency][0]) + matching_position = str(LUT.data[frequency][1]) + test_button.clicked.connect( + lambda _, tuning_position=tuning_position, matching_position=matching_position: self.module.controller.go_to_position( + tuning_position, matching_position + ) + ) + + self.table_widget.setCellWidget(row, 3, test_button) + # Add table widget to main layout main_layout.addWidget(self.table_widget) - - # Add Test LUT button - test_lut_button = QPushButton("Test LUT") - test_lut_button.clicked.connect(self.test_lut) - main_layout.addWidget(test_lut_button) - self.setLayout(main_layout) def test_lut(self):