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.
public class IntelligentSurveillance {
static List
static List
static List
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");
}
}