Adjustment to do initializationof secure cloud later than the sensor/ZigBee initializ...
authorrtrimana <rtrimana@uci.edu>
Tue, 6 Mar 2018 19:32:02 +0000 (11:32 -0800)
committerrtrimana <rtrimana@uci.edu>
Tue, 6 Mar 2018 19:32:02 +0000 (11:32 -0800)
benchmarks/Java/HomeSecurityController/HomeSecurityController.java
benchmarks/drivers/Java/Makefile

index 09c0527..3cf6c36 100644 (file)
@@ -135,34 +135,15 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                        // Get and init the IoTCloud server address
                        // Setup table
                        t1 = new Table(BASE_URL, PASSWORD, LOCAL_MACHINE_ID, LISTENING_PORT);
-                   t1.initTable();
-                       // Setup is done somewhere else, we just do rebuild()
-                       //t1.rebuild();
+                       t1.initTable();
                        System.out.println("DEBUG: Table initialized!");
                        // Initialize sensors!
-                       // TODO: Still deciding whether to initialize all devices here or inside each init method
                        int id = 0;
                        // Initialize alarms! One alarm for now
                        for(AlarmSmart alarm : alarmSet.values()) {
                                createKeyIoTCloud("alarm", NOT_ACTIVE);
                                System.out.println("DEBUG: Setting alarm to NOT-ACTIVE!");
                        }
-                       // TODO: We can extend the usage of other keys to have a complete monitoring system for every device
-                       /*for(SmartthingsSensorSmart smartSensor : smartSensorsSet.values()) {
-                               
-                               createKeyIoTCloud("sensor" + Integer.toString(id++), NOT_ACTIVE);
-                               System.out.println("DEBUG: Setting sensor" + id + " to NOT-ACTIVE!");                           
-                       }
-                       // Initialize cameras! One camera for now...
-                       for(CameraSmart cam : camSet.values()) {
-                               createKeyIoTCloud("camera", NOT_ACTIVE);
-                               System.out.println("DEBUG: Setting camera to NOT-ACTIVE!");
-                       }
-                       int doorId = 0;
-                       for(SmartthingsActuatorSmart doorlock : doorlockSet.values()) {
-                               createKeyIoTCloud("doorlock" + Integer.toString(doorId), NOT_ACTIVE);
-                               System.out.println("DEBUG: Setting doorlock" + id + " to NOT-ACTIVE!");
-                       }*/
 
                } catch(Exception e) {
                        e.printStackTrace();
@@ -394,11 +375,9 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                if(_activeValue) {
                        System.out.println("DEBUG: Sensor " + sensorId + " is detecting something: " + _activeValue);
                        senDetectStatus.put(_sensorId, true);
-                       //updateIoTCloud(sensor, ACTIVE);
                } else {
-                       //System.out.println("DEBUG: Sensor " + sensorId + " is not detecting something: " + _activeValue);
+                       System.out.println("DEBUG: Sensor " + sensorId + " is not detecting something: " + _activeValue);
                        senDetectStatus.put(_sensorId, false);
-                       //updateIoTCloud(sensor, NOT_ACTIVE);
                }
        }
 
@@ -415,11 +394,9 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                if(_activeValue) {
                        System.out.println("DEBUG: Actuator " + _sensorId + " is detecting something: " + _activeValue);
                        doorlockStatus.put(_sensorId, true);
-                       //updateIoTCloud(actuator, ACTIVE);
                } else {
                        //System.out.println("DEBUG: Actuator " + _sensorId + " is not detecting something: " + _activeValue);
                        doorlockStatus.put(_sensorId, false);
-                       //updateIoTCloud(actuator, NOT_ACTIVE);
                }
        }
 
@@ -455,15 +432,13 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                        System.out.println("DEBUG: Camera detected something!");
                        for(CameraSmart cam : cameras) {
                                camDetectStatus.put(cam, true);
-                               //updateIoTCloud("camera", ACTIVE);
                        }
                } else {
 
                        // No motion was detected
-                       //System.out.println("DEBUG: Camera didn't detect anything!");
+                       System.out.println("DEBUG: Camera didn't detect anything!");
                        for(CameraSmart cam : cameras) {
                                camDetectStatus.put(cam, false);
-                               //updateIoTCloud("camera", NOT_ACTIVE);
                        }
                }
        }
@@ -511,7 +486,6 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                        int doorId = doorlock.getId();
                        System.out.println("DEBUG: Lock doorlock! ID: " + doorId);
                        doorlockStatus.put(doorId, true);
-                       //updateIoTCloud("doorlock" + doorId, ACTIVE);
                }
        }
 
@@ -558,7 +532,6 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                        for (SmartthingsSensorSmart sensor : roomSensorRelation.get(room)) {
 
                                // Get the right sensor and the right detection status (true or false)
-                               //System.out.println("ABOUT TO DETECT: Reading sensor: " + sensor.getId());
                                if (senDetectStatus.get(sensor.getId())) {
                                        zoneId = room.getRoomID();
                                        turnOnAlarms(zoneId);
@@ -624,9 +597,6 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
         */
        public void init() {
 
-               // Initialize IoTCloud server
-               initIoTCloudServer();
-
                // Iterate over the set of rooms
                for (RoomSmart rm : roomSet.values()) {
 
@@ -642,6 +612,9 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                // Init all cameras
                initCameras();
 
+               // Initialize IoTCloud server
+               initIoTCloudServer();
+
                System.out.println("DEBUG: Initialized all devices! Now starting detection loop!");
 
                // Run the main loop that will keep checking the sensors and cameras periodically
index 5cb630b..3ba1d43 100644 (file)
@@ -16,8 +16,8 @@ CHECKER_OPT = -processor iotchecker.IoTJavaChecker -AprintErrorStack
 
 ASTUBS = -Astubs=../../../checker/astubs/ 
 
-all: light camera labroom greenlawn sprinkler blossomsprinkler moisture weathergateway audioroom gpsgateway ihome homeroom alarm motion multipurpose waterleak doorlock doorlockactuator
-check-all: check-light check-camera check-labroom check-greenlawn check-sprinkler check-blossomsprinkler check-moisture check-weathergateway check-audioroom check-gpsgateway check-ihome check-homeroom check-alarm check-motion check-multipurpose check-waterleak check-doorlock check-doorlockactuator
+all: light camera labroom greenlawn sprinkler blossomsprinkler moisture weathergateway audioroom gpsgateway ihome homeroom alarm motion multipurpose waterleak doorlock doorlockactuator dlink-alarm
+check-all: check-light check-camera check-labroom check-greenlawn check-sprinkler check-blossomsprinkler check-moisture check-weathergateway check-audioroom check-gpsgateway check-ihome check-homeroom check-alarm check-motion check-multipurpose check-waterleak check-doorlock check-doorlockactuator check-dlink-alarm
 
 # Compile - without checker
 #