Changed loading of modules.

This commit is contained in:
jupfi 2023-07-03 20:25:05 +02:00
parent 8c825c6300
commit 8f6524c0f2
11 changed files with 70 additions and 47 deletions

View file

@ -2,9 +2,12 @@
requires = ["hatchling"] requires = ["hatchling"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[tool.hatch.metadata]
allow-direct-references = true
[project] [project]
name = "nqrduck-spectrometer" name = "nqrduck-spectrometer"
version = "0.0.5" version = "0.0.6"
authors = [ authors = [
{ name="Julia Pfitzer", email="git@jupfi.me" }, { name="Julia Pfitzer", email="git@jupfi.me" },
] ]
@ -26,3 +29,5 @@ dependencies = [
"NQRduck", "NQRduck",
] ]
[project.entry-points."nqrduck"]
"nqrduck-spectrometer" = "nqrduck_spectrometer.spectrometer:Spectrometer"

View file

@ -0,0 +1,19 @@
class BaseSpectrometer:
"""Base class for all spectrometers. All spectrometers should inherit from this class."""
def __init__(self):
pass
@property
def name(self):
"""Name of the spectrometer."""
raise NotImplementedError
@property
def pulse_program(self):
"""Pulse program of the spectrometer."""
raise NotImplementedError
def start_measurement(self):
"""Starts the measurement."""
raise NotImplementedError

View file

@ -1,11 +1,36 @@
from PyQt5.QtCore import pyqtSignal, QObject import logging
from PyQt5.QtCore import pyqtSignal
from nqrduck.module.module_model import ModuleModel from nqrduck.module.module_model import ModuleModel
logger = logging.getLogger(__name__)
class SpectrometerModel(ModuleModel): class SpectrometerModel(ModuleModel):
spectrometer_changed = pyqtSignal() spectrometer_changed = pyqtSignal()
@property def __init__(self, module) -> None:
def spectrometer(self): super().__init__(module)
return self._spectrometer self._active_spectrometer = None
self._available_spectrometers = []
self._load_available_spectrometers()
@property
def active_spectrometer(self):
return self._active_spectrometer
@active_spectrometer.setter
def active_spectrometer(self, value):
self._active_spectrometer = value
self.spectrometer_changed.emit()
@property
def available_spectrometers(self):
return self._available_spectrometers
def _load_available_spectrometers(self):
pass
def _load_spectrometer(self, spectrometer_module_name):
pass

View file

@ -8,3 +8,4 @@ tooltip = Application used to control the spectrometer
config = resources/spectrometer.ini config = resources/spectrometer.ini
widget_file = spectrometer_widget.py widget_file = spectrometer_widget.py
toolbox_logo = resources/toolbox_logo.png toolbox_logo = resources/toolbox_logo.png

View file

@ -23,27 +23,10 @@
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QStackedWidget" name="stackedWidget">
<property name="text"> <widget class="QWidget" name="page"/>
<string>Spectrometer tests:</string> <widget class="QWidget" name="page_2"/>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View file

@ -1,8 +1,6 @@
from PyQt5.QtCore import pyqtSignal, QObject
from nqrduck.module.module import Module from nqrduck.module.module import Module
from nqrduck_spectrometer.model import SpectrometerModel from nqrduck_spectrometer.model import SpectrometerModel
from nqrduck_spectrometer.view import SpectrometerView from nqrduck_spectrometer.view import SpectrometerView
from nqrduck_spectrometer.controller import SpectrometerController from nqrduck_spectrometer.controller import SpectrometerController
from nqrduck_spectrometer.widget import Ui_Form
Spectrometer = Module(SpectrometerModel, SpectrometerController, SpectrometerView) Spectrometer = Module(SpectrometerModel, SpectrometerView, SpectrometerController)

View file

@ -1,8 +0,0 @@
from ...spectrometer import Spectrometer
class LimeNQR(Spectrometer):
def __init__(self, model, controller):
super(LimeNQR, self).__init__(model, controller)
self._model = model
self._controller = controller

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'modules/spectrometer/resources/spectrometer_widget.ui' # Form implementation generated from reading ui file '../Modules/nqrduck-spectrometer/src/nqrduck_spectrometer/resources/spectrometer_widget.ui'
# #
# Created by: PyQt5 UI code generator 5.15.7 # Created by: PyQt5 UI code generator 5.15.9
# #
# WARNING: Any manual changes made to this file will be lost when pyuic5 is # WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing. # run again. Do not edit this file unless you know what you are doing.
@ -21,14 +21,15 @@ class Ui_Form(object):
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget) self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout") self.gridLayout.setObjectName("gridLayout")
self.lineEdit = QtWidgets.QLineEdit(self.gridLayoutWidget) self.stackedWidget = QtWidgets.QStackedWidget(self.gridLayoutWidget)
self.lineEdit.setObjectName("lineEdit") self.stackedWidget.setObjectName("stackedWidget")
self.gridLayout.addWidget(self.lineEdit, 0, 2, 1, 1) self.page = QtWidgets.QWidget()
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.page.setObjectName("page")
self.gridLayout.addItem(spacerItem, 0, 1, 1, 1) self.stackedWidget.addWidget(self.page)
self.label = QtWidgets.QLabel(self.gridLayoutWidget) self.page_2 = QtWidgets.QWidget()
self.label.setObjectName("label") self.page_2.setObjectName("page_2")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.stackedWidget.addWidget(self.page_2)
self.gridLayout.addWidget(self.stackedWidget, 0, 0, 1, 1)
self.retranslateUi(Form) self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form) QtCore.QMetaObject.connectSlotsByName(Form)
@ -36,4 +37,3 @@ class Ui_Form(object):
def retranslateUi(self, Form): def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form")) Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "Spectrometer tests:"))