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
|
# Base: Hilos y datos buffer de datos compartidos
|
||||||
import queue
|
import queue
|
||||||
import threading
|
|
||||||
|
|
||||||
from src.cliente_ws import websocket_cliente
|
from src.cliente_ws import websocket_cliente
|
||||||
|
from src.graficar import graficar, graficar_rt
|
||||||
from src.gurdar import guardar_datos
|
from src.gurdar import guardar_datos
|
||||||
from src.procesor_data import data_procesor
|
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_1 = websocket_cliente(raw_data, i_paquetes, ip_server)
|
||||||
hilo_2 = data_procesor(raw_data, data_clean, data_grafica, buffer_size)
|
hilo_2 = data_procesor(raw_data, data_clean, data_grafica, buffer_size)
|
||||||
# hilo_3 = threading.Thread(target=debug_print)
|
# hilo_3 = threading.Thread(target=debug_print)
|
||||||
|
# hilo_3 = graficar_rt(data_clean, data_grafica, buffer_size)
|
||||||
hilo_4 = guardar_datos(data_clean)
|
hilo_4 = guardar_datos(data_clean)
|
||||||
|
|
||||||
hilo_1.start()
|
hilo_1.start()
|
||||||
@@ -42,3 +43,5 @@ hilo_1.join()
|
|||||||
hilo_2.join()
|
hilo_2.join()
|
||||||
# hilo_3.join()
|
# hilo_3.join()
|
||||||
hilo_4.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):
|
def graficar(cola_clean, cola_filtrada):
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
win = pg.GraphicsLayoutWidget(show=True, title="Onda senoidal")
|
win = pg.GraphicsLayoutWidget(show=True, title="Onda senoidal")
|
||||||
|
|
||||||
# Un solo plot con ambas curvas
|
|
||||||
p1 = win.addPlot(title="Señal cruda y filtrada")
|
p1 = win.addPlot(title="Señal cruda y filtrada")
|
||||||
p1.addLegend() # leyenda automática
|
p1.addLegend() # leyenda automática
|
||||||
curve1 = p1.plot(pen="r", name="Cruda")
|
curve1 = p1.plot(pen="r", name="Cruda")
|
||||||
curve2 = p1.plot(pen="b", name="Filtrada")
|
curve2 = p1.plot(pen="b", name="Filtrada")
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
# Actualizar señal cruda
|
|
||||||
if not cola_clean.empty():
|
if not cola_clean.empty():
|
||||||
datos = cola_clean.get()
|
datos = cola_clean.get()
|
||||||
muestras = np.arange(len(datos))
|
muestras = np.arange(len(datos))
|
||||||
curve1.setData(muestras, datos)
|
curve1.setData(muestras, datos)
|
||||||
|
|
||||||
# Actualizar señal filtrada
|
|
||||||
if not cola_filtrada.empty():
|
if not cola_filtrada.empty():
|
||||||
datos_f = cola_filtrada.get()
|
datos_f = cola_filtrada.get()
|
||||||
muestras_f = np.arange(len(datos_f))
|
muestras_f = np.arange(len(datos_f))
|
||||||
@@ -37,7 +33,7 @@ def graficar(cola_clean, cola_filtrada):
|
|||||||
app.exec_()
|
app.exec_()
|
||||||
|
|
||||||
|
|
||||||
class websocket_cliente(threading.Thread):
|
class graficar_rt(threading.Thread):
|
||||||
def __init__(self, cola_clean, cola_filtada, buffer_size):
|
def __init__(self, cola_clean, cola_filtada, buffer_size):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.cola_clean = cola_clean
|
self.cola_clean = cola_clean
|
||||||
@@ -48,21 +44,21 @@ class websocket_cliente(threading.Thread):
|
|||||||
self.idx_despla = self.buffer_size / 100
|
self.idx_despla = self.buffer_size / 100
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
app = QtWidgets.QApplication([])
|
||||||
self.buffer_limpio.append(self.cola_clean.get())
|
win = pg.GraphicsLayoutWidget(show=True, title="Onda senoidal")
|
||||||
try:
|
p1 = win.addPlot(title="Señal cruda y filtrada")
|
||||||
self.buffer_filtrado = self.cola_filtrado.get_nowait()
|
p1.addLegend()
|
||||||
except queue.Empty:
|
curve1 = p1.plot(pen="r", name="Cruda")
|
||||||
pass
|
curve2 = p1.plot(pen="b", name="Filtrada")
|
||||||
|
|
||||||
|
def update():
|
||||||
|
|
||||||
# tiempo real
|
if not self.cola_clean.empty():
|
||||||
if __name__ == "__main__":
|
datos = self.cola_clean.get()
|
||||||
cola_clean = queue.Queue()
|
muestras = np.arange(len(datos))
|
||||||
cola_filtrada = queue.Queue()
|
curve1.setData(muestras, datos)
|
||||||
|
|
||||||
cliente = websocket_cliente(cola_clean, cola_filtrada, buffer_size=1024)
|
if not self.cola_filtrado.empty():
|
||||||
cliente.daemon = True
|
datos_f = self.cola_filtrado.get()
|
||||||
cliente.start()
|
muestras_f = np.arange(len(datos_f))
|
||||||
|
curve2.setData(muestras_f, datos_f)
|
||||||
graficar(cola_clean, cola_filtrada)
|
|
||||||
Reference in new issue
Block a user