mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-12-23 00:37:47 +00:00
Changed implementation of pulse options.
This commit is contained in:
parent
a671c339de
commit
b4129f98e2
3 changed files with 57 additions and 32 deletions
|
@ -34,11 +34,16 @@ class BaseSpectrometerModel(ModuleModel):
|
||||||
class PulseParameter:
|
class PulseParameter:
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.options = OrderedDict()
|
||||||
|
|
||||||
def get_pixmap(self):
|
def get_pixmap(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def add_option(self, name, option):
|
||||||
|
self.options[name] = option
|
||||||
|
|
||||||
def get_options(self):
|
def get_options(self):
|
||||||
raise NotImplementedError
|
return self.options
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
class PulseSequence:
|
class PulseSequence:
|
||||||
|
"""A pulse sequence is a collection of events that are executed in a certain order."""
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.events = OrderedDict()
|
self.events = OrderedDict()
|
||||||
|
@ -33,7 +35,7 @@ class PulseSequence:
|
||||||
for parameter in self.events[event].parameters.keys():
|
for parameter in self.events[event].parameters.keys():
|
||||||
event_data["parameters"].append({
|
event_data["parameters"].append({
|
||||||
"name": parameter,
|
"name": parameter,
|
||||||
"value": self.events[event].parameters[parameter].state
|
"value": self.events[event].parameters[parameter].get_options()
|
||||||
})
|
})
|
||||||
data["events"].append(event_data)
|
data["events"].append(event_data)
|
||||||
return data
|
return data
|
|
@ -2,21 +2,53 @@ from PyQt6.QtGui import QPixmap
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .base_spectrometer_model import BaseSpectrometerModel
|
from .base_spectrometer_model import BaseSpectrometerModel
|
||||||
|
|
||||||
|
class Option():
|
||||||
|
"""Defines options for the pulse parameters which can then be set accordingly.
|
||||||
|
"""
|
||||||
|
def set_value(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
class BooleanOption(Option):
|
||||||
|
"""Defines a boolean option for a pulse parameter.
|
||||||
|
"""
|
||||||
|
def __init__(self, state) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.state = state
|
||||||
|
|
||||||
|
def set_value(self, state):
|
||||||
|
self.state = state
|
||||||
|
|
||||||
|
class NumericOption(Option):
|
||||||
|
"""Defines a numeric option for a pulse parameter.
|
||||||
|
"""
|
||||||
|
def __init__(self, value) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.value = value
|
||||||
|
|
||||||
|
def set_value(self, value):
|
||||||
|
self.value = float(value)
|
||||||
|
|
||||||
|
class WidgetSelectionOption(Option):
|
||||||
|
"""Defines a widget selection option for a pulse parameter.
|
||||||
|
"""
|
||||||
|
def __init__(self, widgets) -> None:
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
|
||||||
class TXPulse(BaseSpectrometerModel.PulseParameter):
|
class TXPulse(BaseSpectrometerModel.PulseParameter):
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self.tx_state = False
|
self.add_option("TX Amplitude", NumericOption(0))
|
||||||
self.tx_phase = 0
|
self.add_option("TX Phase", NumericOption(0))
|
||||||
|
|
||||||
# Create a button
|
def get_pixmap(self):
|
||||||
self.button = QPushButton(self)
|
self_path = Path(__file__).parent
|
||||||
self.button.setGeometry(0, 0, 200, 200)
|
if self.options["TX Amplitude"].value > 0:
|
||||||
|
image_path = self_path / "resources/pulseparameter/wip_txpulse.png"
|
||||||
# Set a custom image for the button
|
else:
|
||||||
image_path = "resources/wip_no_pulse.png"
|
image_path = self_path / "resources/pulseparameter/wip_no_txpulse.png"
|
||||||
pixmap = QPixmap(image_path)
|
pixmap = QPixmap(str(image_path))
|
||||||
self.button.setIcon(pixmap)
|
return pixmap
|
||||||
self.button.setIconSize(pixmap.size())
|
|
||||||
|
|
||||||
class RectPulse():
|
class RectPulse():
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
|
@ -30,39 +62,25 @@ class TXPulse(BaseSpectrometerModel.PulseParameter):
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
|
|
||||||
class RXReadout(BaseSpectrometerModel.PulseParameter):
|
class RXReadout(BaseSpectrometerModel.PulseParameter):
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
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):
|
class Gate(BaseSpectrometerModel.PulseParameter):
|
||||||
|
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self.state = False
|
self.add_option("Gate State", BooleanOption(False))
|
||||||
|
|
||||||
def get_pixmap(self):
|
def get_pixmap(self):
|
||||||
self_path = Path(__file__).parent
|
self_path = Path(__file__).parent
|
||||||
if self.state is False:
|
if self.options["Gate State"].state == False:
|
||||||
image_path = self_path / "resources/pulseparameter/wip_no_txpulse.png"
|
image_path = self_path / "resources/pulseparameter/wip_no_txpulse.png"
|
||||||
elif self.state is True:
|
else:
|
||||||
image_path = self_path / "resources/pulseparameter/wip_txpulse.png"
|
image_path = self_path / "resources/pulseparameter/wip_txpulse.png"
|
||||||
pixmap = QPixmap(str(image_path))
|
pixmap = QPixmap(str(image_path))
|
||||||
return pixmap
|
return pixmap
|
||||||
|
|
||||||
def get_options(self):
|
|
||||||
return (bool, self.state)
|
|
||||||
|
|
||||||
def set_options(self, options):
|
def set_options(self, options):
|
||||||
self.state = options
|
self.state = options
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue