Adding missing files, completing driver config files with stub interface, completing...
authorrtrimana <rtrimana@uci.edu>
Thu, 5 Jan 2017 16:48:07 +0000 (08:48 -0800)
committerrtrimana <rtrimana@uci.edu>
Thu, 5 Jan 2017 16:48:07 +0000 (08:48 -0800)
12 files changed:
benchmarks/IrrigationController/CameraCallback_CallbackSkeleton.java [new file with mode: 0644]
benchmarks/IrrigationController/CameraSmart_Stub.java [new file with mode: 0644]
benchmarks/drivers/AudioRoom/AudioRoom.config
benchmarks/drivers/EspSprinkler/EspSprinkler.config
benchmarks/drivers/GPSPhoneGateway/GPSPhoneGateway.config
benchmarks/drivers/GreenLawn/GreenLawn.config
benchmarks/drivers/IHome/IHome.config
benchmarks/drivers/Makefile
benchmarks/drivers/SpruceSensor/SpruceSensor.config
benchmarks/drivers/WeatherPhoneGateway/WeatherPhoneGateway.config
iotjava/Makefile
iotjava/iotruntime/master/IoTMaster.java

diff --git a/benchmarks/IrrigationController/CameraCallback_CallbackSkeleton.java b/benchmarks/IrrigationController/CameraCallback_CallbackSkeleton.java
new file mode 100644 (file)
index 0000000..afe1048
--- /dev/null
@@ -0,0 +1,44 @@
+package IrrigationController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import iotrmi.Java.IoTRMICall;
+import iotrmi.Java.IoTRMIObject;
+
+import iotcode.interfaces.*;
+
+public class CameraCallback_CallbackSkeleton implements CameraCallback {
+
+       private CameraCallback mainObj;
+       private int objectId = 0;
+       private String callbackAddress;
+       
+
+       public CameraCallback_CallbackSkeleton(CameraCallback _mainObj, String _callbackAddress, int _objectId) throws Exception {
+               callbackAddress = _callbackAddress;
+               mainObj = _mainObj;
+               objectId = _objectId;
+       }
+
+       public void newCameraFrameAvailable(byte latestFrame[], long timeStamp) {
+               mainObj.newCameraFrameAvailable(latestFrame, timeStamp);
+       }
+
+       public void ___newCameraFrameAvailable(IoTRMIObject rmiObj) {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { byte[].class, long.class }, 
+               new Class<?>[] { null, null });
+               newCameraFrameAvailable((byte[]) paramObj[0], (long) paramObj[1]);
+       }
+
+       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
+               int methodId = rmiObj.getMethodId();
+               switch (methodId) {
+                       case 0: ___newCameraFrameAvailable(rmiObj); break;
+                       default: 
+                       throw new Error("Method Id " + methodId + " not recognized!");
+               }
+       }
+
+}
diff --git a/benchmarks/IrrigationController/CameraSmart_Stub.java b/benchmarks/IrrigationController/CameraSmart_Stub.java
new file mode 100644 (file)
index 0000000..7c1783b
--- /dev/null
@@ -0,0 +1,184 @@
+package IrrigationController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import iotrmi.Java.IoTRMICall;
+import iotrmi.Java.IoTRMIObject;
+
+import iotcode.interfaces.*;
+
+public class CameraSmart_Stub implements CameraSmart {
+
+       private IoTRMICall rmiCall;
+       private String callbackAddress;
+       private int[] ports;
+
+       private final static int objectId = 0;
+       // Callback properties
+       private IoTRMIObject rmiObj;
+       List<CameraCallback> listCallbackObj;
+       private static int objIdCnt = 0;
+       private final static int object0Id = 0; //CameraSmartCallback
+       private static Integer[] object0Permission = { 0 };
+       private static List<Integer> set0Allowed;
+       
+
+       public CameraSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
+               callbackAddress = _callbackAddress;
+               ports = _ports;
+               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
+               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
+               listCallbackObj = new ArrayList<CameraCallback>();
+               set0Allowed.add(-9999);
+               ___initCallBack();
+       }
+
+       public int getMaxFPS() {
+               int methodId = 8;
+               Class<?> retType = int.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (int)retObj;
+       }
+
+       public boolean setFPS(int _fps) {
+               int methodId = 7;
+               Class<?> retType = boolean.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class };
+               Object[] paramObj = new Object[] { _fps };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (boolean)retObj;
+       }
+
+       public int getMinFPS() {
+               int methodId = 9;
+               Class<?> retType = int.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (int)retObj;
+       }
+
+       public boolean setResolution(Resolution _res) {
+               int methodId = 6;
+               Class<?> retType = boolean.class;
+               int paramEnum0[] = new int[1];
+               paramEnum0[0] = _res.ordinal();
+               Class<?>[] paramCls = new Class<?>[] { int[].class };
+               Object[] paramObj = new Object[] { paramEnum0 };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (boolean)retObj;
+       }
+
+       public void stop() {
+               int methodId = 2;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+       }
+
+       public void start() {
+               int methodId = 1;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+       }
+
+       public long getTimestamp() {
+               int methodId = 4;
+               Class<?> retType = long.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (long)retObj;
+       }
+
+       public byte[] getLatestFrame() {
+               int methodId = 3;
+               Class<?> retType = byte[].class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               return (byte[])retObj;
+       }
+
+       public void init() {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+       }
+
+       public void registerCallback(CameraCallback _callbackTo) {
+               try {
+                       CameraCallback_CallbackSkeleton skel0 = new CameraCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
+                       listCallbackObj.add(skel0);
+               } catch (Exception ex) {
+                       ex.printStackTrace();
+                       throw new Error("Exception when generating skeleton objects!");
+               }
+
+               int methodId = 10;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class };
+               Object[] paramObj = new Object[] { new Integer(1) };
+               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+       }
+
+       public void ___initCallBack() {
+               Thread thread = new Thread() {
+                       public void run() {
+                               try {
+                                       rmiObj = new IoTRMIObject(ports[0]);
+                                       while (true) {
+                                               byte[] method = rmiObj.getMethodBytes();
+                                               int objId = IoTRMIObject.getObjectId(method);
+                                               CameraCallback_CallbackSkeleton skel = (CameraCallback_CallbackSkeleton) listCallbackObj.get(objId);
+                                               if (skel != null) {
+                                                       int methodId = IoTRMIObject.getMethodId(method);
+                                                       if (!set0Allowed.contains(methodId)) {
+                                                               throw new Error("Callback object for CameraCallback is not allowed to access method: " + methodId);
+                                                       }
+                                                       skel.invokeMethod(rmiObj);
+                                               } else {
+                                                       throw new Error("CameraCallback: Object with Id " + objId + " not found!");
+                                               }
+                                       }
+                               } catch (Exception ex) {
+                                       ex.printStackTrace();
+                                       throw new Error("Error instantiating class CameraCallback_CallbackSkeleton!");
+                               }
+                       }
+               };
+               thread.start();
+
+               int methodId = -9998;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
+               Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
+               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+       }
+
+       public List<Resolution> getSupportedResolutions() {
+               int methodId = 5;
+               Class<?> retType = int[].class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               int[] retEnum = (int[]) retObj;
+               Resolution[] enumVals = Resolution.values();
+               int retLen = retEnum.length;
+               List<Resolution> enumRetVal = new ArrayList<Resolution>();
+               for (int i = 0; i < retLen; i++) {
+                       enumRetVal.add(enumVals[retEnum[i]]);
+               }
+               return enumRetVal;
+       }
+
+}
index 6af9ab2..f10cb63 100644 (file)
@@ -1 +1,4 @@
+# Skeleton/original interface
 INTERFACE_CLASS=Room
