diff --git a/src/nqrduck_spectrometer/pulse_sequence.py b/src/nqrduck_spectrometer/pulse_sequence.py index 8236c07..c089ea0 100644 --- a/src/nqrduck_spectrometer/pulse_sequence.py +++ b/src/nqrduck_spectrometer/pulse_sequence.py @@ -1,6 +1,8 @@ +from collections import OrderedDict class PulseSequence: - def __init__(self) -> None: - self.events = list() + def __init__(self, name) -> None: + self.name = name + self.events = OrderedDict() def get_event_names(self) -> list: return [event.name for event in self.events] @@ -8,11 +10,30 @@ 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.""" - parameters = list() - def __init__(self, name: str, duration: float) -> None: + self.parameters = OrderedDict() self.name = name self.duration = duration def add_parameter(self, parameter) -> None: - self.parameters.append(parameter) \ No newline at end of file + self.parameters.append(parameter) + + def dump_sequence_data(self): + """Returns a dict with all the data in the pulse sequence""" + data = { + "name": self.name, + "events": [] + } + for event in self.events.keys(): + event_data = { + "name": self.events[event].name, + "duration": self.events[event].duration, + "parameters": [] + } + for parameter in self.events[event].parameters.keys(): + event_data["parameters"].append({ + "name": parameter, + "value": self.events[event].parameters[parameter].state + }) + data["events"].append(event_data) + return data \ No newline at end of file diff --git a/src/nqrduck_spectrometer/base_spectrometer_pulseparameters.py b/src/nqrduck_spectrometer/pulseparameters.py similarity index 85% rename from src/nqrduck_spectrometer/base_spectrometer_pulseparameters.py rename to src/nqrduck_spectrometer/pulseparameters.py index df16022..05e6ca9 100644 --- a/src/nqrduck_spectrometer/base_spectrometer_pulseparameters.py +++ b/src/nqrduck_spectrometer/pulseparameters.py @@ -36,6 +36,15 @@ class TXPulse(BaseSpectrometerModel.PulseParameter): self.rx_freq = 0 self.rx_phase = 0 +class TXPhase(BaseSpectrometerModel.PulseParameter): + def __init__(self, name) -> None: + super().__init__(name) + self.phase = 0 + +class RXPhase(BaseSpectrometerModel.PulseParameter): + def __init__(self, name) -> None: + super().__init__(name) + self.phase = 0 class Gate(BaseSpectrometerModel.PulseParameter): def __init__(self, name) -> None: