def create_application(): # APLICATION a = Application(name="VLIoT") # MODULES (face detection, feature extraction, face recognition) a.set_modules([{"Camera":{"Type":Application.TYPE_SOURCE}}, {"MLTTask": {"RAM": 256, "Type": Application.TYPE_MODULE}}, {"FLTTask": {"RAM": 256, "Type": Application.TYPE_MODULE}}, {"DLTTask": {"Type": Application.TYPE_SINK}} ]) # MESSAGES m_cam_mlt = Message("M.Cam", "Camera", "MLTTask", instructions=1*10^6, bytes=2000) m_mlt_flt = Message("M.MLT", "MLTTask", "FLTTask", instructions=1*10^6, bytes=2000) m_flt_dlt = Message("M.FLT", "FLTTask", "DLTTask", instructions=1*10^6, bytes=2000) # Add in the application those messages that come from pure sources (sensors). This distinction allows them to be controlled by the (:mod:`Population`) algorithm a.add_source_messages(m_cam_mlt) # Este nao eh o caso de usar um service_source - VER EXEMPLO DE VRGAME # Um service_source normalmente modela um Module que produz dados de controle, por exemplo. # dDistribution = deterministicDistribution(name="Deterministic", time=100) # a.add_service_source("Camera", dDistribution, m_mlt_flt) # MODULE SERVICES a.add_service_module("MLTTask", m_cam_mlt, m_mlt_flt, fractional_selectivity, threshold=1.0) a.add_service_module("FLTTask", m_mlt_flt, m_flt_dlt, fractional_selectivity, threshold=1.0) a.add_service_module("DLTTask", m_flt_dlt) return a
def create_applications_from_json(data): applications = {} for app in data: a = Application(name=app["name"]) modules = [{"None":{"Type":Application.TYPE_SOURCE}}] for module in app["module"]: if "RAM" in module.keys(): modules.append({module["name"]: {"RAM": module["RAM"], "Type": Application.TYPE_MODULE}}) else: modules.append({module["name"]: {"RAM": 1, "Type": Application.TYPE_MODULE}}) a.set_modules(modules) ms = {} for message in app["message"]: #print "Creando mensaje: %s" %message["name"] ms[message["name"]] = Message(message["name"],message["s"],message["d"],instructions=message["instructions"],bytes=message["bytes"]) if message["s"] == "None": a.add_source_messages(ms[message["name"]]) #print "Total mensajes creados %i" %len(ms.keys()) for idx, message in enumerate(app["transmission"]): if "message_out" in message.keys(): value_treshld = 1.0 if "fractional" in message.keys(): value_treshld = message["fractional"] a.add_service_module(message["module"],ms[message["message_in"]], ms[message["message_out"]], fractional_selectivity, threshold=value_treshld) else: a.add_service_module(message["module"], ms[message["message_in"]]) applications[app["name"]]=a #a.add_service_module("Client", m_egg, m_sensor, fractional_selectivity, threshold=0.9) return applications
def create_application(workload_type): # APLICATION a = Application(name="WL-%s" % workload_type) a.set_modules([{ "Source": { "Type": Application.TYPE_SOURCE } }, { "Storage": { "Type": Application.TYPE_SINK } }]) """ Messages among MODULES (AppEdge in iFogSim) """ m_data = Message("m-st", "Source", "Storage", instructions=2000 * 10 ^ 6, bytes=500) """ Defining which messages will be dynamically generated # the generation is controlled by Population algorithm """ a.add_source_messages(m_data) return a
def create_application(name): # APLICATION a = Application(name=name) a.set_modules([{"Generator":{"Type":Application.TYPE_SOURCE}}, {"Actuator": {"Type": Application.TYPE_SINK}} ]) m_egg = Message("M.Action", "Generator", "Actuator", instructions=100, bytes=10) a.add_source_messages(m_egg) return a
def create_application(): # APLICATION a = Application(name="SimpleCase") # (S) --> (ServiceA) --> (A) a.set_modules([{ "Sensor": { "Type": Application.TYPE_SOURCE } }, { "ServiceA": { "RAM": 10, "Type": Application.TYPE_MODULE } }, { "Actuator": { "Type": Application.TYPE_SINK } }]) """ Messages among MODULES (AppEdge in iFogSim) """ m_a = Message("M.A", "Sensor", "ServiceA", instructions=20 * 10 ^ 6, bytes=1000) m_b = Message("M.B", "ServiceA", "Actuator", instructions=30 * 10 ^ 6, bytes=500, broadcasting=True) """ Defining which messages will be dynamically generated # the generation is controlled by Population algorithm """ a.add_source_messages(m_a) """ MODULES/SERVICES: Definition of Generators and Consumers (AppEdges and TupleMappings in iFogSim) """ # MODULE SERVICES a.add_service_module("ServiceA", m_a, m_b, fractional_selectivity, threshold=1.0) return a
def create_application(): # APLICATION a = Application(name="EGG_GAME") a.set_modules([{"EGG":{"Type":Application.TYPE_SOURCE}}, {"Display": {"Type": Application.TYPE_SINK}}, {"Client": {"RAM": 10, "Type": Application.TYPE_MODULE}}, {"Calculator": {"RAM": 10, "Type": Application.TYPE_MODULE}}, {"Coordinator": {"RAM": 10, "Type": Application.TYPE_MODULE}} ]) """ Messages among MODULES (AppEdge in iFogSim) """ m_egg = Message("M.EGG", "EGG", "Client", instructions=2000*10^6, bytes=500) m_sensor = Message("M.Sensor", "Client", "Calculator", instructions=3500*10^6, bytes=500) m_player_game_state = Message("M.Player_Game_State", "Calculator", "Coordinator", instructions=1000*10^6, bytes=1000) m_concentration = Message("M.Concentration", "Calculator", "Client", instructions=14*10^6, bytes=500) # This message is sent to all client modules m_global_game_state = Message("M.Global_Game_State", "Coordinator", "Client", instructions=28*10^6, bytes=1000, broadcasting=True) # This message is sent to all client modules m_global_state_update = Message("M.Global_State_Update", "Client", "Display",instructions=1000*10^6,bytes=500) m_self_state_update = Message("M.Self_State_Update", "Client", "Display",instructions=1000*10^6,bytes=500) """ Defining which messages will be dynamically generated # the generation is controlled by Population algorithm """ a.add_source_messages(m_egg) """ MODULES/SERVICES: Definition of Generators and Consumers (AppEdges and TupleMappings in iFogSim) """ # MODULE SOURCES: only periodic messages dDistribution = deterministicDistribution(name="Deterministic", time=100) a.add_service_source("Calculator", dDistribution, m_player_game_state) #According with the comments on VRGameFog.java, the period is 100ms a.add_service_source("Coordinator", dDistribution, m_global_game_state) # # MODULE SERVICES a.add_service_module("Client", m_egg, m_sensor, fractional_selectivity, threshold=0.9) a.add_service_module("Client", m_concentration, m_self_state_update, fractional_selectivity, threshold=1.0) a.add_service_module("Client", m_global_game_state, m_global_state_update, fractional_selectivity, threshold=1.0) a.add_service_module("Calculator", m_sensor, m_concentration, fractional_selectivity, threshold=1.0) a.add_service_module("Coordinator", m_player_game_state) return a
def create_applications_from_json(data): applications = {} for app in data: # Create application a = Application(name=app["name"]) # Set modules modules = [] for module in app["module"]: modules.append({ module["name"]: { "RAM": module["RAM"], "Type": module["Type"] } }) a.set_modules(modules) # Set messages ms = {} for message in app["message"]: # print "Creando mensaje: %s" %message["name"] ms[message["name"]] = Message(message["name"], message["src"], message["dst"], instructions=message["instructions"], bytes=message["bytes"]) if message["src"] == "Source": a.add_source_messages(ms[message["name"]]) for idx, message in enumerate(app["service"]): if "message_out" in message.keys(): a.add_service_module(message["module"], ms[message["message_in"]], ms[message["message_out"]], fractional_selectivity, threshold=1.0) # else: # a.add_service_module(message["module"], ms[message["message_in"]]) applications[app["name"]] = a return applications
def create_application(name, params=None): # APLICATION a = Application(name=name, params=params) # MODULES (face detection, feature extraction, face recognition) a.set_modules([{ "Camera": { "Type": Application.TYPE_SOURCE } }, { "MLO": { "RAM": 256, "Type": Application.TYPE_MODULE } }, { "Broker": { "RAM": 256, "Type": Application.TYPE_MODULE } }, { "FLO": { "RAM": 256, "Type": Application.TYPE_MODULE } }, { "DLO": { "Type": Application.TYPE_SINK } }]) # MESSAGES m_cam_mlo = Message("RawVideo", "Camera", "MLO", instructions=100 * 10 ^ 6, bytes=20000) m_mlo_brk = Message("ObjectDetected", "MLO", "Broker", instructions=5 * 10 ^ 6, bytes=2000) m_brk_flo = Message("IdentifyObject", "Broker", "FLO", instructions=50 * 10 ^ 6, bytes=2000) m_flo_brk = Message("ObjectIdentified", "FLO", "Broker", instructions=2 * 10 ^ 6, bytes=100) m_brk_dlo = Message("EventIdentified", "Broker", "DLO", instructions=5 * 10 ^ 6, bytes=2000) # Add in the application those messages that come from pure sources (sensors). # This distinction allows them to be controlled by the (:mod:`Population`) algorithm a.add_source_messages(m_cam_mlo) # dDistribution = deterministicDistribution(name="Deterministic", time=50) # Which module will start processing services and in which distribution and message # a.add_service_source("Camera", dDistribution, m_cam_mlo) # MODULE SERVICES a.add_service_module("MLO", message_in=m_cam_mlo, message_out=m_mlo_brk, distribution=fractional_selectivity, threshold=0.5) # probability to yield message_out a.add_service_module("Broker", message_in=m_mlo_brk, message_out=m_brk_flo) a.add_service_module("FLO", message_in=m_brk_flo, message_out=m_flo_brk) a.add_service_module("Broker", message_in=m_flo_brk, message_out=m_brk_dlo) a.add_service_module("DLO", message_in=m_brk_dlo) return a