Compare commits

..

No commits in common. "25cd1c0585504161bc802970bc14637fde8d4238" and "74007668a930a4f7ad9c832b1989187e1ab2f3b0" have entirely different histories.

4 changed files with 15 additions and 81 deletions

13
poetry.lock generated
View File

@ -726,17 +726,6 @@ files = [
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, {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]] [[package]]
name = "typer" name = "typer"
version = "0.12.5" version = "0.12.5"
@ -779,4 +768,4 @@ files = [
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.12" python-versions = "^3.12"
content-hash = "6b680c385942c0a2c0eef934f3fb37fdc3d2e1dc058a7f2d891d4f2f0607d9c6" content-hash = "3095576f87f3ef0a0e8fea79a5d076d7bc2b655d0eb6ed28ac5b325ac233497a"

View File

@ -12,7 +12,6 @@ typer = "^0.12.5"
matplotlib = "^3.9.2" matplotlib = "^3.9.2"
numpy = "^2.1.1" numpy = "^2.1.1"
pyqt6 = "^6.7.1" pyqt6 = "^6.7.1"
tomli = "^2.0.1"
[build-system] [build-system]

View File

@ -1,20 +1,7 @@
from PyQt6.QtGui import QAction
import sys import sys
import pathlib
from PyQt6.QtCore import QSize, Qt from PyQt6.QtCore import QSize, Qt
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import QApplication, QGridLayout, QPushButton, QWidget, QMainWindow
QApplication,
QGridLayout,
QPushButton,
QToolBar,
QWidget,
QMainWindow,
)
import tomli
import uldaq import uldaq
from IPython import embed
import numpy as np
from pyrelacs.util.logging import config_logging from pyrelacs.util.logging import config_logging
@ -26,25 +13,22 @@ class PyRelacs(QMainWindow):
super().__init__() super().__init__()
self.setWindowTitle("PyRelacs") self.setWindowTitle("PyRelacs")
self.daq_connect_button = QPushButton("Connect Daq") self.daq_connect_button = QPushButton("Connect to Daq")
self.daq_connect_button.setCheckable(True) self.daq_connect_button.setCheckable(True)
self.daq_connect_button.clicked.connect(self.connect_dac) self.daq_connect_button.clicked.connect(self.connect_dac)
self.daq_disconnect_button = QPushButton("Disconnect Daq") self.daq_disconnect_button = QPushButton("Disconnect to Daq")
self.daq_disconnect_button.setCheckable(True) self.daq_disconnect_button.setCheckable(True)
self.daq_disconnect_button.clicked.connect(self.disconnect_dac) self.daq_disconnect_button.clicked.connect(self.disconnect_dac)
self.repro_button = QPushButton("Load Repros") self.send_data_button = QPushButton("Send Sinus")
self.repro_button.setCheckable(True) self.send_data_button.setCheckable(True)
self.repro_button.clicked.connect(self.repro) self.send_data_button.clicked.connect(self.send_sinus)
layout = QGridLayout() layout = QGridLayout()
layout.addWidget(self.daq_connect_button, 0, 0) layout.addWidget(self.daq_connect_button, 0, 0)
layout.addWidget(self.daq_disconnect_button, 0, 1) layout.addWidget(self.daq_disconnect_button, 0, 1)
layout.addWidget(self.repro_button, 1, 0) layout.addWidget(self.send_data_button, 1, 0)
self.toolbar = QToolBar("Repros")
self.addToolBar(self.toolbar)
self.setFixedSize(QSize(400, 300)) self.setFixedSize(QSize(400, 300))
widget = QWidget() widget = QWidget()
@ -52,15 +36,15 @@ class PyRelacs(QMainWindow):
self.setCentralWidget(widget) self.setCentralWidget(widget)
def connect_dac(self): def connect_dac(self):
devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB)
try: try:
self.daq_device = uldaq.DaqDevice(devices[0]) devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB)
log.debug(f"Found daq devices {len(devices)}, connecting to the first one") log.debug(f"Found daq devices {len(devices)}, connecting to the first one")
self.daq_device = uldaq.DaqDevice(devices[0])
self.daq_device.connect() self.daq_device.connect()
log.debug("Connected") log.debug("Connected")
except IndexError: except uldaq.ULException as e:
log.debug("DAQ is not connected, closing") log.debug(f"DAQ was not connected\n {e}")
QApplication.quit()
self.daq_connect_button.setDisabled(True) self.daq_connect_button.setDisabled(True)
def disconnect_dac(self): def disconnect_dac(self):
@ -74,40 +58,8 @@ class PyRelacs(QMainWindow):
except AttributeError: except AttributeError:
log.debug("DAQ was not connected") log.debug("DAQ was not connected")
def repro(self): def send_sinus(self):
config_path = pathlib.Path(__file__).parent.resolve() / "repro.toml" pass
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__": if __name__ == "__main__":

View File

@ -1,6 +0,0 @@
[Sinus]
duration = 10
fs = 30000.0
amplitude = 1
freq = 10