From: rtrimana Date: Sat, 7 Jan 2017 00:09:52 +0000 (-0800) Subject: Perfecting 4th benchmark; adding needed MySQL config files; maturing Zigbee drivers X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iot2.git;a=commitdiff_plain;h=f4d00be7711e47df2aa3b78f8d4fc5e35dc4bcf0 Perfecting 4th benchmark; adding needed MySQL config files; maturing Zigbee drivers --- diff --git a/benchmarks/HomeSecurityController/HomeSecurityController.java b/benchmarks/HomeSecurityController/HomeSecurityController.java index 5129e4a..bab46cd 100644 --- a/benchmarks/HomeSecurityController/HomeSecurityController.java +++ b/benchmarks/HomeSecurityController/HomeSecurityController.java @@ -131,8 +131,12 @@ public class HomeSecurityController implements SmartthingsSensorCallback { try { // Initialize sensors sen.init(); + System.out.println("DEBUG: Initialized smartthings sensor! ID: " + sensorId + " Room ID: " + rm.getRoomID()); + senDetectStatus.put(sensorId, false); + System.out.println("DEBUG: Initialized sensor detection to false!"); sen.setId(sensorId++); - System.out.println("DEBUG: Initialized smartthings sensor!"); + sen.registerCallback(this); + System.out.println("DEBUG: Registered sensor callback!"); } catch (Exception e) { e.printStackTrace(); } @@ -146,10 +150,10 @@ public class HomeSecurityController implements SmartthingsSensorCallback { */ private void initCameras(RoomSmart rm) { - // Get and init the cameras for this specific room + // Get and init the IAS sensors for this specific room HashSet cameras = roomCameraRelation.get(rm); // Setup the cameras, start them all and assign each one a motion detector - for (CameraSmart cam : camSet.values()) { + for (CameraSmart cam : cameras) { // Each camera will have a motion detector unique to it since the motion detection has state MotionDetection mo = new MotionDetection(12, 0.5f, 10, 10); @@ -170,6 +174,9 @@ public class HomeSecurityController implements SmartthingsSensorCallback { // Remember which motion detector is for what camera camMotionDetect.put(cam, mo); + + // Initialize detection to false + camDetectStatus.put(cam, false); } } @@ -242,9 +249,9 @@ public class HomeSecurityController implements SmartthingsSensorCallback { * @param _numberOfSeconds [int] , Number of seconds in the past that we consider recent. * @param _upperThreshold [int] , Number of seconds as an upper bound before we turn off. * - * @return [void] None. + * @return [boolean] None. */ - private void updateCameraStatus(RoomSmart _room, int _numberOfSeconds) { + private boolean roomDidHaveMotionRecently(RoomSmart _room, int _numberOfSeconds) { long currentTimeSeconds = (new Date()).getTime() / 1000; // Loop through all the cameras in the room @@ -259,14 +266,16 @@ public class HomeSecurityController implements SmartthingsSensorCallback { } else { // motionTime == null means this is the initialization phase // so we put false - camDetectStatus.put(cam, false); + return false; } // Did detect motion recently if (Math.abs(currentTimeSeconds - lastDetectedMotionSeconds) < _numberOfSeconds) { - camDetectStatus.put(cam, true); + return true; } } + + return false; } @@ -278,11 +287,11 @@ public class HomeSecurityController implements SmartthingsSensorCallback { System.out.println("DEBUG: Sensor reading value: " + _value); if(_activeValue) { - + System.out.println("DEBUG: Sensor is detecting something: " + _activeValue); senDetectStatus.put(_sensorId, true); } else { - + //System.out.println("DEBUG: Sensor is not detecting something: " + _activeValue); senDetectStatus.put(_sensorId, false); } } @@ -342,7 +351,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback { for (RoomSmart room : roomSet.values()) { // Update status of camera - updateCameraStatus(room, MOTION_TIME_THRESHOLD); + updateCameraStatus(room); // Update status of doorlocks //updateDoorLockStatus(room); @@ -353,6 +362,28 @@ public class HomeSecurityController implements SmartthingsSensorCallback { } + /** Update the status of all devices + * + * @return [void] None. + */ + private void updateCameraStatus(RoomSmart room) { + + HashSet cameras = roomCameraRelation.get(room); + if (roomDidHaveMotionRecently(room, MOTION_TIME_THRESHOLD)) { + + // Motion was detected + System.out.println("DEBUG: Camera detected something!"); + for(CameraSmart cam : cameras) + camDetectStatus.put(cam, true); + } else { + + // No motion was detected + //System.out.println("DEBUG: Camera didn't detect anything!"); + for(CameraSmart cam : cameras) + camDetectStatus.put(cam, false); + } + } + /** Method to turn on alarms * * @return [void] None. @@ -410,10 +441,12 @@ public class HomeSecurityController implements SmartthingsSensorCallback { 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); System.out.println("DETECTION: Sensor active in room: " + zoneId); + System.out.println("DETECTION: Detection by sensor: " + sensor.getId()); } } } @@ -494,15 +527,17 @@ public class HomeSecurityController implements SmartthingsSensorCallback { initCameras(rm); // Init all doorlocks - //initDoorLocks(rm); + //initDoorLocks(); // Init all outlets - //initOutlets(rm); + //initOutlets(); } // Init all alarms initAlarms(); + System.out.println("DEBUG: Initialized all devices! Now starting detection loop!"); + // Run the main loop that will keep checking the sensors and cameras periodically while (true) { diff --git a/benchmarks/drivers/Makefile b/benchmarks/drivers/Makefile index 46e189d..b842e02 100644 --- a/benchmarks/drivers/Makefile +++ b/benchmarks/drivers/Makefile @@ -101,7 +101,7 @@ multipurpose: PHONY += waterleak waterleak: $(JAVAC) $(JFLAGS) WaterLeakSensor/*.java - cp MotionSensor/WaterLeakSensor.config $(BIN_DIR)/iotcode/WaterLeakSensor + cp WaterLeakSensor/WaterLeakSensor.config $(BIN_DIR)/iotcode/WaterLeakSensor cd $(BIN_DIR)/iotcode/WaterLeakSensor; $(JAR) $(JARFLAGS) WaterLeakSensor.jar ../../iotcode/WaterLeakSensor/*.class ../../iotcode/interfaces/SmartthingsSensor*.class ../../iotcode/interfaces/Camera*.class ../../IrrigationController/MotionDetection*.class .PHONY: $(PHONY) diff --git a/benchmarks/drivers/MotionSensor/MotionSensor.java b/benchmarks/drivers/MotionSensor/MotionSensor.java index 6520de0..23e31b5 100644 --- a/benchmarks/drivers/MotionSensor/MotionSensor.java +++ b/benchmarks/drivers/MotionSensor/MotionSensor.java @@ -42,12 +42,14 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor { private int sensorId = 0; - @config private IoTSet devUdpAddress; - @config private IoTSet devZigbeeAddress; - - public MotionSensor(IoTSet dSet, IoTSet zigSet) { - //devUdpAddress = dSet; - //devZigbeeAddress = zigSet; + @config private IoTSet motionSensorUdpAddress; + @config private IoTSet motionSensorZigbeeAddress; + + //public MotionSensor(IoTSet dSet, IoTSet zigSet) { + //motionSensorUdpAddress = dSet; + //motionSensorZigbeeAddress = zigSet; + //} + public MotionSensor() { } public void init() { @@ -59,20 +61,20 @@ public class MotionSensor implements IoTZigbeeCallback, SmartthingsSensor { didAlreadyClose.set(false); try { - Iterator itrUdp = devUdpAddress.iterator(); - Iterator itrZig = devZigbeeAddress.iterator(); + Iterator itrUdp = motionSensorUdpAddress.iterator(); + Iterator itrZig = motionSensorZigbeeAddress.iterator(); zigConnection = new IoTZigbee((IoTDeviceAddress)itrUdp.next(), (IoTZigbeeAddress)itrZig.next()); // DEBUG System.out.println("DEBUG: Allocate iterators to print out addresses!"); - Iterator itrDebugUdp = devUdpAddress.iterator(); + Iterator itrDebugUdp = motionSensorUdpAddress.iterator(); IoTDeviceAddress iotaddDebug = (IoTDeviceAddress)itrDebugUdp.next(); System.out.println("IP address: " + iotaddDebug.getCompleteAddress()); System.out.println("Source port: " + iotaddDebug.getSourcePortNumber()); System.out.println("Destination port: " + iotaddDebug.getDestinationPortNumber()); - Iterator itrDebugZig = devZigbeeAddress.iterator(); + Iterator itrDebugZig = motionSensorZigbeeAddress.iterator(); IoTZigbeeAddress iotzbaddDebug = (IoTZigbeeAddress)itrDebugZig.next(); System.out.println("Zigbee address: " + iotzbaddDebug.getAddress()); diff --git a/benchmarks/drivers/MultipurposeSensor/MultipurposeSensor.java b/benchmarks/drivers/MultipurposeSensor/MultipurposeSensor.java index d2123e3..ae1aaf3 100644 --- a/benchmarks/drivers/MultipurposeSensor/MultipurposeSensor.java +++ b/benchmarks/drivers/MultipurposeSensor/MultipurposeSensor.java @@ -42,12 +42,14 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor private int sensorId = 0; - @config private IoTSet devUdpAddress; - @config private IoTSet devZigbeeAddress; - - public MultipurposeSensor(IoTSet dSet, IoTSet zigSet) { - //devUdpAddress = dSet; - //devZigbeeAddress = zigSet; + @config private IoTSet multipurposeSensorUdpAddress; + @config private IoTSet multipurposeSensorZigbeeAddress; + + //public MultipurposeSensor(IoTSet dSet, IoTSet zigSet) { + //multipurposeSensorUdpAddress = dSet; + //multipurposeSensorZigbeeAddress = zigSet; + //} + public MultipurposeSensor() { } public void init() { @@ -59,20 +61,20 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor didAlreadyClose.set(false); try { - Iterator itrUdp = devUdpAddress.iterator(); - Iterator itrZig = devZigbeeAddress.iterator(); + Iterator itrUdp = multipurposeSensorUdpAddress.iterator(); + Iterator itrZig = multipurposeSensorZigbeeAddress.iterator(); zigConnection = new IoTZigbee((IoTDeviceAddress)itrUdp.next(), (IoTZigbeeAddress)itrZig.next()); // DEBUG System.out.println("DEBUG: Allocate iterators to print out addresses!"); - Iterator itrDebugUdp = devUdpAddress.iterator(); + Iterator itrDebugUdp = multipurposeSensorUdpAddress.iterator(); IoTDeviceAddress iotaddDebug = (IoTDeviceAddress)itrDebugUdp.next(); System.out.println("IP address: " + iotaddDebug.getCompleteAddress()); System.out.println("Source port: " + iotaddDebug.getSourcePortNumber()); System.out.println("Destination port: " + iotaddDebug.getDestinationPortNumber()); - Iterator itrDebugZig = devZigbeeAddress.iterator(); + Iterator itrDebugZig = multipurposeSensorZigbeeAddress.iterator(); IoTZigbeeAddress iotzbaddDebug = (IoTZigbeeAddress)itrDebugZig.next(); System.out.println("Zigbee address: " + iotzbaddDebug.getAddress()); diff --git a/benchmarks/drivers/WaterLeakSensor/WaterLeakSensor.java b/benchmarks/drivers/WaterLeakSensor/WaterLeakSensor.java index ca85856..7a28cbe 100644 --- a/benchmarks/drivers/WaterLeakSensor/WaterLeakSensor.java +++ b/benchmarks/drivers/WaterLeakSensor/WaterLeakSensor.java @@ -42,12 +42,14 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor { private int sensorId = 0; - @config private IoTSet devUdpAddress; - @config private IoTSet devZigbeeAddress; - - public WaterLeakSensor(IoTSet dSet, IoTSet zigSet) { - //devUdpAddress = dSet; - //devZigbeeAddress = zigSet; + @config private IoTSet waterleakSensorUdpAddress; + @config private IoTSet waterleakSensorZigbeeAddress; + + //public WaterLeakSensor(IoTSet dSet, IoTSet zigSet) { + //waterleakSensorUdpAddress = dSet; + //waterleakSensorZigbeeAddress = zigSet; + //} + public WaterLeakSensor() { } public void init() { @@ -59,20 +61,20 @@ public class WaterLeakSensor implements IoTZigbeeCallback, SmartthingsSensor { didAlreadyClose.set(false); try { - Iterator itrUdp = devUdpAddress.iterator(); - Iterator itrZig = devZigbeeAddress.iterator(); + Iterator itrUdp = waterleakSensorUdpAddress.iterator(); + Iterator itrZig = waterleakSensorZigbeeAddress.iterator(); zigConnection = new IoTZigbee((IoTDeviceAddress)itrUdp.next(), (IoTZigbeeAddress)itrZig.next()); // DEBUG System.out.println("DEBUG: Allocate iterators to print out addresses!"); - Iterator itrDebugUdp = devUdpAddress.iterator(); + Iterator itrDebugUdp = waterleakSensorUdpAddress.iterator(); IoTDeviceAddress iotaddDebug = (IoTDeviceAddress)itrDebugUdp.next(); System.out.println("IP address: " + iotaddDebug.getCompleteAddress()); System.out.println("Source port: " + iotaddDebug.getSourcePortNumber()); System.out.println("Destination port: " + iotaddDebug.getDestinationPortNumber()); - Iterator itrDebugZig = devZigbeeAddress.iterator(); + Iterator itrDebugZig = waterleakSensorZigbeeAddress.iterator(); IoTZigbeeAddress iotzbaddDebug = (IoTZigbeeAddress)itrDebugZig.next(); System.out.println("Zigbee address: " + iotzbaddDebug.getAddress()); diff --git a/benchmarks/other/ZigbeeTest/IoTZigbee.java b/benchmarks/other/ZigbeeTest/IoTZigbee.java index 31c1d8a..4a931d0 100644 --- a/benchmarks/other/ZigbeeTest/IoTZigbee.java +++ b/benchmarks/other/ZigbeeTest/IoTZigbee.java @@ -300,6 +300,7 @@ public class IoTZigbee { } */ + // made by changwoo if (packetData.get("type").equals("zcl_zone_status_change_notification")){ int packetId = Integer.parseInt(packetData.get("packet_id"), 16); diff --git a/iotjava/iotrmi/Java/IoTSocket.java b/iotjava/iotrmi/Java/IoTSocket.java index 8db9a91..ba8af4a 100644 --- a/iotjava/iotrmi/Java/IoTSocket.java +++ b/iotjava/iotrmi/Java/IoTSocket.java @@ -34,8 +34,8 @@ public abstract class IoTSocket { /** * Class Constant */ - //protected static int BUFFSIZE = 128000; // how many bytes our incoming buffer can hold (original) - protected static int BUFFSIZE = 8388608; // 8388608 = 2^23 bytes of memory (8MB) - this is required by our IHome speaker driver + protected static int BUFFSIZE = 128000; // how many bytes our incoming buffer can hold (original) + //protected static int BUFFSIZE = 8388608; // 8388608 = 2^23 bytes of memory (8MB) - this is required by our IHome speaker driver protected static int MSG_LEN_SIZE = 4; // send length in the size of integer (4 bytes) /** diff --git a/iotjava/iotruntime/master/IoTMaster.java b/iotjava/iotruntime/master/IoTMaster.java index 31f82e9..1f7e697 100644 --- a/iotjava/iotruntime/master/IoTMaster.java +++ b/iotjava/iotruntime/master/IoTMaster.java @@ -84,6 +84,8 @@ public class IoTMaster { private static String STR_ZB_GATEWAY_PORT; private static String STR_ZB_IOTMASTER_PORT; private static String STR_NUM_CALLBACK_PORTS; + private static String STR_JVM_INIT_HEAP_SIZE; + private static String STR_JVM_MAX_HEAP_SIZE; private static boolean BOOL_VERBOSE; /** @@ -156,6 +158,8 @@ public class IoTMaster { STR_ZB_GATEWAY_PORT = null; STR_ZB_IOTMASTER_PORT = null; STR_NUM_CALLBACK_PORTS = null; + STR_JVM_INIT_HEAP_SIZE = null; + STR_JVM_MAX_HEAP_SIZE = null; BOOL_VERBOSE = false; } @@ -211,6 +215,8 @@ public class IoTMaster { STR_ZB_GATEWAY_PORT = prop.getProperty("ZIGBEE_GATEWAY_PORT"); STR_ZB_IOTMASTER_PORT = prop.getProperty("ZIGBEE_IOTMASTER_PORT"); STR_NUM_CALLBACK_PORTS = prop.getProperty("NUMBER_CALLBACK_PORTS"); + STR_JVM_INIT_HEAP_SIZE = prop.getProperty("JVM_INIT_HEAP_SIZE"); + STR_JVM_MAX_HEAP_SIZE = prop.getProperty("JVM_MAX_HEAP_SIZE"); if(prop.getProperty("VERBOSE").equals(STR_YES)) { BOOL_VERBOSE = true; } @@ -231,6 +237,8 @@ public class IoTMaster { RuntimeOutput.print("STR_ZB_GATEWAY_PORT=" + STR_ZB_GATEWAY_PORT, BOOL_VERBOSE); RuntimeOutput.print("STR_ZB_IOTMASTER_PORT=" + STR_ZB_IOTMASTER_PORT, BOOL_VERBOSE); RuntimeOutput.print("STR_NUM_CALLBACK_PORTS=" + STR_NUM_CALLBACK_PORTS, BOOL_VERBOSE); + RuntimeOutput.print("STR_JVM_INIT_HEAP_SIZE=" + STR_JVM_INIT_HEAP_SIZE, BOOL_VERBOSE); + RuntimeOutput.print("STR_JVM_MAX_HEAP_SIZE=" + STR_JVM_MAX_HEAP_SIZE, BOOL_VERBOSE); RuntimeOutput.print("BOOL_VERBOSE=" + BOOL_VERBOSE, BOOL_VERBOSE); RuntimeOutput.print("IoTMaster: Information extracted successfully!", BOOL_VERBOSE); } @@ -333,7 +341,7 @@ public class IoTMaster { * @params inStream ObjectOutputStream communication * @return void */ - private void instrumentIoTSetDevice(String strFieldIdentifier, String strFieldName, String strIoTSlaveObjectHostAdd, + private void instrumentIoTSetDevice(String strFieldIdentifier, String strObjName, String strFieldName, String strIoTSlaveObjectHostAdd, ObjectInputStream inStream, ObjectOutputStream outStream) throws IOException, ClassNotFoundException, InterruptedException { @@ -349,10 +357,13 @@ public class IoTMaster { arrFieldValues = listObject.get(iRow); // Get device address - if 00:00:00:00:00:00 that means it needs the driver object address (self) String strDeviceAddress = null; + String strDeviceAddressKey = null; if (arrFieldValues[0].equals(STR_SELF_MAC_ADD)) { strDeviceAddress = strIoTSlaveObjectHostAdd; + strDeviceAddressKey = strObjName + "-" + strIoTSlaveObjectHostAdd; } else { strDeviceAddress = routerConfig.getIPFromMACAddress((String) arrFieldValues[0]); + strDeviceAddressKey = strObjName + "-" + strDeviceAddress; } int iDestDeviceDriverPort = (int) arrFieldValues[1]; String strProtocol = (String) arrFieldValues[2]; @@ -364,18 +375,24 @@ public class IoTMaster { bDstPortWildCard = (boolean) arrFieldValues[4]; } // Add the port connection into communication handler - if it's not assigned yet - if (commHan.getComPort(strDeviceAddress) == null) { - commHan.addPortConnection(strIoTSlaveObjectHostAdd, strDeviceAddress); + if (commHan.getComPort(strDeviceAddressKey) == null) { + commHan.addPortConnection(strIoTSlaveObjectHostAdd, strDeviceAddressKey); } + + // TODO: DEBUG!!! + System.out.println("\n\n DEBUG: InstrumentSetDevice: Object Name: " + strObjName); + System.out.println("DEBUG: InstrumentSetDevice: Port number: " + commHan.getComPort(strDeviceAddressKey)); + System.out.println("DEBUG: InstrumentSetDevice: Device address: " + strDeviceAddressKey + "\n\n"); + // Send address one by one Message msgGetIoTSetObj = null; if (bDstPortWildCard) { - String strUniqueDev = strDeviceAddress + ":" + iRow; + String strUniqueDev = strDeviceAddressKey + ":" + iRow; msgGetIoTSetObj = new MessageGetDeviceObject(IoTCommCode.GET_DEVICE_IOTSET_OBJECT, strDeviceAddress, commHan.getAdditionalPort(strUniqueDev), iDestDeviceDriverPort, bSrcPortWildCard, bDstPortWildCard); } else msgGetIoTSetObj = new MessageGetDeviceObject(IoTCommCode.GET_DEVICE_IOTSET_OBJECT, - strDeviceAddress, commHan.getComPort(strDeviceAddress), iDestDeviceDriverPort, bSrcPortWildCard, bDstPortWildCard); + strDeviceAddress, commHan.getComPort(strDeviceAddressKey), iDestDeviceDriverPort, bSrcPortWildCard, bDstPortWildCard); commMasterToSlave(msgGetIoTSetObj, "Get IoTSet objects!", inStream, outStream); } // Reinitialize IoTSet on device object @@ -394,7 +411,7 @@ public class IoTMaster { * @params inStream ObjectOutputStream communication * @return void */ - private void instrumentIoTSetZBDevice(Map.Entry map, String strFieldName, String strIoTSlaveObjectHostAdd, + private void instrumentIoTSetZBDevice(Map.Entry map, String strObjName, String strFieldName, String strIoTSlaveObjectHostAdd, ObjectInputStream inStream, ObjectOutputStream outStream) throws IOException, ClassNotFoundException, InterruptedException { @@ -405,24 +422,31 @@ public class IoTMaster { commMasterToSlave(msgCrtIoTSet, "Create new IoTSet for IoTZigbeeAddress!", inStream, outStream); // Prepare ZigbeeConfig String strZigbeeGWAddress = routerConfig.getIPFromMACAddress(STR_ZB_GATEWAY_ADDRESS); + String strZigbeeGWAddressKey = strObjName + "-" + strZigbeeGWAddress; int iZigbeeGWPort = Integer.parseInt(STR_ZB_GATEWAY_PORT); int iZigbeeIoTMasterPort = Integer.parseInt(STR_ZB_IOTMASTER_PORT); commHan.addDevicePort(iZigbeeIoTMasterPort); ZigbeeConfig zbConfig = new ZigbeeConfig(strZigbeeGWAddress, iZigbeeGWPort, iZigbeeIoTMasterPort, BOOL_VERBOSE); // Add the port connection into communication handler - if it's not assigned yet - if (commHan.getComPort(strZigbeeGWAddress) == null) { - commHan.addPortConnection(strIoTSlaveObjectHostAdd, strZigbeeGWAddress); + if (commHan.getComPort(strZigbeeGWAddressKey) == null) { + commHan.addPortConnection(strIoTSlaveObjectHostAdd, strZigbeeGWAddressKey); } int iRows = setInstrumenter.numberOfRows(); RuntimeOutput.print("IoTMaster: Number of rows for IoTZigbeeAddress: " + iRows, BOOL_VERBOSE); + + // TODO: DEBUG!!! + System.out.println("\n\n DEBUG: InstrumentZigbeeDevice: Object Name: " + strObjName); + System.out.println("DEBUG: InstrumentZigbeeDevice: Port number: " + commHan.getComPort(strZigbeeGWAddressKey)); + System.out.println("DEBUG: InstrumentZigbeeDevice: Device address: " + strZigbeeGWAddress + "\n\n"); + // Transfer the address for(int iRow=0; iRow 3) { bDstPortWildCard = (boolean) arrFieldValues[4]; if (bDstPortWildCard) { // This needs a unique source port - String strUniqueDev = strDeviceAddress + ":" + iRow; + String strUniqueDev = strDeviceAddressKey + ":" + iRow; commHan.addAdditionalPort(strUniqueDev); } } + + // TODO: DEBUG!!! + System.out.println("\n\n DEBUG: InstrumentPolicySetDevice: Object Name: " + strObjName); + System.out.println("DEBUG: InstrumentPolicySetDevice: Port number: " + commHan.getComPort(strDeviceAddressKey)); + System.out.println("DEBUG: InstrumentPolicySetDevice: Device address: " + strDeviceAddressKey + "\n\n"); + + // Send routing policy to router for device drivers and devices // ROUTING POLICY: RMI communication - RMI registry and stub ports if((iDestDeviceDriverPort == -1) && (!strProtocol.equals(STR_NO_PROTOCOL))) { // Port number -1 means that we don't set the policy strictly to port number level // "nopro" = no protocol specified for just TCP or just UDP (can be both used as well) // ROUTING POLICY: Device driver and device - routerConfig.configureRouterMainPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress, - strProtocol); + routerConfig.configureRouterMainPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress, strProtocol); // ROUTING POLICY: Send to the compute node where the device driver is - routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, - strDeviceAddress, strProtocol); + routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress, strProtocol); } else if((iDestDeviceDriverPort == -1) && (strProtocol.equals(STR_NO_PROTOCOL))) { routerConfig.configureRouterMainPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress); routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress); @@ -629,19 +659,17 @@ public class IoTMaster { // This is a TCP protocol that connects, e.g. a phone to our runtime system // that provides a gateway access (accessed through destination port number) commHan.addDevicePort(iDestDeviceDriverPort); - routerConfig.configureRouterMainPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress, - STR_TCP_PROTOCOL, iDestDeviceDriverPort); - routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress, - STR_TCP_PROTOCOL, iDestDeviceDriverPort); + routerConfig.configureRouterMainPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress, STR_TCP_PROTOCOL, iDestDeviceDriverPort); + routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress, STR_TCP_PROTOCOL, iDestDeviceDriverPort); routerConfig.configureRouterHTTPPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress); routerConfig.configureHostHTTPPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress); } else { // Other port numbers... commHan.addDevicePort(iDestDeviceDriverPort); - routerConfig.configureRouterMainPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress, - strProtocol, commHan.getComPort(strDeviceAddress), iDestDeviceDriverPort); - routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress, - strProtocol, commHan.getComPort(strDeviceAddress), iDestDeviceDriverPort); + routerConfig.configureRouterMainPolicies(STR_ROUTER_ADD, strIoTSlaveObjectHostAdd, strDeviceAddress, strProtocol, commHan.getComPort(strDeviceAddressKey), + iDestDeviceDriverPort); + routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress, strProtocol, commHan.getComPort(strDeviceAddressKey), + iDestDeviceDriverPort); } } } @@ -824,12 +852,12 @@ public class IoTMaster { if(setInstrumenter.getObjTableName().equals(STR_IOT_DEV_ADD_CLS)) { // Instrument the normal IoTDeviceAddress synchronized(this) { - instrumentIoTSetDevice(strFieldIdentifier, strFieldName, strIoTSlaveObjectHostAdd, inStream, outStream); + instrumentIoTSetDevice(strFieldIdentifier, strObjName, strFieldName, strIoTSlaveObjectHostAdd, inStream, outStream); } } else if(setInstrumenter.getObjTableName().equals(STR_IOT_ZB_ADD_CLS)) { // Instrument the IoTZigbeeAddress - special feature for Zigbee device support synchronized(this) { - instrumentIoTSetZBDevice(map, strFieldName, strIoTSlaveObjectHostAdd, inStream, outStream); + instrumentIoTSetZBDevice(map, strObjName, strFieldName, strIoTSlaveObjectHostAdd, inStream, outStream); } } else if(setInstrumenter.getObjTableName().equals(STR_IOT_ADD_CLS)) { // Instrument the IoTAddress @@ -1185,7 +1213,8 @@ public class IoTMaster { // Construct ssh command line and create a controller thread for e.g. AcmeProximity String strSSHCommand = STR_SSH_USERNAME + strIoTSlaveControllerHostAdd + " cd " + - STR_RUNTIME_DIR + " sudo java " + STR_CLS_PATH + " " + + STR_RUNTIME_DIR + " sudo java " + STR_JVM_INIT_HEAP_SIZE + " " + + STR_JVM_MAX_HEAP_SIZE + " " + STR_CLS_PATH + " " + STR_RMI_PATH + " " + STR_IOT_SLAVE_CLS + " " + strIoTMasterHostAdd + " " + commHan.getComPort(strObjControllerName) + " " + commHan.getRMIRegPort(strObjControllerName) + " " + diff --git a/iotjava/iotruntime/zigbee/IoTZigbee.java b/iotjava/iotruntime/zigbee/IoTZigbee.java index a772918..b4f2a3f 100644 --- a/iotjava/iotruntime/zigbee/IoTZigbee.java +++ b/iotjava/iotruntime/zigbee/IoTZigbee.java @@ -287,7 +287,28 @@ public class IoTZigbee { } else { IoTZigbeeMessage callbackMessage = null; - if (packetData.get("type").equals("zcl_read_attributes_response")) { + //made by changwoo + if (packetData.get("type").equals("zcl_zone_status_change_notification")){ + int packetId = Integer.parseInt(packetData.get("packet_id"), 16); + int clusterId = Integer.parseInt(packetData.get("cluster_id"), 16); + int profileId = Integer.parseInt(packetData.get("profile_id"), 16); + int status = Integer.parseInt(packetData.get("status"), 10); + boolean successOrFail = false; + if(packetData.get("attributes").equals("success")) successOrFail=true; + callbackMessage = new IoTZigbeeMessageZclZoneStatusChangeNotification(packetId, clusterId, profileId, status, successOrFail); + + //made by changwoo + } else if (packetData.get("type").equals("zcl_write_attributes_response")) { + + int packetId = Integer.parseInt(packetData.get("packet_id"), 16); + int clusterId = Integer.parseInt(packetData.get("cluster_id"), 16); + int profileId = Integer.parseInt(packetData.get("profile_id"), 16); + boolean successOrFail = false; + if(packetData.get("attributes").equals("success")) successOrFail=true; + + callbackMessage = new IoTZigbeeMessageZclWriteAttributesResponse(packetId, clusterId, profileId, successOrFail); + + } else if (packetData.get("type").equals("zcl_read_attributes_response")) { int packetId = Integer.parseInt(packetData.get("packet_id"), 16); int clusterId = Integer.parseInt(packetData.get("cluster_id"), 16); int profileId = Integer.parseInt(packetData.get("profile_id"), 16); diff --git a/localconfig/iotruntime/IoTMaster.config b/localconfig/iotruntime/IoTMaster.config index d98aa4d..79e16e8 100644 --- a/localconfig/iotruntime/IoTMaster.config +++ b/localconfig/iotruntime/IoTMaster.config @@ -30,3 +30,9 @@ VERBOSE=Yes #Number of callback ports NUMBER_CALLBACK_PORTS=1 +#JVM heap size - can go out of memory if a IoTSlave needs to handle a lot of objects +#E.g. JVM_INIT_HEAP_SIZE=-Xms64m, JVM_MAX_HEAP_SIZE=-Xmx64m (64 MB of heap) +#Made empty for now as it needs fine-tuning +JVM_INIT_HEAP_SIZE= +JVM_MAX_HEAP_SIZE= + diff --git a/localconfig/mysql/alm_Addresses.config b/localconfig/mysql/alm_Addresses.config new file mode 100644 index 0000000..2564492 --- /dev/null +++ b/localconfig/mysql/alm_Addresses.config @@ -0,0 +1,5 @@ +SELECT * FROM +IoTDeviceAddress +WHERE +TYPE='EspAlarmAdd' +; diff --git a/localconfig/mysql/camSet.config b/localconfig/mysql/camSet.config index 5798c17..083ca82 100644 --- a/localconfig/mysql/camSet.config +++ b/localconfig/mysql/camSet.config @@ -1,5 +1,3 @@ SELECT * FROM CameraSmart -WHERE -ID='CM1' ; diff --git a/localconfig/mysql/motionSensorUdpAddress.config b/localconfig/mysql/motionSensorUdpAddress.config new file mode 100644 index 0000000..31f215b --- /dev/null +++ b/localconfig/mysql/motionSensorUdpAddress.config @@ -0,0 +1,5 @@ +SELECT * FROM +IoTDeviceAddress +WHERE +TYPE='MotionSensorAdd' +; diff --git a/localconfig/mysql/motionSensorZigbeeAddress.config b/localconfig/mysql/motionSensorZigbeeAddress.config new file mode 100644 index 0000000..8b66bb2 --- /dev/null +++ b/localconfig/mysql/motionSensorZigbeeAddress.config @@ -0,0 +1,5 @@ +SELECT * FROM +IoTZigbeeAddress +WHERE +TYPE='MotionSensorZBAdd' +; diff --git a/localconfig/mysql/multipurposeSensorUdpAddress.config b/localconfig/mysql/multipurposeSensorUdpAddress.config new file mode 100644 index 0000000..5e97f18 --- /dev/null +++ b/localconfig/mysql/multipurposeSensorUdpAddress.config @@ -0,0 +1,5 @@ +SELECT * FROM +IoTDeviceAddress +WHERE +TYPE='MultipurposeSensorAdd' +; diff --git a/localconfig/mysql/multipurposeSensorZigbeeAddress.config b/localconfig/mysql/multipurposeSensorZigbeeAddress.config new file mode 100644 index 0000000..212b248 --- /dev/null +++ b/localconfig/mysql/multipurposeSensorZigbeeAddress.config @@ -0,0 +1,5 @@ +SELECT * FROM +IoTZigbeeAddress +WHERE +TYPE='MultipurposeSensorZBAdd' +; diff --git a/localconfig/mysql/waterleakSensorUdpAddress.config b/localconfig/mysql/waterleakSensorUdpAddress.config new file mode 100644 index 0000000..95437ce --- /dev/null +++ b/localconfig/mysql/waterleakSensorUdpAddress.config @@ -0,0 +1,5 @@ +SELECT * FROM +IoTDeviceAddress +WHERE +TYPE='WaterLeakSensorAdd' +; diff --git a/localconfig/mysql/waterleakSensorZigbeeAddress.config b/localconfig/mysql/waterleakSensorZigbeeAddress.config new file mode 100644 index 0000000..70d216c --- /dev/null +++ b/localconfig/mysql/waterleakSensorZigbeeAddress.config @@ -0,0 +1,5 @@ +SELECT * FROM +IoTZigbeeAddress +WHERE +TYPE='WaterLeakSensorZBAdd' +;