mirror of
https://github.com/nqrduck/nqrduck-autotm.git
synced 2024-12-21 07:10:27 +00:00
Updated voltage sweep functionality.
This commit is contained in:
parent
a6521ad5b2
commit
7541a20cf3
5 changed files with 96 additions and 88 deletions
|
@ -222,6 +222,17 @@ class AutoTMController(ModuleController):
|
|||
LUT.started_frequency = next_frequency
|
||||
logger.debug("Starting next voltage sweep: %s", command)
|
||||
self.send_command(command)
|
||||
else:
|
||||
logger.debug("Voltage sweep finished")
|
||||
self.module.view.el_LUT_spinner.hide()
|
||||
self.module.model.voltage_sweep_stop = time.time()
|
||||
self.module.view.add_info_text(
|
||||
"Voltage sweep finished in %.2f seconds"
|
||||
% (
|
||||
self.module.model.voltage_sweep_stop
|
||||
- self.module.model.voltage_sweep_start
|
||||
)
|
||||
)
|
||||
|
||||
def on_short_calibration(
|
||||
self, start_frequency: float, stop_frequency: float
|
||||
|
@ -419,7 +430,6 @@ class AutoTMController(ModuleController):
|
|||
start_frequency: str,
|
||||
stop_frequency: str,
|
||||
frequency_step: str,
|
||||
voltage_resolution: str,
|
||||
) -> None:
|
||||
"""This method is called when the generate LUT button is pressed.
|
||||
It generates a lookup table for the specified frequency range and voltage resolution.
|
||||
|
@ -428,20 +438,17 @@ class AutoTMController(ModuleController):
|
|||
start_frequency (str): The start frequency in Hz.
|
||||
stop_frequency (str): The stop frequency in Hz.
|
||||
frequency_step (str): The frequency step in Hz.
|
||||
voltage_resolution (str): The voltage resolution in V.
|
||||
"""
|
||||
logger.debug("Generating LUT")
|
||||
try:
|
||||
start_frequency = start_frequency.replace(",", ".")
|
||||
stop_frequency = stop_frequency.replace(",", ".")
|
||||
frequency_step = frequency_step.replace(",", ".")
|
||||
voltage_resolution = voltage_resolution.replace(",", ".")
|
||||
start_frequency = float(start_frequency)
|
||||
stop_frequency = float(stop_frequency)
|
||||
frequency_step = float(frequency_step)
|
||||
voltage_resolution = float(voltage_resolution)
|
||||
except ValueError:
|
||||
error = "Could not generate LUT. Start frequency, stop frequency, frequency step and voltage resolution must be floats"
|
||||
error = "Could not generate LUT. Start frequency, stop frequency, frequency step must be floats"
|
||||
logger.error(error)
|
||||
self.module.view.add_info_text(error)
|
||||
return
|
||||
|
@ -450,9 +457,8 @@ class AutoTMController(ModuleController):
|
|||
start_frequency < 0
|
||||
or stop_frequency < 0
|
||||
or frequency_step < 0
|
||||
or voltage_resolution < 0
|
||||
):
|
||||
error = "Could not generate LUT. Start frequency, stop frequency, frequency step and voltage resolution must be positive"
|
||||
error = "Could not generate LUT. Start frequency, stop frequency, frequency step must be positive"
|
||||
logger.error(error)
|
||||
self.module.view.add_info_text(error)
|
||||
return
|
||||
|
@ -470,16 +476,15 @@ class AutoTMController(ModuleController):
|
|||
return
|
||||
|
||||
logger.debug(
|
||||
"Generating LUT from %s MHz to %s MHz with a frequency step of %s MHz and a voltage resolution of %s V",
|
||||
"Generating LUT from %s MHz to %s MHz with a frequency step of %s MHz",
|
||||
start_frequency,
|
||||
stop_frequency,
|
||||
frequency_step,
|
||||
voltage_resolution,
|
||||
)
|
||||
|
||||
# We create the lookup table
|
||||
LUT = LookupTable(
|
||||
start_frequency, stop_frequency, frequency_step, voltage_resolution
|
||||
start_frequency, stop_frequency, frequency_step
|
||||
)
|
||||
|
||||
LUT.started_frequency = start_frequency
|
||||
|
@ -487,6 +492,9 @@ class AutoTMController(ModuleController):
|
|||
|
||||
# We write the first command to the serial connection
|
||||
command = "s%s" % (start_frequency)
|
||||
self.module.view.create_el_LUT_spinner_dialog()
|
||||
# For timing of the voltage sweep
|
||||
self.module.model.voltage_sweep_start = time.time()
|
||||
confirmation = self.send_command(command)
|
||||
if not confirmation:
|
||||
return
|
||||
|
@ -544,7 +552,7 @@ class AutoTMController(ModuleController):
|
|||
logger.debug("Confirmation: %s", confirmation)
|
||||
|
||||
if confirmation == "c":
|
||||
logger.debug("Command send successfully")
|
||||
logger.debug("Command sent successfully")
|
||||
return True
|
||||
else:
|
||||
logger.error("Could not send command. No confirmation received")
|
||||
|
|
|
@ -170,12 +170,10 @@ class LookupTable:
|
|||
start_frequency: float,
|
||||
stop_frequency: float,
|
||||
frequency_step: float,
|
||||
voltage_resolution: float,
|
||||
) -> None:
|
||||
self.start_frequency = start_frequency
|
||||
self.stop_frequency = stop_frequency
|
||||
self.frequency_step = frequency_step
|
||||
self.voltage_resolution = voltage_resolution
|
||||
|
||||
# This is the frequency at which the tuning and matching process was started
|
||||
self.started_frequency = None
|
||||
|
|
|
@ -93,7 +93,11 @@
|
|||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="stopfrequencyBox"/>
|
||||
<widget class="QDoubleSpinBox" name="stopfrequencyBox">
|
||||
<property name="value">
|
||||
<double>80.299999999999997</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
|
@ -103,7 +107,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="startfrequencyBox"/>
|
||||
<widget class="QDoubleSpinBox" name="startfrequencyBox">
|
||||
<property name="value">
|
||||
<double>80.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
|
@ -120,7 +128,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="frequencystepBox"/>
|
||||
<widget class="QDoubleSpinBox" name="frequencystepBox">
|
||||
<property name="value">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -140,7 +152,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="typeTab">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mechTab">
|
||||
<attribute name="title">
|
||||
|
@ -283,9 +295,13 @@
|
|||
<attribute name="title">
|
||||
<string>Electrical</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0">
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="matchingBox"/>
|
||||
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="generateLUTButton">
|
||||
<property name="text">
|
||||
<string>Start Voltage Sweep</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
|
@ -294,20 +310,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="resolutionBox"/>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="tuningBox"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="setvoltagesButton">
|
||||
<property name="text">
|
||||
<string>Set Voltages</string>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Voltage Resolution</string>
|
||||
<string>Generate LUT:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -318,9 +333,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="tuningBox"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="font">
|
||||
|
@ -334,32 +346,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="viewelLUTButton">
|
||||
<property name="text">
|
||||
<string>View LUT</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="generateLUTButton">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="setvoltagesButton">
|
||||
<property name="text">
|
||||
<string>Start Voltage Sweep</string>
|
||||
<string>Set Voltages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate LUT:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="matchingBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -34,7 +34,7 @@ class AutoTMView(ModuleView):
|
|||
self._ui_form.setupUi(self)
|
||||
self.widget = widget
|
||||
|
||||
self.frequency_sweep_spinner = self.FrequencySweepSpinner(self)
|
||||
self.frequency_sweep_spinner = self.LoadingSpinner(self)
|
||||
self.frequency_sweep_spinner.hide()
|
||||
|
||||
# Disable the connectButton while no devices are selected
|
||||
|
@ -67,7 +67,6 @@ class AutoTMView(ModuleView):
|
|||
self._ui_form.startfrequencyBox.text(),
|
||||
self._ui_form.stopfrequencyBox.text(),
|
||||
self._ui_form.frequencystepBox.text(),
|
||||
self._ui_form.resolutionBox.text(),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -289,21 +288,26 @@ class AutoTMView(ModuleView):
|
|||
|
||||
def create_frequency_sweep_spinner_dialog(self) -> None:
|
||||
"""Creates a frequency sweep spinner dialog."""
|
||||
self.frequency_sweep_spinner = self.FrequencySweepSpinner(self)
|
||||
self.frequency_sweep_spinner = self.LoadingSpinner("Performing frequency sweep ...", self)
|
||||
self.frequency_sweep_spinner.show()
|
||||
|
||||
def create_el_LUT_spinner_dialog(self) -> None:
|
||||
"""Creates a electrical LUT spinner dialog."""
|
||||
self.el_LUT_spinner = self.LoadingSpinner("Generating electrical LUT ...", self)
|
||||
self.el_LUT_spinner.show()
|
||||
|
||||
def view_el_lut(self) -> None:
|
||||
"""Creates a new Dialog that shows the currently active electrical LUT."""
|
||||
logger.debug("View LUT")
|
||||
self.lut_window = self.LutWindow(self.module)
|
||||
self.lut_window.show()
|
||||
|
||||
class FrequencySweepSpinner(QDialog):
|
||||
class LoadingSpinner(QDialog):
|
||||
"""This class implements a spinner dialog that is shown during a frequency sweep."""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, text : str, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle("Frequency sweep")
|
||||
self.setWindowTitle("Loading")
|
||||
self.setModal(True)
|
||||
self.setWindowFlag(Qt.WindowType.FramelessWindowHint)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
@ -313,7 +317,7 @@ class AutoTMView(ModuleView):
|
|||
self.spinner_label.setMovie(self.spinner_movie)
|
||||
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout.addWidget(QLabel("Performing frequency sweep..."))
|
||||
self.layout.addWidget(QLabel(text))
|
||||
self.layout.addWidget(self.spinner_label)
|
||||
|
||||
self.spinner_movie.start()
|
||||
|
|
|
@ -61,12 +61,14 @@ class Ui_Form(object):
|
|||
self.gridLayout_8 = QtWidgets.QGridLayout()
|
||||
self.gridLayout_8.setObjectName("gridLayout_8")
|
||||
self.stopfrequencyBox = QtWidgets.QDoubleSpinBox(parent=Form)
|
||||
self.stopfrequencyBox.setProperty("value", 80.3)
|
||||
self.stopfrequencyBox.setObjectName("stopfrequencyBox")
|
||||
self.gridLayout_8.addWidget(self.stopfrequencyBox, 1, 1, 1, 1)
|
||||
self.label_13 = QtWidgets.QLabel(parent=Form)
|
||||
self.label_13.setObjectName("label_13")
|
||||
self.gridLayout_8.addWidget(self.label_13, 1, 0, 1, 1)
|
||||
self.startfrequencyBox = QtWidgets.QDoubleSpinBox(parent=Form)
|
||||
self.startfrequencyBox.setProperty("value", 80.0)
|
||||
self.startfrequencyBox.setObjectName("startfrequencyBox")
|
||||
self.gridLayout_8.addWidget(self.startfrequencyBox, 0, 1, 1, 1)
|
||||
self.label_12 = QtWidgets.QLabel(parent=Form)
|
||||
|
@ -76,6 +78,7 @@ class Ui_Form(object):
|
|||
self.label_14.setObjectName("label_14")
|
||||
self.gridLayout_8.addWidget(self.label_14, 2, 0, 1, 1)
|
||||
self.frequencystepBox = QtWidgets.QDoubleSpinBox(parent=Form)
|
||||
self.frequencystepBox.setProperty("value", 0.1)
|
||||
self.frequencystepBox.setObjectName("frequencystepBox")
|
||||
self.gridLayout_8.addWidget(self.frequencystepBox, 2, 1, 1, 1)
|
||||
self.verticalLayout_2.addLayout(self.gridLayout_8)
|
||||
|
@ -154,27 +157,25 @@ class Ui_Form(object):
|
|||
self.elecTab.setObjectName("elecTab")
|
||||
self.gridLayout_3 = QtWidgets.QGridLayout(self.elecTab)
|
||||
self.gridLayout_3.setObjectName("gridLayout_3")
|
||||
self.matchingBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
||||
self.matchingBox.setObjectName("matchingBox")
|
||||
self.gridLayout_3.addWidget(self.matchingBox, 2, 1, 1, 1)
|
||||
self.generateLUTButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||
self.generateLUTButton.setObjectName("generateLUTButton")
|
||||
self.gridLayout_3.addWidget(self.generateLUTButton, 8, 0, 1, 2)
|
||||
self.label_2 = QtWidgets.QLabel(parent=self.elecTab)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.gridLayout_3.addWidget(self.label_2, 1, 0, 1, 1)
|
||||
self.resolutionBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
||||
self.resolutionBox.setObjectName("resolutionBox")
|
||||
self.gridLayout_3.addWidget(self.resolutionBox, 5, 1, 1, 1)
|
||||
self.setvoltagesButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||
self.setvoltagesButton.setObjectName("setvoltagesButton")
|
||||
self.gridLayout_3.addWidget(self.setvoltagesButton, 3, 0, 1, 2)
|
||||
self.label_4 = QtWidgets.QLabel(parent=self.elecTab)
|
||||
self.label_4.setObjectName("label_4")
|
||||
self.gridLayout_3.addWidget(self.label_4, 5, 0, 1, 1)
|
||||
self.label_3 = QtWidgets.QLabel(parent=self.elecTab)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.gridLayout_3.addWidget(self.label_3, 2, 0, 1, 1)
|
||||
self.tuningBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
||||
self.tuningBox.setObjectName("tuningBox")
|
||||
self.gridLayout_3.addWidget(self.tuningBox, 1, 1, 1, 1)
|
||||
self.label_11 = QtWidgets.QLabel(parent=self.elecTab)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.label_11.setFont(font)
|
||||
self.label_11.setObjectName("label_11")
|
||||
self.gridLayout_3.addWidget(self.label_11, 4, 0, 1, 1)
|
||||
self.label_3 = QtWidgets.QLabel(parent=self.elecTab)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.gridLayout_3.addWidget(self.label_3, 2, 0, 1, 1)
|
||||
self.label_9 = QtWidgets.QLabel(parent=self.elecTab)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
|
@ -184,17 +185,13 @@ class Ui_Form(object):
|
|||
self.gridLayout_3.addWidget(self.label_9, 0, 0, 1, 1)
|
||||
self.viewelLUTButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||
self.viewelLUTButton.setObjectName("viewelLUTButton")
|
||||
self.gridLayout_3.addWidget(self.viewelLUTButton, 10, 0, 1, 2)
|
||||
self.generateLUTButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||
self.generateLUTButton.setObjectName("generateLUTButton")
|
||||
self.gridLayout_3.addWidget(self.generateLUTButton, 9, 0, 1, 2)
|
||||
self.label_11 = QtWidgets.QLabel(parent=self.elecTab)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.label_11.setFont(font)
|
||||
self.label_11.setObjectName("label_11")
|
||||
self.gridLayout_3.addWidget(self.label_11, 4, 0, 1, 1)
|
||||
self.gridLayout_3.addWidget(self.viewelLUTButton, 9, 0, 1, 2)
|
||||
self.setvoltagesButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||
self.setvoltagesButton.setObjectName("setvoltagesButton")
|
||||
self.gridLayout_3.addWidget(self.setvoltagesButton, 3, 0, 1, 2)
|
||||
self.matchingBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
||||
self.matchingBox.setObjectName("matchingBox")
|
||||
self.gridLayout_3.addWidget(self.matchingBox, 2, 1, 1, 1)
|
||||
self.typeTab.addTab(self.elecTab, "")
|
||||
self.verticalLayout_2.addWidget(self.typeTab)
|
||||
self.rfswitchLabel = QtWidgets.QLabel(parent=Form)
|
||||
|
@ -280,7 +277,7 @@ class Ui_Form(object):
|
|||
self.horizontalLayout_2.setStretch(1, 1)
|
||||
|
||||
self.retranslateUi(Form)
|
||||
self.typeTab.setCurrentIndex(0)
|
||||
self.typeTab.setCurrentIndex(1)
|
||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
|
@ -310,14 +307,13 @@ class Ui_Form(object):
|
|||
self.mechLUTButton.setText(_translate("Form", "Generate LUT"))
|
||||
self.viewmechLUTButton.setText(_translate("Form", "View LUT"))
|
||||
self.typeTab.setTabText(self.typeTab.indexOf(self.mechTab), _translate("Form", "Mechanical"))
|
||||
self.generateLUTButton.setText(_translate("Form", "Start Voltage Sweep"))
|
||||
self.label_2.setText(_translate("Form", "Voltage Tuning"))
|
||||
self.setvoltagesButton.setText(_translate("Form", "Set Voltages"))
|
||||
self.label_4.setText(_translate("Form", "Voltage Resolution"))
|
||||
self.label_11.setText(_translate("Form", "Generate LUT:"))
|
||||
self.label_3.setText(_translate("Form", "Voltage Matching"))
|
||||
self.label_9.setText(_translate("Form", "Set Voltages:"))
|
||||
self.viewelLUTButton.setText(_translate("Form", "View LUT"))
|
||||
self.generateLUTButton.setText(_translate("Form", "Start Voltage Sweep"))
|
||||
self.label_11.setText(_translate("Form", "Generate LUT:"))
|
||||
self.setvoltagesButton.setText(_translate("Form", "Set Voltages"))
|
||||
self.typeTab.setTabText(self.typeTab.indexOf(self.elecTab), _translate("Form", "Electrical"))
|
||||
self.rfswitchLabel.setText(_translate("Form", "RF Switch:"))
|
||||
self.switchATMButton.setText(_translate("Form", "ATM"))
|
||||
|
|
Loading…
Reference in a new issue