From: rtrimana <rtrimana@uci.edu>
Date: Tue, 14 Feb 2017 18:03:46 +0000 (-0800)
Subject: Fixing a bug in IoTMaster (wrong variable for language flag check); adding LANGUAGE... 
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e7713056b0b0d2f6df424f88317a3d1738f5e3af;p=iot2.git

Fixing a bug in IoTMaster (wrong variable for language flag check); adding LANGUAGE field in controller config file
---

diff --git a/benchmarks/Java/HomeSecurityController/HomeSecurityController.config b/benchmarks/Java/HomeSecurityController/HomeSecurityController.config
index 5a44766..a3a2f98 100644
--- a/benchmarks/Java/HomeSecurityController/HomeSecurityController.config
+++ b/benchmarks/Java/HomeSecurityController/HomeSecurityController.config
@@ -1 +1,4 @@
 ADDITIONAL_ZIP_FILE=No
+
+# Language
+LANGUAGE=Java
diff --git a/benchmarks/Java/HomeSecurityController/HomeSecurityController.java b/benchmarks/Java/HomeSecurityController/HomeSecurityController.java
index 8647f2e..68cf0fb 100644
--- a/benchmarks/Java/HomeSecurityController/HomeSecurityController.java
+++ b/benchmarks/Java/HomeSecurityController/HomeSecurityController.java
@@ -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 {
diff --git a/benchmarks/Java/IrrigationController/IrrigationController.config b/benchmarks/Java/IrrigationController/IrrigationController.config
index a53b2c1..7f70cd7 100644
--- a/benchmarks/Java/IrrigationController/IrrigationController.config
+++ b/benchmarks/Java/IrrigationController/IrrigationController.config
@@ -1 +1,4 @@
 ADDITIONAL_ZIP_FILE=Yes
+
+# Language
+LANGUAGE=Java
diff --git a/benchmarks/Java/SmartLightsController/SmartLightsController.config b/benchmarks/Java/SmartLightsController/SmartLightsController.config
index 5a44766..a3a2f98 100644
--- a/benchmarks/Java/SmartLightsController/SmartLightsController.config
+++ b/benchmarks/Java/SmartLightsController/SmartLightsController.config
@@ -1 +1,4 @@
 ADDITIONAL_ZIP_FILE=No
+
+# Language
+LANGUAGE=Java
diff --git a/benchmarks/Java/SpeakerController/SpeakerController.config b/benchmarks/Java/SpeakerController/SpeakerController.config
index a53b2c1..7f70cd7 100644
--- a/benchmarks/Java/SpeakerController/SpeakerController.config
+++ b/benchmarks/Java/SpeakerController/SpeakerController.config
@@ -1 +1,4 @@
 ADDITIONAL_ZIP_FILE=Yes
+
+# Language
+LANGUAGE=Java
diff --git a/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java b/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java
index ae1aaf3..5b91b4e 100644
--- a/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java
+++ b/benchmarks/drivers/Java/MultipurposeSensor/MultipurposeSensor.java
@@ -57,7 +57,6 @@ public class MultipurposeSensor implements IoTZigbeeCallback, SmartthingsSensor
 		if (didAlreadyInit.compareAndSet(false, true) == false) {
 			return; // already init
 		}
-
 		didAlreadyClose.set(false);
 
 		try {
diff --git a/iotjava/iotruntime/master/IoTMaster.java b/iotjava/iotruntime/master/IoTMaster.java
index e85f8d2..5fb9178 100644
--- a/iotjava/iotruntime/master/IoTMaster.java
+++ b/iotjava/iotruntime/master/IoTMaster.java
@@ -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