OpenZWave Library
1.6.1914
Toggle main menu visibility
Loading...
Searching...
No Matches
cpp
src
value_classes
ValueID.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
//
3
// ValueID.h
4
//
5
// Unique identifier for a Value object
6
//
7
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
8
//
9
// SOFTWARE NOTICE AND LICENSE
10
//
11
// This file is part of OpenZWave.
12
//
13
// OpenZWave is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU Lesser General Public License as published
15
// by the Free Software Foundation, either version 3 of the License,
16
// or (at your option) any later version.
17
//
18
// OpenZWave is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
// GNU Lesser General Public License for more details.
22
//
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25
//
26
//-----------------------------------------------------------------------------
27
28
#ifndef _ValueID_H
29
#define _ValueID_H
30
31
#include <string>
32
#include <assert.h>
33
34
#include "
ValueIDIndexes.h
"
35
#include "
Defs.h
"
36
37
class
TiXmlElement;
38
39
namespace
OpenZWave
40
{
41
42
namespace
Internal
43
{
44
namespace
VC
45
{
46
class
Value
;
47
class
ValueStore
;
48
}
49
;
50
}
51
;
52
59
75
76
class
OPENZWAVE_EXPORT
ValueID
77
{
78
public
:
84
enum
ValueGenre
85
{
86
ValueGenre_Basic
= 0,
87
ValueGenre_User
,
88
ValueGenre_Config
,
89
ValueGenre_System
,
90
ValueGenre_Count
91
};
92
98
enum
ValueType
99
{
100
ValueType_Bool
= 0,
101
ValueType_Byte
,
102
ValueType_Decimal
,
103
ValueType_Int
,
104
ValueType_List
,
105
ValueType_Schedule
,
106
ValueType_Short
,
107
ValueType_String
,
108
ValueType_Button
,
109
ValueType_Raw
,
110
ValueType_BitSet
,
111
ValueType_Max
=
ValueType_BitSet
112
};
113
118
uint32
GetHomeId
()
const
119
{
120
return
m_homeId;
121
}
122
127
uint8
GetNodeId
()
const
128
{
129
return
((
uint8
) ((m_id & 0xff000000) >> 24));
130
}
131
138
ValueGenre
GetGenre
()
const
139
{
140
return
((
ValueGenre
) ((m_id & 0x00c00000) >> 22));
141
}
142
149
string
GetGenreAsString()
const
;
150
157
uint8
GetCommandClassId
()
const
158
{
159
return
((
uint8
) ((m_id & 0x003fc000) >> 14));
160
}
161
170
uint8
GetInstance
()
const
171
{
172
return
((
uint8
) (((m_id & 0xff0)) >> 4));
173
}
174
183
uint16
GetIndex
()
const
184
{
185
return
((
uint16
) ((m_id1 & 0xFFFF0000) >> 16));
186
}
187
195
ValueType
GetType
()
const
196
{
197
return
((
ValueType
) (m_id & 0x0000000f));
198
}
199
207
string
GetTypeAsString()
const
;
208
214
uint64
GetId
()
const
215
{
216
return
(uint64) (((uint64) m_id1 << 32) | m_id);
217
}
218
222
string
const
GetAsString()
const
;
223
224
// Comparison Operators
225
bool
operator ==(
ValueID
const
& _other)
const
226
{
227
return
((m_homeId == _other.m_homeId) && (m_id == _other.m_id) && (m_id1 == _other.m_id1));
228
}
229
bool
operator !=(
ValueID
const
& _other)
const
230
{
231
return
((m_homeId != _other.m_homeId) || (m_id != _other.m_id) || (m_id1 != _other.m_id1));
232
}
233
bool
operator <(
ValueID
const
& _other)
const
234
{
235
if
(m_homeId == _other.m_homeId)
236
{
237
if
(m_id == _other.m_id)
238
{
239
return
(m_id1 < _other.m_id1);
240
}
241
else
242
{
243
return
(m_id < _other.m_id);
244
}
245
}
246
else
247
{
248
return
(m_homeId < _other.m_homeId);
249
}
250
}
251
bool
operator >(
ValueID
const
& _other)
const
252
{
253
if
(m_homeId == _other.m_homeId)
254
{
255
if
(m_id == _other.m_id)
256
{
257
return
(m_id1 > _other.m_id1);
258
}
259
else
260
{
261
return
(m_id > _other.m_id);
262
}
263
}
264
else
265
{
266
return
(m_homeId > _other.m_homeId);
267
}
268
}
269
284
ValueID
(
uint32
const
_homeId,
uint8
const
_nodeId,
ValueGenre
const
_genre,
uint8
const
_commandClassId,
uint8
const
_instance,
uint16
const
_valueIndex,
ValueType
const
_type) :
285
m_homeId(_homeId)
286
{
287
m_id = (((
uint32
) _nodeId) << 24) | (((
uint32
) _genre) << 22) | (((
uint32
) _commandClassId) << 14) | (((
uint32
) (_instance & 0xFF)) << 4) | ((
uint32
) _type);
288
m_id1 = (((
uint32
) _valueIndex) << 16);
289
}
290
291
/* construct a ValueID based on the HomeID and the unit64 returned from GetID
292
* \param _homeId - The HomeID
293
* \param id - The ID returned from ValueID::GetID
294
* \see ValueID::GetId
295
*/
296
ValueID
(
uint32
_homeId, uint64
id
) :
297
m_homeId(_homeId)
298
{
299
m_id = ((
uint32
) (
id
& 0xFFFFFFFF));
300
m_id1 = (
uint32
) (
id
>> 32);
301
}
302
303
// Construct a value id for use in notifications
304
ValueID
(
uint32
const
_homeId,
uint8
const
_nodeId) :
305
m_id1(0), m_homeId(_homeId)
306
{
307
m_id = ((
uint32
) _nodeId) << 24;
308
}
309
ValueID
(
uint32
const
_homeId,
uint8
const
_nodeId,
uint32
const
_instance) :
310
m_homeId(_homeId)
311
{
312
m_id = (((
uint32
) _nodeId) << 24) | (((
uint32
) _instance) << 4);
313
m_id1 = 0;
314
}
315
316
// Default constructor
317
ValueID
() :
318
m_id(0), m_id1(0), m_homeId(0)
319
{
320
321
}
322
323
// Not all parts of the ValueID are necessary to uniquely identify the value. In the case of a
324
// Node's ValueStore, we can ignore the home ID, node ID, genre and type and still be left with
325
// a unique integer than can be used as a key to look up values. The two GetValueStoreKey methods
326
// below are helpers to enable command classes to easily access their values from the ValueStore.
327
328
// Get the key from our own m_id
329
uint32
GetValueStoreKey
()
const
330
{
331
/* 0xIIIICCii
332
* I = Index
333
* C = CC
334
* i = Instance
335
*/
336
/* CC Index Instance */
337
return
(((m_id & 0x003fc000) >> 6) | (m_id1 & 0xffff0000) | ((m_id & 0xFF0) >> 4));
338
}
339
340
// Generate a key from its component parts
341
static
uint32
GetValueStoreKey
(
uint8
const
_commandClassId,
uint8
const
_instance,
uint16
const
_valueIndex)
342
{
343
344
uint32
key = (((
uint32
) _instance)) | (((
uint32
) _commandClassId) << 8) | (((
uint32
) (_valueIndex & 0xFFFF)) << 16);
345
346
return
key;
347
}
348
349
private
:
350
351
// ID Packing:
352
// Bits
353
// 24-31: 8 bits. Node ID of device
354
// 22-23: 2 bits. genre of value (see ValueGenre enum).
355
// 14-21: 8 bits. ID of command class that created and manages this value.
356
// 12-13 Unused.
357
// 04-11: 8 bits. Instance of the Value
358
// 00-03: 4 bits. Type of value (bool, byte, string etc).
359
uint32
m_id;
360
361
// ID1 Packing:
362
// Bits
363
// 16-31 16 bits. Instance Index of the command class.
364
uint32
m_id1;
365
366
// Unique PC interface identifier
367
uint32
m_homeId;
368
};
369
370
}
// namespace OpenZWave
371
372
#endif
Defs.h
uint16
unsigned short uint16
Definition
Defs.h:88
uint32
unsigned int uint32
Definition
Defs.h:91
OPENZWAVE_EXPORT
#define OPENZWAVE_EXPORT
Definition
Defs.h:52
uint8
unsigned char uint8
Definition
Defs.h:85
ValueIDIndexes.h
OpenZWave::Internal::VC::ValueStore
Container that holds all of the values associated with a given node.
Definition
ValueStore.h:50
OpenZWave::Internal::VC::Value
Base class for values associated with a node.
Definition
Value.h:55
OpenZWave::ValueID::ValueID
ValueID(uint32 const _homeId, uint8 const _nodeId, uint32 const _instance)
Definition
ValueID.h:309
OpenZWave::ValueID::ValueType
ValueType
Definition
ValueID.h:99
OpenZWave::ValueID::ValueType_Button
@ ValueType_Button
Definition
ValueID.h:108
OpenZWave::ValueID::ValueType_Raw
@ ValueType_Raw
Definition
ValueID.h:109
OpenZWave::ValueID::ValueType_Int
@ ValueType_Int
Definition
ValueID.h:103
OpenZWave::ValueID::ValueType_String
@ ValueType_String
Definition
ValueID.h:107
OpenZWave::ValueID::ValueType_Bool
@ ValueType_Bool
Definition
ValueID.h:100
OpenZWave::ValueID::ValueType_List
@ ValueType_List
Definition
ValueID.h:104
OpenZWave::ValueID::ValueType_Schedule
@ ValueType_Schedule
Definition
ValueID.h:105
OpenZWave::ValueID::ValueType_Short
@ ValueType_Short
Definition
ValueID.h:106
OpenZWave::ValueID::ValueType_Byte
@ ValueType_Byte
Definition
ValueID.h:101
OpenZWave::ValueID::ValueType_Max
@ ValueType_Max
Definition
ValueID.h:111
OpenZWave::ValueID::ValueType_Decimal
@ ValueType_Decimal
Definition
ValueID.h:102
OpenZWave::ValueID::ValueType_BitSet
@ ValueType_BitSet
Definition
ValueID.h:110
OpenZWave::ValueID::ValueID
ValueID()
Definition
ValueID.h:317
OpenZWave::ValueID::GetHomeId
uint32 GetHomeId() const
Definition
ValueID.h:118
OpenZWave::ValueID::GetIndex
uint16 GetIndex() const
Definition
ValueID.h:183
OpenZWave::ValueID::GetType
ValueType GetType() const
Definition
ValueID.h:195
OpenZWave::ValueID::GetCommandClassId
uint8 GetCommandClassId() const
Definition
ValueID.h:157
OpenZWave::ValueID::ValueID
ValueID(uint32 const _homeId, uint8 const _nodeId, ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex, ValueType const _type)
Definition
ValueID.h:284
OpenZWave::ValueID::GetValueStoreKey
static uint32 GetValueStoreKey(uint8 const _commandClassId, uint8 const _instance, uint16 const _valueIndex)
Definition
ValueID.h:341
OpenZWave::ValueID::ValueID
ValueID(uint32 const _homeId, uint8 const _nodeId)
Definition
ValueID.h:304
OpenZWave::ValueID::GetInstance
uint8 GetInstance() const
Definition
ValueID.h:170
OpenZWave::ValueID::ValueID
ValueID(uint32 _homeId, uint64 id)
Definition
ValueID.h:296
OpenZWave::ValueID::GetValueStoreKey
uint32 GetValueStoreKey() const
Definition
ValueID.h:329
OpenZWave::ValueID::GetGenre
ValueGenre GetGenre() const
Definition
ValueID.h:138
OpenZWave::ValueID::GetId
uint64 GetId() const
Definition
ValueID.h:214
OpenZWave::ValueID::GetNodeId
uint8 GetNodeId() const
Definition
ValueID.h:127
OpenZWave::ValueID::ValueGenre
ValueGenre
Definition
ValueID.h:85
OpenZWave::ValueID::ValueGenre_Config
@ ValueGenre_Config
Definition
ValueID.h:88
OpenZWave::ValueID::ValueGenre_System
@ ValueGenre_System
Definition
ValueID.h:89
OpenZWave::ValueID::ValueGenre_User
@ ValueGenre_User
Definition
ValueID.h:87
OpenZWave::ValueID::ValueGenre_Count
@ ValueGenre_Count
Definition
ValueID.h:90
OpenZWave::ValueID::ValueGenre_Basic
@ ValueGenre_Basic
Definition
ValueID.h:86
OpenZWave::Internal::VC
Definition
Driver.h:64
OpenZWave::Internal
Definition
Bitfield.cpp:33
OpenZWave
Definition
Bitfield.cpp:31
Generated on
for OpenZWave Library by
1.17.0