##// END OF EJS Templates
Se resolvió plot pattern de ABS
Se resolvió plot pattern de ABS

File last commit:

r388:7b60d9ecd28a
r390:5670a70fd8d1
Show More
mqtt.py
38 lines | 1.4 KiB | text/x-python | PythonLexer
Renato Huallpa
Recuperación parcial
r383 import os
Renato Huallpa
Se unió ATRAD al SIR
r380 import paho.mqtt.client as mqtt
from radarsys import settings
from radarsys.socketconfig import sio as sio
import numpy as np
def on_connect(mqtt_client, userdata, flags, rc):
if rc == 0:
Renato Huallpa
Avance scheduler
r388 # print('Connected successfully')
Renato Huallpa
Se unió ATRAD al SIR
r380 mqtt_client.subscribe('atrad/test3')
else:
print('Bad connection. Code:', rc)
def maxima_temp(trs):
np_array = [np.array(i) for i in trs]
temps = [max(i[i<40]) for i in np_array]
return max(temps)
def on_message(mqtt_client, userdata, msg):
Renato Huallpa
Recuperación parcial
r383 # print(f'Received message on topic: {msg.topic} with payload: {msg.payload}', flush=True)
Renato Huallpa
Se unió ATRAD al SIR
r380 trsi = [[],[],[],[]]
mensaje = str(msg.payload)
datos = [i for i in mensaje[21:-1].split("*")]
Renato Huallpa
Recuperación parcial
r383 status=''.join([datos[i][3] for i in range(3)])
Renato Huallpa
Se unió ATRAD al SIR
r380 for trs,i in zip(datos,[0,1,2,3]) :
trsi[i]= [int(i) for i in trs[1:-1].split(",")]
potencias = [trsi[0][34],trsi[0][36],trsi[2][32],trsi[2][34]]
tmax = maxima_temp(trsi)
sio.emit('test', data={'time':mensaje[2:21],'num':trsi[0][0],'pow':potencias,'tmax':str(tmax),'status':status})
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
Renato Huallpa
Recuperación parcial
r383 client.username_pw_set(os.environ.get('MQTT_USER_ATRAD', 'atrad'), os.environ.get('MQTT_PASSWORD_ATRAD', 'atrad'))
Renato Huallpa
Se unió ATRAD al SIR
r380 client.connect(
Renato Huallpa
Se recuperó el avance de implementación mqtt para abs
r384 host=os.environ.get('MQTT_SERVER', '10.10.10.200'),
Renato Huallpa
Recuperación parcial
r383 port=int(settings.os.environ.get('MQTT_PORT', 1883)),
keepalive=int(os.environ.get('MQTT_KEEPALIVE', 36000))
Renato Huallpa
Se unió ATRAD al SIR
r380 )