2023-07-11 09:18:29 +00:00
|
|
|
from PyQt6.QtGui import QPixmap
|
|
|
|
from pathlib import Path
|
|
|
|
from .base_spectrometer_model import BaseSpectrometerModel
|
|
|
|
|
2023-07-11 15:50:42 +00:00
|
|
|
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__()
|
|
|
|
|
|
|
|
|
2023-07-11 09:18:29 +00:00
|
|
|
class TXPulse(BaseSpectrometerModel.PulseParameter):
|
|
|
|
def __init__(self, name) -> None:
|
|
|
|
super().__init__(name)
|
2023-07-11 15:50:42 +00:00
|
|
|
self.add_option("TX Amplitude", NumericOption(0))
|
|
|
|
self.add_option("TX Phase", NumericOption(0))
|
2023-07-11 09:18:29 +00:00
|
|
|
|
2023-07-11 15:50:42 +00:00
|
|
|
def get_pixmap(self):
|
|
|
|
self_path = Path(__file__).parent
|
|
|
|
if self.options["TX Amplitude"].value > 0:
|
2023-07-12 15:14:16 +00:00
|
|
|
image_path = self_path / "resources/pulseparameter/TX_Pulse.png"
|
2023-07-11 15:50:42 +00:00
|
|
|
else:
|
2023-07-12 15:14:16 +00:00
|
|
|
image_path = self_path / "resources/pulseparameter/NoPulse.png"
|
2023-07-11 15:50:42 +00:00
|
|
|
pixmap = QPixmap(str(image_path))
|
|
|
|
return pixmap
|
2023-07-11 09:18:29 +00:00
|
|
|
|
|
|
|
class RectPulse():
|
|
|
|
def __init__(self, name) -> None:
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
class SincPulse():
|
|
|
|
def __init__(self, name) -> None:
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
class GaussianPulse():
|
|
|
|
def __init__(self, name) -> None:
|
|
|
|
super().__init__(name)
|
|
|
|
|
2023-07-11 15:50:42 +00:00
|
|
|
class RXReadout(BaseSpectrometerModel.PulseParameter):
|
2023-07-11 11:58:07 +00:00
|
|
|
def __init__(self, name) -> None:
|
|
|
|
super().__init__(name)
|
2023-07-12 15:14:16 +00:00
|
|
|
self.add_option("RX", BooleanOption(False))
|
|
|
|
|
|
|
|
def get_pixmap(self):
|
|
|
|
self_path = Path(__file__).parent
|
|
|
|
if self.options["RX"].state == False:
|
|
|
|
image_path = self_path / "resources/pulseparameter/RXOff.png"
|
|
|
|
else:
|
|
|
|
image_path = self_path / "resources/pulseparameter/RXOn.png"
|
|
|
|
pixmap = QPixmap(str(image_path))
|
|
|
|
return pixmap
|
|
|
|
|
|
|
|
def set_options(self, options):
|
|
|
|
self.state = options
|
2023-07-11 09:18:29 +00:00
|
|
|
|
|
|
|
class Gate(BaseSpectrometerModel.PulseParameter):
|
2023-07-11 15:50:42 +00:00
|
|
|
|
2023-07-11 09:18:29 +00:00
|
|
|
def __init__(self, name) -> None:
|
|
|
|
super().__init__(name)
|
2023-07-11 15:50:42 +00:00
|
|
|
self.add_option("Gate State", BooleanOption(False))
|
2023-07-11 09:18:29 +00:00
|
|
|
|
|
|
|
def get_pixmap(self):
|
|
|
|
self_path = Path(__file__).parent
|
2023-07-11 15:50:42 +00:00
|
|
|
if self.options["Gate State"].state == False:
|
2023-07-12 15:14:16 +00:00
|
|
|
image_path = self_path / "resources/pulseparameter/GateOff.png"
|
2023-07-11 15:50:42 +00:00
|
|
|
else:
|
2023-07-12 15:14:16 +00:00
|
|
|
image_path = self_path / "resources/pulseparameter/GateOn.png"
|
2023-07-11 09:18:29 +00:00
|
|
|
pixmap = QPixmap(str(image_path))
|
|
|
|
return pixmap
|
|
|
|
|
|
|
|
def set_options(self, options):
|
|
|
|
self.state = options
|
|
|
|
|
|
|
|
|