measure value into paylod

master
ademant 2019-06-24 16:08:14 +02:00
parent 777674c710
commit f789f1c408
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
import socket,numpy,time,thread,json
class meas_data:
def __init__(self,var_name,ring_length=100,device=socket.gethostname(),sensor="CPU",i2c=0,store_file="/home/pi/data"):
def __init__(self,var_name,ring_length=100,sigma=2,device=socket.gethostname(),sensor="CPU",i2c=0,store_file="/home/pi/data"):
self.var_name=var_name
self.value=[]
self.stat_val_mean=0
@ -20,6 +20,7 @@ class meas_data:
self.store_file=store_file
self.act_value=0
self.act_time=0
self.sigma=sigma
self.device=device
self.sensor=sensor
self.i2c=i2c
@ -83,7 +84,7 @@ class meas_data:
def send_sql(self,trigger=0):
self.json_out['time']=self.act_time
self.json_out['payload']['timestamp']=self.act_time
self.json_out['payload']['value']=self.act_value
self.json_out['payload'][self.var_name]['value']=self.act_value
print(json.dumps(self.json_out))
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)