def handle_service(msg): #print("#######",msg['service_id'],"for Logging") service_id = msg['service_id'] code = msg['code'] logmsg = {} logmsg['component'] = 'Server_lifecycle' logmsg['msg'] = msg # cm.common_Logger_Producer_interface(logmsg) producer_json.send_message(service_id, msg)
def sensor_run(id, typ, loc, range, ip, port): with open('meta.json') as f: meta = json.load(f) # print(meta[typ]) rang = meta[typ]['range'] # frequency=meta[typ]['frequency'] type_ = meta[typ]['type'] if type_ == 'real': min_limit_of_data = meta[typ]['min'] max_limit_of_data = meta[typ]['max'] topic = typ message = {} message['type'] = typ message['id'] = id message['location'] = loc message['location_type'] = None #GPS or room no message['range'] = rang message['data'] = random.randrange(int(min_limit_of_data), int(max_limit_of_data)) producer_json.send_message(topic, message)
def Topology_to_ServiceLifeCycle_Producer_interface(mess): producer_json.send_message('Topology_to_ServiceLifeCycle',mess)
def ServiceLifeCycle_to_DeployManager_Producer_interface(mess): producer_json.send_message('ServiceLifeCycle_to_DeployManager',mess)
def Schedular_to_ServiceLifeCycle_Producer_interface(mess): producer_json.send_message('Schedular_to_ServiceLifeCycle',mess)
def Deployer_to_Monitoring_Module_Producer_interface(mess): producer_json.send_message('Deployer_to_Monitoring_Module', mess)
def Authentication_to_ServiceLifeCycle_Producer_interface(mess): producer_json.send_message('Authentication_to_ServiceLifeCycle',mess)
def HealthManager_to_Registry_Producer_interface(mess): producer_json.send_message('HealthManager_to_Registry',mess)
def DeployManager_to_SensorManager_Producer_interface(mess): producer_json.send_message('DeployManager_to_SensorManager',mess)
def DeployManager_to_RuntimeServer_Producer_interface(mess): producer_json.send_message('DeployManager_to_RuntimeServer', mess)
def Runtime_Servers_to_Monitoring_Module_Producer_interface(mess): producer_json.send_message('Runtime_Server_to_Monitoring_Module', mess)
def Scheduler_to_Logger_Producer_interface(mess): producer_json.send_message('common_Logger', mess)
def Deployer_to_Logger_Producer_interface(mess): producer_json.send_message('common_Logger', mess)
def RuntimeServer_to_ActionServer_Producer_interface(mess): producer_json.send_message('RuntimeServer_to_ActionServer', mess)
def TopoManager_to_ServerLifeCycle_Producer_interface(mess): producer_json.send_message('TopoManager_to_ServerLifeCycle', mess)
def Monitoring_Module_to_Deployer_Producer_interface(mess): producer_json.send_message('Monitoring_Module_to_Deployer', mess)
def Topology_to_Registry_Producer_interface(mess): producer_json.send_message('Topology_to_Registry',mess)
def handle_service(msg): service_id = msg['service_id'] code = msg['code'] producer_json.send_message(service_id, code)
def HealthManager_to_ServiceLifeCycle_Producer_interface(mess): producer_json.send_message('HealthManager_to_ServiceLifeCycle',mess)
def ServiceLifeCycle_to_ServerLifeCycle_Producer_interface(mess): producer_json.send_message('ServiceLifeCycle_to_ServerLifeCycle',mess)
def ApplicationManager_to_ServiceLifeCycle_Producer_interface(mess): producer_json.send_message('ApplicationManager_to_ServiceLifeCycle',mess)
import sys import sensor sys.path.insert(0, "../communication_module") import threading import communication_module import producer_json mess = {} print('Enter the command') com = input() mess['command'] = com # print(mess) producer_json.send_message('Temperature', mess)
def ApplicationManager_to_Scheduler_Producer_interface(mess): producer_json.send_message('ApplicationManager_to_Scheduler',mess)
def Scheduler_to_Monitoring_Module_Producer_interface(mess): producer_json.send_message('Scheduler_to_Monitoring_Module', mess)
def ServiceLifeCycle_to_Authentication_Producer_interface(mess): producer_json.send_message('ServiceLifeCycle_to_Authentication',mess)
def sensor_run(i,typ,loc,ip,port): curpath=str(os.path.dirname(os.path.realpath(__file__))) with open(curpath+'/meta.json') as f: meta = json.load(f) # print(meta[typ]) rang=meta[typ]['range'] # frequency=meta[typ]['frequency'] type_=meta[typ]['type'] data=None if type_ == '4': min_max1=meta[typ]['min_max1'] min_max2=meta[typ]['min_max2'] min_max3=meta[typ]['min_max3'] min_max4=meta[typ]['min_max4'] ran=random.randrange(0,100) if ran>=min_max1[1] and ran <=min_max1[2]: data=random.randrange(min_max1[0][0],min_max1[0][1]) elif ran>=min_max2[1] and ran <=min_max2[2]: data=random.randrange(min_max2[0][0],min_max2[0][1]) elif ran>=min_max3[1] and ran <=min_max3[2]: data=random.randrange(min_max3[0][0],min_max3[0][1]) elif ran>=min_max4[1] and ran <=min_max4[2]: data=random.randrange(min_max4[0][0],min_max4[0][1]) elif type_=='1': # print('here in',type_) min_max1=meta[typ]['min_max1'] ran=random.randrange(0,100) # print(ran) if ran>=min_max1[1] and ran <=min_max1[2]: data=min_max1[0][1] else: data=min_max1[0][0] elif type_=='2': # print('here in',type_) ran=random.randrange(0,100) if ran>=0 and ran<60: data='' data+=str(random.randrange(30,70)) data+=':' data+=str(random.randrange(150,250)) elif ran>=60 and ran<80: data='' data+=str(random.randrange(50,100)) data+=':' data+=str(random.randrange(100,150)) else: data='' data+=str(random.randrange(30,50)) data+=':' data+=str(random.randrange(80,100)) if typ == 'temperature': curpath=str(os.path.dirname(os.path.realpath(__file__))) # print("curpath",curpath) ppath=dirname(curpath) # print("ppath",ppath) ppp_path=dirname(ppath) f=open(ppp_path+'/Applications/shubham/SmartClass/Emergency Fire Alarm Service/temperature.txt','a+') f.write(str(data)) f.write("\n") f.close() topic= typ+'_'+i # print('#topic=',topic) message={} message['type']=typ message['id']= i message['location']=loc message['location_type']=None #GPS or room no message['range']=rang message['data']=data producer_json.send_message(topic,message)