measure value into paylod
parent
777674c710
commit
f789f1c408
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue