OpenZWave Library
1.4.0
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
#include "
Defs.h
"
34
35
class
TiXmlElement;
36
37
namespace
OpenZWave
38
{
53
class
OPENZWAVE_EXPORT
ValueID
54
{
55
friend
class
Manager
;
56
friend
class
Driver
;
57
friend
class
Node
;
58
friend
class
Group
;
59
friend
class
CommandClass
;
60
friend
class
Value
;
61
friend
class
ValueStore
;
62
friend
class
Notification
;
63
friend
class
ManufacturerSpecific
;
64
65
public
:
71
enum
ValueGenre
72
{
73
ValueGenre_Basic
= 0,
74
ValueGenre_User
,
75
ValueGenre_Config
,
76
ValueGenre_System
,
77
ValueGenre_Count
78
};
79
85
enum
ValueType
86
{
87
ValueType_Bool
= 0,
88
ValueType_Byte
,
89
ValueType_Decimal
,
90
ValueType_Int
,
91
ValueType_List
,
92
ValueType_Schedule
,
93
ValueType_Short
,
94
ValueType_String
,
95
ValueType_Button
,
96
ValueType_Raw
,
97
ValueType_Max
=
ValueType_Raw
98
};
99
104
uint32
GetHomeId
()
const
{
return
m_homeId; }
105
110
uint8
GetNodeId
()
const
{
return
( (
uint8
)( (m_id & 0xff000000) >> 24 ) ); }
111
118
ValueGenre
GetGenre
()
const
{
return
( (
ValueGenre
)( (m_id & 0x00c00000) >> 22 ) ); }
119
126
uint8
GetCommandClassId
()
const
{
return
( (
uint8
)( (m_id & 0x003fc000) >> 14 ) ); }
127
136
uint8
GetInstance
()
const
{
return
( (
uint8
)( ( (m_id1 & 0xff000000) ) >> 24 ) ); }
137
146
uint8
GetIndex
()
const
{
return
( (
uint8
)( (m_id & 0x00000ff0) >> 4 ) ); }
147
155
ValueType
GetType
()
const
{
return
( (
ValueType
)( m_id & 0x0000000f ) ); }
156
162
uint64
GetId
()
const
{
return
(uint64) ( ( (uint64)m_id1 << 32 ) | m_id );}
163
164
// Comparison Operators
165
bool
operator == (
ValueID
const
& _other )
const
{
return
( ( m_homeId == _other.m_homeId ) && ( m_id == _other.m_id ) && ( m_id1 == _other.m_id1 ) ); }
166
bool
operator != (
ValueID
const
& _other )
const
{
return
( ( m_homeId != _other.m_homeId ) || ( m_id != _other.m_id ) || ( m_id1 != _other.m_id1 ) ); }
167
bool
operator < (
ValueID
const
& _other )
const
168
{
169
if
( m_homeId == _other.m_homeId )
170
{
171
if
( m_id == _other.m_id )
172
{
173
return
( m_id1 < _other.m_id1 );
174
}
175
else
176
{
177
return
( m_id < _other.m_id );
178
}
179
}
180
else
181
{
182
return
( m_homeId < _other.m_homeId );
183
}
184
}
185
bool
operator > (
ValueID
const
& _other )
const
186
{
187
if
( m_homeId == _other.m_homeId )
188
{
189
if
( m_id == _other.m_id )
190
{
191
return
( m_id1 > _other.m_id1 );
192
}
193
else
194
{
195
return
( m_id > _other.m_id );
196
}
197
}
198
else
199
{
200
return
( m_homeId > _other.m_homeId );
201
}
202
}
203
218
ValueID
219
(
220
uint32
const
_homeId,
221
uint8
const
_nodeId,
222
ValueGenre
const
_genre,
223
uint8
const
_commandClassId,
224
uint8
const
_instance,
225
uint8
const
_valueIndex,
226
ValueType
const
_type
227
):
228
m_homeId( _homeId )
229
{
230
m_id = (((
uint32
)_nodeId)<<24)
231
| (((
uint32
)_genre)<<22)
232
| (((
uint32
)_commandClassId)<<14)
233
| (((
uint32
)_valueIndex)<<4)
234
| ((
uint32
)_type);
235
m_id1 = (((
uint32
)_instance)<<24);
236
}
237
238
/* construct a ValueID based on the HomeID and the unit64 returned from GetID
239
* \param _homeId - The HomeID
240
* \param id - The ID returned from ValueID::GetID
241
* \see ValueID::GetId
242
*/
243
ValueID
244
(
245
uint32
_homeId,
246
uint64
id
247
):
248
m_homeId(_homeId)
249
{
250
m_id = ((
uint32
)(
id
& 0xFFFFFFFF));
251
m_id1 = (
uint32
)(
id
>> 32);
252
}
253
private
:
254
// Construct a value id for use in notifications
255
ValueID
(
uint32
const
_homeId,
uint8
const
_nodeId ): m_id1( 0 ),m_homeId( _homeId ){ m_id = ((
uint32
)_nodeId)<<24; }
256
ValueID(
uint32
const
_homeId,
uint8
const
_nodeId,
uint32
const
_instance ):
257
m_homeId( _homeId )
258
{
259
m_id = (((
uint32
)_nodeId)<<24);
260
m_id1 = (((
uint32
)_instance)<<24);
261
}
262
263
// Default constructor
264
ValueID():m_id(0),m_id1(0),m_homeId(0){}
265
266
// Not all parts of the ValueID are necessary to uniquely identify the value. In the case of a
267
// Node's ValueStore, we can ignore the home ID, node ID, genre and type and still be left with
268
// a unique integer than can be used as a key to look up values. The two GetValueStoreKey methods
269
// below are helpers to enable command classes to easily access their values from the ValueStore.
270
271
// Get the key from our own m_id
272
uint32
GetValueStoreKey()
const
273
{
274
return
( ( m_id & 0x003ffff0 ) | ( m_id1 & 0xff000000 ) );
275
}
276
277
// Generate a key from its component parts
278
static
uint32
GetValueStoreKey(
uint8
const
_commandClassId,
uint8
const
_instance,
uint8
const
_valueIndex )
279
{
280
281
uint32
key = (((
uint32
)_instance)<<24)
282
| (((
uint32
)_commandClassId)<<14)
283
| (((
uint32
)_valueIndex)<<4);
284
285
return
key;
286
}
287
288
// ID Packing:
289
// Bits
290
// 24-31: 8 bits. Node ID of device
291
// 22-23: 2 bits. genre of value (see ValueGenre enum).
292
// 14-21: 8 bits. ID of command class that created and manages this value.
293
// 12-13: 2 bits. Unused.
294
// 04-11: 8 bits. Index of value within all the value created by the command class
295
// instance (in configuration parameters, this is also the parameter ID).
296
// 00-03: 4 bits. Type of value (bool, byte, string etc).
297
uint32
m_id;
298
299
// ID1 Packing:
300
// Bits
301
// 24-31 8 bits. Instance Index of the command class.
302
uint32
m_id1;
303
304
// Unique PC interface identifier
305
uint32
m_homeId;
306
};
307
308
}
// namespace OpenZWave
309
310
#endif
Defs.h
uint32
unsigned int uint32
Definition
Defs.h:80
OPENZWAVE_EXPORT
#define OPENZWAVE_EXPORT
Definition
Defs.h:52
uint8
unsigned char uint8
Definition
Defs.h:74
OpenZWave::ValueID
Provides a unique ID for a value reported by a Z-Wave device.
Definition
ValueID.h:54
OpenZWave::ValueID::GetIndex
uint8 GetIndex() const
Definition
ValueID.h:146
OpenZWave::ValueID::CommandClass
friend class CommandClass
Definition
ValueID.h:59
OpenZWave::ValueID::ValueType
ValueType
Definition
ValueID.h:86
OpenZWave::ValueID::ValueType_Button
@ ValueType_Button
Definition
ValueID.h:95
OpenZWave::ValueID::ValueType_Raw
@ ValueType_Raw
Definition
ValueID.h:96
OpenZWave::ValueID::ValueType_Int
@ ValueType_Int
Definition
ValueID.h:90
OpenZWave::ValueID::ValueType_String
@ ValueType_String
Definition
ValueID.h:94
OpenZWave::ValueID::ValueType_Bool
@ ValueType_Bool
Definition
ValueID.h:87
OpenZWave::ValueID::ValueType_List
@ ValueType_List
Definition
ValueID.h:91
OpenZWave::ValueID::ValueType_Schedule
@ ValueType_Schedule
Definition
ValueID.h:92
OpenZWave::ValueID::ValueType_Short
@ ValueType_Short
Definition
ValueID.h:93
OpenZWave::ValueID::ValueType_Byte
@ ValueType_Byte
Definition
ValueID.h:88
OpenZWave::ValueID::ValueType_Max
@ ValueType_Max
Definition
ValueID.h:97
OpenZWave::ValueID::ValueType_Decimal
@ ValueType_Decimal
Definition
ValueID.h:89
OpenZWave::ValueID::Group
friend class Group
Definition
ValueID.h:58
OpenZWave::ValueID::GetHomeId
uint32 GetHomeId() const
Definition
ValueID.h:104
OpenZWave::ValueID::ValueID
ValueID(uint32 const _homeId, uint8 const _nodeId, ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex, ValueType const _type)
Definition
ValueID.h:219
OpenZWave::ValueID::Notification
friend class Notification
Definition
ValueID.h:62
OpenZWave::ValueID::GetType
ValueType GetType() const
Definition
ValueID.h:155
OpenZWave::ValueID::GetCommandClassId
uint8 GetCommandClassId() const
Definition
ValueID.h:126
OpenZWave::ValueID::ManufacturerSpecific
friend class ManufacturerSpecific
Definition
ValueID.h:63
OpenZWave::ValueID::Node
friend class Node
Definition
ValueID.h:57
OpenZWave::ValueID::GetInstance
uint8 GetInstance() const
Definition
ValueID.h:136
OpenZWave::ValueID::ValueID
ValueID(uint32 _homeId, uint64 id)
Definition
ValueID.h:244
OpenZWave::ValueID::Driver
friend class Driver
Definition
ValueID.h:56
OpenZWave::ValueID::GetGenre
ValueGenre GetGenre() const
Definition
ValueID.h:118
OpenZWave::ValueID::ValueStore
friend class ValueStore
Definition
ValueID.h:61
OpenZWave::ValueID::GetId
uint64 GetId() const
Definition
ValueID.h:162
OpenZWave::ValueID::GetNodeId
uint8 GetNodeId() const
Definition
ValueID.h:110
OpenZWave::ValueID::Manager
friend class Manager
Definition
ValueID.h:55
OpenZWave::ValueID::Value
friend class Value
Definition
ValueID.h:60
OpenZWave::ValueID::ValueGenre
ValueGenre
Definition
ValueID.h:72
OpenZWave::ValueID::ValueGenre_Config
@ ValueGenre_Config
Definition
ValueID.h:75
OpenZWave::ValueID::ValueGenre_System
@ ValueGenre_System
Definition
ValueID.h:76
OpenZWave::ValueID::ValueGenre_User
@ ValueGenre_User
Definition
ValueID.h:74
OpenZWave::ValueID::ValueGenre_Count
@ ValueGenre_Count
Definition
ValueID.h:77
OpenZWave::ValueID::ValueGenre_Basic
@ ValueGenre_Basic
Definition
ValueID.h:73
OpenZWave
Definition
Bitfield.h:35
Generated on
for OpenZWave Library by
1.18.0