示例#1
0
__version__ = "1.0.0"
__maintainer__ = "Filip Lemic"
__email__ = "*****@*****.**"
__status__ = "Development"

import sys
import urllib2
import json
from generateURL import RequestWithMethod

# The URL where server listens
apiURL = 'http://localhost:5000/'

# The name of a database
db_id = 'test_db'

# The old name of a collection in the database
coll_id = 'test_coll_01'

# The new name of the collection in the database
new_name = 'test_coll_02'

req = RequestWithMethod(apiURL + 'etd/v1.0/database/' + db_id +
                        '/collection/' + coll_id,
                        'PATCH',
                        headers={"Content-Type": "application/json"},
                        data=new_name)
resp = urllib2.urlopen(req)
response = json.loads(resp.read())
print response
示例#2
0
__author__ = "Filip Lemic"
__copyright__ = "Copyright 2015, EVARILOS Project"

__version__ = "1.0.0"
__maintainer__ = "Filip Lemic"
__email__ = "*****@*****.**"
__status__ = "Development"

import sys
import urllib2
from generateURL import RequestWithMethod
import json

# The URL where server listens
apiURL = 'http://localhost:5001/'

# The name of the database
db_id = 'test_db'

# The name of an experiment in the database
exp_id = 'test_exp'

obj = json.dumps({"experiment_description": 'test_01'})

req = RequestWithMethod(apiURL + 'evarilos/metrics/v1.0/database/' + db_id +
                        '/experiment/' + exp_id,
                        'PATCH',
                        headers={"Content-Type": "application/json"},
                        data=obj)
resp = urllib2.urlopen(req)
print json.loads(resp.read())
示例#3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""deleteDatabase.py: Delete a database in the ETD service."""

__author__ = "Filip Lemic"
__copyright__ = "Copyright 2015, Telecommunication Networks Group (TKN), TU Berlin"

__version__ = "1.0.0"
__maintainer__ = "Filip Lemic"
__email__ = "*****@*****.**"
__status__ = "Development"

from generateURL import RequestWithMethod
import sys
import urllib2
import json

# The URL where server listens
apiURL = 'http://localhost:5000/'

# The ID of the database
db_id = 'test_db'

req = RequestWithMethod(apiURL + 'etd/v1.0/database/' + db_id, 'DELETE', headers={"Content-Type": "application/json"})
resp = urllib2.urlopen(req)
response = json.loads(resp.read())
print response	
示例#4
0
__copyright__ = "Copyright 2015, Telecommunication Networks Group (TKN), TU Berlin"

__version__ = "1.0.0"
__maintainer__ = "Filip Lemic"
__email__ = "*****@*****.**"
__status__ = "Development"

import sys
import urllib2
import json
from generateURL import RequestWithMethod

# The URL where server listens
apiURL = 'http://localhost:5000/'

# The ID of the database
db_id = 'test_db'

# The ID of the collection in the database
coll_id = 'test_coll'

# The ID of the data
data_id = 'test_data'

req = RequestWithMethod(apiURL + 'evarilos/raw_data/v1.0/database/' + db_id +
                        '/collection/' + coll_id + '/message/' + data_id,
                        'DELETE',
                        headers={"Content-Type": "application/json"})
resp = urllib2.urlopen(req)
response = json.loads(resp.read())
print response
# The ID of the collection in the database storing training fingerprints
coll_id_training = 'test_coll_training'

req = urllib2.Request(apiURL + 'etd/v1.0/database/' + db_id + '/collection/' +
                      coll_id + '/message',
                      headers={"Content-Type": "application/json"})
resp = urllib2.urlopen(req)
messages = json.loads(resp.read())

