Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to add modules to the fog devices in iFogSim?

Description

Adding modules to the fog devices without implementing the module placement. Cloud mode is set to FALSE, all the modules will be placed on fog nodes and all the computational operations will be performed at fog nodes. In case if cloud mode is set to TRUE, then all the modules will be placed on cloud server and all the computations will be performed on cloud server.

Source Code

public class IntelligentSurveillance {

static List fogDevices = new ArrayList();

static List sensors = new ArrayList();

static List actuators = new ArrayList();

static int numOfAreas = 1;

static int numOfCamerasPerArea = 4;

private static boolean CLOUD = false;

public static void main(String[] args) {

Log.printLine("Starting Intelligent Surveillance...");

try {

Log.disable();

int num_user = 1; // number of cloud users

Calendar calendar = Calendar.getInstance();

boolean trace_flag = false; // mean trace events

CloudSim.init(num_user, calendar, trace_flag);

String appId = "Intelligent Surveillance"; // identifier of the application

FogBroker broker = new FogBroker("broker");

Application application = createApplication(appId, broker.getId());

application.setUserId(broker.getId());

createFogDevices(broker.getId(), appId);

Controller controller = null;

ModuleMapping moduleMapping = ModuleMapping.createModuleMapping();

moduleMapping.addModuleToDevice("user_interface", "cloud");

if (CLOUD) {

moduleMapping.addModuleToDevice("object_detector", "cloud"); moduleMapping.addModuleToDevice("object_tracker", "cloud");

moduleMapping.addModuleToDevice("motion_detector", "cloud");

}

controller = new Controller("master-controller", fogDevices, sensors,

actuators);

controller.submitApplication(application,

(CLOUD)?(new ModulePlacementMapping(fogDevices, application, moduleMapping))

:(new ModulePlacementEdgewards(fogDevices, sensors, actuators, application, moduleMapping)));

TimeKeeper.getInstance().setSimulationStartTime(Calendar.getInstance().getTimeInMillis());

CloudSim.startSimulation();

CloudSim.stopSimulation();

Log.printLine("Intelligent Surveillance finished!");

} catch (Exception e) {

e.printStackTrace();

Log.printLine("Unwanted errors happen");

}

}

Output
Cloud mode is “FALSE”,Cloud mode is “TRUE”
To add modules to the fog devices
Cloud mode is “FALSE”,Cloud mode is “TRUE”