1 package SmartLightsController;
3 import java.io.IOException;
5 import java.util.ArrayList;
6 import java.util.Arrays;
7 import iotrmi.Java.IoTRMICall;
8 import iotrmi.Java.IoTRMIObject;
10 import iotcode.interfaces.*;
12 public class CameraSmart_Stub implements CameraSmart {
14 private IoTRMICall rmiCall;
15 private String callbackAddress;
18 private final static int objectId = 0;
19 // Callback properties
20 private IoTRMIObject rmiObj;
21 List<CameraCallback> listCallbackObj;
22 private static int objIdCnt = 0;
23 private final static int object0Id = 0; //CameraSmartCallback
24 private static Integer[] object0Permission = { 0 };
25 private static List<Integer> set0Allowed;
28 public CameraSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
29 callbackAddress = _callbackAddress;
31 rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
32 set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
33 listCallbackObj = new ArrayList<CameraCallback>();
34 set0Allowed.add(-9999);
38 public int getMaxFPS() {
40 Class<?> retType = int.class;
41 Class<?>[] paramCls = new Class<?>[] { };
42 Object[] paramObj = new Object[] { };
43 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
47 public boolean setFPS(int _fps) {
49 Class<?> retType = boolean.class;
50 Class<?>[] paramCls = new Class<?>[] { int.class };
51 Object[] paramObj = new Object[] { _fps };
52 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
53 return (boolean)retObj;
56 public int getMinFPS() {
58 Class<?> retType = int.class;
59 Class<?>[] paramCls = new Class<?>[] { };
60 Object[] paramObj = new Object[] { };
61 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
65 public boolean setResolution(Resolution _res) {
67 Class<?> retType = boolean.class;
68 int paramEnum0[] = new int[1];
69 paramEnum0[0] = _res.ordinal();
70 Class<?>[] paramCls = new Class<?>[] { int[].class };
71 Object[] paramObj = new Object[] { paramEnum0 };
72 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
73 return (boolean)retObj;
78 Class<?> retType = void.class;
79 Class<?>[] paramCls = new Class<?>[] { };
80 Object[] paramObj = new Object[] { };
81 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
86 Class<?> retType = void.class;
87 Class<?>[] paramCls = new Class<?>[] { };
88 Object[] paramObj = new Object[] { };
89 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
92 public long getTimestamp() {
94 Class<?> retType = long.class;
95 Class<?>[] paramCls = new Class<?>[] { };
96 Object[] paramObj = new Object[] { };
97 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
101 public byte[] getLatestFrame() {
103 Class<?> retType = byte[].class;
104 Class<?>[] paramCls = new Class<?>[] { };
105 Object[] paramObj = new Object[] { };
106 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
107 return (byte[])retObj;
112 Class<?> retType = void.class;
113 Class<?>[] paramCls = new Class<?>[] { };
114 Object[] paramObj = new Object[] { };
115 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
118 public void registerCallback(CameraCallback _callbackTo) {
120 CameraCallback_CallbackSkeleton skel0 = new CameraCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
121 listCallbackObj.add(skel0);
122 } catch (Exception ex) {
123 ex.printStackTrace();
124 throw new Error("Exception when generating skeleton objects!");
128 Class<?> retType = void.class;
129 Class<?>[] paramCls = new Class<?>[] { int.class };
130 Object[] paramObj = new Object[] { new Integer(1) };
131 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
134 public void ___initCallBack() {
135 Thread thread = new Thread() {
138 rmiObj = new IoTRMIObject(ports[0]);
140 byte[] method = rmiObj.getMethodBytes();
141 int objId = IoTRMIObject.getObjectId(method);
142 CameraCallback_CallbackSkeleton skel = (CameraCallback_CallbackSkeleton) listCallbackObj.get(objId);
144 int methodId = IoTRMIObject.getMethodId(method);
145 if (!set0Allowed.contains(methodId)) {
146 throw new Error("Callback object for CameraCallback is not allowed to access method: " + methodId);
148 skel.invokeMethod(rmiObj);
150 throw new Error("CameraCallback: Object with Id " + objId + " not found!");
153 } catch (Exception ex) {
154 ex.printStackTrace();
155 throw new Error("Error instantiating class CameraCallback_CallbackSkeleton!");
161 int methodId = -9998;
162 Class<?> retType = void.class;
163 Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
164 Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
165 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
168 public List<Resolution> getSupportedResolutions() {
170 Class<?> retType = int[].class;
171 Class<?>[] paramCls = new Class<?>[] { };
172 Object[] paramObj = new Object[] { };
173 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
174 int[] retEnum = (int[]) retObj;
175 Resolution[] enumVals = Resolution.values();
176 int retLen = retEnum.length;
177 List<Resolution> enumRetVal = new ArrayList<Resolution>();
178 for (int i = 0; i < retLen; i++) {
179 enumRetVal.add(enumVals[retEnum[i]]);