for mes_key in messages.keys():
    data_id = messages[mes_key]['data_id']
    raw_data_collection = raw_data_pb2.RawRFReadingCollection()
    req = RequestWithMethod(apiURL + 'etd/v1.0/database/' + db_id +
                            '/collection/' + coll_id + '/message/' + data_id,
                            'GET',
                            headers={"Content-Type": "application/json"},
                            data='json')
    response = urllib2.urlopen(req)
    message = json.loads(response.read())

    raw_data_collection = raw_data_pb2.RawRFReadingCollection()
    raw_data_collection.data_id = data_id

    # Raw RSSI measurements from each AP are stored in a dictionary structure. Dictionary keys are the AP BSSIDs.
    meas_aps = {}

    for i in message['raw_measurement']:

        try:
            meas_aps[i['sender_bssid']]['rssi'].append(i['rssi'])
示例#6
0
location2.localized_node_id = 3
location2.true_coordinate_x = 3
location2.true_coordinate_y = 3
location2.true_coordinate_z = 3
location2.true_room_label = 'Room_3'
location2.est_coordinate_x = 3.3
location2.est_coordinate_y = 4.2
location2.est_coordinate_z = 1.9
location2.est_room_label = 'Room_3'
location2.latency = 15.15
location2.power_consumption = 1.99

# Define the scenario of the experiment
experiment.scenario.testbed_label = 'dummy'              # Label the testbed 
experiment.scenario.testbed_description = 'dummy'        # Give the description
experiment.scenario.experiment_description = 'dummy'     # Describe your experiment
experiment.scenario.sut_description = 'dummy'            # Describe your SUT
experiment.scenario.receiver_description = 'dummy'       # Describe your receiver(s)
experiment.scenario.sender_description = 'dummy'         # Describe your sender(s)
experiment.scenario.interference_description = 'dummy'   # Describe interference scenario
  
# Send your data to the ECE (EVARILOS Central Engine) service
# Serialize your protobuffer to binary string 
experiment_string = experiment.SerializeToString()
	
# Send your data to over HTTP to the ECE service	
req = RequestWithMethod(apiURI_ECE + 'evarilos/ece/v1.0/calculate_and_store_metrics', 'POST', headers={"Content-Type": "application/x-protobuf"}, data = experiment_string)
resp = urllib2.urlopen(req)
response = json.loads(resp.read())
print json.dumps(response)
示例#7
0
experiment.scenario.receiver_description = 'dummy'  # Describe your receiver(s)
experiment.scenario.sender_description = 'dummy'  # Describe your sender(s)
experiment.scenario.interference_description = 'dummy'  # Describe interference scenario

experiment.ground_truth.point_id = 1
experiment.ground_truth.localized_node_id = 1
experiment.ground_truth.true_coordinate_x = 3.0
experiment.ground_truth.true_coordinate_y = 3.1
experiment.ground_truth.true_coordinate_z = 3.4
experiment.ground_truth.true_room_label = 'dummy'

experiment.estimate.est_coordinate_x = 4.1
experiment.estimate.est_coordinate_y = 4.1
experiment.estimate.est_coordinate_z = 4.1
experiment.estimate.est_room_label = 'dummy'
experiment.estimate.latency = 1.0
experiment.estimate.power_consumption = 1.0

# Send your data to the ECE (EVARILOS Central Engine) service
# Serialize your protobuffer to binary string

experiment_string = experiment.SerializeToString()

# Send your data to over HTTP to the ECE service
req = RequestWithMethod(apiURI_ECE + 'evarilos/ece/v1.0/add_one_location',
                        'POST',
                        headers={"Content-Type": "application/x-protobuf"},
                        data=experiment_string)
