Compare commits

...

4 Commits

5 changed files with 51 additions and 18 deletions

20
poetry.lock generated
View File

@ -1060,6 +1060,24 @@ files = [
{file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"}, {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"},
] ]
[[package]]
name = "quantities"
version = "0.16.0"
description = "Support for physical quantities with units, based on numpy"
optional = false
python-versions = ">=3.8"
files = [
{file = "quantities-0.16.0-py3-none-any.whl", hash = "sha256:189e573953e7864d8c303a3472f6ad39fbe0698c3d75c17059b70bc457c7c66d"},
{file = "quantities-0.16.0.tar.gz", hash = "sha256:211cce2d268da7e202abab5c2533ce3200ff619dd8ac2a3cd98f861b8a57c6eb"},
]
[package.dependencies]
numpy = ">=1.20"
[package.extras]
doc = ["sphinx"]
test = ["pytest", "wheel"]
[[package]] [[package]]
name = "rich" name = "rich"
version = "13.9.2" version = "13.9.2"
@ -1248,4 +1266,4 @@ files = [
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.11, <3.13" python-versions = ">=3.11, <3.13"
content-hash = "f10a3cf403151d2c96c5c45a546860eaa3883d47cdc8d719a3e49ad0d4bb95d4" content-hash = "31433ed1dc0cc83dd7e781546dad5b8f068d59eaf692b4d3c12e07c604b1a6dd"

View File

@ -35,6 +35,7 @@ pytest = "^8.3.3"
pglive = "^0.7.6" pglive = "^0.7.6"
pyyaml = "^6.0.2" pyyaml = "^6.0.2"
dacite = "^1.8.1" dacite = "^1.8.1"
quantities = "^0.16.0"
[tool.poetry.scripts] [tool.poetry.scripts]
pyrelacs = "pyrelacs.app:main" pyrelacs = "pyrelacs.app:main"

View File

@ -2,9 +2,10 @@ import sys
from PyQt6.QtCore import QSettings from PyQt6.QtCore import QSettings
from PyQt6.QtWidgets import QApplication from PyQt6.QtWidgets import QApplication
from IPython import embed
from pyrelacs import info from pyrelacs import info
from pyrelacs.config.config_loader import Config from pyrelacs.config.config_loader import load_config
from pyrelacs.ui.mainwindow import PyRelacs from pyrelacs.ui.mainwindow import PyRelacs
from pyrelacs import ( from pyrelacs import (
@ -28,10 +29,9 @@ def main():
# load the config # load the config
config = Config() config = load_config()
# start the app # start the app
window = PyRelacs() window = PyRelacs(config)
window.setMinimumWidth(200) window.setMinimumWidth(200)
window.setMinimumHeight(200) window.setMinimumHeight(200)
window.resize(width, height) window.resize(width, height)

View File

@ -102,17 +102,22 @@ class Config:
metadata: Metadata metadata: Metadata
pyrelacs: PyRelacs pyrelacs: PyRelacs
@classmethod
def load_config(cls): def load_config():
pyrelacs_config_path = pathlib.Path(__file__).parent / "config.yaml" pyrelacs_config_path = pathlib.Path(__file__).parent.parent / "config.yaml"
log.debug(pyrelacs_config_path) log.debug(pyrelacs_config_path)
if not pyrelacs_config_path.is_file(): if not pyrelacs_config_path.is_file():
log.error("Config File was not found") log.error("Config File was not found")
with open(pyrelacs_config_path, "r") as config_file: with open(pyrelacs_config_path, "r") as config_file:
try:
data = yaml.full_load(config_file)
try: try:
return yaml.full_load(config_file) config = from_dict(data_class=Config, data=data)
except yaml.YAMLError as e: return config
raise yaml.YAMLError(f"Error parsing YAML file: {e}") except dacite.DaciteError as e:
log.error(f"Invalid Config, {e}")
except yaml.YAMLError as e:
raise yaml.YAMLError(f"Error parsing YAML file: {e}")
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -17,6 +17,7 @@ import uldaq
import nixio as nix import nixio as nix
import pyqtgraph as pg import pyqtgraph as pg
import numpy as np import numpy as np
import quantities as pq
from pyrelacs.dataio.daq_producer import DaqProducer from pyrelacs.dataio.daq_producer import DaqProducer
@ -39,8 +40,9 @@ from IPython import embed
class PyRelacs(QMainWindow): class PyRelacs(QMainWindow):
def __init__(self): def __init__(self, config):
super().__init__() super().__init__()
self.config = config
self.setToolButtonStyle( self.setToolButtonStyle(
Qt.ToolButtonStyle.ToolButtonTextBesideIcon Qt.ToolButtonStyle.ToolButtonTextBesideIcon
) # Ensure icons are displayed with text ) # Ensure icons are displayed with text
@ -79,9 +81,16 @@ class PyRelacs(QMainWindow):
widget.setLayout(layout) widget.setLayout(layout)
self.setCentralWidget(widget) self.setCentralWidget(widget)
SAMPLERATE = 40_000 SAMPLERATE = pq.Quantity(
self.config.pyrelacs.data.input.inputsamplerate,
self.config.pyrelacs.data.input.inputsamplerateunit,
)
INPUTTRACECAPACITY = pq.Quantity(
self.config.pyrelacs.data.input.inputtracecapacity,
self.config.pyrelacs.data.input.inputtracecapacityunit,
)
start = time.time() start = time.time()
BUFFERSIZE = SAMPLERATE * 10 * 60 BUFFERSIZE = (SAMPLERATE * INPUTTRACECAPACITY).simplified
end = time.time() end = time.time()
log.debug(f"Buffer allocation took {end - start}") log.debug(f"Buffer allocation took {end - start}")