Cleaning up benchmarks and drivers code.
authorrtrimana <rtrimana@uci.edu>
Tue, 10 Apr 2018 16:18:04 +0000 (09:18 -0700)
committerrtrimana <rtrimana@uci.edu>
Tue, 10 Apr 2018 16:18:04 +0000 (09:18 -0700)
19 files changed:
benchmarks/Java/HomeSecurityController/MotionDetection.java
benchmarks/Java/IrrigationController/MotionDetection.java
benchmarks/Java/Lifxtest/Lifxtest.java
benchmarks/Java/SmartLightsController/MotionDetection.java
benchmarks/drivers/Java/AmcrestCamera/AmcrestCamera.java
benchmarks/drivers/Java/BlossomSprinkler/BlossomSprinkler.java
benchmarks/drivers/Java/DlinkAlarm/DlinkAlarm.java
benchmarks/drivers/Java/DoorlockActuator/DoorlockActuator.java
benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java
benchmarks/drivers/Java/EspAlarm/EspAlarm.java
benchmarks/drivers/Java/EspSprinkler/EspSprinkler.java
benchmarks/drivers/Java/GPSPhoneGateway/GPSPhoneGateway.java
benchmarks/drivers/Java/IHome/IHome.java
benchmarks/drivers/Java/LifxLightBulb/LifxLightBulb.java
benchmarks/drivers/Java/MotionSensor/MotionSensor.java
benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java
benchmarks/drivers/Java/SpruceSensor/SpruceSensor.java
benchmarks/drivers/Java/WaterLeakSensor/WaterLeakSensor.java
benchmarks/drivers/Java/WeatherPhoneGateway/WeatherPhoneGateway.java

index dceeb7f97740ccbc40d491c3d4b5dc11ea83dff8..bb6ffc63acfeb0201659a7ae62f6077fba7bd7c2 100644 (file)
@@ -415,10 +415,7 @@ class MotionDetection implements CameraCallback {
                                // Motion was detected so issue callbacks to all objects that registered
                                // to receive callback from this class.
                                for (MotionDetectionCallback c : callbackList) {
-                                       //try {
-                                               c.motionDetected(this);
-                                       //} catch (RemoteException re) {
-                                       //}
+                                       c.motionDetected(this);
                                }
 
                        } else {
@@ -431,33 +428,5 @@ class MotionDetection implements CameraCallback {
                        }
                }
        }
-
-
-
-
-       // /*******************************************************************************************************************************************
-       // **  Main Method used for testing
-       // *******************************************************************************************************************************************/
-       // public static void main(String[] args) {
-       //     MotionDetection mo = new MotionDetection(12, 0.5f, 10, 10);
-
-       //     AmcrestCamera cam = null;
-       //     try {
-
-       //         InetAddress addr = InetAddress.getByName("192.168.1.29");
-       //         cam = new AmcrestCamera(addr, "admin", "55779CatSoundz32");
-       //         cam.registerCallback(mo);
-       //         cam.start();
-       //         // cam.streamDisconnect();
-
-       //     } catch (Exception e) {
-
-       //     }
-
-       //     while (true) {
-
-       //     }
-
-       // }
 }
 