resp = urllib2.urlopen(req)
response = json.loads(resp.read())
print json.dumps(response)
示例#8
0
if __name__ == '__main__':
    
    raw_data_collection = raw_data_pb2.RawRFReadingCollection() 
    raw_data_collection.metadata_id = "1"
    raw_data_collection.data_id = "1"
    raw_data_collection.meas_number = NUMBER_OF_SCANS

    for scans in range(1, NUMBER_OF_SCANS + 1):
        fpf = wifiFingerprint()
        fpf.scan(1)
        fp = fpf.getFingerprint()
        for key in fp.keys():
            raw_data_reading = raw_data_collection.raw_measurement.add()
            x = datetime.utcnow()
            raw_data_reading.timestamp_utc = timestamp_utc = int(time.mktime(x.timetuple()))
            raw_data_reading.receiver_id = 'MacBook'
            raw_data_reading.receiver_location.coordinate_x = 1
            raw_data_reading.receiver_location.coordinate_y = 1
            raw_data_reading.receiver_location.coordinate_z = 1
            raw_data_reading.receiver_location.room_label = 'test'
            raw_data_reading.run_nr = scans
            raw_data_reading.sender_bssid = key
            raw_data_reading.sender_id = fp[key]['ssid']
            raw_data_reading.rssi = int(fp[key]['rssi'][0])
            raw_data_reading.channel = fp[key]['channel']

    obj = raw_data_collection.SerializeToString()

    req = RequestWithMethod(apiURL + 'etd/v1.0/database/' + db_id + '/collection/' + coll_id + '/message/' + data_id, 'PUT', headers={"Content-Type": "application/x-protobuf"}, data = obj)
    resp = urllib2.urlopen(req)
    print json.loads(resp.read())
