Compare commits

...

3 Commits

4 changed files with 18 additions and 15 deletions

View File

@ -1,3 +1,4 @@
import time
from IPython import embed from IPython import embed
import nixio import nixio
@ -17,15 +18,21 @@ class NixWriter:
chunk = 1000 chunk = 1000
log.debug("Starting the writing") log.debug("Starting the writing")
self.write = True self.write = True
total_count = self.buffer.totalcount()
while self.write: while self.write:
# log.debug(items) if total_count - items >= chunk:
try: log.debug(items)
data, _ = self.buffer.read(items, extend=chunk) try:
self.data_array.append(data) data, _ = self.buffer.read(items, extend=chunk)
except IndexError as e: self.data_array.append(data)
# log.debug(f"{e}") except IndexError as e:
time.sleep(0.01)
log.debug(f"{e}")
items += chunk
else:
time.sleep(0.01)
continue continue
items += chunk
log.debug("Stoppint the writing") log.debug("Stoppint the writing")
log.debug(f"Samples written {items}") log.debug(f"Samples written {items}")
self.nix_file.close() self.nix_file.close()

View File

@ -38,12 +38,7 @@ class SinProducer:
log.debug(f"duration sinus {end_time-start_time}") log.debug(f"duration sinus {end_time-start_time}")
log.debug(f"Stimulation time {t}") log.debug(f"Stimulation time {t}")
log.debug(f"{self.buffer.totalcount()}") log.debug(f"Total samples produced {self.buffer.totalcount()}")
# data = self.buffer.get_all()
# log.debug(data.shape[0])
# log.debug(data.shape[0] / self.buffer.samplerate)
# plt.plot(np.arange(data.size) / self.buffer.samplerate, data)
# plt.show()
def stop_request(self): def stop_request(self):
self.stop = True self.stop = True

View File

@ -13,6 +13,7 @@ from PyQt6.QtWidgets import (
QStatusBar, QStatusBar,
) )
from pyqtgraph.Qt.QtCore import QThread
import uldaq import uldaq
import nixio as nix import nixio as nix
import pyqtgraph as pg import pyqtgraph as pg
@ -100,12 +101,11 @@ class PyRelacs(QMainWindow):
mutex=self.mutex, mutex=self.mutex,
) )
self.continously_plot = Continously(self.figure, self.buffer) self.continously_plot = Continously(self.figure, self.buffer)
self.continously_plot.plot() # self.continously_plot.plot()
if self.config.settings.daq: if self.config.settings.daq:
log.debug("Creating Daq Generator") log.debug("Creating Daq Generator")
self.daq_producer = DaqProducer(self.buffer, self.mccdaq.daq_device, [1, 1]) self.daq_producer = DaqProducer(self.buffer, self.mccdaq.daq_device, [1, 1])
log.debug("Creating Sinus Generator") log.debug("Creating Sinus Generator")
self.sinus_producer = SinProducer(self.buffer) self.sinus_producer = SinProducer(self.buffer)

View File

@ -53,6 +53,7 @@ class Continously:
self.last_plotted_index, self.last_plotted_index,
extend=self.CHUNK_PLOT, extend=self.CHUNK_PLOT,
) )
self.time = np.concatenate((self.time, times))[-self.PLOT_HISTORY :] self.time = np.concatenate((self.time, times))[-self.PLOT_HISTORY :]
self.data = np.concatenate((self.data, items))[-self.PLOT_HISTORY :] self.data = np.concatenate((self.data, items))[-self.PLOT_HISTORY :]
self.line.setData( self.line.setData(