1 package IrrigationController;
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 WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
14 private IoTRMICall rmiCall;
15 private String callbackAddress;
18 private final static int objectId = 0;
19 // Callback properties
20 private IoTRMIObject rmiObj;
21 List<WeatherGatewayCallback> listCallbackObj;
22 private int objIdCnt = 0;
23 private final static int object0Id = 0; //WeatherGatewaySmartCallback
24 private static Integer[] object0Permission = { 0 };
25 private static List<Integer> set0Allowed;
28 public WeatherGatewaySmart_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<WeatherGatewayCallback>();
34 set0Allowed.add(-9999);
38 public double getInchesPerWeek() {
40 Class<?> retType = double.class;
41 Class<?>[] paramCls = new Class<?>[] { };
42 Object[] paramObj = new Object[] { };
43 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
44 return (double)retObj;
47 public double getInchesPerMinute() {
49 Class<?> retType = double.class;
50 Class<?>[] paramCls = new Class<?>[] { };
51 Object[] paramObj = new Object[] { };
52 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
53 return (double)retObj;
56 public int getDaysToWaterOn() {
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 void registerCallback(WeatherGatewayCallback _callbackTo) {
67 WeatherGatewayCallback_CallbackSkeleton skel0 = new WeatherGatewayCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
68 listCallbackObj.add(skel0);
69 } catch (Exception ex) {
71 throw new Error("Exception when generating skeleton objects!");
75 Class<?> retType = void.class;
76 Class<?>[] paramCls = new Class<?>[] { int.class };
77 Object[] paramObj = new Object[] { new Integer(1) };
78 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
81 public void ___initCallBack() {
82 Thread thread = new Thread() {
85 rmiObj = new IoTRMIObject(ports[0]);
87 byte[] method = rmiObj.getMethodBytes();
88 int objId = IoTRMIObject.getObjectId(method);
89 WeatherGatewayCallback_CallbackSkeleton skel = (WeatherGatewayCallback_CallbackSkeleton) listCallbackObj.get(objId);
91 int methodId = IoTRMIObject.getMethodId(method);
92 if (!set0Allowed.contains(methodId)) {
93 throw new Error("Callback object for WeatherGatewayCallback is not allowed to access method: " + methodId);
95 skel.invokeMethod(rmiObj);
97 throw new Error("WeatherGatewayCallback: Object with Id " + objId + " not found!");
100 } catch (Exception ex) {
101 ex.printStackTrace();
102 throw new Error("Error instantiating class WeatherGatewayCallback_CallbackSkeleton!");
108 int methodId = -9998;
109 Class<?> retType = void.class;
110 Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
111 Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
112 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
117 Class<?> retType = void.class;
118 Class<?>[] paramCls = new Class<?>[] { };
119 Object[] paramObj = new Object[] { };
120 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
123 public void start() {
125 Class<?> retType = void.class;
126 Class<?>[] paramCls = new Class<?>[] { };
127 Object[] paramObj = new Object[] { };
128 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
133 Class<?> retType = void.class;
134 Class<?>[] paramCls = new Class<?>[] { };
135 Object[] paramObj = new Object[] { };
136 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
139 public int getWeatherZipCode() {
141 Class<?> retType = int.class;
142 Class<?>[] paramCls = new Class<?>[] { };
143 Object[] paramObj = new Object[] { };
144 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);