示例#9
0
def type3():
    try:
        experiment = message_evarilos_engine_type2_pb2.ece_type2()
        experiment.ParseFromString(request.data)
    except:
        return json.dumps('Experiment is not well defined!')

    response ={}
       
    if experiment.store_metrics is True:
        apiURL_metrics = experiment.metrics_storage_URI
        db_id = experiment.metrics_storage_database
        req = urllib2.Request(apiURL_metrics + 'evarilos/metrics/v1.0/database', headers={"Content-Type": "application/json"}, data = db_id)
        resp = urllib2.urlopen(req)

        coll_id = experiment.metrics_storage_collection
        req = RequestWithMethod(apiURL_metrics + 'evarilos/metrics/v1.0/database/' + db_id  + '/experiment', 'POST', headers={"Content-Type": "application/json"}, data = coll_id)
        resp = urllib2.urlopen(req)
            
        try:   
            req = RequestWithMethod(apiURL_metrics + 'evarilos/metrics/v1.0/database/' + db_id + '/experiment/' + coll_id, 'GET', headers={"Content-Type": "application/x-protobuf"}, data = 'protobuf')
            resp = urllib2.urlopen(req)
            message = resp.read()
            experiment_results = experiment_results_pb2.Experiment() 
            experiment_results.ParseFromString(message)
        except:
            experiment_results = experiment_results_pb2.Experiment() 

    localization_error_2D = {}
    localization_error_3D = {}
    latency = {} 
    power_consumption = {}
    number_of_points = 0
    number_of_good_rooms = {}

    for location in experiment_results.locations:
        number_of_points += 1
        x1 = location.true_coordinate_x
        y1 = location.true_coordinate_y
        x2 = location.est_coordinate_x
        y2 = location.est_coordinate_y
        localization_error_2D[number_of_points] = math.sqrt(math.pow((x1-x2), 2) + math.pow((y1-y2), 2))
        try:
            z1 = location.true_coordinate_z
            z2 = location.est_coordinate_z
            localization_error_3D[number_of_points] = math.sqrt(math.pow((x1-x2), 2) + math.pow((y1-y2), 2) + math.pow((z1-z2), 2))
        except:
            pass
        try:
            room1 = location.true_room_label
            room2 = location.est_room_label
            if room1.strip() == room2.strip():
                number_of_good_rooms[number_of_points] = 1 
            else:
                number_of_good_rooms[number_of_points] = 0
        except:
            pass
        try:
            latency[number_of_points] = location.latency
        except:
            pass
        try:
            power_consumption[number_of_points] = location.power_consumption
        except:
            pass

    # Get location estimate from the SUT
    if experiment.request_estimates is True:
        time1 = time.time()
        req = urllib2.Request(str(experiment.sut_location_estimate_URI), headers={"Content-Type": "application/json"})
        resp = urllib2.urlopen(req)
        time2 = time.time()
        loc_est_latency = time2 - time1
        estimated_location = json.loads(resp.read())
    else:
        estimated_location = {}
        try:
            estimated_location['coordinate_x'] = experiment.estimate.est_coordinate_x
            estimated_location['coordinate_y'] = experiment.estimate.est_coordinate_y
        except:
            return json.dumps('Define the location estimate in the message!')
        try:  
            estimated_location['coordinate_z'] = experiment.estimate.est_coordinate_z
        except:
            pass
        try:  
            estimated_location['room_label'] = experiment.estimate.est_room_label
        except:
            pass

    measurement_location = experiment_results.locations.add()
    number_of_points += 1
    measurement_location.point_id = experiment.ground_truth.point_id
    try:
        measurement_location.localized_node_id = experiment.ground_truth.localized_node_id 
    except:
        pass
    measurement_location.true_coordinate_x = x1 = experiment.ground_truth.true_coordinate_x
    measurement_location.true_coordinate_y = y1 = experiment.ground_truth.true_coordinate_y
    measurement_location.est_coordinate_x = x2 = estimated_location['coordinate_x']
    measurement_location.est_coordinate_y = y2 = estimated_location['coordinate_y']
    measurement_location.localization_error_2D = math.sqrt(math.pow((x1-x2), 2) + math.pow((y1-y2), 2))
    localization_error_2D[number_of_points] = measurement_location.localization_error_2D
    try:
        measurement_location.true_coordinate_z = z1 = experiment.ground_truth.true_coordinate_z
        measurement_location.est_coordinate_z = z2 = estimated_location['coordinate_z']
        measurement_location.localization_error_3D = math.sqrt(math.pow((x1-x2), 2) + math.pow((y1-y2), 2) + math.pow((z1-z2), 2))
        localization_error_3D[number_of_points] = measurement_location.localization_error_3D
    except:
        time.sleep(0)
    try:
        measurement_location.true_room_label = room1 = experiment.ground_truth.true_room_label
        measurement_location.est_room_label = room2 = estimated_location['room_label']
        if room1.strip() == room2.strip():
            measurement_location.localization_correct_room = 1
            number_of_good_rooms[number_of_points] = 1
        else:
            measurement_location.localization_correct_room = 0
            number_of_good_rooms[number_of_points] = 0
    except:
        pass
    try:
        measurement_location.latency = latency[number_of_points] = loc_est_latency
    except:
        pass
    try:
        measurement_location.latency = latency[number_of_points] = experiment.estimate.latency
    except:
        pass
    try:
        measurement_location.power_consumption = location.power_consumption
        power_consumption[number_of_points] = measurement_location.power_consumption
    except:
        pass
    try:
        measurement_location.power_consumption = experiment.estimate.power_consumption
        power_consumption[number_of_points] = measurement_location.power_consumption
    except:
        pass
    
    experiment_results.primary_metrics.error_2D_average = float(sum(localization_error_2D.values()))/number_of_points
    experiment_results.primary_metrics.error_2D_min = min(localization_error_2D.values())
    experiment_results.primary_metrics.error_2D_max = max(localization_error_2D.values())
    experiment_results.primary_metrics.error_2D_std = numpy.std(localization_error_2D.values())
    experiment_results.primary_metrics.error_2D_median = numpy.median(localization_error_2D.values())
    if len(localization_error_3D) != 0:
        experiment_results.primary_metrics.error_3D_average = float(sum(localization_error_3D.values()))/number_of_points
        experiment_results.primary_metrics.error_3D_min = min(localization_error_3D.values())
        experiment_results.primary_metrics.error_3D_max = max(localization_error_3D.values())
        experiment_results.primary_metrics.error_3D_std = numpy.std(localization_error_3D.values())
        experiment_results.primary_metrics.error_3D_median = numpy.median(localization_error_3D.values())
    if len(number_of_good_rooms) != 0:
        experiment_results.primary_metrics.room_error_average = float(sum(number_of_good_rooms.values()))/number_of_points
        print number_of_good_rooms.values()
        print number_of_points
    if len(latency) != 0:
        experiment_results.primary_metrics.latency_average = float(sum(latency.values()))/number_of_points
        experiment_results.primary_metrics.latency_min = min(latency.values())
        experiment_results.primary_metrics.latency_max = max(latency.values())
        experiment_results.primary_metrics.latency_std = numpy.std(latency.values())
        experiment_results.primary_metrics.latency_median = numpy.median(latency.values())
    if sum(power_consumption) != 0:
        experiment_results.primary_metrics.power_consumption_average = float(sum(power_consumption.values()))/number_of_points
        experiment_results.primary_metrics.power_consumption_median = numpy.median(power_consumption.values())
        experiment_results.primary_metrics.power_consumption_min = min(power_consumption.values())
        experiment_results.primary_metrics.power_consumption_max = max(power_consumption.values())
        experiment_results.primary_metrics.power_consumption_std = numpy.std(power_consumption.values())
    else:
        try:
            experiment_results.primary_metrics.power_consumption_average = experiment.power_consumption_per_experiment
        except:
            pass
    
    experiment_results.scenario.testbed_label = experiment.scenario.testbed_label
    experiment_results.scenario.testbed_description = experiment.scenario.testbed_description
    experiment_results.scenario.experiment_description = experiment.scenario.experiment_description
    experiment_results.sut.sut_name = experiment.scenario.sut_description
    experiment_results.scenario.receiver_description = experiment.scenario.receiver_description 
    experiment_results.scenario.sender_description = experiment.scenario.sender_description  
    experiment_results.scenario.interference_description = experiment.scenario.interference_description
    experiment_results.timestamp_utc = experiment.timestamp_utc
    experiment_results.experiment_label = experiment.experiment_label
    
    obj = json.dumps(protobuf_json.pb2json(experiment_results))

    if experiment.store_metrics is True:
        apiURL_metrics = experiment.metrics_storage_URI
        db_id = experiment.metrics_storage_database
        req = urllib2.Request(apiURL_metrics + 'evarilos/metrics/v1.0/database', headers={"Content-Type": "application/json"}, data = db_id)
        resp = urllib2.urlopen(req)
        
        coll_id = experiment.metrics_storage_collection
        req = RequestWithMethod(apiURL_metrics + 'evarilos/metrics/v1.0/database/' + db_id  + '/experiment/' + coll_id, 'DELETE', headers={"Content-Type": "application/json"}, data = coll_id)
        resp = urllib2.urlopen(req)
        
        req = RequestWithMethod(apiURL_metrics + 'evarilos/metrics/v1.0/database/' + db_id  + '/experiment', 'POST', headers={"Content-Type": "application/json"}, data = coll_id)
        resp = urllib2.urlopen(req)
               
        req = urllib2.Request(apiURL_metrics + 'evarilos/metrics/v1.0/database/' + db_id + '/experiment/' + coll_id, headers={"Content-Type": "application/json"}, data = obj)
        resp = urllib2.urlopen(req)
        
    response = protobuf_json.pb2json(experiment_results)

    return json.dumps(response)       
