def __init__(self, settingFilePath="./settings.json"):
     '''Initialize instance and load settings'''
     setting = JsonSetting(settingFilePath)
     self.bd_rest_api = setting.get('bd_rest_api')
     self.oauth = setting.get('oauth')
     self.others = setting.get('others')
     self.access_token = self.get_oauth_token()
 def __init__(self, settingFilePath="./giotto_setting.json"):
     setting = JsonSetting(settingFilePath)
     self.giotto_rest_api = setting.get('giotto_rest_api')
     self.ml_rest_api = setting.get('ml_rest_api')
     self.gateway = setting.get('gateway')
     self.oauth = setting.get('oauth')
     self.access_token = self.get_oauth_token()
     print self.access_token
	def __init__(self, data_upload_delay):
		'''Initialize class and set upload period
	
		Args:
			data_upload_period: A number of seconds to be waited between data uploads
		'''
		super(DataStoreThread, self).__init__()

		global sensor_data_buffer
		sensor_data_buffer = []
		for i in range(len(sensors)+1):
			sensor_data_buffer.append([])

		self.data_upload_delay = 1
		self.stop_event = threading.Event()
		self.last_executed = 0

		connector_setting = JsonSetting('./connector_setting.json')
		self.sensor_uuids = connector_setting.get('sensor_uuids')
		self.bd_helper = BuildingDepotHelper('./buildingdepot_setting.json')
import math
import random

from json_setting import JsonSetting
from buildingdepot_helper import BuildingDepotHelper

if __name__ == "__main__":
	'''Load settings
	If you installed BuildingDepot with its demo database, you do not need to
	change the parameters in connector_setting.json. Otherwise, update the
	file according to what you configured in BuildingDepot.
	'''
	connector_setting = JsonSetting('./connector_setting.json')
	bd_helper = BuildingDepotHelper()

	uuids = connector_setting.get('sensor_uuids')
	sampling_period = connector_setting.get('sampling_period')

	'Sends dummy data'
	while True:
		data_array = []
		timestamp = time.time()
		
		for uuid in uuids:
			dic = {}
			dic['sensor_id'] = uuid
			dic['samples'] = [{"time":timestamp,"value":random.random()}]
			dic['value_type']=''
			data_array.append(dic)

 def __init__(self, settingFilePath="./giotto_setting.json"):
     setting = JsonSetting(settingFilePath)
     self.giotto_rest_api = setting.get('giotto_rest_api')
     self.oauth = setting.get('oauth')
     self.access_token = self.get_oauth_token()
     print self.access_token
import time
import math

from json_setting import JsonSetting
from giotto_helper import GiottoHelper

if __name__ == "__main__":
	connector_setting = JsonSetting('./connector_setting.json')
	giotto_helper = GiottoHelper()

	uuids = connector_setting.get('sensor_uuids')
	sampling_rate = connector_setting.get('sampling_rate')

	while True:
		data_array = []
		timestamp = time.time()
		value = 0
		
		for uuid in uuids:
			dic = {}
			dic['sensor_id'] = uuid
			dic['samples'] = [{"time":timestamp,"value":value}]
			dic['value_type']=''
			data_array.append(dic)


		result = giotto_helper.post_data_array(data_array)
		print result
		time.sleep(sampling_rate);
		
Esempio n. 7
0
"""

import time
import math
import random

from json_setting import JsonSetting
from buildingdepot_helper import BuildingDepotHelper

if __name__ == "__main__":
	#Load settings

	connector_setting = JsonSetting('./connector_setting.json')
	bd_helper = BuildingDepotHelper()

	buildingdepot_uuid = connector_setting.get('sensor_uuid')
	virtual_sensor_id = connector_setting.get('virtual_sensor_id')
	sampling_period = connector_setting.get('sampling_period')

	#Make predictions periodically and send them to BD
	while True:
		data_array = []
		timestamp = time.time()
		
		#Make prediction
        url = 'http://localhost:5000/sensor/' + virtual_sensor_id + '/classifier/predict'
        result = requests.get(url)
        prediction = result['ret']
		
		#Send data
		dic = {}
Esempio n. 8
0
import time
import math

from json_setting import JsonSetting
from giotto_helper import GiottoHelper

if __name__ == "__main__":
	giotto_setting = JsonSetting('./giotto_setting.json')
	connector_setting = JsonSetting('./connector_setting.json')
	giotto_helper = GiottoHelper()

	uuids = connector_setting.get('sensor_uuids')
	sampling_rate = connector_setting.get('sampling_rate')

	while True:
		data_array = []
		timestamp = time.time()
		value = math.sin(timestamp/10.) * 50 + 50
		
		for uuid in uuids:
			dic = {}
			dic['sensor_id'] = uuid
			dic['samples'] = [{"time":timestamp,"value":value}]
			dic['value_type']=''
			data_array.append(dic)


		giotto_helper.post_data_array(data_array)
		time.sleep(sampling_rate);
		
	return gatt_interface


if __name__ == "__main__":
	'''Initializes a SensorTag and continuously collect data from it
	'''
	SAMPLING_RATE = 1
	MAX_SAMPLING_NUMBER = 10


	connector_setting = JsonSetting('./connector_setting.json')
	bd_helper = BuildingDepotHelper('./buildingdepot_setting.json')

	# Turn on and configure a SensorTag
	mac_address = connector_setting.get('sensor_tag')['mac_address']
	gattInterface = setup_sensortag(mac_address)

	# Start a thread that post sampled data to a GIoTTO server
	dataStoreThread = DataStoreThread(SAMPLING_RATE)
	dataStoreThread.start()

	try:
		while True:
			#Process each notification as it is received and convert the sensor value
			#according to the handle
			gattInterface.expect('\r\nNotification handle = .* \r\n')

			receivedString = gattInterface.after

			# split lines because multiple data can be notified at the same time
Esempio n. 10
0
 def __init__(self, settingFilePath="./buildingdepot_setting.json"):
     '''Initialize instance and load settings'''
     setting = JsonSetting(settingFilePath)
     self.bd_rest_api = setting.get('buildingdepot_rest_api')
     self.oauth = setting.get('oauth')
     self.access_token = self.get_oauth_token()