[ui] updating plot for continously plotting
This commit is contained in:
parent
85fd70f8ca
commit
cd936b1ed1
@ -1,4 +1,5 @@
|
||||
from pathlib import Path as path
|
||||
from re import I
|
||||
|
||||
from PyQt6.QtGui import QAction, QIcon, QKeySequence
|
||||
from PyQt6.QtCore import Qt, QSize, QThreadPool, QTimer
|
||||
@ -72,9 +73,9 @@ class PyRelacs(QMainWindow):
|
||||
widget.setLayout(layout)
|
||||
self.setCentralWidget(widget)
|
||||
|
||||
self.buffer = CircBuffer(size=500)
|
||||
self.buffer = CircBuffer(size=1_000_000, samplerate=20)
|
||||
self.connect_dac()
|
||||
self.daq_producer = DaqProducer(self.buffer, self.daq_device)
|
||||
self.daq_producer = DaqProducer(self.buffer, self.daq_device, [1, 1])
|
||||
self.plot_daq()
|
||||
|
||||
def create_actions(self):
|
||||
@ -190,6 +191,7 @@ class PyRelacs(QMainWindow):
|
||||
self.data = list(range(10))
|
||||
self.line = self.daq_plot.plot(self.time, self.data, pen=pen)
|
||||
|
||||
self.item_index = 0
|
||||
self.timer = QTimer()
|
||||
self.timer.setInterval(50)
|
||||
self.timer.timeout.connect(self.update_plot)
|
||||
@ -200,9 +202,15 @@ class PyRelacs(QMainWindow):
|
||||
self.time = self.time[1:]
|
||||
self.time.append(self.time[-1] + 1)
|
||||
self.data = self.data[1:]
|
||||
try:
|
||||
item = self.buffer.get(self.buffer.write_index() - 1)
|
||||
except IndexError:
|
||||
log.debug(self.buffer.totocount())
|
||||
if self.buffer.totocount() > 20:
|
||||
try:
|
||||
log.debug(self.item_index)
|
||||
item = self.buffer.get(self.item_index)
|
||||
self.item_index += 1
|
||||
except IndexError:
|
||||
item = 0
|
||||
else:
|
||||
item = 0
|
||||
|
||||
self.data.append(item)
|
||||
@ -236,10 +244,8 @@ class PyRelacs(QMainWindow):
|
||||
|
||||
def disconnect_dac(self):
|
||||
try:
|
||||
log.debug(f"{self.daq_device}")
|
||||
self.daq_device.disconnect()
|
||||
self.daq_device.release()
|
||||
log.debug(f"{self.daq_device}")
|
||||
self.daq_disconnect_button.setDisabled(True)
|
||||
self.daq_connect_button.setEnabled(True)
|
||||
except AttributeError:
|
||||
@ -260,6 +266,7 @@ class PyRelacs(QMainWindow):
|
||||
def on_exit(self):
|
||||
log.info("exit button!")
|
||||
self.add_to_textfield("exiting")
|
||||
self.disconnect_dac()
|
||||
self.close()
|
||||
|
||||
def on_about(self, e):
|
||||
|
Loading…
Reference in New Issue
Block a user