示例#10
0
def type1():
    
    try:
        experiment = message_evarilos_engine_type1_pb2.ece_type1()
        experiment.ParseFromString(request.data)
    except:
        return json.dumps('Experiment is not well defined!')

    experiment_results = experiment_results_pb2.Experiment()
    localization_error_2D = {}
    localization_error_3D = {}
    latency = {} 
    power_consumption = {}
    number_of_points = 0
    number_of_good_rooms = {}

    for location in experiment.locations:
        number_of_points += 1
        measurement_location = experiment_results.locations.add()
        measurement_location.point_id = location.point_id
        try:
            measurement_location.localized_node_id = location.localized_node_id
        except:
            pass
        measurement_location.true_coordinate_x = x1 = location.true_coordinate_x
        measurement_location.true_coordinate_y = y1 = location.true_coordinate_y
        measurement_location.est_coordinate_x = x2 = location.est_coordinate_x
        measurement_location.est_coordinate_y = y2 = location.est_coordinate_y
        measurement_location.localization_error_2D = math.sqrt(math.pow((x1-x2), 2) + math.pow((y1-y2), 2))
        localization_error_2D[number_of_points] = measurement_location.localization_error_2D
        try:
            measurement_location.true_coordinate_z = z1 = location.true_coordinate_z
            measurement_location.est_coordinate_z = z2 = location.est_coordinate_z
            measurement_location.localization_error_3D = math.sqrt(math.pow((x1-x2), 2) + math.pow((y1-y2), 2) + math.pow((z1-z2), 2))
            localization_error_3D[number_of_points] = measurement_location.localization_error_3D
        except:
            pass
        try:
            measurement_location.true_room_label = room1 = location.true_room_label
            measurement_location.est_room_label = room2 = location.est_room_label
            if room1.strip() == room2.strip():
                measurement_location.localization_correct_room = 1
                number_of_good_rooms[number_of_points] = 1
            else:
                measurement_location.localization_correct_room = 0
                number_of_good_rooms[number_of_points] = 0
        except:
            pass
        try:
            measurement_location.latency = location.latency
            latency[number_of_points] = location.latency
        except:
            pass
        try:
            measurement_location.power_consumption = location.power_consumption
            power_consumption[number_of_points] = location.power_consumption
        except:
            pass

    experiment_results.primary_metrics.accuracy_error_2D_average = float(sum(localization_error_2D.values()))/number_of_points
    experiment_results.primary_metrics.accuracy_error_2D_min = min(localization_error_2D.values())
    experiment_results.primary_metrics.accuracy_error_2D_max = max(localization_error_2D.values())
    experiment_results.primary_metrics.accuracy_error_2D_variance = numpy.var(localization_error_2D.values())
    experiment_results.primary_metrics.accuracy_error_2D_median = numpy.median(localization_error_2D.values())
    experiment_results.primary_metrics.accuracy_error_2D_75_percentile = numpy.percentile(localization_error_2D.values(), 75)
    experiment_results.primary_metrics.accuracy_error_2D_90_percentile = numpy.percentile(localization_error_2D.values(), 90)
    experiment_results.primary_metrics.accuracy_error_2D_rms = math.sqrt( (1 / float(number_of_points)) * numpy.sum( numpy.power( localization_error_2D.values(), 2)))

    if len(localization_error_3D) != 0:
         experiment_results.primary_metrics.accuracy_error_3D_average = float(sum(localization_error_3D.values()))/number_of_points
         experiment_results.primary_metrics.accuracy_error_3D_min = min(localization_error_3D.values())
         experiment_results.primary_metrics.accuracy_error_3D_max = max(localization_error_3D.values())
         experiment_results.primary_metrics.accuracy_error_3D_variance = numpy.var(localization_error_3D.values())
         experiment_results.primary_metrics.accuracy_error_3D_median = numpy.median(localization_error_3D.values())
         experiment_results.primary_metrics.accuracy_error_3D_75_percentile = numpy.percentile(localization_error_3D.values(), 75)
         experiment_results.primary_metrics.accuracy_error_3D_90_percentile = numpy.percentile(localization_error_3D.values(), 90)
         experiment_results.primary_metrics.accuracy_error_3D_rms = math.sqrt( (1 / float(number_of_points)) * numpy.sum( numpy.power( localization_error_3D.values(), 2)))

    if len(number_of_good_rooms) != 0: 
        experiment_results.primary_metrics.room_accuracy_error_average = float(sum(number_of_good_rooms.values()))/number_of_points
    if len(latency) != 0:
        experiment_results.primary_metrics.latency_average = float(sum(latency.values()))/number_of_points
        experiment_results.primary_metrics.latency_min = min(latency.values())
        experiment_results.primary_metrics.latency_max = max(latency.values())
        experiment_results.primary_metrics.latency_variance = numpy.var(latency.values())
        experiment_results.primary_metrics.latency_median = numpy.median(latency.values())
        experiment_results.primary_metrics.latency_75_percentile = numpy.percentile(latency.values(), 75)
        experiment_results.primary_metrics.latency_90_percentile = numpy.percentile(latency.values(), 90)
        experiment_results.primary_metrics.latency_rms = math.sqrt( (1 / float(number_of_points)) * numpy.sum( numpy.power( latency.values(), 2)))
    if len(power_consumption) != 0:
        experiment_results.primary_metrics.power_consumption_average = float(sum(power_consumption.values()))/number_of_points
        experiment_results.primary_metrics.power_consumption_median = numpy.median(power_consumption.values())
        experiment_results.primary_metrics.power_consumption_min = min(power_consumption.values())
        experiment_results.primary_metrics.power_consumption_max = max(power_consumption.values())
        experiment_results.primary_metrics.power_consumption_variance = numpy.var(power_consumption.values())
        experiment_results.primary_metrics.power_consumption_75_percentile = numpy.percentile(power_consumption.values(), 75)
        experiment_results.primary_metrics.power_consumption_90_percentile = numpy.percentile(power_consumption.values(), 90)
        experiment_results.primary_metrics.power_consumption_rms = math.sqrt( (1 / float(number_of_points)) * numpy.sum( numpy.power( power_consumption.values(), 2)))
    else:
        try:
            experiment_results.primary_metrics.power_consumption_average = experiment.power_consumption_per_experiment
        except:
            pass
    
    experiment_results.scenario.testbed_label = experiment.scenario.testbed_label
    experiment_results.scenario.testbed_description = experiment.scenario.testbed_description
    experiment_results.scenario.experiment_description = experiment.scenario.experiment_description
    experiment_results.sut.sut_name = experiment.scenario.sut_description
    experiment_results.scenario.receiver_description = experiment.scenario.receiver_description 
    experiment_results.scenario.sender_description = experiment.scenario.sender_description  
    experiment_results.scenario.interference_description = experiment.scenario.interference_description
    experiment_results.timestamp_utc = experiment.timestamp_utc
    experiment_results.experiment_label = experiment.experiment_label

    obj = json.dumps(protobuf_json.pb2json(experiment_results))

    response = {}
    if experiment.store_metrics is True:
        apiURL_metrics = experiment.metrics_storage_URI

        db_id = experiment.metrics_storage_database
        req = urllib2.Request(apiURL_metrics + 'evarilos/metrics/v1.0/database', headers={"Content-Type": "application/json"}, data = db_id)
        resp = urllib2.urlopen(req)
        coll_id = experiment.metrics_storage_collection
        req = RequestWithMethod(apiURL_metrics + 'evarilos/metrics/v1.0/database/' + db_id  + '/experiment', 'POST', headers={"Content-Type": "application/json"}, data = coll_id)
        resp = urllib2.urlopen(req)       
        req = urllib2.Request(apiURL_metrics + 'evarilos/metrics/v1.0/database/' + db_id + '/experiment/' + coll_id, headers={"Content-Type": "application/json"}, data = obj)
        resp = urllib2.urlopen(req)
    
    response = protobuf_json.pb2json(experiment_results)
    
    return json.dumps(response)
