mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-12-22 16:27:48 +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:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.options = OrderedDict()
|
||||
|
||||
def get_pixmap(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def add_option(self, name, option):
|
||||
self.options[name] = option
|
||||
|
||||
def get_options(self):
|
||||
raise NotImplementedError
|
||||
return self.options
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
class PulseSequence:
|
||||
"""A pulse sequence is a collection of events that are executed in a certain order."""
|
||||
def __init__(self, name) -> None:
|
||||
self.name = name
|
||||
self.events = OrderedDict()
|
||||
|
@ -33,7 +35,7 @@ class PulseSequence:
|
|||
for parameter in self.events[event].parameters.keys():
|
||||
event_data["parameters"].append({
|
||||
"name": parameter,
|
||||
"value": self.events[event].parameters[parameter].state
|
||||
"value": self.events[event].parameters[parameter].get_options()
|
||||
})
|
||||
data["events"].append(event_data)
|
||||
return data
|
|
@ -2,21 +2,53 @@ from PyQt6.QtGui import QPixmap
|
|||
from pathlib import Path
|
||||
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):
|
||||
def __init__(self, name) -> None:
|
||||
super().__init__(name)
|
||||
self.tx_state = False
|
||||
self.tx_phase = 0
|
||||
self.add_option("TX Amplitude", NumericOption(0))
|
||||
self.add_option("TX Phase", NumericOption(0))
|
||||
|
||||
# Create a button
|
||||
self.button = QPushButton(self)
|
||||
self.button.setGeometry(0, 0, 200, 200)
|
||||
|
||||
# Set a custom image for the button
|
||||
image_path = "resources/wip_no_pulse.png"
|
||||
pixmap = QPixmap(image_path)
|
||||
self.button.setIcon(pixmap)
|
||||
self.button.setIconSize(pixmap.size())
|
||||
def get_pixmap(self):
|
||||
self_path = Path(__file__).parent
|
||||
if self.options["TX Amplitude"].value > 0:
|
||||
image_path = self_path / "resources/pulseparameter/wip_txpulse.png"
|
||||
else:
|
||||
image_path = self_path / "resources/pulseparameter/wip_no_txpulse.png"
|
||||
pixmap = QPixmap(str(image_path))
|
||||
return pixmap
|
||||
|
||||
class RectPulse():
|
||||
def __init__(self, name) -> None:
|
||||
|
@ -30,39 +62,25 @@ class TXPulse(BaseSpectrometerModel.PulseParameter):
|
|||
def __init__(self, name) -> None:
|
||||
super().__init__(name)
|
||||
|
||||
class RXReadout(BaseSpectrometerModel.PulseParameter):
|
||||
def __init__(self, name) -> None:
|
||||
super().__init__(name)
|
||||
self.rx_freq = 0
|
||||
self.rx_phase = 0
|
||||
|
||||
class TXPhase(BaseSpectrometerModel.PulseParameter):
|
||||
class RXReadout(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:
|
||||
super().__init__(name)
|
||||
self.state = False
|
||||
self.add_option("Gate State", BooleanOption(False))
|
||||
|
||||
def get_pixmap(self):
|
||||
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"
|
||||
elif self.state is True:
|
||||
else:
|
||||
image_path = self_path / "resources/pulseparameter/wip_txpulse.png"
|
||||
pixmap = QPixmap(str(image_path))
|
||||
return pixmap
|
||||
|
||||
def get_options(self):
|
||||
return (bool, self.state)
|
||||
|
||||
def set_options(self, options):
|
||||
self.state = options
|
||||
|
||||
|
|
Loading…
Reference in a new issue