Compare commits
4 Commits
b22ef04317
...
afc37adb1a
Author | SHA1 | Date | |
---|---|---|---|
afc37adb1a | |||
b87e7f1ffa | |||
f576f33cc5 | |||
e16211b988 |
20
poetry.lock
generated
20
poetry.lock
generated
@ -1060,6 +1060,24 @@ files = [
|
||||
{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]]
|
||||
name = "rich"
|
||||
version = "13.9.2"
|
||||
@ -1248,4 +1266,4 @@ files = [
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">=3.11, <3.13"
|
||||
content-hash = "f10a3cf403151d2c96c5c45a546860eaa3883d47cdc8d719a3e49ad0d4bb95d4"
|
||||
content-hash = "31433ed1dc0cc83dd7e781546dad5b8f068d59eaf692b4d3c12e07c604b1a6dd"
|
||||
|
@ -35,6 +35,7 @@ pytest = "^8.3.3"
|
||||
pglive = "^0.7.6"
|
||||
pyyaml = "^6.0.2"
|
||||
dacite = "^1.8.1"
|
||||
quantities = "^0.16.0"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
pyrelacs = "pyrelacs.app:main"
|
||||
|
@ -2,9 +2,10 @@ import sys
|
||||
|
||||
from PyQt6.QtCore import QSettings
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
from IPython import embed
|
||||
|
||||
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 import (
|
||||
@ -28,10 +29,9 @@ def main():
|
||||
|
||||
# load the config
|
||||
|
||||
config = Config()
|
||||
|
||||
config = load_config()
|
||||
# start the app
|
||||
window = PyRelacs()
|
||||
window = PyRelacs(config)
|
||||
window.setMinimumWidth(200)
|
||||
window.setMinimumHeight(200)
|
||||
window.resize(width, height)
|
||||
|
@ -102,17 +102,22 @@ class Config:
|
||||
metadata: Metadata
|
||||
pyrelacs: PyRelacs
|
||||
|
||||
@classmethod
|
||||
def load_config(cls):
|
||||
pyrelacs_config_path = pathlib.Path(__file__).parent / "config.yaml"
|
||||
log.debug(pyrelacs_config_path)
|
||||
if not pyrelacs_config_path.is_file():
|
||||
log.error("Config File was not found")
|
||||
with open(pyrelacs_config_path, "r") as config_file:
|
||||
|
||||
def load_config():
|
||||
pyrelacs_config_path = pathlib.Path(__file__).parent.parent / "config.yaml"
|
||||
log.debug(pyrelacs_config_path)
|
||||
if not pyrelacs_config_path.is_file():
|
||||
log.error("Config File was not found")
|
||||
with open(pyrelacs_config_path, "r") as config_file:
|
||||
try:
|
||||
data = yaml.full_load(config_file)
|
||||
try:
|
||||
return yaml.full_load(config_file)
|
||||
except yaml.YAMLError as e:
|
||||
raise yaml.YAMLError(f"Error parsing YAML file: {e}")
|
||||
config = from_dict(data_class=Config, data=data)
|
||||
return config
|
||||
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__":
|
||||
|
@ -17,6 +17,7 @@ import uldaq
|
||||
import nixio as nix
|
||||
import pyqtgraph as pg
|
||||
import numpy as np
|
||||
import quantities as pq
|
||||
|
||||
|
||||
from pyrelacs.dataio.daq_producer import DaqProducer
|
||||
@ -39,8 +40,9 @@ from IPython import embed
|
||||
|
||||
|
||||
class PyRelacs(QMainWindow):
|
||||
def __init__(self):
|
||||
def __init__(self, config):
|
||||
super().__init__()
|
||||
self.config = config
|
||||
self.setToolButtonStyle(
|
||||
Qt.ToolButtonStyle.ToolButtonTextBesideIcon
|
||||
) # Ensure icons are displayed with text
|
||||
@ -79,9 +81,16 @@ class PyRelacs(QMainWindow):
|
||||
widget.setLayout(layout)
|
||||
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()
|
||||
BUFFERSIZE = SAMPLERATE * 10 * 60
|
||||
BUFFERSIZE = (SAMPLERATE * INPUTTRACECAPACITY).simplified
|
||||
end = time.time()
|
||||
log.debug(f"Buffer allocation took {end - start}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user