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 final static int object0Id = 0; //LightBulbTest
18 private static Integer[] object0Permission = { 2, 1, 3, 4, 0, 5 };
19 private static List<Integer> set0Allowed;
22 public LightBulb_Skeleton(LightBulb _mainObj, int _port) throws Exception {
24 rmiObj = new IoTRMIObject(_port);
25 set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
26 ___waitRequestInvokeMethod();
33 public void turnOff() {
37 public void turnOn() {
41 public boolean getState() {
42 return mainObj.getState();
45 public void setColor(double _hue, double _saturation, double _brightness) {
46 mainObj.setColor(_hue, _saturation, _brightness);
49 public void setTemperature(int _temperature) {
50 mainObj.setTemperature(_temperature);
53 public double getBrightness() {
54 return mainObj.getBrightness();
57 public double getHue() {
58 return mainObj.getHue();
61 public double getSaturation() {
62 return mainObj.getSaturation();
65 public int getTemperature() {
66 return mainObj.getTemperature();
69 public double getBrightnessRangeLowerBound() {
70 return mainObj.getBrightnessRangeLowerBound();
73 public double getBrightnessRangeUpperBound() {
74 return mainObj.getBrightnessRangeUpperBound();
77 public double getHueRangeLowerBound() {
78 return mainObj.getHueRangeLowerBound();
81 public double getHueRangeUpperBound() {
82 return mainObj.getHueRangeUpperBound();
85 public double getSaturationRangeLowerBound() {
86 return mainObj.getSaturationRangeLowerBound();
89 public double getSaturationRangeUpperBound() {
90 return mainObj.getSaturationRangeUpperBound();
93 public int getTemperatureRangeLowerBound() {
94 return mainObj.getTemperatureRangeLowerBound();
97 public int getTemperatureRangeUpperBound() {
98 return mainObj.getTemperatureRangeUpperBound();
101 public void ___init() {
102 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
107 public void ___turnOff() {
108 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
113 public void ___turnOn() {
114 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
119 public void ___getState() throws IOException {
120 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
122 Object retObj = getState();
123 rmiObj.sendReturnObj(retObj);
126 public void ___setColor() {
127 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { double.class, double.class, double.class },
128 new Class<?>[] { null, null, null });
129 setColor((double) paramObj[0], (double) paramObj[1], (double) paramObj[2]);
132 public void ___setTemperature() {
133 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
134 new Class<?>[] { null });
135 setTemperature((int) paramObj[0]);
138 public void ___getBrightness() throws IOException {
139 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
141 Object retObj = getBrightness();
142 rmiObj.sendReturnObj(retObj);
145 public void ___getHue() throws IOException {
146 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
148 Object retObj = getHue();
149 rmiObj.sendReturnObj(retObj);
152 public void ___getSaturation() throws IOException {
153 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
155 Object retObj = getSaturation();
156 rmiObj.sendReturnObj(retObj);
159 public void ___getTemperature() throws IOException {
160 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
162 Object retObj = getTemperature();
163 rmiObj.sendReturnObj(retObj);
166 public void ___getBrightnessRangeLowerBound() throws IOException {
167 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
169 Object retObj = getBrightnessRangeLowerBound();
170 rmiObj.sendReturnObj(retObj);
173 public void ___getBrightnessRangeUpperBound() throws IOException {
174 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
176 Object retObj = getBrightnessRangeUpperBound();
177 rmiObj.sendReturnObj(retObj);
180 public void ___getHueRangeLowerBound() throws IOException {
181 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
183 Object retObj = getHueRangeLowerBound();
184 rmiObj.sendReturnObj(retObj);
187 public void ___getHueRangeUpperBound() throws IOException {
188 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
190 Object retObj = getHueRangeUpperBound();
191 rmiObj.sendReturnObj(retObj);
194 public void ___getSaturationRangeLowerBound() throws IOException {
195 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
197 Object retObj = getSaturationRangeLowerBound();
198 rmiObj.sendReturnObj(retObj);
201 public void ___getSaturationRangeUpperBound() throws IOException {
202 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
204 Object retObj = getSaturationRangeUpperBound();
205 rmiObj.sendReturnObj(retObj);
208 public void ___getTemperatureRangeLowerBound() throws IOException {
209 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
211 Object retObj = getTemperatureRangeLowerBound();
212 rmiObj.sendReturnObj(retObj);
215 public void ___getTemperatureRangeUpperBound() throws IOException {
216 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
218 Object retObj = getTemperatureRangeUpperBound();
219 rmiObj.sendReturnObj(retObj);
222 private void ___waitRequestInvokeMethod() throws IOException {
224 rmiObj.getMethodBytes();
225 int _objectId = rmiObj.getObjectId();
226 int methodId = rmiObj.getMethodId();
227 if (_objectId == object0Id) {
228 if (!set0Allowed.contains(methodId)) {
229 throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
233 throw new Error("Object Id: " + _objectId + " not recognized!");
236 case 0: ___init(); break;
237 case 1: ___turnOff(); break;
238 case 2: ___turnOn(); break;
239 case 3: ___getState(); break;
240 case 4: ___setColor(); break;
241 case 5: ___setTemperature(); break;
242 case 6: ___getBrightness(); break;
243 case 7: ___getHue(); break;
244 case 8: ___getSaturation(); break;
245 case 9: ___getTemperature(); break;
246 case 10: ___getBrightnessRangeLowerBound(); break;
247 case 11: ___getBrightnessRangeUpperBound(); break;
248 case 12: ___getHueRangeLowerBound(); break;
249 case 13: ___getHueRangeUpperBound(); break;
250 case 14: ___getSaturationRangeLowerBound(); break;
251 case 15: ___getSaturationRangeUpperBound(); break;
252 case 16: ___getTemperatureRangeLowerBound(); break;
253 case 17: ___getTemperatureRangeUpperBound(); break;
255 throw new Error("Method Id " + methodId + " not recognized!");