index 0ae1e70ced0155387b072846b3134677401ba570..c6f82793eca19e0cde41eb0c60ba4dac8ce82844 100644 (file)
@@ -257,7 +257,6 @@ class MotionDetection extends UnicastRemoteObject implements CameraCallback {
 
                try {
                        // Parse the byte array into a Buffered Image
-                       //InputStream in = new ByteArrayInputStream(_camera.getLatestFrame());
                        InputStream in = new ByteArrayInputStream(latestFrame);
                        img = ImageIO.read(in);
 
@@ -273,16 +272,11 @@ class MotionDetection extends UnicastRemoteObject implements CameraCallback {
 
                // Save the image and timestamp for use later
                imageWriteLock.lock();                  // lock the image and timestamp buffers since multithread
-               latestImage = img;                                      // image into image buffer
+               latestImage = img;                              // image into image buffer
 
                // timestamp from camera into timestamo buffer
-               //try {
-                       //long dateLong = _camera.getTimestamp();
-                       long dateLong = timeStamp;
-                       possibleDate = new Date(dateLong);
-               //} catch (RemoteException e) {
-               //      e.printStackTrace();
-               //}
+               long dateLong = timeStamp;
+               possibleDate = new Date(dateLong);
 
                imageWriteLock.unlock();                // Never forget to unlock
 
@@ -416,10 +410,7 @@ class MotionDetection extends UnicastRemoteObject implements CameraCallback {
                                // Motion was detected so issue callbacks to all objects that registered
                                // to receive callback from this class.
                                for (MotionDetectionCallback c : callbackList) {
-                                       //try {
-                                               c.motionDetected(this.getTimestampOfLastMotion());
-                                       //} catch (RemoteException re) {
-                                       //}
+                                       c.motionDetected(this.getTimestampOfLastMotion());
                                }
 
                        } else {
index 64469f5481a68b5f2172dc3db83f4635fb273197..b968682b2f3be42772cd1d31caf55d65e8abf796 100644 (file)
@@ -27,12 +27,8 @@ public class Lifxtest {
        public void init() throws InterruptedException {
 
                for(LightBulbTest lifx : lifx_light_bulb.values()) {
-                       //Thread thread = new Thread(new Runnable() {
-                       //      public void run() {
-                                       lifx.init();
-                       //      }
-                       //});
-                       //thread.start();
+
+                       lifx.init();
                        Thread.sleep(1000);
 
                        for (int i = 0; i < 5; i++) {
@@ -68,8 +64,7 @@ public class Lifxtest {
                                lifx.setColor(lifx.getHue(), lifx.getSaturation(), i);
                                Thread.sleep(500);
                        }
-                        lifx.turnOff();
-                       //thread.join();
+                       lifx.turnOff();
                }
        }
 }
index 84913186479c51f531299fd8fb5a297a4791c739..c3346e713763fa2ea9265b56a17ea57bc20199e1 100644 (file)
@@ -258,13 +258,9 @@ class MotionDetection implements CameraCallback {
         *   @return [void] None.
         */
        public void newCameraFrameAvailable(byte[] latestFrame, long timeStamp) {
-       //public void newCameraFrameAvailable(CameraSmart _camera) {
                BufferedImage img = null;
                
-               //byte[] newImg = _camera.getLatestFrame();
                try {
-                       //InputStream in = new ByteArrayInputStream(_camera.getLatestFrame());
-                       //InputStream in = new ByteArrayInputStream(newImg);
                        // Parse the byte array into a Buffered Image
                        InputStream in = new ByteArrayInputStream(latestFrame);
                        img = ImageIO.read(in);
@@ -285,7 +281,6 @@ class MotionDetection implements CameraCallback {
 
                // timestamp from camera into timestamp buffer
                long dateLong = timeStamp;
-               //long dateLong = _camera.getTimestamp();
                //System.out.println("DEBUG: New image at time: " + dateLong);
                possibleDate = new Date(dateLong);
 
@@ -424,10 +419,7 @@ class MotionDetection implements CameraCallback {
                                // Motion was detected so issue callbacks to all objects that registered
                                // to receive callback from this class.
                                for (MotionDetectionCallback c : callbackList) {
-                                       //try {
-                                               c.motionDetected(this);
-                                       //} catch (RemoteException re) {
-                                       //}
+                                       c.motionDetected(this);
                                }
 
                        } else {
@@ -442,8 +434,6 @@ class MotionDetection implements CameraCallback {
        }
 
 
-
-
        // /*******************************************************************************************************************************************
        // **  Main Method used for testing
        // *******************************************************************************************************************************************/
@@ -454,10 +444,9 @@ class MotionDetection implements CameraCallback {
        //     try {
 
        //         InetAddress addr = InetAddress.getByName("192.168.1.29");
-       //         cam = new AmcrestCamera(addr, "admin", "55779CatSoundz32");
+       //         cam = new AmcrestCamera(addr, "admin", "admin");
        //         cam.registerCallback(mo);
        //         cam.start();
-       //         // cam.streamDisconnect();
 
        //     } catch (Exception e) {
 
index f186be19adb53c31cfd3171736dbbff9fce24e16..b57d6eeeed1fabcfd41e10a52a0ecaa4fde30d42 100644 (file)
@@ -41,9 +41,6 @@ import java.util.concurrent.Semaphore;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 
-// Checker annotations
-//import iotchecker.qual.*;
-
 public class AmcrestCamera implements Camera {
 
        /*******************************************************************************************************************************************
@@ -528,7 +525,9 @@ public class AmcrestCamera implements Camera {
        public static void main(String[] args) throws Exception {
 
                System.out.println("Running AmcrestCamera!");
-
+               
+               // The constructor for IoTDeviceAddress needs to be changed temporarily to make this
+               // to work.
                IoTDeviceAddress iotDevAdd = new IoTDeviceAddress(args[0], 12345, 80, false, false);
                Set<IoTDeviceAddress> set = new HashSet<IoTDeviceAddress>();
                set.add(iotDevAdd);
index 42145a1b73764b1d84ef6738231506e2c1dfe2ca..483d3c2574040331f52f4a9745ec5ee18522a308 100644 (file)
@@ -26,8 +26,6 @@ import iotcode.annotation.*;
 import iotcode.interfaces.ZoneState;
 import iotcode.interfaces.Sprinkler;
 
-//import iotchecker.qual.*;
-
 /** Class BlossomSprinkler for the Blossom Sprinkler.
  *
  * @author      Ali Younis <ayounis @ uci.edu>
index c1232b9b1062180d5c2aa0e7a7b92b7df1a77660..59a129f949b8a7959c7b6c9caa82c35ed7da268a 100644 (file)
@@ -28,7 +28,6 @@ import iotruntime.slave.IoTSet;
 import iotcode.interfaces.ZoneState;
 import iotcode.interfaces.Alarm;
 
-//import iotchecker.qual.*;
 import iotcode.annotation.*;
 
 /** Class DlinkAlarm for the D-Link Alarm.
index 09eb5398b5e9dca50930508fb28a94c3d7867363..be92effb66bfe09e1a2e5390d1aedcb34bab9285 100644 (file)
@@ -6,11 +6,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Semaphore;
 
-// Checker annotations
-//import iotchecker.qual.*;
-import iotcode.annotation.*;
-
 // IoT Packages
+import iotcode.annotation.*;
 import iotruntime.slave.*;
 import iotcode.interfaces.*;
 import iotruntime.zigbee.*;
@@ -37,7 +34,7 @@ public class DoorlockActuator implements IoTZigbeeCallback, SmartthingsActuator
        private AtomicBoolean didWriteAttrb = new AtomicBoolean(false);
        private AtomicBoolean didMatchDscr = new AtomicBoolean(false);
        private AtomicBoolean didBind = new AtomicBoolean(false);
-       private AtomicBoolean didDoorLockConfigureReporting = new AtomicBoolean(false); //made by Jiawei
+       private AtomicBoolean didDoorLockConfigureReporting = new AtomicBoolean(false); // made by Jiawei
        static Semaphore gettingLatestDataMutex = new Semaphore(1);
 
        private List < SmartthingsActuatorSmartCallback > callbackList = new CopyOnWriteArrayList < SmartthingsActuatorSmartCallback > ();
@@ -88,14 +85,11 @@ public class DoorlockActuator implements IoTZigbeeCallback, SmartthingsActuator
 
 
             
-                       //made by changwoo
+                       // made by Changwoo
                        sleep(10);
 
-            // System.out.println("BroadcastingRouteRecordRequest ");
-                       // zigConnection.sendBroadcastingRouteRecordRequest(0x0001);
-            // sleep(6);
-
                        System.out.println("Sending Management Permit Joining Request");
+                       // TODO: Might/might not need to send this 3 times
                        // for(int z=0; z<3; z++){
                                zigConnection.sendManagementPermitJoiningRequest(0x0002, 0x0036, 0x00);
                                sleep(0);
@@ -159,7 +153,7 @@ public class DoorlockActuator implements IoTZigbeeCallback, SmartthingsActuator
                }
        }
 
-       //made by changwoo
+       // made by Changwoo
        private void sleep(int multipleTime){
                if(multipleTime<=0){
                        multipleTime=1;
@@ -251,7 +245,7 @@ public class DoorlockActuator implements IoTZigbeeCallback, SmartthingsActuator
 
        public void newMessageAvailable(IoTZigbeeMessage _zm) {
                
-               //made by yuting
+               // made by Yuting
                if (_zm instanceof IoTZigbeeMessageZdoBindResponse) {
                        IoTZigbeeMessageZdoBindResponse message = (IoTZigbeeMessageZdoBindResponse)_zm;
                        if (message.getSucceeded()) {
index a3ea7721e74edcbb529e2154d10f4bf2716c2f26..ac3b7f77ac494c65c6058f668f6e261fc61dc35a 100644 (file)
@@ -6,11 +6,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Semaphore;
 
-// Checker annotations
-//import iotchecker.qual.*;
-import iotcode.annotation.*;
-
 // IoT Packages
+import iotcode.annotation.*;
 import iotruntime.slave.*;
 import iotcode.interfaces.*;
 import iotruntime.zigbee.*;
@@ -37,7 +34,7 @@ public class DoorlockSensor implements IoTZigbeeCallback, SmartthingsSensor {
        private AtomicBoolean didWriteAttrb = new AtomicBoolean(false);
        private AtomicBoolean didMatchDscr = new AtomicBoolean(false);
        private AtomicBoolean didBind = new AtomicBoolean(false);
-       private AtomicBoolean didDoorLockConfigureReporting = new AtomicBoolean(false); //made by Jiawei
+       private AtomicBoolean didDoorLockConfigureReporting = new AtomicBoolean(false); // made by Jiawei
        static Semaphore gettingLatestDataMutex = new Semaphore(1);
 
        private List < SmartthingsSensorSmartCallback > callbackList = new CopyOnWriteArrayList < SmartthingsSensorSmartCallback > ();
@@ -91,11 +88,8 @@ public class DoorlockSensor implements IoTZigbeeCallback, SmartthingsSensor {
                        //made by changwoo
                        sleep(10);
 
-            // System.out.println("BroadcastingRouteRecordRequest ");
-                       // zigConnection.sendBroadcastingRouteRecordRequest(0x0001);
-            // sleep(6);
-
                        System.out.println("Sending Management Permit Joining Request");
+                       // TODO: Might/might not need to send this 3 times
                        // for(int z=0; z<3; z++){
                                zigConnection.sendManagementPermitJoiningRequest(0x0002, 0x0036, 0x00);
                                sleep(0);
@@ -141,7 +135,7 @@ public class DoorlockSensor implements IoTZigbeeCallback, SmartthingsSensor {
                }
        }
 
-       //made by changwoo
+       // made by Changwoo
        private void sleep(int multipleTime){
                if(multipleTime<=0){
                        multipleTime=1;
@@ -154,7 +148,6 @@ public class DoorlockSensor implements IoTZigbeeCallback, SmartthingsSensor {
        }
 
        // made by Jiawei
-    //public int getStatus() {
        public int getValue() {
                int tmp = 0;
 
@@ -233,7 +226,7 @@ public class DoorlockSensor implements IoTZigbeeCallback, SmartthingsSensor {
 
        public void newMessageAvailable(IoTZigbeeMessage _zm) {
                
-               //made by yuting
+               // made by Yuting
                if (_zm instanceof IoTZigbeeMessageZdoBindResponse) {
                        IoTZigbeeMessageZdoBindResponse message = (IoTZigbeeMessageZdoBindResponse)_zm;
                        if (message.getSucceeded()) {
index a162ed93698527e8fb01f4cfd066d345f8d75297..484e71ea3563f3309940b745f9c08885da8ca587 100644 (file)
@@ -18,8 +18,6 @@ import iotruntime.slave.IoTDeviceAddress;
 import iotruntime.slave.IoTSet;
 import iotcode.interfaces.ZoneState;
 import iotcode.interfaces.Alarm;
-
-//import iotchecker.qual.*;
 import iotcode.annotation.*;
 
 /** Class EspAlarm for the ESP8266 plrg Alarm.
@@ -64,7 +62,8 @@ public class EspAlarm implements Alarm {
        // Will be filled with only 1 address.
        @config private IoTSet<IoTDeviceAddress> alm_Addresses;
 
-       /*public EspSprinkler(IoTUDP _udp) {
+       /* TODO: Use this constructor to test this driver manually
+       public EspSprinkler(IoTUDP _udp) {
                communicationSockect = _udp;
        }*/
 
@@ -271,7 +270,6 @@ public class EspAlarm implements Alarm {
                        boolean onOff = onOffInt != 0;
                        int duration = Integer.parseInt(splitSting[2].trim());
 
-                       //ZoneState zTmp = new ZoneState(zoneNum, onOff, duration);
                        ZoneState zTmp = new ZoneState();
                        zTmp.zoneNumber = zoneNum;
                        zTmp.onOffState = onOff;
index 41c9ac0a2b925ac449345a33db1df36a0f38679f..bb40a7258f1372a310e6a9144aeb85a44bf8c6aa 100644 (file)
@@ -20,8 +20,6 @@ import iotcode.interfaces.ZoneState;
 import iotcode.interfaces.Sprinkler;
 import iotcode.annotation.*;
 
-//import iotchecker.qual.*;
-
 /** Class EspSprinkler for the ESP8266 plrg Sprinkler.
  *
  * @author      Ali Younis <ayounis @ uci.edu>
@@ -370,10 +368,3 @@ public class EspSprinkler implements Sprinkler {
 
 }
 
-
-
-
-
-
-
-
index 7f401ae35a6b3fed8cbcb8833c3f8ce0aa6f5085..65ac9b5cc9c8bb86aad6478834baa9a88c4f2a0e 100644 (file)
@@ -18,8 +18,6 @@ import iotruntime.slave.IoTDeviceAddress;
 import iotcode.annotation.*;
 import iotcode.interfaces.*;
 
-// Checker annotations
-//import iotchecker.qual.*;
 
 /** GPSPhoneGateway that uses IoTRemoteCall and PhoneInfo class
  *  to get information from a phone app
@@ -57,10 +55,6 @@ public class GPSPhoneGateway implements GPSGateway {
                // Get address
                Iterator it = gps_address.iterator();
                iotDevAdd = (IoTDeviceAddress) it.next();
-//             try {
-//                     iotDevAdd = new IoTDeviceAddress("192.168.2.100", 1234, 8000);
-//             } catch (Exception ex) {
-//             }
                System.out.println("Address: " + iotDevAdd.getCompleteAddress());
                System.out.println("Source port: " + iotDevAdd.getSourcePortNumber());
                System.out.println("Destination port: " + iotDevAdd.getDestinationPortNumber());
@@ -138,34 +132,27 @@ public class GPSPhoneGateway implements GPSGateway {
 
                        for (GPSGatewaySmartCallback c : listPGWCallback) {
 
-                               //try {
-                                       // Only call back if there is new data  
-                                       if (phoneInfo.isNewRoomIDAvailable()) {
+                               // Only call back if there is new data  
+                               if (phoneInfo.isNewRoomIDAvailable()) {
 
-                                               System.out.println("GPSPhoneGateway: new room ID available - call back!");
-                                               // Call back!
-                                               //c.newRoomIDRetrieved(this);
-                                               c.newRoomIDRetrieved(this.getRoomID());
-                                               //this.setNewRoomIDAvailable(false);
+                                       System.out.println("GPSPhoneGateway: new room ID available - call back!");
+                                       // Call back!
+                                       //c.newRoomIDRetrieved(this);
+                                       c.newRoomIDRetrieved(this.getRoomID());
+                                       //this.setNewRoomIDAvailable(false);
 
-                                               // Set back to false after reading
-                                               phoneInfo.setNewRoomIDAvailable(false);
+                                       // Set back to false after reading
+                                       phoneInfo.setNewRoomIDAvailable(false);
 
-                                       } else if (phoneInfo.isNewRingStatusAvailable()) {
+                               } else if (phoneInfo.isNewRingStatusAvailable()) {
 
-                                               System.out.println("GPSPhoneGateway: new ring status available - call back!");
-                                               // Call back!
-                                               //c.newRingStatusRetrieved(this);
-                                               c.newRingStatusRetrieved(this.getRingStatus());
-                                               //this.setNewRingStatusAvailable(false);
+                                       System.out.println("GPSPhoneGateway: new ring status available - call back!");
+                                       // Call back!
+                                       c.newRingStatusRetrieved(this.getRingStatus());
 
-                                               // Set back to false after reading
-                                               phoneInfo.setNewRingStatusAvailable(false);
-                                       }
-
-                               //} catch (RemoteException ex) {
-                               //      ex.printStackTrace();
-                               //}
+                                       // Set back to false after reading
+                                       phoneInfo.setNewRingStatusAvailable(false);
+                               }
                        }
                }
        }
@@ -201,11 +188,5 @@ public class GPSPhoneGateway implements GPSGateway {
 
                phoneInfo.setNewRingStatusAvailable(bValue);
        }
-
-/*     public static void main(String[] args) throws UnknownHostException, RemoteException {
-
-               @LocalRemote GPSPhoneGateway gpg = new @LocalRemote GPSPhoneGateway();
-               gpg.init();
-               gpg.start();
-       }*/
 }
+
index b7ba3b4414d9cb0f1405ea10118f81b47d062db5..b9ced38da6dcde4eed6e53fc11381317568de712 100644 (file)
@@ -695,7 +695,7 @@ public class IHome implements Speaker {
                     // System.out.println(packetData);
 
                 } catch (Exception e) {
-                    // e.printStackTrace();
+                    e.printStackTrace();
                 }
 
 
@@ -706,10 +706,10 @@ public class IHome implements Speaker {
 
 
                 if (first) {
-                    sendData[0] = (byte)0x90;                       // Header bit field
+                    sendData[0] = (byte)0x90;               // Header bit field
                     first = false;
                 } else {
-                    sendData[0] = (byte)0x80;                       // Header bit field
+                    sendData[0] = (byte)0x80;               // Header bit field
                 }
 
 
@@ -978,7 +978,7 @@ public class IHome implements Speaker {
     }
        
        
-       // TODO: REMOVE THIS
+       // TODO: The following is only for test
        /**
         * Prepare the speakers for a new song to start playing
         */
index 909a90c4b7e936ba86604157d34c9670add98270..858b3f4dbc28acd7481feb6c778e30554525f2b2 100644 (file)
@@ -97,7 +97,7 @@ public class LifxLightBulb implements LightBulb {
        @config private IoTSet<IoTDeviceAddress> lb_addresses;
 
        /**
-        * Used for testing only
+        * TODO: Used for testing only
         */
        /*public LifxLightBulb(IoTUDP udp, byte[] macAddress) {
                communicationSockect = udp;
@@ -111,18 +111,6 @@ public class LifxLightBulb implements LightBulb {
 
        public LifxLightBulb(String macAddress) {
                communicationSockect = null;
-
-               // Set the Mac Address to a default value
-               // Probably not needed for anything
-               /*bulbMacAdd[0] = (byte)0x00;
-                  bulbMacAdd[1] = (byte)0x00;
-                  bulbMacAdd[2] = (byte)0x00;
-                  bulbMacAdd[3] = (byte)0x00;
-                  bulbMacAdd[4] = (byte)0x00;
-                  bulbMacAdd[5] = (byte)0x00;
-                  bulbMacAdd[6] = (byte)0x00;
-                  bulbMacAdd[7] = (byte)0x00;*/
-
                bulbMacAddress = DatatypeConverter.parseHexBinary(macAddress);
        }
 
index 23e31b59ca8d8a3d4a94a24d5220a7d92e82b3ab..ee2119550c8f6397f3ce91f953b3c9b76704a334 100644 (file)
@@ -45,10 +45,12 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor {
        @config private IoTSet<IoTDeviceAddress> motionSensorUdpAddress;
        @config private IoTSet<IoTZigbeeAddress> motionSensorZigbeeAddress;
 
+       // TODO: Test constructor
        //public MotionSensor(IoTSet<IoTDeviceAddress> dSet, IoTSet<IoTZigbeeAddress> zigSet) {
                //motionSensorUdpAddress = dSet;
                //motionSensorZigbeeAddress = zigSet;
        //}
+
        public MotionSensor() {
        }
 
@@ -83,7 +85,7 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor {
                        zigConnection.init();
                        System.out.println("Initialized!");
 
-                       //made by changwoo
+                       // made by Changwoo
                        sleep(10);
 
                        System.out.println("Sending Management Permit Joining Request");
@@ -92,14 +94,14 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor {
                                sleep(0);
                        }
                        
-                       //made by changwoo
+                       // made by Changwoo
                        while (!didWriteAttrb.get()) {
                                System.out.println("Sending Write Attribute Request");
                                zigConnection.sendWriteAttributesCommand(0x0002, 0x0500, 0x0104, 0x01);
                                sleep(0);
                        }
 
-                       //made by changwoo
+                       // made by Changwoo
                        System.out.println("Sending Enrollment Reponse");
                        zigConnection.sendEnrollmentResponse(0x0003, 0x0500, 0x0104, 0x01);
                        sleep(0);
@@ -109,7 +111,7 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor {
                }
        }
 
-       //made by changwoo
+       // made by Changwoo
        private void sleep(int multipleTime){
                if(multipleTime<=0){
                        multipleTime=1;
@@ -204,7 +206,7 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor {
 
        public void newMessageAvailable(IoTZigbeeMessage _zm) {
 
-               //made by changwoo
+               // made by Changwoo
                if(_zm instanceof IoTZigbeeMessageZclZoneStatusChangeNotification){
                        IoTZigbeeMessageZclZoneStatusChangeNotification message = (IoTZigbeeMessageZclZoneStatusChangeNotification)_zm;
                        if(message.getSuccessOrFail()){
@@ -227,7 +229,7 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor {
                                }
                        }//if
                
-               //made by changwoo
+               // made by Changwoo
                } else if (_zm instanceof IoTZigbeeMessageZclWriteAttributesResponse) {
                        IoTZigbeeMessageZclWriteAttributesResponse message = (IoTZigbeeMessageZclWriteAttributesResponse)_zm;
                        if (message.getSuccessOrFail()) {
index 5b91b4ef4922393d1d34a0f8f2340b8a4fe90b50..3f3266a754e1d832f78133293c9b579e412288e1 100644 (file)
@@ -6,11 +6,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Semaphore;
 
-// Checker annotations
-//import iotchecker.qual.*;
-import iotcode.annotation.*;
-
 // IoT Packages
+import iotcode.annotation.*;
 import iotruntime.slave.*;
 import iotcode.interfaces.*;
 import iotruntime.zigbee.*;
@@ -45,6 +42,7 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
        @config private IoTSet<IoTDeviceAddress> multipurposeSensorUdpAddress;
        @config private IoTSet<IoTZigbeeAddress> multipurposeSensorZigbeeAddress;
 
+       // TODO: Test constructor
        //public MultipurposeSensor(IoTSet<IoTDeviceAddress> dSet, IoTSet<IoTZigbeeAddress> zigSet) {
                //multipurposeSensorUdpAddress = dSet;
                //multipurposeSensorZigbeeAddress = zigSet;
@@ -82,7 +80,7 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
                        zigConnection.init();
                        System.out.println("Initialized!");
 
-                       //made by changwoo
+                       // made by Changwoo
                        sleep(10);
                        System.out.println("Sending Management Permit Joining Request");
                        for(int z=0; z<3; z++){
@@ -90,14 +88,14 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
                                sleep(0);
                        }
 
-                       //made by changwoo
+                       // made by Changwoo
                        while (!didWriteAttrb.get()) {
                                System.out.println("Sending Write Attribute Request");
                                zigConnection.sendWriteAttributesCommand(0x0002, 0x0500, 0x0104, 0x01);
                                sleep(0);
                        }
 
-                       //made by changwoo
+                       // made by Changwoo
                        System.out.println("Sending Enrollment Reponse");
                        zigConnection.sendEnrollmentResponse(0x0003, 0x0500, 0x0104, 0x01);
                        sleep(0);
@@ -107,7 +105,7 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
                }
        }
 
-       //made by changwoo
+       // made by Changwoo
        private void sleep(int multipleTime){
                if(multipleTime<=0){
                        multipleTime=1;
@@ -200,7 +198,7 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
 
        public void newMessageAvailable(IoTZigbeeMessage _zm) {
 
-               //made by changwoo
+               // made by Changwoo
                if(_zm instanceof IoTZigbeeMessageZclZoneStatusChangeNotification){
                        IoTZigbeeMessageZclZoneStatusChangeNotification message = (IoTZigbeeMessageZclZoneStatusChangeNotification)_zm;
                        if(message.getSuccessOrFail()){
@@ -222,14 +220,14 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
                                }
                        }//if
                
-               //made by changwoo
-               }//if
+               // made by Changwoo
+               }
                else if (_zm instanceof IoTZigbeeMessageZclWriteAttributesResponse) {
                        IoTZigbeeMessageZclWriteAttributesResponse message = (IoTZigbeeMessageZclWriteAttributesResponse)_zm;
                        if (message.getSuccessOrFail()) {
                                didWriteAttrb.set(true);
-                       }//if
-               }//else if
+                       }
+               }
        }
 
        public void registerCallback(SmartthingsSensorSmartCallback _callbackTo) {
index d0b0f11ce4bf1e898b4770e769ea050e7f6d144e..2df9b7c3077f1c2fc3ef77fba01e444e6fc5f154 100644 (file)
@@ -9,10 +9,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Semaphore;
 
-
-// Checker annotations
-//import iotchecker.qual.*;
-
 // IoT Packages
 import iotruntime.slave.*;
 import iotcode.interfaces.MoistureSensor;
index 7a28cbe8c6a6df49de5a4d7dfc644e93d1cdf0bf..ec8c5e17c31cffb98f7ab8bbfd5590c8ac08db8b 100644 (file)
@@ -6,11 +6,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Semaphore;
 
-// Checker annotations
-//import iotchecker.qual.*;
-import iotcode.annotation.*;
-
 // IoT Packages
+import iotcode.annotation.*;
 import iotruntime.slave.*;
 import iotcode.interfaces.*;
 import iotruntime.zigbee.*;
@@ -45,6 +42,7 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor {
        @config private IoTSet<IoTDeviceAddress> waterleakSensorUdpAddress;
        @config private IoTSet<IoTZigbeeAddress> waterleakSensorZigbeeAddress;
 
+       // TODO: Test constructor
        //public WaterLeakSensor(IoTSet<IoTDeviceAddress> dSet, IoTSet<IoTZigbeeAddress> zigSet) {
                //waterleakSensorUdpAddress = dSet;
                //waterleakSensorZigbeeAddress = zigSet;
@@ -83,7 +81,7 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor {
                        zigConnection.init();
                        System.out.println("Initialized!");
 
-                       //made by changwoo
+                       // made by Changwoo
                        sleep(10);
                        System.out.println("Sending Management Permit Joining Request");
                        for(int z=0; z<3; z++){
@@ -91,14 +89,14 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor {
                                sleep(0);
                        }
 
-                       //made by changwoo
+                       // made by Changwoo
                        while (!didWriteAttrb.get()) {
                                System.out.println("Sending Write Attribute Request");
                                zigConnection.sendWriteAttributesCommand(0x0002, 0x0500, 0x0104, 0x01);
                                sleep(0);
                        }
 
-                       //made by changwoo
+                       // made by Changwoo
                        System.out.println("Sending Enrollment Reponse");
                        zigConnection.sendEnrollmentResponse(0x0003, 0x0500, 0x0104, 0x01);
                        sleep(0);
@@ -108,7 +106,7 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor {
                }
        }
 
-       //made by changwoo
+       // made by Changwoo
        private void sleep(int multipleTime){
                if(multipleTime<=0){
                        multipleTime=1;
@@ -201,7 +199,7 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor {
 
        public void newMessageAvailable(IoTZigbeeMessage _zm) {
 
-               //made by changwoo
+               // made by Changwoo
                if(_zm instanceof IoTZigbeeMessageZclZoneStatusChangeNotification){
                        IoTZigbeeMessageZclZoneStatusChangeNotification message = (IoTZigbeeMessageZclZoneStatusChangeNotification)_zm;
                        if(message.getSuccessOrFail()){
@@ -224,14 +222,14 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor {
                                }
                        }//if
                
-               //made by changwoo
-               }//if
+               // made by Changwoo
+               }
                else if (_zm instanceof IoTZigbeeMessageZclWriteAttributesResponse) {
                        IoTZigbeeMessageZclWriteAttributesResponse message = (IoTZigbeeMessageZclWriteAttributesResponse)_zm;
                        if (message.getSuccessOrFail()) {
                                didWriteAttrb.set(true);
                        }//if
-               }//else if
+               }
        }
 
        public void registerCallback(SmartthingsSensorSmartCallback _callbackTo) {
index 7ac5b85be439da3b652cf1c6ecc532db1994a218..1d5944cd17fed9b638eb21b72f66e633fddd2ade 100644 (file)
@@ -18,9 +18,6 @@ import iotruntime.slave.IoTDeviceAddress;
 import iotcode.annotation.*;
 import iotcode.interfaces.*;
 
-// Checker annotations
-//import iotchecker.qual.*;
-
 /** WeatherPhoneProxy that uses IoTRemoteCall and WeatherInfo class
  *  to get information from a phone app
  *
@@ -46,23 +43,6 @@ public class WeatherPhoneGateway implements WeatherGateway {
        /**
         * Constructor
         */
-       /*public WeatherPhoneGateway() throws RemoteException, UnknownHostException {
-
-               iotDevAdd = new IoTDeviceAddress("192.168.2.101", 1234, 8000);
-               weatherInfo = new WeatherInfo();
-
-               // Launch IoTRemoteCall server in a separate thread
-               workerThread = new Thread(new Runnable() {
-                       public void run() {
-                               iotRemCall = new IoTRemoteCall(WeatherInfoInterface.class, 
-                                       weatherInfo, iotDevAdd.getDestinationPortNumber());
-                       }
-               });
-               workerThread.start();
-
-               System.out.println("PhoneGateway is started");
-       
-       }*/
        public WeatherPhoneGateway() {
        }
 
@@ -74,10 +54,6 @@ public class WeatherPhoneGateway implements WeatherGateway {
                // Get address
                Iterator it = ph_address.iterator();
                iotDevAdd = (IoTDeviceAddress) it.next();
-//             try {
-//                     iotDevAdd = new IoTDeviceAddress("192.168.2.101", 1234, 8000);
-//             } catch (Exception ex) {
-//             }
                System.out.println("Address: " + iotDevAdd.getCompleteAddress());
                System.out.println("Source port: " + iotDevAdd.getSourcePortNumber());
                System.out.println("Destination port: " + iotDevAdd.getDestinationPortNumber());
@@ -158,14 +134,9 @@ public class WeatherPhoneGateway implements WeatherGateway {
                                System.out.println("We get into doCallbacks!");
                                System.out.println("weatherInfo.isNewDataAvailable(): " + weatherInfo.isNewDataAvailable());
                                for (WeatherGatewaySmartCallback c : listPGWCallback) {
-                                       //try {
-                                               //c.informationRetrieved(this);
-                                               c.informationRetrieved(this.getInchesPerWeek(), this.getWeatherZipCode(), this.getDaysToWaterOn(), this.getInchesPerMinute());
-                                       //} catch (RemoteException ex) {
-                                       //      ex.printStackTrace();
-                                       //}
-                                       // We have read data - set this back to false
+                                       c.informationRetrieved(this.getInchesPerWeek(), this.getWeatherZipCode(), this.getDaysToWaterOn(), this.getInchesPerMinute());
                                }
+                               // We have read data - set this back to false
                                weatherInfo.setNewDataAvailable(false);
                        }
                }
@@ -202,12 +173,4 @@ public class WeatherPhoneGateway implements WeatherGateway {
 
                return weatherInfo.getInchesPerMinute();
        }
-
-
-//     public static void main(String[] args) throws UnknownHostException, RemoteException {
-
-//             @LocalRemote WeatherPhoneGateway wpg = new @LocalRemote WeatherPhoneGateway();
-//             wpg.init();
-//             wpg.start();
-//     }
 }