forked from OpenZWave/open-zwave
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotification.cpp
More file actions
339 lines (330 loc) · 9.31 KB
/
Copy pathNotification.cpp
File metadata and controls
339 lines (330 loc) · 9.31 KB
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
//-----------------------------------------------------------------------------
//
// Notification.cpp
//
// OZW to Application Notification Callbacks
//
// Copyright (c) 2015 Justin Hammond <justin@dynam.ac>
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#include "Defs.h"
#include "Notification.h"
#include "Driver.h"
using namespace OpenZWave;
//-----------------------------------------------------------------------------
// <Notification::GetAsString>
// Return a string representation of OZW
//-----------------------------------------------------------------------------
string Notification::GetAsString() const
{
string str;
string command;
switch (m_type)
{
case Type_ValueAdded:
str = "ValueAdded";
break;
case Type_ValueRemoved:
str = "ValueRemoved";
break;
case Type_ValueChanged:
str = "ValueChanged";
break;
case Type_ValueRefreshed:
str = "ValueRefreshed";
break;
case Type_Group:
str = "Group";
break;
case Type_NodeNew:
str = "NodeNew";
break;
case Type_NodeAdded:
str = "NodeAdded";
break;
case Type_NodeRemoved:
str = "NodeRemoved";
break;
case Type_NodeProtocolInfo:
str = "NodeProtocolInfo";
break;
case Type_NodeNaming:
str = "NodeNaming";
break;
case Type_NodeEvent:
str = "NodeEvent";
break;
case Type_PollingDisabled:
str = "PollingDisabled";
break;
case Type_PollingEnabled:
str = "PollingEnabled";
break;
case Type_SceneEvent:
str = "SceneEvent";
break;
case Type_CreateButton:
str = "CreateButton";
break;
case Type_DeleteButton:
str = "DeleteButton";
break;
case Type_ButtonOn:
str = "ButtonOn";
break;
case Type_ButtonOff:
str = "ButtonOff";
break;
case Type_DriverReady:
str = "DriverReady";
break;
case Type_DriverFailed:
str = "DriverFailed: " + m_comport;
break;
case Type_DriverReset:
str = "DriverReset";
break;
case Type_EssentialNodeQueriesComplete:
str = "EssentialNodeQueriesComplete";
break;
case Type_NodeQueriesComplete:
str = "NodeQueriesComplete";
break;
case Type_AwakeNodesQueried:
str = "AwakeNodesQueried";
break;
case Type_AllNodesQueriedSomeDead:
str = "AllNodesQueriedSomeDead";
break;
case Type_AllNodesQueried:
str = "AllNodesQueried";
break;
case Type_Notification:
switch (m_byte)
{
case Code_MsgComplete:
str = "Notification - MsgComplete";
break;
case Code_Timeout:
str = "Notification - TimeOut";
break;
case Code_NoOperation:
str = "Notification - NoOperation";
break;
case Code_Awake:
str = "Notification - Node Awake";
break;
case Code_Sleep:
str = "Notification - Node Asleep";
break;
case Code_Dead:
str = "Notification - Node Dead";
break;
case Code_Alive:
str = "Notification - Node Alive";
break;
}
break;
case Type_DriverRemoved:
str = "DriverRemoved";
break;
case Type_ControllerCommand:
switch (m_command)
{
case Driver::ControllerCommand_AddDevice:
command = "AddDevice ";
break;
case Driver::ControllerCommand_AssignReturnRoute:
command = "AssignReturnRoute ";
break;
case Driver::ControllerCommand_CreateButton:
command = "CreateButton ";
break;
case Driver::ControllerCommand_CreateNewPrimary:
command = "CreateNewPrimary ";
break;
case Driver::ControllerCommand_DeleteAllReturnRoutes:
command = "DeleteAllReturnRoutes ";
break;
case Driver::ControllerCommand_DeleteButton:
command = "DeleteButton ";
break;
case Driver::ControllerCommand_HasNodeFailed:
command = "HasNodeFailed ";
break;
case Driver::ControllerCommand_ReceiveConfiguration:
command = "ReceiveConfiguration ";
break;
case Driver::ControllerCommand_RemoveDevice:
command = "RemoveDevice ";
break;
case Driver::ControllerCommand_RemoveFailedNode:
command = "RemoveFailedNode ";
break;
case Driver::ControllerCommand_ReplaceFailedNode:
command = "ReplaceFailedNode ";
break;
case Driver::ControllerCommand_ReplicationSend:
command = "ReplicationSend ";
break;
case Driver::ControllerCommand_RequestNetworkUpdate:
command = "RequestNetworkUpdate ";
break;
case Driver::ControllerCommand_RequestNodeNeighborUpdate:
command = "RequestNodeNeighborUpdate ";
break;
case Driver::ControllerCommand_SendNodeInformation:
command = "SendNodeInformation ";
break;
case Driver::ControllerCommand_TransferPrimaryRole:
command = "TransferPrimaryRole ";
break;
}
switch (m_event)
{
case Driver::ControllerState_Normal:
str = command + "ControllerCommand - Normal";
break;
case Driver::ControllerState_Starting:
str = command + "ControllerCommand - Starting";
break;
case Driver::ControllerState_Cancel:
str = command + "ControllerCommand - Canceled";
break;
case Driver::ControllerState_Error:
switch (m_byte)
{
case Driver::ControllerError_None:
str = "ControllerCommand - Error - None";
break;
case Driver::ControllerError_ButtonNotFound:
str = "ControllerCommand - Error - ButtonNotFound";
break;
case Driver::ControllerError_NodeNotFound:
str = "ControllerCommand - Error - NodeNotFound";
break;
case Driver::ControllerError_NotBridge:
str = "ControllerCommand - Error - NotBridge";
break;
case Driver::ControllerError_NotSUC:
str = "ControllerCommand - Error - NotSUC";
break;
case Driver::ControllerError_NotSecondary:
str = "ControllerCommand - Error - NotSecondary";
break;
case Driver::ControllerError_NotPrimary:
str = "ControllerCommand - Error - NotPrimary";
break;
case Driver::ControllerError_IsPrimary:
str = "ControllerCommand - Error - IsPrimary";
break;
case Driver::ControllerError_NotFound:
str = "ControllerCommand - Error - NotFound";
break;
case Driver::ControllerError_Busy:
str = "ControllerCommand - Error - Busy";
break;
case Driver::ControllerError_Failed:
str = "ControllerCommand - Error - Failed";
break;
case Driver::ControllerError_Disabled:
str = "ControllerCommand - Error - Disabled";
break;
case Driver::ControllerError_Overflow:
str = "ControllerCommand - Error - OverFlow";
break;
}
break;
case Driver::ControllerState_Waiting:
str = command + "ControllerCommand - Waiting";
break;
case Driver::ControllerState_Sleeping:
str = command + "ControllerCommand - Sleeping";
break;
case Driver::ControllerState_InProgress:
str = command + "ControllerCommand - InProgress";
break;
case Driver::ControllerState_Completed:
str = command + "ControllerCommand - Completed";
break;
case Driver::ControllerState_Failed:
str = command + "ControllerCommand - Failed";
break;
case Driver::ControllerState_NodeOK:
str = command + "ControllerCommand - NodeOK";
break;
case Driver::ControllerState_NodeFailed:
str = command + "ControllerCommand - NodeFailed";
break;
}
break;
case Type_NodeReset:
str = "Node Reset";
break;
case Type_UserAlerts:
switch (m_useralerttype)
{
case Alert_None:
str = "User Alert - No Alert";
break;
case Alert_ConfigOutOfDate:
str = "User Alert - Config File out of Date";
break;
case Alert_MFSOutOfDate:
str = "User Alert - Manufacturer_specific.xml out of Date";
break;
case Alert_ConfigFileDownloadFailed:
str = "A Config File Failed to download";
break;
case Alert_DNSError:
str = "A DNS Error Occurred";
break;
case Alert_NodeReloadRequired:
str = "Node Reload Is Required due to new Config File";
break;
case Alert_UnsupportedController:
str = "Controller Library is not a type we support";
break;
case Alert_ApplicationStatus_Retry:
str = "Application Status: Retry Later";
break;
case Alert_ApplicationStatus_Queued:
str = "Application Status: Command has been queued for execution later";
break;
case Alert_ApplicationStatus_Rejected:
str = "Application Status: Command Rejected";
}
break;
case Type_ManufacturerSpecificDBReady:
str = "ManufacturerSpecificDB Ready";
break;
}
return str;
}
std::ostream& operator<<(std::ostream &os, const Notification &dt)
{
os << dt.GetAsString();
return os;
}
std::ostream& operator<<(std::ostream &os, const Notification *dt)
{
os << dt->GetAsString();
return os;
}