Fixing a bug in IoTMaster (wrong variable for language flag check); adding LANGUAGE...
authorrtrimana <rtrimana@uci.edu>
Tue, 14 Feb 2017 18:03:46 +0000 (10:03 -0800)
committerrtrimana <rtrimana@uci.edu>
Tue, 14 Feb 2017 18:03:46 +0000 (10:03 -0800)
benchmarks/Java/HomeSecurityController/HomeSecurityController.config
benchmarks/Java/HomeSecurityController/HomeSecurityController.java
benchmarks/Java/IrrigationController/IrrigationController.config
benchmarks/Java/SmartLightsController/SmartLightsController.config
benchmarks/Java/SpeakerController/SpeakerController.config
benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java
iotjava/iotruntime/master/IoTMaster.java

index 8647f2e..68cf0fb 100644 (file)
@@ -127,6 +127,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback {
 
                // Get and init the IAS sensors for this specific room
                HashSet<SmartthingsSensorSmart> sensors = roomSensorRelation.get(rm);
+               System.out.println("DEBUG: We have " + sensors.size() + " sensors!");
                for (SmartthingsSensorSmart sen : sensors) {
        
                        try {
index ae1aaf3..5b91b4e 100644 (file)
@@ -57,7 +57,6 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
                if (didAlreadyInit.compareAndSet(false, true) == false) {
                        return; // already init
                }
-
                didAlreadyClose.set(false);
 
                try {
index e85f8d2..5fb9178 100644 (file)
@@ -381,6 +381,7 @@ public class IoTMaster {
         * @params  strIoTSlaveObjectHostAdd  String slave host address
         * @params  inStream                  ObjectInputStream communication
         * @params  inStream                  ObjectOutputStream communication
+        * @params  strLanguage                           String language
         * @return  void
         */
        private void instrumentIoTSetDevice(String strFieldIdentifier, String strObjName, String strFieldName, String strIoTSlaveObjectHostAdd,
@@ -460,6 +461,7 @@ public class IoTMaster {
         * @params  strIoTSlaveObjectHostAdd  String slave host address
         * @params  inStream                  ObjectInputStream communication
         * @params  inStream                  ObjectOutputStream communication
+        * @params  strLanguage                           String language
         * @return  void
         */
        private void instrumentIoTSetZBDevice(Map.Entry<String,Object> map, String strObjName, String strFieldName, String strIoTSlaveObjectHostAdd,
@@ -521,6 +523,7 @@ public class IoTMaster {
         * @params  strFieldName              String field name
         * @params  inStream                  ObjectInputStream communication
         * @params  inStream                  ObjectOutputStream communication
+        * @params  strLanguage                           String language
         * @return  void
         */
        private void instrumentIoTSetAddress(String strFieldIdentifier, String strFieldName,
@@ -558,10 +561,11 @@ public class IoTMaster {
        /**
         * A private method to instrument an object on a specific machine and setting up policies
         *
-        * @params  strFieldObjectID  String field object ID
+        * @params  strFieldObjectID              String field object ID
+        * @params  strLanguage                           String language
         * @return  void
         */
-       private void instrumentObject(String strFieldObjectID) throws IOException {
+       private void instrumentObject(String strFieldObjectID, String strLanguage) throws IOException {
 
                // Extract the interface name for RMI
                // e.g. ProximitySensorInterface, TempSensorInterface, etc.
@@ -607,7 +611,7 @@ public class IoTMaster {
                        routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveControllerHostAdd,
                                strIoTSlaveObjectHostAdd, STR_TCP_PROTOCOL);
                        // Instrument the IoTSet declarations inside the class file
-                       instrumentObjectIoTSet(strFieldObjectID);
+                       instrumentObjectIoTSet(strFieldObjectID, strLanguage);
                }
                // Send routing policy to router for controller object
                // ROUTING POLICY: RMI communication - RMI registry and stub ports
@@ -766,16 +770,17 @@ public class IoTMaster {
         * <p>
         * Mostly the IoTSet fields would contain IoTDeviceAddress objects
         *
-        * @params  strFieldObjectID  String field object ID
+        * @params  strFieldObjectID    String field object ID
+        * @params  strLanguage                 String language
         * @return  void
         */
-       private void instrumentObjectIoTSet(String strFieldObjectID) throws IOException {
+       private void instrumentObjectIoTSet(String strFieldObjectID, String strLanguage) throws IOException {
 
                // If this is a new object ... then create one
                // Instrument the class source code and look for IoTSet for device addresses
                // e.g. @config private IoTSet<IoTDeviceAddress> lb_addresses;
                HashMap<String,Object> hmObjectFieldObjects = null;
-               if(STR_LANGUAGE.equals(STR_JAVA)) {
+               if(strLanguage.equals(STR_JAVA)) {
                        String strObjectClassNamePath = STR_IOT_CODE_PATH + strObjClassName + "/" + strObjClassName + STR_CLS_FILE_EXT;
                        FileInputStream fis = new FileInputStream(strObjectClassNamePath);
                        ClassReader cr = new ClassReader(fis);
@@ -1126,9 +1131,10 @@ public class IoTMaster {
         *
         * @params  Map.Entry<String,Object>  Entry of map IoTSet instrumentation
         * @params  strFieldName              String field name
+        * @params  strLanguage                           String language
         * @return  void
         */
-       private void instrumentIoTSet(Map.Entry<String,Object> map, String strFieldName) 
+       private void instrumentIoTSet(Map.Entry<String,Object> map, String strFieldName, String strLanguage
                throws IOException, ClassNotFoundException, InterruptedException {
                                
                // Get information from the set
@@ -1144,7 +1150,7 @@ public class IoTMaster {
                        String strObjID = setInstrumenter.fieldObjectID(iRow);
                        strObjClassName = setInstrumenter.fieldEntryType(strObjID);
                        // Call the method to create an object
-                       instrumentObject(strObjID);
+                       instrumentObject(strObjID, strLanguage);
                        int iNumOfPorts = Integer.parseInt(STR_NUM_CALLBACK_PORTS);
                        objInitHand.addObjectIntoField(strFieldName, strIoTSlaveObjectHostAdd, strObjName,
                                strObjClassName, strObjClassInterfaceName, strObjStubClsIntfaceName, commHan.getRMIRegPort(strObjName), 
@@ -1158,9 +1164,10 @@ public class IoTMaster {
         *
         * @params  Map.Entry<String,Object>  Entry of map IoTRelation instrumentation
         * @params  strFieldName              String field name
+        * @params  strLanguage                           String language
         * @return  void
         */
-       private void instrumentIoTRelation(Map.Entry<String,Object> map, String strFieldName) 
+       private void instrumentIoTRelation(Map.Entry<String,Object> map, String strFieldName, String strLanguage
                throws IOException, ClassNotFoundException, InterruptedException {
 
                        // Get information from the set
@@ -1175,7 +1182,7 @@ public class IoTMaster {
                        String strObjID = relationInstrumenter.firstFieldObjectID(iRow);
                        strObjClassName = relationInstrumenter.firstEntryFieldType(strObjID);
                        // Call the method to create an object
-                       instrumentObject(strObjID);
+                       instrumentObject(strObjID, strLanguage);
                        // Get the first object controller host address
                        String strFirstIoTSlaveObjectHostAdd = strIoTSlaveObjectHostAdd;
                        int iNumOfPorts = Integer.parseInt(STR_NUM_CALLBACK_PORTS);
@@ -1189,7 +1196,7 @@ public class IoTMaster {
                        strObjID = relationInstrumenter.secondFieldObjectID(iRow);
                        strObjClassName = relationInstrumenter.secondEntryFieldType(strObjID);
                        // Call the method to create an object
-                       instrumentObject(strObjID);
+                       instrumentObject(strObjID, strLanguage);
                        // Get the second object controller host address
                        String strSecondIoTSlaveObjectHostAdd = strIoTSlaveObjectHostAdd;
                        objInitHand.addSecondObjectIntoField(strFieldName, strIoTSlaveObjectHostAdd, strObjName,
@@ -2035,10 +2042,10 @@ public class IoTMaster {
                                                        instrumentIoTSetAddress(strFieldName, strFieldName, inStream, outStream, STR_LANGUAGE_CONTROLLER);
                                                } else {
                                                // Any other cases
-                                                       instrumentIoTSet(map, strFieldName);
+                                                       instrumentIoTSet(map, strFieldName, STR_LANGUAGE_CONTROLLER);
                                                }
                                        } else if (strClassName.equals(STR_REL_INSTRUMENTER_CLS)) {
-                                               instrumentIoTRelation(map, strFieldName);
+                                               instrumentIoTRelation(map, strFieldName, STR_LANGUAGE_CONTROLLER);
                                        }
                                }
                                // PROFILING