[ui] creates a nix file with pressing the record button
This commit is contained in:
parent
038327bfeb
commit
e2b7ed3a61
@ -1,5 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
from pathlib import Path as path
|
from pathlib import Path as path
|
||||||
|
from datetime import datetime
|
||||||
|
from dataclasses import asdict
|
||||||
|
|
||||||
from PyQt6.QtGui import QAction, QIcon, QKeySequence
|
from PyQt6.QtGui import QAction, QIcon, QKeySequence
|
||||||
from PyQt6.QtCore import Qt, QSize, QThreadPool, QMutex
|
from PyQt6.QtCore import Qt, QSize, QThreadPool, QMutex
|
||||||
@ -13,9 +15,8 @@ from PyQt6.QtWidgets import (
|
|||||||
QStatusBar,
|
QStatusBar,
|
||||||
)
|
)
|
||||||
|
|
||||||
from pyqtgraph.Qt.QtCore import QThread
|
|
||||||
import uldaq
|
import nixio
|
||||||
import nixio as nix
|
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
import quantities as pq
|
import quantities as pq
|
||||||
|
|
||||||
@ -110,6 +111,7 @@ class PyRelacs(QMainWindow):
|
|||||||
self.sinus_producer = SinProducer(self.buffer)
|
self.sinus_producer = SinProducer(self.buffer)
|
||||||
|
|
||||||
self.nix_writer = NixWriter(self.buffer)
|
self.nix_writer = NixWriter(self.buffer)
|
||||||
|
self.create_nix_file(f"{_root}/test.nix", self.config.metadata)
|
||||||
|
|
||||||
def create_actions(self):
|
def create_actions(self):
|
||||||
self._rlx_exitaction = QAction(QIcon(":/icons/exit.png"), "Exit", self)
|
self._rlx_exitaction = QAction(QIcon(":/icons/exit.png"), "Exit", self)
|
||||||
@ -222,6 +224,22 @@ class PyRelacs(QMainWindow):
|
|||||||
repro_toolbar.addAction(repro_action)
|
repro_toolbar.addAction(repro_action)
|
||||||
self.addToolBar(Qt.ToolBarArea.BottomToolBarArea, repro_toolbar)
|
self.addToolBar(Qt.ToolBarArea.BottomToolBarArea, repro_toolbar)
|
||||||
|
|
||||||
|
def create_nix_file(self, file_path, metadata):
|
||||||
|
self.nix_file = nixio.File.open(
|
||||||
|
path=f"{file_path}", mode=nixio.FileMode.Overwrite
|
||||||
|
)
|
||||||
|
self.block = self.nix_file.create_block("recording", "testfile")
|
||||||
|
self.section = self.nix_file.create_section("metadata", "config.yaml")
|
||||||
|
for key, value in asdict(metadata).items():
|
||||||
|
self.section[key] = value
|
||||||
|
|
||||||
|
self.data_array_analog1 = self.block.create_data_array(
|
||||||
|
"Analog1", "ndarray", shape=(1000,), dtype=nixio.DataType.Double
|
||||||
|
)
|
||||||
|
self.data_array_analog2 = self.block.create_data_array(
|
||||||
|
"Analog2", "ndarray", shape=(1000,), dtype=nixio.DataType.Double
|
||||||
|
)
|
||||||
|
|
||||||
def recenter_continously_plot(self):
|
def recenter_continously_plot(self):
|
||||||
self.continously_plot.refresh()
|
self.continously_plot.refresh()
|
||||||
|
|
||||||
@ -251,12 +269,33 @@ class PyRelacs(QMainWindow):
|
|||||||
self.continously_plot.plot()
|
self.continously_plot.plot()
|
||||||
|
|
||||||
def record(self):
|
def record(self):
|
||||||
nix_writer = Worker(self.nix_writer.write_nix)
|
self.create_nix_file("test.nix", self.config.metadata)
|
||||||
|
log.debug("Created nix file")
|
||||||
|
|
||||||
|
nix_writer = Worker(
|
||||||
|
self.nix_writer.write_nix,
|
||||||
|
data_array=self.data_array_analog1,
|
||||||
|
mutex=self.mutex,
|
||||||
|
channel=0,
|
||||||
|
chunk_size=1000,
|
||||||
|
)
|
||||||
nix_writer.signals.result.connect(self.print_output)
|
nix_writer.signals.result.connect(self.print_output)
|
||||||
nix_writer.signals.finished.connect(self.thread_complete)
|
nix_writer.signals.finished.connect(self.thread_complete)
|
||||||
nix_writer.signals.progress.connect(self.progress_fn)
|
nix_writer.signals.progress.connect(self.progress_fn)
|
||||||
self.threadpool.start(nix_writer)
|
self.threadpool.start(nix_writer)
|
||||||
|
|
||||||
|
nix_writer2 = Worker(
|
||||||
|
self.nix_writer.write_nix,
|
||||||
|
data_array=self.data_array_analog2,
|
||||||
|
mutex=self.mutex,
|
||||||
|
channel=0,
|
||||||
|
chunk_size=1000,
|
||||||
|
)
|
||||||
|
nix_writer2.signals.result.connect(self.print_output)
|
||||||
|
nix_writer2.signals.finished.connect(self.thread_complete)
|
||||||
|
nix_writer2.signals.progress.connect(self.progress_fn)
|
||||||
|
self.threadpool.start(nix_writer2)
|
||||||
|
|
||||||
def stop_recording(self):
|
def stop_recording(self):
|
||||||
self.add_to_textfield("Stopping the recording")
|
self.add_to_textfield("Stopping the recording")
|
||||||
self.continously_plot.stop_plotting()
|
self.continously_plot.stop_plotting()
|
||||||
@ -272,6 +311,8 @@ class PyRelacs(QMainWindow):
|
|||||||
if hasattr(PyRelacs, "daq_device"):
|
if hasattr(PyRelacs, "daq_device"):
|
||||||
log.debug("Stopping DAQ")
|
log.debug("Stopping DAQ")
|
||||||
self.daq_producer.stop_aquisition()
|
self.daq_producer.stop_aquisition()
|
||||||
|
embed()
|
||||||
|
exit()
|
||||||
|
|
||||||
def run_repro(self, n, fn):
|
def run_repro(self, n, fn):
|
||||||
self.text.appendPlainText(f"started Repro {n}, {fn}")
|
self.text.appendPlainText(f"started Repro {n}, {fn}")
|
||||||
|
Loading…
Reference in New Issue
Block a user