2 #include "LightBulbTest_Stub.hpp"
6 //LightBulbTest_Stub::LightBulbTest_Stub(int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult) {
7 LightBulbTest_Stub::LightBulbTest_Stub(int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult) {
10 string file = "LightBulbTest_cpp" + to_string(i) + ".log";
11 while (ifstream(file.c_str())) {
13 file = "LightBulbTest_cpp" + to_string(i) + ".log";
16 log << "Constructing LightBulbTest_Stub!" << endl;
17 log << "Port send: " << _portSend << endl;
18 log << "Port recv: " << _portRecv << endl;
19 log << "Skeleton addr: " << _skeletonAddress << endl;
20 log << "Rev: " << _rev << endl;
21 log << "Result: " << _bResult << endl;
23 rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev, _bResult);
24 log << "Reached 1!" << endl;
25 rmiComm->registerStub(objectId, 6, &retValueReceived6);
26 rmiComm->registerStub(objectId, 3, &retValueReceived3);
27 rmiComm->registerStub(objectId, 8, &retValueReceived8);
28 rmiComm->registerStub(objectId, 7, &retValueReceived7);
29 rmiComm->registerStub(objectId, 9, &retValueReceived9);
30 IoTRMIUtil::mapStub->insert(make_pair(objectId, this));
33 LightBulbTest_Stub::LightBulbTest_Stub(IoTRMIComm* _rmiComm, int _objectId) {
36 rmiComm->registerStub(objectId, 6, &retValueReceived6);
37 rmiComm->registerStub(objectId, 3, &retValueReceived3);
38 rmiComm->registerStub(objectId, 8, &retValueReceived8);
39 rmiComm->registerStub(objectId, 7, &retValueReceived7);
40 rmiComm->registerStub(objectId, 9, &retValueReceived9);
43 LightBulbTest_Stub::~LightBulbTest_Stub() {
44 if (rmiComm != NULL) {
50 mutex mtxLightBulbTest_StubMethodExec2;
51 void LightBulbTest_Stub::turnOn() {
52 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec2);
54 string retType = "void";
56 string paramCls[] = { };
57 void* paramObj[] = { };
58 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
61 mutex mtxLightBulbTest_StubMethodExec6;
62 double LightBulbTest_Stub::getBrightness() {
63 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec6);
65 string retType = "double";
67 string paramCls[] = { };
68 void* paramObj[] = { };
70 void* retObj = &retVal;
71 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
72 // Waiting for return value
73 while (!retValueReceived6);
74 rmiComm->getReturnValue(retType, retObj);
75 retValueReceived6 = false;
76 didGetReturnBytes.exchange(true);
81 mutex mtxLightBulbTest_StubMethodExec1;
82 void LightBulbTest_Stub::turnOff() {
83 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec1);
85 string retType = "void";
87 string paramCls[] = { };
88 void* paramObj[] = { };
89 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
92 mutex mtxLightBulbTest_StubMethodExec3;
93 bool LightBulbTest_Stub::getState() {
94 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec3);
96 string retType = "boolean";
98 string paramCls[] = { };
99 void* paramObj[] = { };
101 void* retObj = &retVal;
102 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
103 // Waiting for return value
104 while (!retValueReceived3);
105 rmiComm->getReturnValue(retType, retObj);
106 retValueReceived3 = false;
107 didGetReturnBytes.exchange(true);
112 mutex mtxLightBulbTest_StubMethodExec4;
113 void LightBulbTest_Stub::setColor(double _hue, double _saturation, double _brightness) {
114 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec4);
116 string retType = "void";
118 string paramCls[] = { "double", "double", "double" };
119 void* paramObj[] = { &_hue, &_saturation, &_brightness };
120 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
123 mutex mtxLightBulbTest_StubMethodExec8;
124 double LightBulbTest_Stub::getSaturation() {
125 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec8);
127 string retType = "double";
129 string paramCls[] = { };
130 void* paramObj[] = { };
132 void* retObj = &retVal;
133 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
134 // Waiting for return value
135 while (!retValueReceived8);
136 rmiComm->getReturnValue(retType, retObj);
137 retValueReceived8 = false;
138 didGetReturnBytes.exchange(true);
143 mutex mtxLightBulbTest_StubMethodExec0;
144 void LightBulbTest_Stub::init() {
145 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec0);
147 string retType = "void";
149 string paramCls[] = { };
150 void* paramObj[] = { };
151 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
154 mutex mtxLightBulbTest_StubMethodExec5;
155 void LightBulbTest_Stub::setTemperature(int _temperature) {
156 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec5);
158 string retType = "void";
160 string paramCls[] = { "int" };
161 void* paramObj[] = { &_temperature };
162 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
165 mutex mtxLightBulbTest_StubMethodExec7;
166 double LightBulbTest_Stub::getHue() {
167 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec7);
169 string retType = "double";
171 string paramCls[] = { };
172 void* paramObj[] = { };
174 void* retObj = &retVal;
175 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
176 // Waiting for return value
177 while (!retValueReceived7);
178 rmiComm->getReturnValue(retType, retObj);
179 retValueReceived7 = false;
180 didGetReturnBytes.exchange(true);
185 mutex mtxLightBulbTest_StubMethodExec9;
186 int LightBulbTest_Stub::getTemperature() {
187 lock_guard<mutex> guard(mtxLightBulbTest_StubMethodExec9);
189 string retType = "int";
191 string paramCls[] = { };
192 void* paramObj[] = { };
194 void* retObj = &retVal;
195 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
196 // Waiting for return value
197 while (!retValueReceived9);
198 rmiComm->getReturnValue(retType, retObj);
199 retValueReceived9 = false;
200 didGetReturnBytes.exchange(true);
205 extern "C" void* createLightBulbTest_Stub(void** params) {
206 // Args: int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult
207 return new LightBulbTest_Stub(*((int*) params[0]), *((int*) params[1]), ((string*) params[2])->c_str(), *((int*) params[3]), (bool*) params[4]);
210 extern "C" void destroyLightBulbTest_Stub(void* t) {
211 LightBulbTest_Stub* obj = (LightBulbTest_Stub*) t;
215 extern "C" void initLightBulbTest_Stub(void* t) {