forked from OpenZWave/Thrift4OZW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemoteManager_server.cpp.patch
252 lines (216 loc) · 8.77 KB
/
RemoteManager_server.cpp.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
*** gen-cpp/RemoteManager_server.cpp.orig 2013-03-09 21:01:53.973455995 +0200
--- gen-cpp/RemoteManager_server.cpp.patched 2013-03-10 09:25:27.455986522 +0200
***************
*** 1,11 ****
// Automatically generated OpenZWave::Manager_server wrapper
! // (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
#include "RemoteManager.h"
! #include <thrift/protocol/TBinaryProtocol.h>
! #include <thrift/server/TSimpleServer.h>
! #include <thrift/transport/TServerSocket.h>
! #include <thrift/transport/TBufferTransports.h>
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
--- 1,11 ----
// Automatically generated OpenZWave::Manager_server wrapper
! // (c) 2011-2012 Elias Karakoulakis <elias.karakoulakis@gmail.com>
#include "RemoteManager.h"
! #include <protocol/TBinaryProtocol.h>
! #include <server/TSimpleServer.h>
! #include <transport/TServerSocket.h>
! #include <transport/TBufferTransports.h>
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
***************
*** 17,23 ****
using namespace ::OpenZWave;
void BeginControllerCommand_callback(OpenZWave::Driver::ControllerState arg1, OpenZWave::Driver::ControllerError arg2, void* arg3) {
! // FIXME: fill in the blanks (sorry!)
}
class RemoteManagerHandler : virtual public RemoteManagerIf {
--- 17,33 ----
using namespace ::OpenZWave;
void BeginControllerCommand_callback(OpenZWave::Driver::ControllerState arg1, OpenZWave::Driver::ControllerError arg2, void* arg3) {
! g_criticalSection.lock();
! //
! STOMP::hdrmap headers;
! headers["ControllerState"] = to_string<uint16_t>(arg1, std::hex);
! if (arg2 != OpenZWave::Driver::ControllerError_None ) {
! headers["ControllerError"] = to_string<uint16_t>(arg2, std::hex);
! }
! string empty = "" ;
! stomp_client->send(*notifications_topic, headers, empty);
! //
! g_criticalSection.unlock();
}
class RemoteManagerHandler : virtual public RemoteManagerIf {
***************
*** 283,292 ****
}
void GetNodeNeighbors(UInt32_ListByte& _return, const int32_t _homeId, const int8_t _nodeId) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetNodeNeighbors((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8**) &_return._nodeNeighbors);
g_criticalSection.unlock();
}
void GetNodeManufacturerName(std::string& _return, const int32_t _homeId, const int8_t _nodeId) {
--- 293,307 ----
}
void GetNodeNeighbors(UInt32_ListByte& _return, const int32_t _homeId, const int8_t _nodeId) {
+ uint8* arr;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetNodeNeighbors((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8**) &arr);
g_criticalSection.unlock();
+ if (_return.retval > 0) {
+ for (int i=0; i<_return.retval; i++) _return._nodeNeighbors.push_back(arr[i]);
+ delete arr;
+ }
}
void GetNodeManufacturerName(std::string& _return, const int32_t _homeId, const int8_t _nodeId) {
***************
*** 571,581 ****
g_criticalSection.unlock();
}
! void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetValueListItems(_id.toValueID(), (std::vector<std::string, std::allocator<std::string> >*) &_return.o_value);
g_criticalSection.unlock();
}
void GetValueFloatPrecision(Bool_UInt8& _return, const RemoteValueID& _id) {
--- 586,600 ----
g_criticalSection.unlock();
}
! void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
! std::vector<std::string> o_values;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetValueListItems(_id.toValueID(), &o_values);
g_criticalSection.unlock();
+ if (_return.retval > 0) {
+ for (int i=0; i< _return.retval; i++) _return.o_value.push_back(std::string(o_values[i]));
+ }
}
void GetValueFloatPrecision(Bool_UInt8& _return, const RemoteValueID& _id) {
***************
*** 604,610 ****
bool SetValue_UInt8_UInt8(const RemoteValueID& _id, const std::vector<int8_t> & _value, const int8_t _length) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! bool function_result = mgr->SetValue(_id.toValueID(), (::uint8 const*) &_value, (::uint8 const) _length);
g_criticalSection.unlock();
return(function_result);
}
--- 623,629 ----
bool SetValue_UInt8_UInt8(const RemoteValueID& _id, const std::vector<int8_t> & _value, const int8_t _length) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! bool function_result = mgr->SetValue(_id.toValueID(), (const uint8*) _value.data(), _value.size());
g_criticalSection.unlock();
return(function_result);
}
***************
*** 658,667 ****
}
void SetChangeVerified(const RemoteValueID& _id, const bool _verify) {
! Manager* mgr = Manager::Get();
! g_criticalSection.lock();
! mgr->SetChangeVerified(_id.toValueID(), (bool) _verify);
! g_criticalSection.unlock();
}
bool PressButton(const RemoteValueID& _id) {
--- 677,686 ----
}
void SetChangeVerified(const RemoteValueID& _id, const bool _verify) {
! Manager* mgr = Manager::Get();
! g_criticalSection.lock();
! mgr->SetChangeVerified(_id.toValueID(), (bool) _verify);
! g_criticalSection.unlock();
}
bool PressButton(const RemoteValueID& _id) {
***************
*** 763,772 ****
}
void GetAssociations(GetAssociationsReturnStruct& _return, const int32_t _homeId, const int8_t _nodeId, const int8_t _groupIdx) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetAssociations((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8 const) _groupIdx, (::uint8**) &_return.o_associations);
g_criticalSection.unlock();
}
int8_t GetMaxAssociations(const int32_t _homeId, const int8_t _nodeId, const int8_t _groupIdx) {
--- 782,796 ----
}
void GetAssociations(GetAssociationsReturnStruct& _return, const int32_t _homeId, const int8_t _nodeId, const int8_t _groupIdx) {
+ uint8* o_associations;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetAssociations((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8 const) _groupIdx, (::uint8**) &o_associations);
g_criticalSection.unlock();
+ if (_return.retval > 0) {
+ for (int i=0; i<_return.retval; i++) _return.o_associations.push_back(o_associations[i]);
+ delete o_associations;
+ }
}
int8_t GetMaxAssociations(const int32_t _homeId, const int8_t _nodeId, const int8_t _groupIdx) {
***************
*** 865,874 ****
}
void GetAllScenes(GetAllScenesReturnStruct& _return) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetAllScenes((::uint8**) &_return._sceneIds);
g_criticalSection.unlock();
}
void RemoveAllScenes(const int32_t _homeId) {
--- 889,903 ----
}
void GetAllScenes(GetAllScenesReturnStruct& _return) {
+ uint8* _sceneIds;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->GetAllScenes((::uint8**) &_sceneIds);
g_criticalSection.unlock();
+ if (_return.retval>0) {
+ for (int i=0; i<_return.retval; i++) _return._sceneIds.push_back(_sceneIds[i]);
+ delete(_sceneIds);
+ }
}
void RemoveAllScenes(const int32_t _homeId) {
***************
*** 967,976 ****
}
void SceneGetValues(SceneGetValuesReturnStruct& _return, const int8_t _sceneId) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->SceneGetValues((::uint8 const) _sceneId, _return.o_value.toValueID());
g_criticalSection.unlock();
}
void SceneGetValueAsBool(Bool_Bool& _return, const int8_t _sceneId, const RemoteValueID& _valueId) {
--- 996,1007 ----
}
void SceneGetValues(SceneGetValuesReturnStruct& _return, const int8_t _sceneId) {
+ std::vector<OpenZWave::ValueID> o_values;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
! _return.retval = mgr->SceneGetValues((::uint8 const) _sceneId, &o_values);
g_criticalSection.unlock();
+ for (int i=0; i< _return.retval; i++) _return.o_value.push_back(RemoteValueID(o_values[i]));
}
void SceneGetValueAsBool(Bool_Bool& _return, const int8_t _sceneId, const RemoteValueID& _valueId) {
***************
*** 1138,1145 ****
}
void SendAllValues() {
! // Your implementation goes here
! printf("SendAllValues\n");
}
void ping() {
--- 1169,1177 ----
}
void SendAllValues() {
! g_criticalSection.lock();
! send_all_values();
! g_criticalSection.unlock();
}
void ping() {