From e717cb2a24b78b86c5b558919e73f696c1a65391 Mon Sep 17 00:00:00 2001 From: jupfi Date: Thu, 14 Mar 2024 17:04:43 +0100 Subject: [PATCH] Added frequency target_frequency property. --- .../controller.py | 17 ++++++++++------- src/nqrduck_spectrometer_simulator/model.py | 10 ++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/nqrduck_spectrometer_simulator/controller.py b/src/nqrduck_spectrometer_simulator/controller.py index 3f74a01..7bfc237 100644 --- a/src/nqrduck_spectrometer_simulator/controller.py +++ b/src/nqrduck_spectrometer_simulator/controller.py @@ -302,13 +302,16 @@ class SimulatorController(BaseSpectrometerController): """This method is called when the set_frequency signal is received from the core. For the simulator this just prints a warning that the simulator is selected. """ - self.module.nqrduck_signal.emit( - "notification", - [ - "Warning", - "Could not set averages to because the simulator is selected as active spectrometer ", - ], - ) + logger.debug("Setting frequency to: %s", value) + try: + self.module.model.target_frequency = float(value) + logger.debug("Successfully set frequency to: %s", value) + except ValueError: + logger.warning("Could not set frequency to: %s", value) + self.module.nqrduck_signal.emit( + "notification", ["Error", "Could not set frequency to: " + value] + ) + self.module.nqrduck_signal.emit("failure_set_frequency", value) def set_averages(self, value: str) -> None: """This method is called when the set_averages signal is received from the core. diff --git a/src/nqrduck_spectrometer_simulator/model.py b/src/nqrduck_spectrometer_simulator/model.py index 5a5cb14..d07142b 100644 --- a/src/nqrduck_spectrometer_simulator/model.py +++ b/src/nqrduck_spectrometer_simulator/model.py @@ -283,6 +283,7 @@ class SimulatorModel(BaseSpectrometerModel): self.add_pulse_parameter_option(self.RX, RXReadout) self.averages = 1 + self.target_frequency = 100e6 # Try to load the pulse programmer module try: @@ -301,3 +302,12 @@ class SimulatorModel(BaseSpectrometerModel): @averages.setter def averages(self, value): self._averages = value + + @property + def target_frequency(self): + return self._target_frequency + + @target_frequency.setter + def target_frequency(self, value): + self._target_frequency = value +