Perfecting IoTSlave for C++; Found one issue with SSH/Java process execution in which...
[iot2.git] / benchmarks / Cpp / Lifxtest / LightBulbTest_Stub.hpp
1 #ifndef _LIGHTBULBTEST_STUB_HPP__
2 #define _LIGHTBULBTEST_STUB_HPP__
3 #include <iostream>
4 #include <fstream>
5 #include "LightBulbTest.hpp"
6
7 using namespace std;
8
9 class LightBulbTest_Stub : public LightBulbTest
10 {
11         private:
12
13         IoTRMICall *rmiCall;
14         string callbackAddress;
15         vector<int> ports;
16
17         const static int objectId = 0;
18
19         ofstream log;
20
21         public:
22
23         LightBulbTest_Stub() { }
24         
25         LightBulbTest_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
26                 callbackAddress = _callbackAddress;
27                 ports = _ports;
28                 // Logging
29                 log.open("LightBulbTest_Stub_cpp.log");
30                 log << "Port: " << _port << endl;
31                 log << "Skeleton address: " << _skeletonAddress << endl;
32                 log << "Callback address: " << callbackAddress << endl;
33                 log << "Rev: " << _rev << endl;
34                 log << "bResult: " << *_bResult << endl;
35                 log << "Ports: " << _ports[0] << endl;
36                 rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
37                 log << "Established connection with skeleton!" << endl;
38                 //log.close();
39         }
40
41         ~LightBulbTest_Stub() {
42                 if (rmiCall != NULL) {
43                         delete rmiCall;
44                         rmiCall = NULL;
45                 }
46         }
47         
48         void turnOn() { 
49                 int methodId = 2;
50                 string retType = "void";
51                 int numParam = 0;
52                 string paramCls[] = {  };
53                 void* paramObj[] = {  };
54                 void* retObj = NULL;
55                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
56         }
57
58         double getBrightness() { 
59                 int methodId = 6;
60                 string retType = "double";
61                 int numParam = 0;
62                 string paramCls[] = {  };
63                 void* paramObj[] = {  };
64                 double retVal = 0;
65                 void* retObj = &retVal;
66                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
67                 return retVal;
68         }
69
70         void turnOff() { 
71                 int methodId = 1;
72                 string retType = "void";
73                 int numParam = 0;
74                 string paramCls[] = {  };
75                 void* paramObj[] = {  };
76                 void* retObj = NULL;
77                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
78         }
79
80         bool getState() { 
81                 int methodId = 3;
82                 string retType = "boolean";
83                 int numParam = 0;
84                 string paramCls[] = {  };
85                 void* paramObj[] = {  };
86                 bool retVal = false;
87                 void* retObj = &retVal;
88                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
89                 return retVal;
90         }
91
92         void setColor(double _hue, double _saturation, double _brightness) { 
93                 int methodId = 4;
94                 string retType = "void";
95                 int numParam = 3;
96                 string paramCls[] = { "double", "double", "double" };
97                 void* paramObj[] = { &_hue, &_saturation, &_brightness };
98                 void* retObj = NULL;
99                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
100         }
101
102         double getSaturation() { 
103                 int methodId = 8;
104                 string retType = "double";
105                 int numParam = 0;
106                 string paramCls[] = {  };
107                 void* paramObj[] = {  };
108                 double retVal = 0;
109                 void* retObj = &retVal;
110                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
111                 return retVal;
112         }
113
114         void init() {
115                 log << "Calling init() in stub!" << endl;
116                 int methodId = 0;
117                 string retType = "void";
118                 int numParam = 0;
119                 string paramCls[] = {  };
120                 void* paramObj[] = {  };
121                 void* retObj = NULL;
122                 log << "About to remote call!" << endl;
123                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
124                 log << "Remote call performed!" << endl;
125                 log.close();
126         }
127
128         void setTemperature(int _temperature) { 
129                 int methodId = 5;
130                 string retType = "void";
131                 int numParam = 1;
132                 string paramCls[] = { "int" };
133                 void* paramObj[] = { &_temperature };
134                 void* retObj = NULL;
135                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
136         }
137
138         double getHue() { 
139                 int methodId = 7;
140                 string retType = "double";
141                 int numParam = 0;
142                 string paramCls[] = {  };
143                 void* paramObj[] = {  };
144                 double retVal = 0;
145                 void* retObj = &retVal;
146                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
147                 return retVal;
148         }
149
150         int getTemperature() { 
151                 int methodId = 9;
152                 string retType = "int";
153                 int numParam = 0;
154                 string paramCls[] = {  };
155                 void* paramObj[] = {  };
156                 int retVal = 0;
157                 void* retObj = &retVal;
158                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
159                 return retVal;
160         }
161
162 };
163
164 #endif