import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
import iotcode.interfaces.*;
public class AlarmSmart_Stub implements AlarmSmart {
- private IoTRMICall rmiCall;
- private String callbackAddress;
- private int[] ports;
-
- private final static int objectId = 0;
+ private int objectId = 1;
+ private IoTRMIComm rmiComm;
+ // Synchronization variables
+ private AtomicBoolean retValueReceived4 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived2 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived3 = new AtomicBoolean(false);
- public AlarmSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
- callbackAddress = _callbackAddress;
- ports = _ports;
- rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
+ public AlarmSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+ if (_localPortSend != 0 && _localPortRecv != 0) {
+ rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+ } else
+ {
+ rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+ }
+ rmiComm.registerStub(objectId, 4, retValueReceived4);
+ rmiComm.registerStub(objectId, 2, retValueReceived2);
+ rmiComm.registerStub(objectId, 3, retValueReceived3);
+ IoTRMIUtil.mapStub.put(objectId, this);
+ }
+
+ public AlarmSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+ rmiComm = _rmiComm;
+ objectId = _objectId;
+ rmiComm.registerStub(objectId, 4, retValueReceived4);
+ rmiComm.registerStub(objectId, 2, retValueReceived2);
+ rmiComm.registerStub(objectId, 3, retValueReceived3);
}
public boolean doesHaveZoneTimers() {
Class<?> retType = boolean.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived4.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived4.set(false);
+ rmiComm.setGetReturnBytes();
+
return (boolean)retObj;
}
Class<?> retType = int.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retLenObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
- int retLen = (int) retLenObj;
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived2.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived2.set(false);
+ rmiComm.setGetReturnBytes();
+
+ int retLen = (int) retObj;
Class<?>[] retCls = new Class<?>[3*retLen];
Class<?>[] retClsVal = new Class<?>[3*retLen];
int retPos = 0;
retCls[retPos] = int.class;
retClsVal[retPos++] = null;
}
- Object[] retObj = rmiCall.getStructObjects(retCls, retClsVal);
+ // Waiting for return value
+ while (!retValueReceived2.get());
+ Object[] retActualObj = rmiComm.getStructObjects(retCls, retClsVal);
+ retValueReceived2.set(false);
+ rmiComm.setGetReturnBytes();
+
List<ZoneState> structRet = new ArrayList<ZoneState>();
int retObjPos = 0;
for(int i = 0; i < retLen; i++) {
ZoneState structRetMem = new ZoneState();
- structRetMem.zoneNumber = (int) retObj[retObjPos++];
- structRetMem.onOffState = (boolean) retObj[retObjPos++];
- structRetMem.duration = (int) retObj[retObjPos++];
+ structRetMem.zoneNumber = (int) retActualObj[retObjPos++];
+ structRetMem.onOffState = (boolean) retActualObj[retObjPos++];
+ structRetMem.duration = (int) retActualObj[retObjPos++];
structRet.add(structRetMem);
}
return structRet;
Class<?> retType = void.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public void setZone(int _zone, boolean _onOff, int _onDurationSeconds) {
Class<?> retType = void.class;
Class<?>[] paramCls = new Class<?>[] { int.class, boolean.class, int.class };
Object[] paramObj = new Object[] { _zone, _onOff, _onDurationSeconds };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public int getNumberOfZones() {
Class<?> retType = int.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived3.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived3.set(false);
+ rmiComm.setGetReturnBytes();
+
return (int)retObj;
}
+++ /dev/null
-package HomeSecurityController;
-
-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!");
- }
- }
-
-}
--- /dev/null
+package HomeSecurityController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class CameraCallback_Skeleton implements CameraCallback {
+
+ private CameraCallback mainObj;
+ private int objectId = 3;
+ // Communications and synchronizations
+ private IoTRMIComm rmiComm;
+ private AtomicBoolean didAlreadyInitWaitInvoke;
+ private AtomicBoolean methodReceived;
+ private byte[] methodBytes = null;
+ // Permissions
+ private static Integer[] object3Permission = { 0 };
+ private static List<Integer> set3Allowed;
+
+
+ public CameraCallback_Skeleton(CameraCallback _mainObj, int _portSend, int _portRecv) throws Exception {
+ mainObj = _mainObj;
+ rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+ set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+ IoTRMIUtil.mapSkel.put(_mainObj, this);
+ IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+ didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+ methodReceived = new AtomicBoolean(false);
+ rmiComm.registerSkeleton(objectId, methodReceived);
+ Thread thread1 = new Thread() {
+ public void run() {
+ try {
+ ___waitRequestInvokeMethod();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ };
+ thread1.start();
+ }
+
+ public CameraCallback_Skeleton(CameraCallback _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
+ mainObj = _mainObj;
+ rmiComm = _rmiComm;
+ objectId = _objectId;
+ set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+ didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+ methodReceived = new AtomicBoolean(false);
+ rmiComm.registerSkeleton(objectId, methodReceived);
+ }
+
+ public boolean didAlreadyInitWaitInvoke() {
+ return didAlreadyInitWaitInvoke.get();
+ }
+
+ public void newCameraFrameAvailable(byte latestFrame[], long timeStamp) {
+ mainObj.newCameraFrameAvailable(latestFrame, timeStamp);
+ }
+
+ public void ___newCameraFrameAvailable() {
+ byte[] localMethodBytes = methodBytes;
+ rmiComm.setGetMethodBytes();
+ Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { byte[].class, long.class }, new Class<?>[] { null, null }, localMethodBytes);
+ newCameraFrameAvailable((byte[]) paramObj[0], (long) paramObj[1]);
+ }
+
+ public void ___waitRequestInvokeMethod() throws IOException {
+ didAlreadyInitWaitInvoke.compareAndSet(false, true);
+ while (true) {
+ if (!methodReceived.get()) {
+ continue;
+ }
+ methodBytes = rmiComm.getMethodBytes();
+ methodReceived.set(false);
+ int _objectId = IoTRMIComm.getObjectId(methodBytes);
+ int methodId = IoTRMIComm.getMethodId(methodBytes);
+ if (_objectId == objectId) {
+ if (!set3Allowed.contains(methodId)) {
+ throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
+ }
+ }
+ else {
+ continue;
+ }
+ switch (methodId) {
+ case 0:
+ new Thread() {
+ public void run() {
+ try {
+ ___newCameraFrameAvailable();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }.start();
+ break;
+ default:
+ throw new Error("Method Id " + methodId + " not recognized!");
+ }
+ }
+ }
+
+}
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
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;
+ private int objectId = 2;
+ private IoTRMIComm rmiComm;
+ // Synchronization variables
+ private AtomicBoolean retValueReceived8 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived7 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived9 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived6 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived4 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived3 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived5 = new AtomicBoolean(false);
- 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 CameraSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+ if (_localPortSend != 0 && _localPortRecv != 0) {
+ rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+ } else
+ {
+ rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+ }
+ rmiComm.registerStub(objectId, 8, retValueReceived8);
+ rmiComm.registerStub(objectId, 7, retValueReceived7);
+ rmiComm.registerStub(objectId, 9, retValueReceived9);
+ rmiComm.registerStub(objectId, 6, retValueReceived6);
+ rmiComm.registerStub(objectId, 4, retValueReceived4);
+ rmiComm.registerStub(objectId, 3, retValueReceived3);
+ rmiComm.registerStub(objectId, 5, retValueReceived5);
+ IoTRMIUtil.mapStub.put(objectId, this);
+ }
+
+ public CameraSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+ rmiComm = _rmiComm;
+ objectId = _objectId;
+ rmiComm.registerStub(objectId, 8, retValueReceived8);
+ rmiComm.registerStub(objectId, 7, retValueReceived7);
+ rmiComm.registerStub(objectId, 9, retValueReceived9);
+ rmiComm.registerStub(objectId, 6, retValueReceived6);
+ rmiComm.registerStub(objectId, 4, retValueReceived4);
+ rmiComm.registerStub(objectId, 3, retValueReceived3);
+ rmiComm.registerStub(objectId, 5, retValueReceived5);
}
public int getMaxFPS() {
Class<?> retType = int.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived8.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived8.set(false);
+ rmiComm.setGetReturnBytes();
+
return (int)retObj;
}
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);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived7.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived7.set(false);
+ rmiComm.setGetReturnBytes();
+
return (boolean)retObj;
}
Class<?> retType = int.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived9.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived9.set(false);
+ rmiComm.setGetReturnBytes();
+
return (int)retObj;
}
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);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived6.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived6.set(false);
+ rmiComm.setGetReturnBytes();
+
return (boolean)retObj;
}
Class<?> retType = void.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public void start() {
Class<?> retType = void.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public long getTimestamp() {
Class<?> retType = long.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived4.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived4.set(false);
+ rmiComm.setGetReturnBytes();
+
return (long)retObj;
}
Class<?> retType = byte[].class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived3.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived3.set(false);
+ rmiComm.setGetReturnBytes();
+
return (byte[])retObj;
}
Class<?> retType = void.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public void registerCallback(CameraCallback _callbackTo) {
+ int[] objIdSent0 = new int[1];
try {
- CameraCallback_CallbackSkeleton skel0 = new CameraCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
- listCallbackObj.add(skel0);
+ if (!IoTRMIUtil.mapSkel.containsKey(_callbackTo)) {
+ int newObjIdSent = rmiComm.getObjectIdCounter();
+ objIdSent0[0] = newObjIdSent;
+ rmiComm.decrementObjectIdCounter();
+ CameraCallback_Skeleton skel0 = new CameraCallback_Skeleton(_callbackTo, rmiComm, newObjIdSent);
+ IoTRMIUtil.mapSkel.put(_callbackTo, skel0);
+ IoTRMIUtil.mapSkelId.put(_callbackTo, newObjIdSent);
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ skel0.___waitRequestInvokeMethod();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new Error("Exception when trying to run ___waitRequestInvokeMethod() for CameraCallback_Skeleton!");
+ }
+ }
+ };
+ thread.start();
+ while(!skel0.didAlreadyInitWaitInvoke());
+ }
+ else
+ {
+ int newObjIdSent = IoTRMIUtil.mapSkelId.get(_callbackTo);
+ objIdSent0[0] = newObjIdSent;
+ }
} 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);
+ Class<?>[] paramCls = new Class<?>[] { int[].class };
+ Object[] paramObj = new Object[] { objIdSent0 };
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public List<Resolution> getSupportedResolutions() {
Class<?> retType = int[].class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived5.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived5.set(false);
+ rmiComm.setGetReturnBytes();
+
int[] retEnum = (int[]) retObj;
Resolution[] enumVals = Resolution.values();
int retLen = retEnum.length;
homesecurity:
$(JAVAC) $(JFLAGS) *.java
cp HomeSecurityController.config $(BIN_DIR)/HomeSecurityController
- cd $(BIN_DIR)/HomeSecurityController; $(JAR) $(JARFLAGS) HomeSecurityController.jar ../HomeSecurityController/HomeSecurityController*.class ../HomeSecurityController/MotionDetection*.class ../iotcode/interfaces/SmartthingsSensor*.class ../iotcode/interfaces/Camera*.class ../iotcode/interfaces/Alarm*.class ../iotcode/interfaces/Room*.class ../iotcode/interfaces/ZoneState*.class
+ cd $(BIN_DIR)/HomeSecurityController; $(JAR) $(JARFLAGS) HomeSecurityController.jar ../HomeSecurityController/HomeSecurityController*.class ../HomeSecurityController/MotionDetection*.class ../iotcode/interfaces/SmartthingsSensor*.class ../iotcode/interfaces/Camera*.class ../iotcode/interfaces/Alarm*.class ../iotcode/interfaces/Room*.class ../iotcode/interfaces/ZoneState*.class ../iotcode/interfaces/Resolution*.class
PHONY += check-homesecurity
check-homesecurity:
$(JAVAC) $(JFLAGS) $(CHECKER_OPT) $(ASTUBS) *.java
cp HomeSecurityController.config $(BIN_DIR)/HomeSecurityController
- cd $(BIN_DIR)/HomeSecurityController; $(JAR) $(JARFLAGS) HomeSecurityController.jar ../HomeSecurityController/HomeSecurityController*.class ../HomeSecurityController/MotionDetection*.class ../iotcode/interfaces/SmartthingsSensor*.class ../iotcode/interfaces/Camera*.class ../iotcode/interfaces/Alarm*.class ../iotcode/interfaces/Room*.class ../iotcode/interfaces/ZoneState*.class
+ cd $(BIN_DIR)/HomeSecurityController; $(JAR) $(JARFLAGS) HomeSecurityController.jar ../HomeSecurityController/HomeSecurityController*.class ../HomeSecurityController/MotionDetection*.class ../iotcode/interfaces/SmartthingsSensor*.class ../iotcode/interfaces/Camera*.class ../iotcode/interfaces/Alarm*.class ../iotcode/interfaces/Room*.class ../iotcode/interfaces/ZoneState*.class ../iotcode/interfaces/Resolution*.class
.PHONY: $(PHONY)
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
-import iotcode.interfaces.RoomSmart;
+import iotcode.interfaces.*;
public class RoomSmart_Stub implements RoomSmart {
- private IoTRMICall rmiCall;
- private String callbackAddress;
- private int[] ports;
-
- private final static int objectId = 0;
+ private int objectId = 4;
+ private IoTRMIComm rmiComm;
+ // Synchronization variables
+ private AtomicBoolean retValueReceived0 = new AtomicBoolean(false);
- public RoomSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
- callbackAddress = _callbackAddress;
- ports = _ports;
- rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
+ public RoomSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+ if (_localPortSend != 0 && _localPortRecv != 0) {
+ rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+ } else
+ {
+ rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+ }
+ rmiComm.registerStub(objectId, 0, retValueReceived0);
+ IoTRMIUtil.mapStub.put(objectId, this);
+ }
+
+ public RoomSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+ rmiComm = _rmiComm;
+ objectId = _objectId;
+ rmiComm.registerStub(objectId, 0, retValueReceived0);
}
public int getRoomID() {
Class<?> retType = int.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived0.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived0.set(false);
+ rmiComm.setGetReturnBytes();
+
return (int)retObj;
}
+++ /dev/null
-package HomeSecurityController;
-
-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 SmartthingsSensorCallback_CallbackSkeleton implements SmartthingsSensorCallback {
-
- private SmartthingsSensorCallback mainObj;
- private int objectId = 0;
- private String callbackAddress;
-
-
- public SmartthingsSensorCallback_CallbackSkeleton(SmartthingsSensorCallback _mainObj, String _callbackAddress, int _objectId) throws Exception {
- callbackAddress = _callbackAddress;
- mainObj = _mainObj;
- objectId = _objectId;
- }
-
- public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
- mainObj.newReadingAvailable(_sensorId, _value, _activeValue);
- }
-
- public void ___newReadingAvailable(IoTRMIObject rmiObj) {
- Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class, int.class, boolean.class },
- new Class<?>[] { null, null, null });
- newReadingAvailable((int) paramObj[0], (int) paramObj[1], (boolean) paramObj[2]);
- }
-
- public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
- int methodId = rmiObj.getMethodId();
- switch (methodId) {
- case 0: ___newReadingAvailable(rmiObj); break;
- default:
- throw new Error("Method Id " + methodId + " not recognized!");
- }
- }
-
-}
--- /dev/null
+package HomeSecurityController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class SmartthingsSensorCallback_Skeleton implements SmartthingsSensorCallback {
+
+ private SmartthingsSensorCallback mainObj;
+ private int objectId = 3;
+ // Communications and synchronizations
+ private IoTRMIComm rmiComm;
+ private AtomicBoolean didAlreadyInitWaitInvoke;
+ private AtomicBoolean methodReceived;
+ private byte[] methodBytes = null;
+ // Permissions
+ private static Integer[] object3Permission = { 0 };
+ private static List<Integer> set3Allowed;
+
+
+ public SmartthingsSensorCallback_Skeleton(SmartthingsSensorCallback _mainObj, int _portSend, int _portRecv) throws Exception {
+ mainObj = _mainObj;
+ rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+ set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+ IoTRMIUtil.mapSkel.put(_mainObj, this);
+ IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+ didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+ methodReceived = new AtomicBoolean(false);
+ rmiComm.registerSkeleton(objectId, methodReceived);
+ Thread thread1 = new Thread() {
+ public void run() {
+ try {
+ ___waitRequestInvokeMethod();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ };
+ thread1.start();
+ }
+
+ public SmartthingsSensorCallback_Skeleton(SmartthingsSensorCallback _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
+ mainObj = _mainObj;
+ rmiComm = _rmiComm;
+ objectId = _objectId;
+ set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+ didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+ methodReceived = new AtomicBoolean(false);
+ rmiComm.registerSkeleton(objectId, methodReceived);
+ }
+
+ public boolean didAlreadyInitWaitInvoke() {
+ return didAlreadyInitWaitInvoke.get();
+ }
+
+ public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
+ mainObj.newReadingAvailable(_sensorId, _value, _activeValue);
+ }
+
+ public void ___newReadingAvailable() {
+ byte[] localMethodBytes = methodBytes;
+ rmiComm.setGetMethodBytes();
+ Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class, int.class, boolean.class }, new Class<?>[] { null, null, null }, localMethodBytes);
+ newReadingAvailable((int) paramObj[0], (int) paramObj[1], (boolean) paramObj[2]);
+ }
+
+ public void ___waitRequestInvokeMethod() throws IOException {
+ didAlreadyInitWaitInvoke.compareAndSet(false, true);
+ while (true) {
+ if (!methodReceived.get()) {
+ continue;
+ }
+ methodBytes = rmiComm.getMethodBytes();
+ methodReceived.set(false);
+ int _objectId = IoTRMIComm.getObjectId(methodBytes);
+ int methodId = IoTRMIComm.getMethodId(methodBytes);
+ if (_objectId == objectId) {
+ if (!set3Allowed.contains(methodId)) {
+ throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
+ }
+ }
+ else {
+ continue;
+ }
+ switch (methodId) {
+ case 0:
+ new Thread() {
+ public void run() {
+ try {
+ ___newReadingAvailable();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }.start();
+ break;
+ default:
+ throw new Error("Method Id " + methodId + " not recognized!");
+ }
+ }
+ }
+
+}
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
import iotcode.interfaces.*;
public class SmartthingsSensorSmart_Stub implements SmartthingsSensorSmart {
- private IoTRMICall rmiCall;
- private String callbackAddress;
- private int[] ports;
-
- private final static int objectId = 0;
- // Callback properties
- private IoTRMIObject rmiObj;
- List<SmartthingsSensorCallback> listCallbackObj;
- private int objIdCnt = 0;
- private final static int object0Id = 0; //SmartthingsSensorSmartCallback
- private static Integer[] object0Permission = { 0 };
- private static List<Integer> set0Allowed;
+ private int objectId = 3;
+ private IoTRMIComm rmiComm;
+ // Synchronization variables
+ private AtomicBoolean retValueReceived3 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived2 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived5 = new AtomicBoolean(false);
+ private AtomicBoolean retValueReceived1 = new AtomicBoolean(false);
- public SmartthingsSensorSmart_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<SmartthingsSensorCallback>();
- set0Allowed.add(-9999);
- ___initCallBack();
+ public SmartthingsSensorSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+ if (_localPortSend != 0 && _localPortRecv != 0) {
+ rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+ } else
+ {
+ rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+ }
+ rmiComm.registerStub(objectId, 3, retValueReceived3);
+ rmiComm.registerStub(objectId, 2, retValueReceived2);
+ rmiComm.registerStub(objectId, 5, retValueReceived5);
+ rmiComm.registerStub(objectId, 1, retValueReceived1);
+ IoTRMIUtil.mapStub.put(objectId, this);
+ }
+
+ public SmartthingsSensorSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+ rmiComm = _rmiComm;
+ objectId = _objectId;
+ rmiComm.registerStub(objectId, 3, retValueReceived3);
+ rmiComm.registerStub(objectId, 2, retValueReceived2);
+ rmiComm.registerStub(objectId, 5, retValueReceived5);
+ rmiComm.registerStub(objectId, 1, retValueReceived1);
}
public long getTimestampOfLastReading() {
Class<?> retType = long.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived3.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived3.set(false);
+ rmiComm.setGetReturnBytes();
+
return (long)retObj;
}
Class<?> retType = boolean.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived2.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived2.set(false);
+ rmiComm.setGetReturnBytes();
+
return (boolean)retObj;
}
Class<?> retType = int.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived5.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived5.set(false);
+ rmiComm.setGetReturnBytes();
+
return (int)retObj;
}
public void registerCallback(SmartthingsSensorCallback _callbackTo) {
+ int[] objIdSent0 = new int[1];
try {
- SmartthingsSensorCallback_CallbackSkeleton skel0 = new SmartthingsSensorCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
- listCallbackObj.add(skel0);
+ if (!IoTRMIUtil.mapSkel.containsKey(_callbackTo)) {
+ int newObjIdSent = rmiComm.getObjectIdCounter();
+ objIdSent0[0] = newObjIdSent;
+ rmiComm.decrementObjectIdCounter();
+ SmartthingsSensorCallback_Skeleton skel0 = new SmartthingsSensorCallback_Skeleton(_callbackTo, rmiComm, newObjIdSent);
+ IoTRMIUtil.mapSkel.put(_callbackTo, skel0);
+ IoTRMIUtil.mapSkelId.put(_callbackTo, newObjIdSent);
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ skel0.___waitRequestInvokeMethod();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new Error("Exception when trying to run ___waitRequestInvokeMethod() for SmartthingsSensorCallback_Skeleton!");
+ }
+ }
+ };
+ thread.start();
+ while(!skel0.didAlreadyInitWaitInvoke());
+ }
+ else
+ {
+ int newObjIdSent = IoTRMIUtil.mapSkelId.get(_callbackTo);
+ objIdSent0[0] = newObjIdSent;
+ }
} catch (Exception ex) {
ex.printStackTrace();
throw new Error("Exception when generating skeleton objects!");
int methodId = 6;
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);
- SmartthingsSensorCallback_CallbackSkeleton skel = (SmartthingsSensorCallback_CallbackSkeleton) listCallbackObj.get(objId);
- if (skel != null) {
- int methodId = IoTRMIObject.getMethodId(method);
- if (!set0Allowed.contains(methodId)) {
- throw new Error("Callback object for SmartthingsSensorCallback is not allowed to access method: " + methodId);
- }
- skel.invokeMethod(rmiObj);
- } else {
- throw new Error("SmartthingsSensorCallback: Object with Id " + objId + " not found!");
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new Error("Error instantiating class SmartthingsSensorCallback_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);
+ Class<?>[] paramCls = new Class<?>[] { int[].class };
+ Object[] paramObj = new Object[] { objIdSent0 };
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public int getValue() {
Class<?> retType = int.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+ // Waiting for return value
+ while (!retValueReceived1.get());
+ Object retObj = rmiComm.getReturnValue(retType, null);
+ retValueReceived1.set(false);
+ rmiComm.setGetReturnBytes();
+
return (int)retObj;
}
Class<?> retType = void.class;
Class<?>[] paramCls = new Class<?>[] { int.class };
Object[] paramObj = new Object[] { id };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
public void init() {
Class<?> retType = void.class;
Class<?>[] paramCls = new Class<?>[] { };
Object[] paramObj = new Object[] { };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+ rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
}
}
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
import iotcode.interfaces.*;
public class Alarm_Skeleton implements Alarm {
private Alarm mainObj;
- private IoTRMIObject rmiObj;
-
- private String callbackAddress;
- private final static int object0Id = 0; //AlarmSmart
- private static Integer[] object0Permission = { 4, 2, 0, 1, 3 };
- private static List<Integer> set0Allowed;
+ private int objectId = 1;
+ // Communications and synchronizations
+ private IoTRMIComm rmiComm;
+ private AtomicBoolean didAlreadyInitWaitInvoke;
+ private AtomicBoolean methodReceived;
+ private byte[] methodBytes = null;
+ // Permissions
+ private static Integer[] object1Permission = { 4, 2, 0, 1, 3 };
+ private static List<Integer> set1Allowed;
- public Alarm_Skeleton(Alarm _mainObj, String _callbackAddress, int _port) throws Exception {
+ public Alarm_Skeleton(Alarm _mainObj, int _portSend, int _portRecv) throws Exception {
+ mainObj = _mainObj;
+ rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+ set1Allowed = new ArrayList<Integer>(Arrays.asList(object1Permission));
+ IoTRMIUtil.mapSkel.put(_mainObj, this);
+ IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+ didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+ methodReceived = new AtomicBoolean(false);
+ rmiComm.registerSkeleton(objectId, methodReceived);
+ Thread thread1 = new Thread() {
+ public void run() {
+ try {
+ ___waitRequestInvokeMethod();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ };
+ thread1.start();
+ }
+
+ public Alarm_Skeleton(Alarm _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
mainObj = _mainObj;
- callbackAddress = _callbackAddress;
- rmiObj = new IoTRMIObject(_port);
- set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
- ___waitRequestInvokeMethod();
+ rmiComm = _rmiComm;
+ objectId = _objectId;
+ set1Allowed = new ArrayList<Integer>(Arrays.asList(object1Permission));
+ didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+ methodReceived = new AtomicBoolean(false);
+ rmiComm.registerSkeleton(objectId, methodReceived);
+ }
+
+ public boolean didAlreadyInitWaitInvoke() {
+ return didAlreadyInitWaitInvoke.get();
}
public void init() {
}
public void ___init() {
- Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
- new Class<?>[] { });
+ byte[] localMethodBytes = methodBytes;
+ rmiComm.setGetMethodBytes();
+ Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { }, new Class<?>[] { }, localMethodBytes);
init();
}
public void ___setZone() {
- Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class, boolean.class, int.class },
- new Class<?>[] { null, null, null });
+ byte[] localMethodBytes = methodBytes;
+ rmiComm.setGetMethodBytes();
+ Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class, boolean.class, int.class }, new Class<?>[] { null, null, null }, localMethodBytes);
setZone((int) paramObj[0], (boolean) paramObj[1], (int) paramObj[2]);
}
public void ___getZoneStates() throws IOException {
- Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
- new Class<?>[] { });
+ byte[] localMethodBytes = methodBytes;
+ rmiComm.setGetMethodBytes();
+ Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { }, new Class<?>[] { }, localMethodBytes);
List<ZoneState> retStruct = getZoneStates();
int retLen = retStruct.size();
Object retLenObj = retLen;
- rmiObj.sendReturnObj(retLenObj);
+ rmiComm.sendReturnObj(retLenObj, localMethodBytes);
Class<?>[] retCls = new Class<?>[3*retLen];
Object[] retObj = new Object[3*retLen];
int retPos = 0;
retCls[retPos] = int.class;
retObj[retPos++] = retStruct.get(i).duration;
}
- rmiObj.sendReturnObj(retCls, retObj);
+ rmiComm.sendReturnObj(retCls, retObj, localMethodBytes);
}
public void ___getNumberOfZones() throws IOException {
- Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
- new Class<?>[] { });
+ byte[] localMethodBytes = methodBytes;
+ rmiComm.setGetMethodBytes();
+ Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { }, new Class<?>[] { }, localMethodBytes);
Object retObj = getNumberOfZones();
- rmiObj.sendReturnObj(retObj);
+ rmiComm.sendReturnObj(retObj, localMethodBytes);
}
public void ___doesHaveZoneTimers() throws IOException {
- Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
- new Class<?>[] { });
+ byte[] localMethodBytes = methodBytes;
+ rmiComm.setGetMethodBytes();
+ Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { }, new Class<?>[] { }, localMethodBytes);
Object retObj = doesHaveZoneTimers();
- rmiObj.sendReturnObj(retObj);
+ rmiComm.sendReturnObj(retObj, localMethodBytes);
}
- private void ___waitRequestInvokeMethod() throws IOException {
+ public void ___waitRequestInvokeMethod() throws IOException {
+ didAlreadyInitWaitInvoke.compareAndSet(false, true);
while (true) {
- rmiObj.getMethodBytes();
- int _objectId = rmiObj.getObjectId();
- int methodId = rmiObj.getMethodId();
- if (_objectId == object0Id) {
- if (!set0Allowed.contains(methodId)) {
+ if (!methodReceived.get()) {
+ continue;
+ }
+ methodBytes = rmiComm.getMethodBytes();
+ methodReceived.set(false);
+ int _objectId = IoTRMIComm.getObjectId(methodBytes);
+ int methodId = IoTRMIComm.getMethodId(methodBytes);
+ if (_objectId == objectId) {
+ if (!set1Allowed.contains(methodId)) {
throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
}
}
else {
- throw new Error("Object Id: " + _objectId + " not recognized!");
+ continue;
}
switch (methodId) {
- case 0: ___init(); break;
- case 1: ___setZone(); break;
- case 2: ___getZoneStates(); break;
- case 3: ___getNumberOfZones(); break;
- case 4: ___doesHaveZoneTimers(); break;
+ case 0:
+ new Thread() {
+ public void run() {
+ try {
+ ___init();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }.start();
+ break;
+ case 1:
+ new Thread() {
+ public void run() {
+ try {
+ ___setZone();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }.start();
+ break;
+ case 2:
+ new Thread() {
+ public void run() {
+ try {
+ ___getZoneStates();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }.start();
+ break;
+ case 3:
+ new Thread() {
+ public void run() {
+ try {
+ ___getNumberOfZones();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }.start();
+ break;
+ case 4:
+ new Thread() {
+ public void run() {
+ try {
+ ___doesHaveZoneTimers();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }.start();
+ break;
default:
throw new Error("Method Id " + methodId + " not recognized!");
}
public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
private SmartthingsSensor mainObj;
- private int objectId = 2;
+ private int objectId = 3;
// Communications and synchronizations
private IoTRMIComm rmiComm;
private AtomicBoolean didAlreadyInitWaitInvoke;
public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
private SmartthingsSensor mainObj;
- private int objectId = 2;
+ private int objectId = 3;
// Communications and synchronizations
private IoTRMIComm rmiComm;
private AtomicBoolean didAlreadyInitWaitInvoke;
public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
private SmartthingsSensor mainObj;
- private int objectId = 2;
+ private int objectId = 3;
// Communications and synchronizations
private IoTRMIComm rmiComm;
private AtomicBoolean didAlreadyInitWaitInvoke;