+++ /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 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;
-
-
- 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 long getTimestampOfLastReading() {
- int methodId = 3;
- 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 boolean isActiveValue() {
- int methodId = 2;
- Class<?> retType = boolean.class;
- Class<?>[] paramCls = new Class<?>[] { };
- Object[] paramObj = new Object[] { };
- Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
- return (boolean)retObj;
- }
-
- public int getId() {
- 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);
- return (int)retObj;
- }
-
- public void registerCallback(SmartthingsSensorCallback _callbackTo) {
- try {
- SmartthingsSensorCallback_CallbackSkeleton skel0 = new SmartthingsSensorCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
- listCallbackObj.add(skel0);
- } 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);
- }
-
- public int getValue() {
- int methodId = 1;
- 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 void setId(int id) {
- int methodId = 4;
- Class<?> retType = void.class;
- Class<?>[] paramCls = new Class<?>[] { int.class };
- Object[] paramObj = new Object[] { id };
- rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
- }
-
- 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);
- }
-
-}