1 package iotcode.WeatherPhoneGateway;
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 WeatherGateway_Skeleton implements WeatherGateway {
14 private WeatherGateway mainObj;
15 private IoTRMIObject rmiObj;
17 private String callbackAddress;
18 private int objIdCnt = 0;
19 private IoTRMICall rmiCall;
22 private final static int object0Id = 0; //WeatherGatewaySmart
23 private static Integer[] object0Permission = { 3, 6, 5, 7, 2, 1, 0, 4 };
24 private static List<Integer> set0Allowed;
27 public WeatherGateway_Skeleton(WeatherGateway _mainObj, String _callbackAddress, int _port) throws Exception {
29 callbackAddress = _callbackAddress;
30 rmiObj = new IoTRMIObject(_port);
31 set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
32 set0Allowed.add(-9998);
33 ___waitRequestInvokeMethod();
48 public double getInchesPerWeek() {
49 return mainObj.getInchesPerWeek();
52 public int getWeatherZipCode() {
53 return mainObj.getWeatherZipCode();
56 public int getDaysToWaterOn() {
57 return mainObj.getDaysToWaterOn();
60 public double getInchesPerMinute() {
61 return mainObj.getInchesPerMinute();
64 public void registerCallback(WeatherGatewaySmartCallback _callbackTo) {
65 mainObj.registerCallback(_callbackTo);
68 public void ___regCB() throws IOException {
69 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
70 ports = (int[]) paramObj[0];
71 rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
74 public void ___init() {
75 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
80 public void ___start() {
81 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
86 public void ___stop() {
87 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
92 public void ___getInchesPerWeek() throws IOException {
93 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
95 Object retObj = getInchesPerWeek();
96 rmiObj.sendReturnObj(retObj);
99 public void ___getWeatherZipCode() throws IOException {
100 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
102 Object retObj = getWeatherZipCode();
103 rmiObj.sendReturnObj(retObj);
106 public void ___getDaysToWaterOn() throws IOException {
107 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
109 Object retObj = getDaysToWaterOn();
110 rmiObj.sendReturnObj(retObj);
113 public void ___getInchesPerMinute() throws IOException {
114 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
116 Object retObj = getInchesPerMinute();
117 rmiObj.sendReturnObj(retObj);
120 public void ___registerCallback() {
121 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
122 new Class<?>[] { null });
124 WeatherGatewaySmartCallback stub0 = new WeatherGatewaySmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
126 registerCallback(stub0);
127 } catch(Exception ex) {
128 ex.printStackTrace();
129 throw new Error("Exception from callback object instantiation!");
133 private void ___waitRequestInvokeMethod() throws IOException {
135 rmiObj.getMethodBytes();
136 int _objectId = rmiObj.getObjectId();
137 int methodId = rmiObj.getMethodId();
138 if (_objectId == object0Id) {
139 if (!set0Allowed.contains(methodId)) {
140 throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
144 throw new Error("Object Id: " + _objectId + " not recognized!");
147 case 0: ___init(); break;
148 case 1: ___start(); break;
149 case 2: ___stop(); break;
150 case 3: ___getInchesPerWeek(); break;
151 case 4: ___getWeatherZipCode(); break;
152 case 5: ___getDaysToWaterOn(); break;
153 case 6: ___getInchesPerMinute(); break;
154 case 7: ___registerCallback(); break;
155 case -9998: ___regCB(); break;
157 throw new Error("Method Id " + methodId + " not recognized!");