1 #ifndef _LIGHTBULB_SKELETON_HPP__
2 #define _LIGHTBULB_SKELETON_HPP__
5 #include "LightBulb.hpp"
9 #include "IoTRMICall.hpp"
10 #include "IoTRMIObject.hpp"
14 class LightBulb_Skeleton : public LightBulb
20 string callbackAddress;
23 const static int object0Id = 0; //LightBulbSmart
24 static set<int> set0Allowed;
29 LightBulb_Skeleton(LightBulb *_mainObj, string _callbackAddress, int _port) {
30 bool _bResult = false;
32 callbackAddress = _callbackAddress;
34 log.open("LightBulb_Skeleton_cpp.log");
35 log << "Callback address: " << callbackAddress << endl;
36 log << "Port: " << _port << endl;
37 rmiObj = new IoTRMIObject(_port, &_bResult);
38 log << "Established connection with slave! Wait request invoke now..." << endl;
39 ___waitRequestInvokeMethod();
42 ~LightBulb_Skeleton() {
62 return mainObj->getState();
65 void setColor(double _hue, double _saturation, double _brightness) {
66 mainObj->setColor(_hue, _saturation, _brightness);
69 void setTemperature(int _temperature) {
70 mainObj->setTemperature(_temperature);
73 double getBrightness() {
74 return mainObj->getBrightness();
78 return mainObj->getHue();
81 double getSaturation() {
82 return mainObj->getSaturation();
85 int getTemperature() {
86 return mainObj->getTemperature();
89 double getBrightnessRangeLowerBound() {
90 return mainObj->getBrightnessRangeLowerBound();
93 double getBrightnessRangeUpperBound() {
94 return mainObj->getBrightnessRangeUpperBound();
97 double getHueRangeLowerBound() {
98 return mainObj->getHueRangeLowerBound();
101 double getHueRangeUpperBound() {
102 return mainObj->getHueRangeUpperBound();
105 double getSaturationRangeLowerBound() {
106 return mainObj->getSaturationRangeLowerBound();
109 double getSaturationRangeUpperBound() {
110 return mainObj->getSaturationRangeUpperBound();
113 int getTemperatureRangeLowerBound() {
114 return mainObj->getTemperatureRangeLowerBound();
117 int getTemperatureRangeUpperBound() {
118 return mainObj->getTemperatureRangeUpperBound();
122 string paramCls[] = { };
124 void* paramObj[] = { };
125 rmiObj->getMethodParams(paramCls, numParam, paramObj);
130 string paramCls[] = { };
132 void* paramObj[] = { };
133 rmiObj->getMethodParams(paramCls, numParam, paramObj);
138 string paramCls[] = { };
140 void* paramObj[] = { };
141 rmiObj->getMethodParams(paramCls, numParam, paramObj);
146 string paramCls[] = { };
148 void* paramObj[] = { };
149 rmiObj->getMethodParams(paramCls, numParam, paramObj);
150 bool retVal = getState();
151 void* retObj = &retVal;
152 rmiObj->sendReturnObj(retObj, "boolean");
156 string paramCls[] = { "double", "double", "double" };
161 void* paramObj[] = { &_hue, &_saturation, &_brightness };
162 rmiObj->getMethodParams(paramCls, numParam, paramObj);
163 setColor(_hue, _saturation, _brightness);
166 void ___setTemperature() {
167 string paramCls[] = { "int" };
170 void* paramObj[] = { &_temperature };
171 rmiObj->getMethodParams(paramCls, numParam, paramObj);
172 setTemperature(_temperature);
175 void ___getBrightness() {
176 string paramCls[] = { };
178 void* paramObj[] = { };
179 rmiObj->getMethodParams(paramCls, numParam, paramObj);
180 double retVal = getBrightness();
181 void* retObj = &retVal;
182 rmiObj->sendReturnObj(retObj, "double");
186 string paramCls[] = { };
188 void* paramObj[] = { };
189 rmiObj->getMethodParams(paramCls, numParam, paramObj);
190 double retVal = getHue();
191 void* retObj = &retVal;
192 rmiObj->sendReturnObj(retObj, "double");
195 void ___getSaturation() {
196 string paramCls[] = { };
198 void* paramObj[] = { };
199 rmiObj->getMethodParams(paramCls, numParam, paramObj);
200 double retVal = getSaturation();
201 void* retObj = &retVal;
202 rmiObj->sendReturnObj(retObj, "double");
205 void ___getTemperature() {
206 string paramCls[] = { };
208 void* paramObj[] = { };
209 rmiObj->getMethodParams(paramCls, numParam, paramObj);
210 int retVal = getTemperature();
211 void* retObj = &retVal;
212 rmiObj->sendReturnObj(retObj, "int");
215 void ___getBrightnessRangeLowerBound() {
216 string paramCls[] = { };
218 void* paramObj[] = { };
219 rmiObj->getMethodParams(paramCls, numParam, paramObj);
220 double retVal = getBrightnessRangeLowerBound();
221 void* retObj = &retVal;
222 rmiObj->sendReturnObj(retObj, "double");
225 void ___getBrightnessRangeUpperBound() {
226 string paramCls[] = { };
228 void* paramObj[] = { };
229 rmiObj->getMethodParams(paramCls, numParam, paramObj);
230 double retVal = getBrightnessRangeUpperBound();
231 void* retObj = &retVal;
232 rmiObj->sendReturnObj(retObj, "double");
235 void ___getHueRangeLowerBound() {
236 string paramCls[] = { };
238 void* paramObj[] = { };
239 rmiObj->getMethodParams(paramCls, numParam, paramObj);
240 double retVal = getHueRangeLowerBound();
241 void* retObj = &retVal;
242 rmiObj->sendReturnObj(retObj, "double");
245 void ___getHueRangeUpperBound() {
246 string paramCls[] = { };
248 void* paramObj[] = { };
249 rmiObj->getMethodParams(paramCls, numParam, paramObj);
250 double retVal = getHueRangeUpperBound();
251 void* retObj = &retVal;
252 rmiObj->sendReturnObj(retObj, "double");
255 void ___getSaturationRangeLowerBound() {
256 string paramCls[] = { };
258 void* paramObj[] = { };
259 rmiObj->getMethodParams(paramCls, numParam, paramObj);
260 double retVal = getSaturationRangeLowerBound();
261 void* retObj = &retVal;
262 rmiObj->sendReturnObj(retObj, "double");
265 void ___getSaturationRangeUpperBound() {
266 string paramCls[] = { };
268 void* paramObj[] = { };
269 rmiObj->getMethodParams(paramCls, numParam, paramObj);
270 double retVal = getSaturationRangeUpperBound();
271 void* retObj = &retVal;
272 rmiObj->sendReturnObj(retObj, "double");
275 void ___getTemperatureRangeLowerBound() {
276 string paramCls[] = { };
278 void* paramObj[] = { };
279 rmiObj->getMethodParams(paramCls, numParam, paramObj);
280 int retVal = getTemperatureRangeLowerBound();
281 void* retObj = &retVal;
282 rmiObj->sendReturnObj(retObj, "int");
285 void ___getTemperatureRangeUpperBound() {
286 string paramCls[] = { };
288 void* paramObj[] = { };
289 rmiObj->getMethodParams(paramCls, numParam, paramObj);
290 int retVal = getTemperatureRangeUpperBound();
291 void* retObj = &retVal;
292 rmiObj->sendReturnObj(retObj, "int");
295 void ___waitRequestInvokeMethod() {
297 log << "Getting into the while loop" << endl;
298 rmiObj->getMethodBytes();
299 log << "Getting method bytes now" << endl;
300 log << "Method len: " << rmiObj->getMethodBytesLen() << endl;
301 int _objectId = rmiObj->getObjectId();
302 log << "Object Id: " << _objectId << endl;
303 int methodId = rmiObj->getMethodId();
304 log << "Method Id: " << methodId << endl;
305 if (_objectId == object0Id) {
306 if (set0Allowed.find(methodId) == set0Allowed.end()) {
307 cerr << "Object with object Id: " << _objectId << " is not allowed to access method: " << methodId << endl;
312 cerr << "Object Id: " << _objectId << " not recognized!" << endl;
316 case 0: ___init(); break;
317 case 1: ___turnOff(); break;
318 case 2: ___turnOn(); break;
319 case 3: ___getState(); break;
320 case 4: ___setColor(); break;
321 case 5: ___setTemperature(); break;
322 case 6: ___getBrightness(); break;
323 case 7: ___getHue(); break;
324 case 8: ___getSaturation(); break;
325 case 9: ___getTemperature(); break;
326 case 10: ___getBrightnessRangeLowerBound(); break;
327 case 11: ___getBrightnessRangeUpperBound(); break;
328 case 12: ___getHueRangeLowerBound(); break;
329 case 13: ___getHueRangeUpperBound(); break;
330 case 14: ___getSaturationRangeLowerBound(); break;
331 case 15: ___getSaturationRangeUpperBound(); break;
332 case 16: ___getTemperatureRangeLowerBound(); break;
333 case 17: ___getTemperatureRangeUpperBound(); break;
335 cerr << "Method Id " << methodId << " not recognized!" << endl;
343 set<int> LightBulb_Skeleton::set0Allowed { 2, 10, 1, 3, 11, 8, 12, 7, 13, 9, 6, 16, 17, 4, 0, 14, 15, 5 };