From b36b8a7269acc8c49d9a18a389acad1076503e95 Mon Sep 17 00:00:00 2001 From: jupfi Date: Sat, 29 Jul 2023 17:12:01 +0200 Subject: [PATCH] Switchted to decimals for event duration. --- src/nqrduck_spectrometer/pulsesequence.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/nqrduck_spectrometer/pulsesequence.py b/src/nqrduck_spectrometer/pulsesequence.py index 9c60f00..c84372a 100644 --- a/src/nqrduck_spectrometer/pulsesequence.py +++ b/src/nqrduck_spectrometer/pulsesequence.py @@ -1,5 +1,6 @@ import logging from collections import OrderedDict +from nqrduck.helpers.unitconverter import UnitConverter from nqrduck_spectrometer.pulseparameters import Option logger = logging.getLogger(__name__) @@ -18,7 +19,7 @@ class PulseSequence: class Event: """An event is a part of a pulse sequence. It has a name and a duration and different parameters that have to be set.""" - def __init__(self, name: str, duration: float) -> None: + def __init__(self, name: str, duration: str) -> None: self.parameters = OrderedDict() self.name = name self.duration = duration @@ -26,7 +27,7 @@ class PulseSequence: def add_parameter(self, parameter) -> None: self.parameters.append(parameter) - def on_duration_changed(self, duration: float) -> None: + def on_duration_changed(self, duration: str) -> None: logger.debug("Duration of event %s changed to %s", self.name, duration) self.duration = duration @@ -68,10 +69,10 @@ class PulseSequence: return self._duration @duration.setter - def duration(self, duration : float): + def duration(self, duration : str): # Duration needs to be a positive number try: - duration = float(duration) + duration = UnitConverter.to_decimal(duration) except ValueError: raise ValueError("Duration needs to be a number") if duration < 0: