1 package iotcode.LifxLightBulb;
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.LightBulb;
12 public class LightBulb_Skeleton implements LightBulb {
14 private LightBulb mainObj;
15 private IoTRMIObject rmiObj;
17 private String callbackAddress;
18 private final static int object0Id = 0; //LightBulbTest
19 private static Integer[] object0Permission = { 2, 6, 1, 3, 4, 8, 0, 5, 7, 9 };
20 private static List<Integer> set0Allowed;
23 public LightBulb_Skeleton(LightBulb _mainObj, String _callbackAddress, int _port) throws Exception {
25 callbackAddress = _callbackAddress;
26 rmiObj = new IoTRMIObject(_port);
27 set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
28 ___waitRequestInvokeMethod();
35 public void turnOff() {
39 public void turnOn() {
43 public boolean getState() {
44 return mainObj.getState();
47 public void setColor(double _hue, double _saturation, double _brightness) {
48 mainObj.setColor(_hue, _saturation, _brightness);
51 public void setTemperature(int _temperature) {
52 mainObj.setTemperature(_temperature);
55 public double getBrightness() {
56 return mainObj.getBrightness();
59 public double getHue() {
60 return mainObj.getHue();
63 public double getSaturation() {
64 return mainObj.getSaturation();
67 public int getTemperature() {
68 return mainObj.getTemperature();
71 public double getBrightnessRangeLowerBound() {
72 return mainObj.getBrightnessRangeLowerBound();
75 public double getBrightnessRangeUpperBound() {
76 return mainObj.getBrightnessRangeUpperBound();
79 public double getHueRangeLowerBound() {
80 return mainObj.getHueRangeLowerBound();
83 public double getHueRangeUpperBound() {
84 return mainObj.getHueRangeUpperBound();
87 public double getSaturationRangeLowerBound() {
88 return mainObj.getSaturationRangeLowerBound();
91 public double getSaturationRangeUpperBound() {
92 return mainObj.getSaturationRangeUpperBound();
95 public int getTemperatureRangeLowerBound() {
96 return mainObj.getTemperatureRangeLowerBound();
99 public int getTemperatureRangeUpperBound() {
100 return mainObj.getTemperatureRangeUpperBound();
103 public void ___init() {
104 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
109 public void ___turnOff() {
110 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
115 public void ___turnOn() {
116 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
121 public void ___getState() throws IOException {
122 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
124 Object retObj = getState();
125 rmiObj.sendReturnObj(retObj);
128 public void ___setColor() {
129 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { double.class, double.class, double.class },
130 new Class<?>[] { null, null, null });
131 setColor((double) paramObj[0], (double) paramObj[1], (double) paramObj[2]);
134 public void ___setTemperature() {
135 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
136 new Class<?>[] { null });
137 setTemperature((int) paramObj[0]);
140 public void ___getBrightness() throws IOException {
141 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
143 Object retObj = getBrightness();
144 rmiObj.sendReturnObj(retObj);
147 public void ___getHue() throws IOException {
148 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
150 Object retObj = getHue();
151 rmiObj.sendReturnObj(retObj);
154 public void ___getSaturation() throws IOException {
155 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
157 Object retObj = getSaturation();
158 rmiObj.sendReturnObj(retObj);
161 public void ___getTemperature() throws IOException {
162 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
164 Object retObj = getTemperature();
165 rmiObj.sendReturnObj(retObj);
168 public void ___getBrightnessRangeLowerBound() throws IOException {
169 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
171 Object retObj = getBrightnessRangeLowerBound();
172 rmiObj.sendReturnObj(retObj);
175 public void ___getBrightnessRangeUpperBound() throws IOException {
176 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
178 Object retObj = getBrightnessRangeUpperBound();
179 rmiObj.sendReturnObj(retObj);
182 public void ___getHueRangeLowerBound() throws IOException {
183 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
185 Object retObj = getHueRangeLowerBound();
186 rmiObj.sendReturnObj(retObj);
189 public void ___getHueRangeUpperBound() throws IOException {
190 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
192 Object retObj = getHueRangeUpperBound();
193 rmiObj.sendReturnObj(retObj);
196 public void ___getSaturationRangeLowerBound() throws IOException {
197 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
199 Object retObj = getSaturationRangeLowerBound();
200 rmiObj.sendReturnObj(retObj);
203 public void ___getSaturationRangeUpperBound() throws IOException {
204 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
206 Object retObj = getSaturationRangeUpperBound();
207 rmiObj.sendReturnObj(retObj);
210 public void ___getTemperatureRangeLowerBound() throws IOException {
211 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
213 Object retObj = getTemperatureRangeLowerBound();
214 rmiObj.sendReturnObj(retObj);
217 public void ___getTemperatureRangeUpperBound() throws IOException {
218 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
220 Object retObj = getTemperatureRangeUpperBound();
221 rmiObj.sendReturnObj(retObj);
224 private void ___waitRequestInvokeMethod() throws IOException {
226 rmiObj.getMethodBytes();
227 int _objectId = rmiObj.getObjectId();
228 int methodId = rmiObj.getMethodId();
229 if (_objectId == object0Id) {
230 if (!set0Allowed.contains(methodId)) {
231 throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
235 throw new Error("Object Id: " + _objectId + " not recognized!");
238 case 0: ___init(); break;
239 case 1: ___turnOff(); break;
240 case 2: ___turnOn(); break;
241 case 3: ___getState(); break;
242 case 4: ___setColor(); break;
243 case 5: ___setTemperature(); break;
244 case 6: ___getBrightness(); break;
245 case 7: ___getHue(); break;
246 case 8: ___getSaturation(); break;
247 case 9: ___getTemperature(); break;
248 case 10: ___getBrightnessRangeLowerBound(); break;
249 case 11: ___getBrightnessRangeUpperBound(); break;
250 case 12: ___getHueRangeLowerBound(); break;
251 case 13: ___getHueRangeUpperBound(); break;
252 case 14: ___getSaturationRangeLowerBound(); break;
253 case 15: ___getSaturationRangeUpperBound(); break;
254 case 16: ___getTemperatureRangeLowerBound(); break;
255 case 17: ___getTemperatureRangeUpperBound(); break;
257 throw new Error("Method Id " + methodId + " not recognized!");