Adding a (potential) initialization for Alarm; Modifying IoTSocket to allocate a...
authorrtrimana <rtrimana@uci.edu>
Sat, 7 Jan 2017 00:35:38 +0000 (16:35 -0800)
committerrtrimana <rtrimana@uci.edu>
Sat, 7 Jan 2017 00:35:38 +0000 (16:35 -0800)
benchmarks/HomeSecurityController/HomeSecurityController.java
iotjava/iotrmi/Java/IoTSocket.java

index bab46cd50c61d3d7ce72ef1eca066f2bfb13c848..8647f2eedbc5f8f44755524025c6d59b4bf9e69e 100644 (file)
@@ -42,6 +42,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback {
        private static final int CAMERA_FPS = 15;
        private static final int CHECK_TIME_WAIT = 1;                   // in seconds
        private static final int SECOND_TO_TURN_ON = 60;                // in seconds
        private static final int CAMERA_FPS = 15;
        private static final int CHECK_TIME_WAIT = 1;                   // in seconds
        private static final int SECOND_TO_TURN_ON = 60;                // in seconds
+       private static final int SECOND_TO_TURN_OFF = 1;                // in seconds
 
        /**
         *  IoT Sets and Relations
 
        /**
         *  IoT Sets and Relations
@@ -194,6 +195,11 @@ public class HomeSecurityController implements SmartthingsSensorCallback {
                try {
                        alm.init();
                        System.out.println("DEBUG: Initialized alarm!");
                try {
                        alm.init();
                        System.out.println("DEBUG: Initialized alarm!");
+                       // TODO: Check that this initialization works for multiple times - might be that setZone() only works once!
+                       //for (RoomSmart room : roomSet.values()) {
+                       //      turnOffAlarms(room.getRoomID());
+                       //      System.out.println("DEBUG: Initialized alarm for room (turn off): " + room.getRoomID());
+                       //}
                } catch (Exception e) {
                        e.printStackTrace();
                }
                } catch (Exception e) {
                        e.printStackTrace();
                }
@@ -393,7 +399,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback {
                // Get and init the alarm (this single alarm set can serve multiple zones / rooms)
                Iterator alarmIt = alarmSet.iterator();
                AlarmSmart alm = (AlarmSmart) alarmIt.next();
                // Get and init the alarm (this single alarm set can serve multiple zones / rooms)
                Iterator alarmIt = alarmSet.iterator();
                AlarmSmart alm = (AlarmSmart) alarmIt.next();
-               alm.setZone(zoneId, true, SECOND_TO_TURN_ON);
+               alm.setZone(zoneId, true, SECOND_TO_TURN_OFF);
        }
 
 
        }
 
 
@@ -407,7 +413,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback {
                Iterator alarmIt = alarmSet.iterator();
                AlarmSmart alm = (AlarmSmart) alarmIt.next();
                // Turn this alarm off indefinitely
                Iterator alarmIt = alarmSet.iterator();
                AlarmSmart alm = (AlarmSmart) alarmIt.next();
                // Turn this alarm off indefinitely
-               alm.setZone(zoneId, false, -1);
+               alm.setZone(zoneId, false, SECOND_TO_TURN_ON);
        }
 
 
        }
 
 
index ba8af4a43fbe689eff8afcf160d892801cd450cb..75855132bbc9a988d69515da21cf65970278c7e7 100644 (file)
@@ -85,6 +85,12 @@ public abstract class IoTSocket {
                // Receive until maxlen
                if (maxlen>BUFFSIZE) {
                        System.out.println("IoTSocketClient/Server: Sending more bytes then will fit in buffer! Number of bytes: " + maxlen);
                // Receive until maxlen
                if (maxlen>BUFFSIZE) {
                        System.out.println("IoTSocketClient/Server: Sending more bytes then will fit in buffer! Number of bytes: " + maxlen);
+                       // Allocate a bigger array when needed
+                       int newLen = 2;
+                       while (newLen < maxlen) // Shift until we get a new buffer size that's bigger than maxLen (basically power of 2)
+                               newLen = newLen << 1;
+                       System.out.println("IoTSocketClient/Server: Allocating a bigger buffer now with size: " + newLen);
+                       data = new byte[newLen];
                }
                val = new byte[maxlen];
                while (totalbytes < maxlen)
                }
                val = new byte[maxlen];
                while (totalbytes < maxlen)