From 3f7f321df88865c44ce21ba16b344be6718b9472 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Tue, 10 Apr 2018 09:18:04 -0700 Subject: [PATCH] Cleaning up benchmarks and drivers code. --- .../MotionDetection.java | 33 +----------- .../IrrigationController/MotionDetection.java | 17 ++---- benchmarks/Java/Lifxtest/Lifxtest.java | 11 ++-- .../MotionDetection.java | 15 +----- .../Java/AmcrestCamera/AmcrestCamera.java | 7 ++- .../BlossomSprinkler/BlossomSprinkler.java | 2 - .../drivers/Java/DlinkAlarm/DlinkAlarm.java | 1 - .../DoorlockActuator/DoorlockActuator.java | 18 +++---- .../Java/DoorlockSensor/DoorlockSensor.java | 17 ++---- .../drivers/Java/EspAlarm/EspAlarm.java | 6 +-- .../Java/EspSprinkler/EspSprinkler.java | 9 ---- .../Java/GPSPhoneGateway/GPSPhoneGateway.java | 53 ++++++------------- benchmarks/drivers/Java/IHome/IHome.java | 8 +-- .../Java/LifxLightBulb/LifxLightBulb.java | 14 +---- .../Java/MotionSensor/MotionSensor.java | 14 ++--- .../MultipurposeSensor.java | 24 ++++----- .../Java/SpruceSensor/SpruceSensor.java | 4 -- .../Java/WaterLeakSensor/WaterLeakSensor.java | 22 ++++---- .../WeatherPhoneGateway.java | 41 +------------- 19 files changed, 79 insertions(+), 237 deletions(-) diff --git a/benchmarks/Java/HomeSecurityController/MotionDetection.java b/benchmarks/Java/HomeSecurityController/MotionDetection.java index dceeb7f..bb6ffc6 100644 --- a/benchmarks/Java/HomeSecurityController/MotionDetection.java +++ b/benchmarks/Java/HomeSecurityController/MotionDetection.java @@ -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) { - - // } - - // } } diff --git a/benchmarks/Java/IrrigationController/MotionDetection.java b/benchmarks/Java/IrrigationController/MotionDetection.java index 0ae1e70..c6f8279 100644 --- a/benchmarks/Java/IrrigationController/MotionDetection.java +++ b/benchmarks/Java/IrrigationController/MotionDetection.java @@ -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 { diff --git a/benchmarks/Java/Lifxtest/Lifxtest.java b/benchmarks/Java/Lifxtest/Lifxtest.java index 64469f5..b968682 100644 --- a/benchmarks/Java/Lifxtest/Lifxtest.java +++ b/benchmarks/Java/Lifxtest/Lifxtest.java @@ -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(); } } } diff --git a/benchmarks/Java/SmartLightsController/MotionDetection.java b/benchmarks/Java/SmartLightsController/MotionDetection.java index 8491318..c3346e7 100644 --- a/benchmarks/Java/SmartLightsController/MotionDetection.java +++ b/benchmarks/Java/SmartLightsController/MotionDetection.java @@ -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) { diff --git a/benchmarks/drivers/Java/AmcrestCamera/AmcrestCamera.java b/benchmarks/drivers/Java/AmcrestCamera/AmcrestCamera.java index f186be1..b57d6ee 100644 --- a/benchmarks/drivers/Java/AmcrestCamera/AmcrestCamera.java +++ b/benchmarks/drivers/Java/AmcrestCamera/AmcrestCamera.java @@ -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 set = new HashSet(); set.add(iotDevAdd); diff --git a/benchmarks/drivers/Java/BlossomSprinkler/BlossomSprinkler.java b/benchmarks/drivers/Java/BlossomSprinkler/BlossomSprinkler.java index 42145a1..483d3c2 100644 --- a/benchmarks/drivers/Java/BlossomSprinkler/BlossomSprinkler.java +++ b/benchmarks/drivers/Java/BlossomSprinkler/BlossomSprinkler.java @@ -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 diff --git a/benchmarks/drivers/Java/DlinkAlarm/DlinkAlarm.java b/benchmarks/drivers/Java/DlinkAlarm/DlinkAlarm.java index c1232b9..59a129f 100644 --- a/benchmarks/drivers/Java/DlinkAlarm/DlinkAlarm.java +++ b/benchmarks/drivers/Java/DlinkAlarm/DlinkAlarm.java @@ -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. diff --git a/benchmarks/drivers/Java/DoorlockActuator/DoorlockActuator.java b/benchmarks/drivers/Java/DoorlockActuator/DoorlockActuator.java index 09eb539..be92eff 100644 --- a/benchmarks/drivers/Java/DoorlockActuator/DoorlockActuator.java +++ b/benchmarks/drivers/Java/DoorlockActuator/DoorlockActuator.java @@ -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()) { diff --git a/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java b/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java index a3ea772..ac3b7f7 100644 --- a/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java +++ b/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java @@ -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()) { diff --git a/benchmarks/drivers/Java/EspAlarm/EspAlarm.java b/benchmarks/drivers/Java/EspAlarm/EspAlarm.java index a162ed9..484e71e 100644 --- a/benchmarks/drivers/Java/EspAlarm/EspAlarm.java +++ b/benchmarks/drivers/Java/EspAlarm/EspAlarm.java @@ -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 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; diff --git a/benchmarks/drivers/Java/EspSprinkler/EspSprinkler.java b/benchmarks/drivers/Java/EspSprinkler/EspSprinkler.java index 41c9ac0..bb40a72 100644 --- a/benchmarks/drivers/Java/EspSprinkler/EspSprinkler.java +++ b/benchmarks/drivers/Java/EspSprinkler/EspSprinkler.java @@ -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 @@ -370,10 +368,3 @@ public class EspSprinkler implements Sprinkler { } - - - - - - - diff --git a/benchmarks/drivers/Java/GPSPhoneGateway/GPSPhoneGateway.java b/benchmarks/drivers/Java/GPSPhoneGateway/GPSPhoneGateway.java index 7f401ae..65ac9b5 100644 --- a/benchmarks/drivers/Java/GPSPhoneGateway/GPSPhoneGateway.java +++ b/benchmarks/drivers/Java/GPSPhoneGateway/GPSPhoneGateway.java @@ -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(); - }*/ } + diff --git a/benchmarks/drivers/Java/IHome/IHome.java b/benchmarks/drivers/Java/IHome/IHome.java index b7ba3b4..b9ced38 100644 --- a/benchmarks/drivers/Java/IHome/IHome.java +++ b/benchmarks/drivers/Java/IHome/IHome.java @@ -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 */ diff --git a/benchmarks/drivers/Java/LifxLightBulb/LifxLightBulb.java b/benchmarks/drivers/Java/LifxLightBulb/LifxLightBulb.java index 909a90c..858b3f4 100644 --- a/benchmarks/drivers/Java/LifxLightBulb/LifxLightBulb.java +++ b/benchmarks/drivers/Java/LifxLightBulb/LifxLightBulb.java @@ -97,7 +97,7 @@ public class LifxLightBulb implements LightBulb { @config private IoTSet 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); } diff --git a/benchmarks/drivers/Java/MotionSensor/MotionSensor.java b/benchmarks/drivers/Java/MotionSensor/MotionSensor.java index 23e31b5..ee21195 100644 --- a/benchmarks/drivers/Java/MotionSensor/MotionSensor.java +++ b/benchmarks/drivers/Java/MotionSensor/MotionSensor.java @@ -45,10 +45,12 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor { @config private IoTSet motionSensorUdpAddress; @config private IoTSet motionSensorZigbeeAddress; + // TODO: Test constructor //public MotionSensor(IoTSet dSet, IoTSet 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()) { diff --git a/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java b/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java index 5b91b4e..3f3266a 100644 --- a/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java +++ b/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java @@ -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 multipurposeSensorUdpAddress; @config private IoTSet multipurposeSensorZigbeeAddress; + // TODO: Test constructor //public MultipurposeSensor(IoTSet dSet, IoTSet 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) { diff --git a/benchmarks/drivers/Java/SpruceSensor/SpruceSensor.java b/benchmarks/drivers/Java/SpruceSensor/SpruceSensor.java index d0b0f11..2df9b7c 100644 --- a/benchmarks/drivers/Java/SpruceSensor/SpruceSensor.java +++ b/benchmarks/drivers/Java/SpruceSensor/SpruceSensor.java @@ -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; diff --git a/benchmarks/drivers/Java/WaterLeakSensor/WaterLeakSensor.java b/benchmarks/drivers/Java/WaterLeakSensor/WaterLeakSensor.java index 7a28cbe..ec8c5e1 100644 --- a/benchmarks/drivers/Java/WaterLeakSensor/WaterLeakSensor.java +++ b/benchmarks/drivers/Java/WaterLeakSensor/WaterLeakSensor.java @@ -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 waterleakSensorUdpAddress; @config private IoTSet waterleakSensorZigbeeAddress; + // TODO: Test constructor //public WaterLeakSensor(IoTSet dSet, IoTSet 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) { diff --git a/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherPhoneGateway.java b/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherPhoneGateway.java index 7ac5b85..1d5944c 100644 --- a/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherPhoneGateway.java +++ b/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherPhoneGateway.java @@ -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(); -// } } -- 2.34.1