diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml index 39c8137..697d1a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,9 +22,9 @@ classifiers = [ dependencies = [ "matplotlib", - "pyqt5", + "pyqt6", "NQRduck", ] [project.entry-points."nqrduck"] -"nqrduck-pulseprogrammer" = "nqrduck_pulseprogrammer.pulseprogrammer:PulseProgrammer" +"nqrduck-pulseprogrammer" = "nqrduck_pulseprogrammer.pulseprogrammer:pulse_programmer" diff --git a/src/nqrduck_pulseprogrammer/__init__.py b/src/nqrduck_pulseprogrammer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/nqrduck_pulseprogrammer/controller.py b/src/nqrduck_pulseprogrammer/controller.py index 53039f0..60ee200 100644 --- a/src/nqrduck_pulseprogrammer/controller.py +++ b/src/nqrduck_pulseprogrammer/controller.py @@ -1,8 +1,10 @@ import logging -from PyQt5.QtCore import pyqtSlot, pyqtSignal from nqrduck.module.module_controller import ModuleController logger = logging.getLogger(__name__) class PulseProgrammerController(ModuleController): - pass \ No newline at end of file + + def on_loading(self, pulse_parameter_options): + logger.debug("Pulse programmer controller on loading") + self.module.model.pulse_parameter_options = pulse_parameter_options \ No newline at end of file diff --git a/src/nqrduck_pulseprogrammer/model.py b/src/nqrduck_pulseprogrammer/model.py index 6bea55c..927c6bb 100644 --- a/src/nqrduck_pulseprogrammer/model.py +++ b/src/nqrduck_pulseprogrammer/model.py @@ -1,6 +1,34 @@ -from PyQt5.QtCore import pyqtSignal +import logging +from collections import OrderedDict +from PyQt6.QtCore import pyqtSignal from nqrduck.module.module_model import ModuleModel +logger = logging.getLogger(__name__) class PulseProgrammerModel(ModuleModel): - pass \ No newline at end of file + pulse_parameter_options_changed = pyqtSignal() + events_changed = pyqtSignal(list) + + def __init__(self, module): + super().__init__(module) + self.pulse_parameter_options = OrderedDict() + self.events = [] + + @property + def events(self): + return self._events + + @events.setter + def events(self, value): + self._events = value + self.events_changed.emit(value) + + @property + def pulse_parameter_options(self): + return self._pulse_parameter_options + + @pulse_parameter_options.setter + def pulse_parameter_options(self, value): + self._pulse_parameter_options = value + logger.debug("Pulse parameter options changed - emitting signal") + self.pulse_parameter_options_changed.emit() diff --git a/src/nqrduck_pulseprogrammer/pulseprogrammer.py b/src/nqrduck_pulseprogrammer/pulseprogrammer.py index 32f4d4f..787b109 100644 --- a/src/nqrduck_pulseprogrammer/pulseprogrammer.py +++ b/src/nqrduck_pulseprogrammer/pulseprogrammer.py @@ -1,7 +1,12 @@ -from PyQt5.QtCore import pyqtSignal, QObject from nqrduck.module.module import Module from .model import PulseProgrammerModel -from .view import PulseProgrammerView from .controller import PulseProgrammerController +from .view import PulseProgrammerView -PulseProgrammer = Module(PulseProgrammerModel, PulseProgrammerView, PulseProgrammerController) +class PulseProgrammer(Module): + def __init__(self, model, view, controller): + super().__init__(model, None, controller) + self.view = None + self.pulse_programmer_view = view(self) + +pulse_programmer = PulseProgrammer(PulseProgrammerModel, PulseProgrammerView, PulseProgrammerController) diff --git a/src/nqrduck_pulseprogrammer/resources/spectrometer.ini b/src/nqrduck_pulseprogrammer/resources/spectrometer.ini new file mode 100644 index 0000000..ef6ab1c --- /dev/null +++ b/src/nqrduck_pulseprogrammer/resources/spectrometer.ini @@ -0,0 +1,10 @@ +[META] +name = nqrduck-pulseprogrammer +toolbar_name = PulseProgrammer +category = Hardware +tooltip = Application used to control the spectrometer + +[FILES] +widget_file = spectrometer_widget.py +toolbox_logo = resources/toolbox_logo.png + diff --git a/src/nqrduck_pulseprogrammer/view.py b/src/nqrduck_pulseprogrammer/view.py index 75fa1f1..66c68b3 100644 --- a/src/nqrduck_pulseprogrammer/view.py +++ b/src/nqrduck_pulseprogrammer/view.py @@ -1,8 +1,33 @@ import logging +from collections import OrderedDict +from PyQt6.QtWidgets import QTableWidget, QVBoxLayout +from PyQt6.QtCore import pyqtSlot from nqrduck.module.module_view import ModuleView logger = logging.getLogger(__name__) class PulseProgrammerView(ModuleView): - pass \ No newline at end of file + + def __init__(self, module): + super().__init__(module) + + self.setup_ui() + + logger.debug("Connecting pulse parameter options changed signal to on_pulse_parameter_options_changed") + module.model.pulse_parameter_options_changed.connect(self.on_pulse_parameter_options_changed) + + def setup_ui(self): + self.pulse_table = QTableWidget(self) + layout = QVBoxLayout() + layout.addWidget(self.pulse_table) + self.setLayout(layout) + + @pyqtSlot() + def on_pulse_parameter_options_changed(self): + logger.debug("Updating pulse parameter options to %s", self.module.model.pulse_parameter_options.keys()) + self.pulse_table.setRowCount(len(self.module.model.pulse_parameter_options)) + self.pulse_table.setVerticalHeaderLabels(self.module.model.pulse_parameter_options.keys()) + + +