mirror of
https://github.com/nqrduck/nqrduck-spectrometer-simulator.git
synced 2025-01-05 06:08:07 +00:00
Improved error handling.
This commit is contained in:
parent
e78319393c
commit
6e3ebc9187
1 changed files with 9 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
import logging
|
||||
from nqrduck_spectrometer.base_spectrometer_controller import BaseSpectrometerController
|
||||
from quackseq_simulator.simulator import Simulator
|
||||
from quackseq.measurement import MeasurementError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -27,6 +28,12 @@ class DuckSimulatorController(BaseSpectrometerController):
|
|||
|
||||
measurement_data = simulator.run_sequence(sequence)
|
||||
|
||||
if isinstance(measurement_data, MeasurementError):
|
||||
error_message = measurement_data.error_message
|
||||
logger.error("Error during simulation: %s", error_message)
|
||||
self.module.nqrduck_signal.emit("measurement_error", error_message)
|
||||
return
|
||||
|
||||
if measurement_data:
|
||||
# Emit the data to the nqrduck core
|
||||
logger.debug("Emitting measurement data")
|
||||
|
@ -36,9 +43,9 @@ class DuckSimulatorController(BaseSpectrometerController):
|
|||
else:
|
||||
logger.warning("No measurement data was returned from the simulator")
|
||||
self.module.nqrduck_signal.emit(
|
||||
"measurement_error", "No measurement data was returned from the simulator. Did you set a TX pulse?"
|
||||
"measurement_error",
|
||||
"No measurement data was returned from the simulator. Did you set a TX pulse?",
|
||||
)
|
||||
|
||||
|
||||
def set_frequency(self, value: str) -> None:
|
||||
"""This method is called when the set_frequency signal is received from the core.
|
||||
|
|
Loading…
Reference in a new issue