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 Camera_CallbackSkeleton implements Camera {
14 private Camera mainObj;
15 private int objectId = 0;
16 private String callbackAddress;
17 private static int objIdCnt = 0;
18 private IoTRMICall rmiCall;
23 public Camera_CallbackSkeleton(Camera _mainObj, String _callbackAddress, int _objectId) throws Exception {
24 callbackAddress = _callbackAddress;
41 public byte[] getLatestFrame() {
42 return mainObj.getLatestFrame();
45 public long getTimestamp() {
46 return mainObj.getTimestamp();
49 public List<Resolution> getSupportedResolutions() {
50 return mainObj.getSupportedResolutions();
53 public boolean setResolution(Resolution _res) {
54 return mainObj.setResolution(_res);
57 public boolean setFPS(int _fps) {
58 return mainObj.setFPS(_fps);
61 public int getMaxFPS() {
62 return mainObj.getMaxFPS();
65 public int getMinFPS() {
66 return mainObj.getMinFPS();
69 public void registerCallback(CameraSmartCallback _callbackTo) {
70 mainObj.registerCallback(_callbackTo);
73 public void ___regCB(IoTRMIObject rmiObj) throws IOException {
74 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
75 ports = (int[]) paramObj[0];
76 rmiCall = new IoTRMICall((int) paramObj[0], (String) paramObj[1], ports[1]);
79 public void ___init(IoTRMIObject rmiObj) {
80 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
85 public void ___start(IoTRMIObject rmiObj) {
86 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
91 public void ___stop(IoTRMIObject rmiObj) {
92 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
97 public void ___getLatestFrame(IoTRMIObject rmiObj) throws IOException {
98 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
100 Object retObj = getLatestFrame();
101 rmiObj.sendReturnObj(retObj);
104 public void ___getTimestamp(IoTRMIObject rmiObj) throws IOException {
105 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
107 Object retObj = getTimestamp();
108 rmiObj.sendReturnObj(retObj);
111 public void ___getSupportedResolutions(IoTRMIObject rmiObj) throws IOException {
112 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
114 List<Resolution> retEnum = getSupportedResolutions();
115 int retLen = retEnum.size();
116 int[] retEnumVal = new int[retLen];
117 for (int i = 0; i < retLen; i++) {
118 retEnumVal[i] = retEnum.get(i).ordinal();
120 Object retObj = retEnumVal;
121 rmiObj.sendReturnObj(retObj);
124 public void ___setResolution(IoTRMIObject rmiObj) throws IOException {
125 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class },
126 new Class<?>[] { null });
127 int paramInt0[] = (int[]) paramObj[0];
128 Resolution[] enumVals = Resolution.values();
129 Resolution paramEnum0 = enumVals[paramInt0[0]];
130 Object retObj = setResolution(paramEnum0);
131 rmiObj.sendReturnObj(retObj);
134 public void ___setFPS(IoTRMIObject rmiObj) throws IOException {
135 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
136 new Class<?>[] { null });
137 Object retObj = setFPS((int) paramObj[0]);
138 rmiObj.sendReturnObj(retObj);
141 public void ___getMaxFPS(IoTRMIObject rmiObj) throws IOException {
142 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
144 Object retObj = getMaxFPS();
145 rmiObj.sendReturnObj(retObj);
148 public void ___getMinFPS(IoTRMIObject rmiObj) throws IOException {
149 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
151 Object retObj = getMinFPS();
152 rmiObj.sendReturnObj(retObj);
155 public void ___registerCallback(IoTRMIObject rmiObj) {
156 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
157 new Class<?>[] { null });
159 CameraSmartCallback stub0 = new CameraSmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
161 registerCallback(stub0);
162 } catch(Exception ex) {
163 ex.printStackTrace();
164 throw new Error("Exception from callback object instantiation!");
168 public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
169 int methodId = rmiObj.getMethodId();
171 case 0: ___init(rmiObj); break;
172 case 1: ___start(rmiObj); break;
173 case 2: ___stop(rmiObj); break;
174 case 3: ___getLatestFrame(rmiObj); break;
175 case 4: ___getTimestamp(rmiObj); break;
176 case 5: ___getSupportedResolutions(rmiObj); break;
177 case 6: ___setResolution(rmiObj); break;
178 case 7: ___setFPS(rmiObj); break;
179 case 8: ___getMaxFPS(rmiObj); break;
180 case 9: ___getMinFPS(rmiObj); break;
181 case 10: ___registerCallback(rmiObj); break;
182 case -9998: ___regCB(rmiObj); break;
184 throw new Error("Method Id " + methodId + " not recognized!");