Fixed frequency step display.

This commit is contained in:
jupfi 2023-12-07 15:58:30 +01:00
parent 3a036d570a
commit 891bd8fbeb
3 changed files with 30 additions and 8 deletions

View file

@ -112,9 +112,7 @@ class BroadbandController(ModuleController):
self.module.view.add_info_text("Starting broadband measurement.") self.module.view.add_info_text("Starting broadband measurement.")
# Start the first measurement # Start the first measurement
self.module.view.add_info_text("Starting measurement at frequency: " + str(start_frequency)) self.start_single_measurement(start_frequency)
self.module.nqrduck_signal.emit("set_frequency", str(start_frequency))
self.module.nqrduck_signal.emit("start_measurement", None)
@pyqtSlot() @pyqtSlot()
@ -129,9 +127,17 @@ class BroadbandController(ModuleController):
# Get the next frequency to measure # Get the next frequency to measure
next_frequency = self.module.model.current_broadband_measurement.get_next_measurement_frequency() next_frequency = self.module.model.current_broadband_measurement.get_next_measurement_frequency()
logger.debug("Next frequency: " + str(next_frequency)) logger.debug("Next frequency: " + str(next_frequency))
# Start the next measurement self.start_single_measurement(next_frequency)
self.module.view.add_info_text("Starting measurement at frequency: " + str(next_frequency))
self.module.nqrduck_signal.emit("set_frequency", str(next_frequency))
self.module.nqrduck_signal.emit("start_measurement", None)
else: else:
self.module.view.add_info_text("Broadband measurement finished.") self.module.view.add_info_text("Broadband measurement finished.")
def start_single_measurement(self, frequency : float) -> None:
"""Starts a single measurement.
Args:
frequency (float): Frequency in MHz.
"""
logger.debug("Starting single measurement.")
self.module.view.add_info_text("Starting measurement at frequency: " + str(frequency))
self.module.nqrduck_signal.emit("set_frequency", str(frequency))
self.module.nqrduck_signal.emit("start_measurement", None)

View file

@ -14,6 +14,7 @@ class BroadbandModel(ModuleModel):
start_frequency_changed = pyqtSignal(float) start_frequency_changed = pyqtSignal(float)
stop_frequency_changed = pyqtSignal(float) stop_frequency_changed = pyqtSignal(float)
frequency_step_changed = pyqtSignal(float)
LUT_changed = pyqtSignal() LUT_changed = pyqtSignal()
def __init__(self, module) -> None: def __init__(self, module) -> None:
@ -48,6 +49,7 @@ class BroadbandModel(ModuleModel):
@frequency_step.setter @frequency_step.setter
def frequency_step(self, value): def frequency_step(self, value):
self._frequency_step = value self._frequency_step = value
self.frequency_step_changed.emit(value)
@property @property
def current_broadband_measurement(self): def current_broadband_measurement(self):

View file

@ -52,6 +52,7 @@ class BroadbandView(ModuleView):
self.module.model.start_frequency_changed.connect(self.on_start_frequency_change) self.module.model.start_frequency_changed.connect(self.on_start_frequency_change)
self.module.model.stop_frequency_changed.connect(self.on_stop_frequency_change) self.module.model.stop_frequency_changed.connect(self.on_stop_frequency_change)
self.module.model.frequency_step_changed.connect(self.on_frequency_step_change)
self._ui_form.start_measurementButton.clicked.connect(self.start_measurement_clicked) self._ui_form.start_measurementButton.clicked.connect(self.start_measurement_clicked)
self.start_broadband_measurement.connect(self.module._controller.start_broadband_measurement) self.start_broadband_measurement.connect(self.module._controller.start_broadband_measurement)
@ -149,6 +150,19 @@ class BroadbandView(ModuleView):
self._ui_form.broadbandPlot.canvas.flush_events() self._ui_form.broadbandPlot.canvas.flush_events()
self._ui_form.stop_frequencyField.setText(str(stop_frequency* 1e-6)) self._ui_form.stop_frequencyField.setText(str(stop_frequency* 1e-6))
@pyqtSlot(float)
def on_frequency_step_change(self, frequency_step : float) -> None:
"""This method is called when the frequency step is changed.
It adjusts the view to the new frequency step.
"""
logger.debug("Adjusting view to new frequency step: " + str(frequency_step * 1e-6))
self._ui_form.broadbandPlot.canvas.ax.set_xlim(right=frequency_step*1e-6)
self._ui_form.broadbandPlot.canvas.draw()
self._ui_form.broadbandPlot.canvas.flush_events()
# Fix float representation
frequency_step = str("{:.2f}".format(frequency_step * 1e-6))
self._ui_form.frequencystepEdit.setText(frequency_step)
@pyqtSlot() @pyqtSlot()
def on_editing_finished(self, value : str) -> None: def on_editing_finished(self, value : str) -> None:
"""This method is called when the user finished editing a field. """This method is called when the user finished editing a field.