Beispiel #1
0
def on_message(mosq, obj, msg):
    key = msg.topic
    parts = key.split("/")
    value = msg.payload*1
    
    if len(parts)>3:
        filename = parts[1]+"."+parts[2]
        
        pyfina.prepare(filename,time.time(),value)
        
        bytes = pyfina.save()
        
        if bytes:
            print str(bytes)+" bytes written to "+filename+" "+value
Beispiel #2
0
pyfina = pyfina(settings['data']['dir'])

while 1:

    buffers = {}

    while r.llen('buffer'):
        csv = r.lpop('buffer').split(',')

        timestamp = int(csv[0])
        nodeid = int(csv[1])

        csv = csv[2:]

        if str(nodeid) in nodelist and 'interval' in nodelist[str(nodeid)]:
            intervals = nodelist[str(nodeid)]['interval']

        vid = 0
        for value in csv:
            vid += 1
            interval = int(intervals[vid - 1])
            if interval > 0:
                filename = str(nodeid) + "." + str(vid)
                pyfina.prepare(filename, timestamp, value, interval)

    bytes = pyfina.save()

    print "Bytes written: " + str(bytes)

    time.sleep(float(settings['data']['saveinterval']))
Beispiel #3
0
import time
import json
from pyfina import pyfina

pyfina = pyfina("data/")

# pyfina.create("lab.battery",10)

pyfina.prepare("lab.battery", time.time(), 100)
pyfina.save()

print json.dumps(pyfina.pipe("lab.battery"))
# print json.dumps(pyfina.data("lab.temperature",1420636578000-(86400000*300),1420636578000,86400))
Beispiel #4
0
pyfina = pyfina(settings['data']['dir'])

while 1:

    buffers = {}
    
    while r.llen('buffer'):
        csv = r.lpop('buffer').split(',')
        
        timestamp = int(csv[0])
        nodeid = int(csv[1])
        
        csv = csv[2:]
        
        if str(nodeid) in nodelist and 'interval' in nodelist[str(nodeid)]:
            intervals = nodelist[str(nodeid)]['interval']
        
        vid = 0
        for value in csv:
            vid += 1
            interval = int(intervals[vid-1])
            if interval>0:
                filename = str(nodeid)+"."+str(vid)
                pyfina.prepare(filename,timestamp,value,interval)
    
    bytes = pyfina.save()
    
    print "Bytes written: " + str(bytes)

    time.sleep(float(settings['data']['saveinterval']))
Beispiel #5
0
import time
import json
from pyfina import pyfina

pyfina = pyfina("data/")

# pyfina.create("lab.battery",10)

pyfina.prepare("lab.battery",time.time(),100)
pyfina.save()

print json.dumps(pyfina.pipe("lab.battery"))
# print json.dumps(pyfina.data("lab.temperature",1420636578000-(86400000*300),1420636578000,86400))