Compare commits
2 Commits
74007668a9
...
25cd1c0585
Author | SHA1 | Date | |
---|---|---|---|
25cd1c0585 | |||
281640e80c |
13
poetry.lock
generated
13
poetry.lock
generated
@ -726,6 +726,17 @@ files = [
|
||||
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
version = "2.0.1"
|
||||
description = "A lil' TOML parser"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typer"
|
||||
version = "0.12.5"
|
||||
@ -768,4 +779,4 @@ files = [
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "3095576f87f3ef0a0e8fea79a5d076d7bc2b655d0eb6ed28ac5b325ac233497a"
|
||||
content-hash = "6b680c385942c0a2c0eef934f3fb37fdc3d2e1dc058a7f2d891d4f2f0607d9c6"
|
||||
|
@ -12,6 +12,7 @@ typer = "^0.12.5"
|
||||
matplotlib = "^3.9.2"
|
||||
numpy = "^2.1.1"
|
||||
pyqt6 = "^6.7.1"
|
||||
tomli = "^2.0.1"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
@ -1,7 +1,20 @@
|
||||
from PyQt6.QtGui import QAction
|
||||
import sys
|
||||
import pathlib
|
||||
|
||||
from PyQt6.QtCore import QSize, Qt
|
||||
from PyQt6.QtWidgets import QApplication, QGridLayout, QPushButton, QWidget, QMainWindow
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication,
|
||||
QGridLayout,
|
||||
QPushButton,
|
||||
QToolBar,
|
||||
QWidget,
|
||||
QMainWindow,
|
||||
)
|
||||
import tomli
|
||||
import uldaq
|
||||
from IPython import embed
|
||||
import numpy as np
|
||||
|
||||
from pyrelacs.util.logging import config_logging
|
||||
|
||||
@ -13,22 +26,25 @@ class PyRelacs(QMainWindow):
|
||||
super().__init__()
|
||||
self.setWindowTitle("PyRelacs")
|
||||
|
||||
self.daq_connect_button = QPushButton("Connect to Daq")
|
||||
self.daq_connect_button = QPushButton("Connect Daq")
|
||||
self.daq_connect_button.setCheckable(True)
|
||||
self.daq_connect_button.clicked.connect(self.connect_dac)
|
||||
|
||||
self.daq_disconnect_button = QPushButton("Disconnect to Daq")
|
||||
self.daq_disconnect_button = QPushButton("Disconnect Daq")
|
||||
self.daq_disconnect_button.setCheckable(True)
|
||||
self.daq_disconnect_button.clicked.connect(self.disconnect_dac)
|
||||
|
||||
self.send_data_button = QPushButton("Send Sinus")
|
||||
self.send_data_button.setCheckable(True)
|
||||
self.send_data_button.clicked.connect(self.send_sinus)
|
||||
self.repro_button = QPushButton("Load Repros")
|
||||
self.repro_button.setCheckable(True)
|
||||
self.repro_button.clicked.connect(self.repro)
|
||||
|
||||
layout = QGridLayout()
|
||||
layout.addWidget(self.daq_connect_button, 0, 0)
|
||||
layout.addWidget(self.daq_disconnect_button, 0, 1)
|
||||
layout.addWidget(self.send_data_button, 1, 0)
|
||||
layout.addWidget(self.repro_button, 1, 0)
|
||||
|
||||
self.toolbar = QToolBar("Repros")
|
||||
self.addToolBar(self.toolbar)
|
||||
|
||||
self.setFixedSize(QSize(400, 300))
|
||||
widget = QWidget()
|
||||
@ -36,15 +52,15 @@ class PyRelacs(QMainWindow):
|
||||
self.setCentralWidget(widget)
|
||||
|
||||
def connect_dac(self):
|
||||
devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB)
|
||||
try:
|
||||
devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB)
|
||||
|
||||
log.debug(f"Found daq devices {len(devices)}, connecting to the first one")
|
||||
self.daq_device = uldaq.DaqDevice(devices[0])
|
||||
log.debug(f"Found daq devices {len(devices)}, connecting to the first one")
|
||||
self.daq_device.connect()
|
||||
log.debug("Connected")
|
||||
except uldaq.ULException as e:
|
||||
log.debug(f"DAQ was not connected\n {e}")
|
||||
except IndexError:
|
||||
log.debug("DAQ is not connected, closing")
|
||||
QApplication.quit()
|
||||
self.daq_connect_button.setDisabled(True)
|
||||
|
||||
def disconnect_dac(self):
|
||||
@ -58,8 +74,40 @@ class PyRelacs(QMainWindow):
|
||||
except AttributeError:
|
||||
log.debug("DAQ was not connected")
|
||||
|
||||
def send_sinus(self):
|
||||
pass
|
||||
def repro(self):
|
||||
config_path = pathlib.Path(__file__).parent.resolve() / "repro.toml"
|
||||
if not config_path.is_file:
|
||||
log.error("repro.toml not found")
|
||||
QApplication.quit()
|
||||
repors = []
|
||||
|
||||
with open(config_path, mode="rb") as fp:
|
||||
self.config = tomli.load(fp)
|
||||
for r in self.config:
|
||||
repors.append(r)
|
||||
|
||||
individual_repro_button = QAction(f"{repors[0]}", self)
|
||||
individual_repro_button.setStatusTip("Button")
|
||||
individual_repro_button.triggered.connect(self.run_repro)
|
||||
self.toolbar.addAction(individual_repro_button)
|
||||
|
||||
def run_repro(self):
|
||||
log.debug("running repro")
|
||||
time = np.arange(
|
||||
0, self.config["Sinus"]["duration"], 1 / self.config["Sinus"]["fs"]
|
||||
)
|
||||
data = self.config["Sinus"]["amplitude"] * np.sin(
|
||||
2 * np.pi * self.config["Sinus"]["freq"] * time
|
||||
)
|
||||
|
||||
ao_device = self.daq_device.get_ao_device()
|
||||
ao_info = ao_device.get_info()
|
||||
try:
|
||||
err = ao_device.a_out_list(
|
||||
0, 0, [uldaq.Range.BIP2VOLTS], uldaq.AOutListFlag.DEFAULT, data
|
||||
)
|
||||
except uldaq.ULException as e:
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
6
pyrelacs/repro.toml
Normal file
6
pyrelacs/repro.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[Sinus]
|
||||
duration = 10
|
||||
fs = 30000.0
|
||||
amplitude = 1
|
||||
freq = 10
|
||||
|
Loading…
Reference in New Issue
Block a user