def __init__(self): """ From config file, get and initialization all variables. """ file_name = os.path.basename(__file__).split('.')[0] self.logger = log_function(file_name) self.redis_obj_register = redis_conn(db_name='REDIS_REGISTER') self.config_obj = Config()
def __init__(self): """ Initialize frequently used parameters""" file_name = os.path.basename(__file__).split('.')[0] self.logger = log_function(file_name) self.config_obj = Config() user_authentication = self.config_obj.user_authentication() gateway = self.config_obj.gateway() derived_KPI = self.config_obj.derived_KPI() self.auth_URL = user_authentication['Auth_URL'] self.derivedKPI_url = derived_KPI['DerivedKPI_url'] self.derivedKPI_fetch_interval = derived_KPI['DerivedKPI_fetch_interval'] self.access_key = user_authentication['access_key'] self.user_key = user_authentication['user_key'] self.user_id = user_authentication['user_id'] self.token = user_authentication['token'] self.application_id = user_authentication['application_id'] self.auth_password = user_authentication['password'] self.gateway_id = gateway['gateway_id'] self.redis_obj_perf_data = redis_conn(db_name = 'REDIS_PERF_DATA') redis_obj_derived_kpi_data = redis_conn(db_name ='REDIS_DERIVED_KPI') try : self.api_response = eval(redis_obj_derived_kpi_data.get("Derived_KPI")) except Exception,error : self.api_response = None
''' Created on 20-Dec-2016 @author: TERAMATRIX/siddhika.nag Script to format data as recognized by xFusion Platform and store in in-memory DB for further computation ''' from logger import log_function from datetime import datetime import os from IotGateway.connection import redis_conn from IotGateway.config import Config file_name = (os.path.basename(__file__)).split('.')[0] redis_obj_perf_data = redis_conn('REDIS_PERF_DATA') logger = log_function(file_name) #Python class to format data class Formatter(): def __init__(self): self.config_obj = Config() self.restrict_data = self.config_obj.gateway()['restrict_data'] def format_data(self,formatted_data,device_id = None,service_name = None, data_source = None,\ current_value = None,check_timestamp= None,sys_timestamp = None,\ is_lat = False, is_long = False,is_host_state = False,\ on_state_value = None, off_state_value = None): """ Format data in list of JSON format including keys for