SHA256
Grafica
This commit is contained in:
1 parent
14e3065f60
commit
2a5fdabf13
3 files changed
+2840
-22
No files matched your search
+16
-20
@@ -10,21 +10,17 @@ from pyqtgraph.Qt import QtCore
|
||||
def graficar(cola_clean, cola_filtrada):
|
||||
app = QtWidgets.QApplication([])
|
||||
win = pg.GraphicsLayoutWidget(show=True, title="Onda senoidal")
|
||||
|
||||
# Un solo plot con ambas curvas
|
||||
p1 = win.addPlot(title="Señal cruda y filtrada")
|
||||
p1.addLegend() # leyenda automática
|
||||
curve1 = p1.plot(pen="r", name="Cruda")
|
||||
curve2 = p1.plot(pen="b", name="Filtrada")
|
||||
|
||||
def update():
|
||||
# Actualizar señal cruda
|
||||
if not cola_clean.empty():
|
||||
datos = cola_clean.get()
|
||||
muestras = np.arange(len(datos))
|
||||
curve1.setData(muestras, datos)
|
||||
|
||||
# Actualizar señal filtrada
|
||||
if not cola_filtrada.empty():
|
||||
datos_f = cola_filtrada.get()
|
||||
muestras_f = np.arange(len(datos_f))
|
||||
@@ -37,7 +33,7 @@ def graficar(cola_clean, cola_filtrada):
|
||||
app.exec_()
|
||||
|
||||
|
||||
class websocket_cliente(threading.Thread):
|
||||
class graficar_rt(threading.Thread):
|
||||
def __init__(self, cola_clean, cola_filtada, buffer_size):
|
||||
super().__init__()
|
||||
self.cola_clean = cola_clean
|
||||
@@ -48,21 +44,21 @@ class websocket_cliente(threading.Thread):
|
||||
self.idx_despla = self.buffer_size / 100
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self.buffer_limpio.append(self.cola_clean.get())
|
||||
try:
|
||||
self.buffer_filtrado = self.cola_filtrado.get_nowait()
|
||||
except queue.Empty:
|
||||
pass
|
||||
app = QtWidgets.QApplication([])
|
||||
win = pg.GraphicsLayoutWidget(show=True, title="Onda senoidal")
|
||||
p1 = win.addPlot(title="Señal cruda y filtrada")
|
||||
p1.addLegend()
|
||||
curve1 = p1.plot(pen="r", name="Cruda")
|
||||
curve2 = p1.plot(pen="b", name="Filtrada")
|
||||
|
||||
def update():
|
||||
|
||||
# tiempo real
|
||||
if __name__ == "__main__":
|
||||
cola_clean = queue.Queue()
|
||||
cola_filtrada = queue.Queue()
|
||||
if not self.cola_clean.empty():
|
||||
datos = self.cola_clean.get()
|
||||
muestras = np.arange(len(datos))
|
||||
curve1.setData(muestras, datos)
|
||||
|
||||
cliente = websocket_cliente(cola_clean, cola_filtrada, buffer_size=1024)
|
||||
cliente.daemon = True
|
||||
cliente.start()
|
||||
|
||||
graficar(cola_clean, cola_filtrada)
|
||||
if not self.cola_filtrado.empty():
|
||||
datos_f = self.cola_filtrado.get()
|
||||
muestras_f = np.arange(len(datos_f))
|
||||
curve2.setData(muestras_f, datos_f)
|
||||
Reference in new issue
Block a user