示例#11
0
from generateURL import RequestWithMethod

# The URL where server listens
apiURL = 'http://localhost:5000/'

# ID of the database where original training fingerprints are stored
db_id_training = 'wifi_beacon_rssi_twist_small_macbook'

# ID of the collection in the database original training fingerprints are stored
coll_id_training = 'training_quantile'

# ID of the database where original and virtual training fingerprints should be stored
db_id_enriched = 'wifi_beacon_rssi_twist_small_macbook'

# The ID of the collection where original and virtual training fingerprints should be stored
coll_id_enriched = 'training_quantile'

parameters= {}
parameters['define_virtual_points'] = 'Voronoi' # User or Voronoi
parameters['propagation_model'] = 'Multiwall'   # IDWI or Multiwall

# Define WiFi APs (BSSIDs) that you want to use in the propagation modeling. 
parameters['transmitters'] = ['64:70:02:3e:aa:ef','64:70:02:3e:9f:63','64:70:02:3e:aa:11','64:70:02:3e:aa:d9']

req = RequestWithMethod(apiURL + 'etd/v1.0/' + db_id_training  + '/' + coll_id_training + '/' + db_id_enriched + '/' + coll_id_enriched,'GET', headers={"Content-Type": "application/json"}, data=json.dumps(parameters))
resp = urllib2.urlopen(req)
response = json.loads(resp.read())
print response