Example #1
0
    def upload_data(self, cluster, node, sensor_t, sensor_q, sensor_u, measurements):

        x = Videk(videk_token)
        x.api_url = videk_api_url

        cluster_id = x.getClusterID(cluster)
        if cluster_id == None:
            x.createCluster(cluster)
            cluster_id = x.getClusterID(cluster)

        node_id = x.getNodeID(node)
        if node_id == None:
            x.createNode(node, cluster_id)
            node_id = x.getNodeID(node)

        sensor_id = x.getSensorID(node, sensor_t, sensor_q)
        if sensor_id == None:
            x.createSensor(node_id, sensor_t, sensor_q, sensor_u)
            sensor_id = x.getSensorID(node, sensor_t, sensor_q)

        videk_m = """{"latitude":"","longitude":"","ts":"","value":""}"""

        preparedData = []
        for measurement in measurements:
            data = json.loads(videk_m)
            data["value"] = measurement["v"]
            data["ts"] = datetime.fromtimestamp(int(measurement["t"])).isoformat()
            data["latitude"] = measurement["lat"]
            data["longitude"] = measurement["lon"]
            preparedData.append(data)

        x.uploadMesurements(preparedData, node_id, sensor_id)
Example #2
0
    def upload_data(self, cluster, node, sensor_t, \
        sensor_q, sensor_u, measurements):

        x = Videk(videk_token)
        x.api_url = videk_api_url

        cluster_id = x.getClusterID(cluster)
        if cluster_id == None:
            x.createCluster(cluster)
            cluster_id = x.getClusterID(cluster)

        node_id = x.getNodeID(node)
        if node_id == None:
            x.createNode(node, cluster_id)
            node_id = x.getNodeID(node)

        sensor_id = x.getSensorID(node, sensor_t, sensor_q)
        if sensor_id == None:
            x.createSensor(node_id, sensor_t, sensor_q, sensor_u)
            sensor_id = x.getSensorID(node, sensor_t, sensor_q)

        videk_m = '''{"latitude":"","longitude":"","ts":"","value":""}'''

        preparedData = []
        for measurement in measurements:
            data = json.loads(videk_m)
            data['value'] = measurement["v"]
            data['ts'] = datetime.fromtimestamp(int(measurement["t"])) \
             .isoformat()
            data['latitude'] = measurement["lat"]
            data['longitude'] = measurement["lon"]
            preparedData.append(data)

        x.uploadMesurements(preparedData, node_id, sensor_id)
Example #3
0
#!/usr/bin/env python

import sys
import time
import json
from datetime import datetime
from videk_rest_client import Videk
from random import randint

x = Videk('secret')
x.api_url = "http://localhost/api"

cluster = "example";
node = "example.com"
sensor_t = "test"
sensor_q = "test_value"
sensor_u = "t"

cluster_id = x.getClusterID(cluster)
if cluster_id == None:
    x.createCluster(cluster)
    cluster_id = x.getClusterID(cluster)

node_id = x.getNodeID(node)
if node_id == None:
    x.createNode(node, cluster_id)
    node_id = x.getNodeID(node)

sensor_id = x.getSensorID(node, sensor_t, sensor_q)
if sensor_id == None:
    x.createSensor(node_id, sensor_t, sensor_q, sensor_u)
Example #4
0
#!/usr/bin/env python

import sys
import time
import json
from datetime import datetime
from videk_rest_client import Videk
from random import randint

x = Videk('secret')
x.api_url = "http://localhost/api"

cluster = "example"
node = "example.com"
sensor_t = "test"
sensor_q = "test_value"
sensor_u = "t"

cluster_id = x.getClusterID(cluster)
if cluster_id == None:
    x.createCluster(cluster)
    cluster_id = x.getClusterID(cluster)

node_id = x.getNodeID(node)
if node_id == None:
    x.createNode(node, cluster_id)
    node_id = x.getNodeID(node)

sensor_id = x.getSensorID(node, sensor_t, sensor_q)
if sensor_id == None:
    x.createSensor(node_id, sensor_t, sensor_q, sensor_u)