X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=benchmarks%2FJava%2FHomeSecurityController%2FHomeSecurityController.java;h=3cf6c366d9881ca4ccce1cf651e9a1696bc888e7;hb=0268a6c65bdbf6984191d01a79cd4c18bbaea9de;hp=09c0527dce1cfe94e6ce4766ceccfc26bf563fc3;hpb=058289ead2515827d0d8ac324f045bf36aa522e1;p=iot2.git diff --git a/benchmarks/Java/HomeSecurityController/HomeSecurityController.java b/benchmarks/Java/HomeSecurityController/HomeSecurityController.java index 09c0527..3cf6c36 100644 --- a/benchmarks/Java/HomeSecurityController/HomeSecurityController.java +++ b/benchmarks/Java/HomeSecurityController/HomeSecurityController.java @@ -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