+# Stub
+INTERFACE_STUB_CLASS=RoomSmart
index 55c4e0c..335a38a 100644 (file)
@@ -1 +1,4 @@
+# Skeleton/original interface
 INTERFACE_CLASS=Sprinkler
+# Stub
+INTERFACE_STUB_CLASS=SprinklerSmart
index 081970f..cce2a04 100644 (file)
@@ -1 +1,4 @@
+# Skeleton/original interface
 INTERFACE_CLASS=GPSGateway
+# Stub
+INTERFACE_STUB_CLASS=GPSGatewaySmart
index 779e2c7..77c2cf6 100644 (file)
@@ -1 +1,4 @@
+# Skeleton/original interface
 INTERFACE_CLASS=Lawn
+# Stub
+INTERFACE_STUB_CLASS=LawnSmart
index 276b02e..a1384ce 100644 (file)
@@ -1 +1,4 @@
-INTERFACE_CLASS=Speaker
\ No newline at end of file
+# Skeleton/original interface
+INTERFACE_CLASS=Speaker
+# Stub
+INTERFACE_STUB_CLASS=SpeakerSmart
index 5e6706b..08aca6d 100644 (file)
@@ -48,7 +48,7 @@ PHONY += moisture
 moisture:
        $(JAVAC) $(JFLAGS) SpruceSensor/*.java
        cp SpruceSensor/SpruceSensor.config $(BIN_DIR)/iotcode/SpruceSensor
-       cd $(BIN_DIR)/iotcode/SpruceSensor; $(JAR) $(JARFLAGS) SpruceSensor.jar ../../iotcode/SpruceSensor/*.class ../../iotcode/interfaces/MoistureSensor*.class ../../iotcode/
+       cd $(BIN_DIR)/iotcode/SpruceSensor; $(JAR) $(JARFLAGS) SpruceSensor.jar ../../iotcode/SpruceSensor/*.class ../../iotcode/interfaces/MoistureSensor*.class ../../iotcode/interfaces/Camera*.class ../../IrrigationController/MotionDetection*.class
 
 PHONY += weathergateway
 weathergateway:
index 2f0da8c..0ba4568 100644 (file)
@@ -1 +1,4 @@
+# Skeleton/original interface
 INTERFACE_CLASS=MoistureSensor
+# Stub
+INTERFACE_STUB_CLASS=MoistureSensorSmart
index f996ce5..c90044f 100644 (file)
@@ -178,6 +178,7 @@ runtime:
        $(JAVAC) -classpath .:$(RUNTIMEJARS):$(PHONEJARS):$(ZIPJARS) iotruntime/*.java iotruntime/master/*.java iotruntime/slave/*.java iotruntime/messages/*.java iotruntime/stub/*.java iotruntime/zigbee/*.java -d $(BIN_DIR)
        cp ../localconfig/iotruntime/IoTMaster.config $(BIN_DIR)/iotruntime/
        cp ../localconfig/iotruntime/IoTSlave.config $(BIN_DIR)/iotruntime/
+       cp ../sslkey/*.jks $(BIN_DIR)/iotruntime/
        cp -r ../localconfig/mysql $(BIN_DIR)/iotruntime/
 
 PHONY += doc
index e35d775..31f82e9 100644 (file)
@@ -1017,7 +1017,8 @@ public class IoTMaster {
                                        commMasterToSlave(new MessageGetObject(IoTCommCode.GET_IOTSET_OBJECT, objInitInfo.getIoTSlaveObjectHostAdd(),
                                                objInitInfo.getObjectName(), objInitInfo.getObjectClassName(), objInitInfo.getObjectClassInterfaceName(), 
                                                objInitInfo.getObjectStubClassInterfaceName(), objInitInfo.getRMIRegistryPort(), objInitInfo.getRMIStubPort(),
-                                               objInitInfo.getRMICallbackPorts()), "Get IoTSet object!", inStream, outStream); 
+                                               objInitInfo.getRMICallbackPorts()), "Get IoTSet object!", inStream, outStream);
+
                                }
                                // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO REINITIALIZE IOTSET FIELD
                                commMasterToSlave(new MessageSimple(IoTCommCode.REINITIALIZE_IOTSET_FIELD),