SHA256
Grafica
This commit is contained in:
1 parent
14e3065f60
commit
2a5fdabf13
3 files changed
+2840
-22
No files matched your search
@@ -1,10 +1,10 @@
|
||||
# Aquitectura: 3 hilos -> Wwebsocket -> Procesamiento -> Visualización
|
||||
# Aquitectura: 4 hilos -> Websocket -> Procesamiento -> Visualización -> Guardado:CSV
|
||||
|
||||
# Base: Hilos y datos buffer de datos compartidos
|
||||
import queue
|
||||
import threading
|
||||
|
||||
from src.cliente_ws import websocket_cliente
|
||||
from src.graficar import graficar, graficar_rt
|
||||
from src.gurdar import guardar_datos
|
||||
from src.procesor_data import data_procesor
|
||||
|
||||
@@ -31,6 +31,7 @@ buffer_size = queue.Queue()
|
||||
hilo_1 = websocket_cliente(raw_data, i_paquetes, ip_server)
|
||||
hilo_2 = data_procesor(raw_data, data_clean, data_grafica, buffer_size)
|
||||
# hilo_3 = threading.Thread(target=debug_print)
|
||||
# hilo_3 = graficar_rt(data_clean, data_grafica, buffer_size)
|
||||
hilo_4 = guardar_datos(data_clean)
|
||||
|
||||
hilo_1.start()
|
||||
@@ -42,3 +43,5 @@ hilo_1.join()
|
||||
hilo_2.join()
|
||||
# hilo_3.join()
|
||||
hilo_4.join()
|
||||
|
||||
graficar(data_clean, data_grafica)
|
||||
+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