From dcd34db340c86d75f18ff349a2a20fc5b436b26f Mon Sep 17 00:00:00 2001 From: jupfi Date: Mon, 18 Mar 2024 14:37:24 +0100 Subject: [PATCH] Added error handling for empty pulse sequences. --- src/nqrduck_spectrometer_limenqr/controller.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/nqrduck_spectrometer_limenqr/controller.py b/src/nqrduck_spectrometer_limenqr/controller.py index 93e6505..ab6f4f1 100644 --- a/src/nqrduck_spectrometer_limenqr/controller.py +++ b/src/nqrduck_spectrometer_limenqr/controller.py @@ -23,7 +23,13 @@ class LimeNQRController(BaseSpectrometerController): self.log_start_message() lime = self.initialize_lime() - if not lime: + if lime is None: + # Emit error message + self.emit_measurement_error("Error with Lime driver. Is the Lime driver installed?") + return -1 + elif lime.Npulses == 0: + # Emit error message + self.emit_measurement_error("Error with pulse sequence. Is the pulse sequence empty?") return -1 self.setup_lime_parameters(lime) @@ -49,7 +55,11 @@ class LimeNQRController(BaseSpectrometerController): logger.debug("Starting measurement with spectrometer: %s", self.module.model.name) def initialize_lime(self): - """This method initializes the limr object that is used to communicate with the pulseN driver.""" + """This method initializes the limr object that is used to communicate with the pulseN driver. + + Returns: + PyLimeConfig: The PyLimeConfig object that is used to communicate with the pulseN driver + """ try: n_pulses = self.get_number_of_pulses() lime = PyLimeConfig(n_pulses) @@ -60,6 +70,7 @@ class LimeNQRController(BaseSpectrometerController): logger.error("Error while initializing Lime driver: %s", e) import traceback traceback.print_exc() + return None def setup_lime_parameters(self, lime):