[ui/plot] adding plot, but plots after while loop is finished
This commit is contained in:
parent
0b36e31135
commit
e3ed301252
@ -1,3 +1,4 @@
|
||||
import time
|
||||
import pyqtgraph as pg
|
||||
from IPython import embed
|
||||
import numpy as np
|
||||
@ -18,31 +19,49 @@ class Continously:
|
||||
self.figure.setBackground("w")
|
||||
self.daq_plot = self.figure.addPlot(row=0, col=0)
|
||||
pen = pg.mkPen("red")
|
||||
self.time = np.arange(self.buffer.size) / self.buffer.samplerate
|
||||
self.data = np.ones(self.buffer.size)
|
||||
self.time = np.zeros(self.buffer.size)
|
||||
self.data = np.zeros(self.buffer.size)
|
||||
log.debug(self.data.size)
|
||||
log.debug(self.time.size)
|
||||
self.line = self.daq_plot.plot(
|
||||
self.time, self.data, pen=pen, setCliptoView=True
|
||||
self.time,
|
||||
self.data,
|
||||
pen=pen,
|
||||
setCliptoView=True,
|
||||
symbol="o",
|
||||
)
|
||||
# self.line.setXRrange(np.arange(0, 10, 1 / self.buffer.samplerate))
|
||||
|
||||
self.item = 0
|
||||
self.timer = QTimer()
|
||||
self.timer.setInterval(1)
|
||||
self.timer.timeout.connect(self.update_plot)
|
||||
self.timer.start()
|
||||
|
||||
def update_plot(self):
|
||||
if self.buffer.totalcount() > 100:
|
||||
if self.buffer.write_index() > self.item:
|
||||
# self.time = self.time[1:]
|
||||
# self.time.append(self.time[-1] + 1)
|
||||
# self.data = self.data[1:]
|
||||
item = self.buffer.get_all()
|
||||
t = np.arange(item.shape[0]) / self.buffer.samplerate
|
||||
# self.data.append(item)
|
||||
self.line.setData(t, item)
|
||||
self.item += 1
|
||||
else:
|
||||
pass
|
||||
|
||||
while self.buffer.totalcount() < 4000:
|
||||
log.debug(self.buffer.totalcount())
|
||||
self.time = np.roll(self.time, -1)
|
||||
self.data = np.roll(self.data, -1)
|
||||
try:
|
||||
item, time_index = self.buffer.get(self.buffer.write_index() - 1)
|
||||
except IndexError:
|
||||
item = 0
|
||||
time_index = 0
|
||||
self.time[-1] = time_index
|
||||
self.data[-1] = item
|
||||
self.line.setData(self.time, self.data)
|
||||
|
||||
# self.timer = QTimer()
|
||||
# self.timer.setInterval(1)
|
||||
# self.timer.timeout.connect(self.update_plot)
|
||||
# self.timer.start()
|
||||
|
||||
# self.update_plot()
|
||||
#
|
||||
# def update_plot(self):
|
||||
# log.debug(self.buffer.totalcount())
|
||||
# while self.buffer.totalcount() < 4000:
|
||||
# log.debug(self.buffer.totalcount())
|
||||
# self.time = np.roll(self.time, -1)
|
||||
# self.data = np.roll(self.data, -1)
|
||||
# try:
|
||||
# item, time_index = self.buffer.get(self.buffer.write_index() - 1)
|
||||
# except IndexError:
|
||||
# item = 0
|
||||
# time_index = 0
|
||||
# self.time[-1] = time_index
|
||||
# self.data[-1] = item
|
||||
# self.line.setData(self.time, self.data)
|
||||
|
Loading…
Reference in New Issue
Block a user