ansible4ozw 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/lib/ansible.rb +12 -9
  2. data/lib/ansible/ansible_device.rb +1 -1
  3. data/lib/ansible/ansible_value.rb +1 -1
  4. data/lib/ansible/config.rb +8 -5
  5. data/lib/ansible/devices.rb +1 -0
  6. data/lib/ansible/knx.rb +0 -0
  7. data/lib/ansible/knx/dpt/tests/test_dpt10.rb~ +45 -0
  8. data/lib/ansible/knx/dpt/tests/test_dpt9.rb~ +55 -0
  9. data/lib/ansible/transceiver.rb +0 -3
  10. data/lib/ansible/version.rb +3 -0
  11. data/lib/ansible/zwave.rb +1 -0
  12. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_constants.rb +1 -2
  13. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_headers.rb +2 -6
  14. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_remote_manager.rb +0 -3
  15. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_types.rb +0 -0
  16. data/lib/ansible/zwave/openzwave/src/Driver.h +695 -0
  17. data/lib/ansible/zwave/openzwave/src/Notification.h +165 -0
  18. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.cpp +142 -0
  19. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.h +69 -0
  20. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.cpp +93 -0
  21. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.h +57 -0
  22. data/lib/ansible/zwave/openzwave/src/command_classes/Association.cpp +385 -0
  23. data/lib/ansible/zwave/openzwave/src/command_classes/Association.h +73 -0
  24. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.cpp +277 -0
  25. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.h +70 -0
  26. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.cpp +212 -0
  27. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.h +72 -0
  28. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.cpp +118 -0
  29. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.h +64 -0
  30. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.cpp +141 -0
  31. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.h +65 -0
  32. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.cpp +415 -0
  33. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.h +71 -0
  34. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.cpp +227 -0
  35. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.h +67 -0
  36. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.cpp +546 -0
  37. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.h +145 -0
  38. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.cpp +291 -0
  39. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.h +79 -0
  40. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.cpp +258 -0
  41. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.h +67 -0
  42. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.cpp +142 -0
  43. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.h +63 -0
  44. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.cpp +163 -0
  45. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.h +65 -0
  46. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.cpp +68 -0
  47. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.h +58 -0
  48. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.cpp +159 -0
  49. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.h +66 -0
  50. data/lib/ansible/zwave/openzwave/src/command_classes/Language.cpp +159 -0
  51. data/lib/ansible/zwave/openzwave/src/command_classes/Language.h +65 -0
  52. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.cpp +159 -0
  53. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.h +66 -0
  54. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.cpp +439 -0
  55. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.h +116 -0
  56. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.cpp +541 -0
  57. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.h +73 -0
  58. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.cpp +137 -0
  59. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.h +65 -0
  60. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.cpp +77 -0
  61. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.h +63 -0
  62. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.cpp +568 -0
  63. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.h +96 -0
  64. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.cpp +61 -0
  65. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.h +59 -0
  66. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.cpp +525 -0
  67. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.h +66 -0
  68. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.cpp +157 -0
  69. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.h +82 -0
  70. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.cpp +62 -0
  71. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.h +58 -0
  72. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.cpp +177 -0
  73. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.h +73 -0
  74. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.cpp +208 -0
  75. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.h +77 -0
  76. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.cpp +134 -0
  77. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.h +65 -0
  78. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.cpp +237 -0
  79. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.h +71 -0
  80. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.cpp +219 -0
  81. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.h +69 -0
  82. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.cpp +157 -0
  83. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.h +66 -0
  84. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.cpp +559 -0
  85. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.h +83 -0
  86. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.cpp +151 -0
  87. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.h +66 -0
  88. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.cpp +195 -0
  89. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.h +75 -0
  90. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.cpp +332 -0
  91. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.h +77 -0
  92. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.cpp +149 -0
  93. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.h +71 -0
  94. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.cpp +373 -0
  95. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.h +76 -0
  96. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.cpp +147 -0
  97. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.h +71 -0
  98. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.cpp +317 -0
  99. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.h +73 -0
  100. data/lib/ansible/zwave/openzwave/src/command_classes/Version.cpp +255 -0
  101. data/lib/ansible/zwave/openzwave/src/command_classes/Version.h +71 -0
  102. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.cpp +391 -0
  103. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.h +85 -0
  104. data/lib/ansible/zwave/openzwave/src/platform/Controller.cpp +68 -0
  105. data/lib/ansible/zwave/openzwave/src/platform/Controller.h +106 -0
  106. data/lib/ansible/zwave/openzwave/src/platform/Event.cpp +102 -0
  107. data/lib/ansible/zwave/openzwave/src/platform/Event.h +91 -0
  108. data/lib/ansible/zwave/openzwave/src/platform/HidController.cpp +539 -0
  109. data/lib/ansible/zwave/openzwave/src/platform/HidController.h +147 -0
  110. data/lib/ansible/zwave/openzwave/src/platform/Log.cpp +310 -0
  111. data/lib/ansible/zwave/openzwave/src/platform/Log.h +184 -0
  112. data/lib/ansible/zwave/openzwave/src/platform/Mutex.cpp +96 -0
  113. data/lib/ansible/zwave/openzwave/src/platform/Mutex.h +88 -0
  114. data/lib/ansible/zwave/openzwave/src/platform/Ref.h +91 -0
  115. data/lib/ansible/zwave/openzwave/src/platform/SerialController.cpp +180 -0
  116. data/lib/ansible/zwave/openzwave/src/platform/SerialController.h +138 -0
  117. data/lib/ansible/zwave/openzwave/src/platform/Stream.cpp +229 -0
  118. data/lib/ansible/zwave/openzwave/src/platform/Stream.h +135 -0
  119. data/lib/ansible/zwave/openzwave/src/platform/Thread.cpp +118 -0
  120. data/lib/ansible/zwave/openzwave/src/platform/Thread.h +101 -0
  121. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.cpp +92 -0
  122. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.h +85 -0
  123. data/lib/ansible/zwave/openzwave/src/platform/Wait.cpp +176 -0
  124. data/lib/ansible/zwave/openzwave/src/platform/Wait.h +113 -0
  125. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.cpp +262 -0
  126. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.h +62 -0
  127. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.cpp +304 -0
  128. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.h +70 -0
  129. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.cpp +136 -0
  130. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.h +56 -0
  131. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.cpp +368 -0
  132. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.h +74 -0
  133. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.cpp +181 -0
  134. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.h +67 -0
  135. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.cpp +121 -0
  136. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.h +84 -0
  137. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.cpp +160 -0
  138. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.h +74 -0
  139. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.cpp +102 -0
  140. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.h +60 -0
  141. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.cpp +302 -0
  142. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.h +71 -0
  143. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.cpp +114 -0
  144. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.h +58 -0
  145. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.cpp +410 -0
  146. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.h +66 -0
  147. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.cpp +158 -0
  148. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.h +71 -0
  149. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.cpp +95 -0
  150. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.h +83 -0
  151. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.cpp +134 -0
  152. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.h +73 -0
  153. data/lib/ansible/zwave/openzwave/src/value_classes/ValueID.h +283 -0
  154. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_bool.rb +0 -0
  155. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_button.rb +0 -0
  156. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_byte.rb +0 -0
  157. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_decimal.rb +0 -0
  158. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_int.rb +0 -0
  159. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_list.rb +0 -0
  160. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_short.rb +0 -0
  161. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_string.rb +0 -0
  162. data/lib/ansible/zwave/zwave_transceiver.rb +2 -8
  163. data/lib/ansible/zwave/zwave_value.rb +6 -10
  164. metadata +159 -17
  165. data/lib/ansible/zwave/zwave_node.rb +0 -5
@@ -0,0 +1,134 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // WaitImpl.cpp
4
+ //
5
+ // Windows implementation of an abstract base class for objects we
6
+ // want to be able to wait for.
7
+ //
8
+ // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
9
+ // All rights reserved.
10
+ //
11
+ // SOFTWARE NOTICE AND LICENSE
12
+ //
13
+ // This file is part of OpenZWave.
14
+ //
15
+ // OpenZWave is free software: you can redistribute it and/or modify
16
+ // it under the terms of the GNU Lesser General Public License as published
17
+ // by the Free Software Foundation, either version 3 of the License,
18
+ // or (at your option) any later version.
19
+ //
20
+ // OpenZWave is distributed in the hope that it will be useful,
21
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ // GNU Lesser General Public License for more details.
24
+ //
25
+ // You should have received a copy of the GNU Lesser General Public License
26
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
27
+ //
28
+ //-----------------------------------------------------------------------------
29
+ #include "Defs.h"
30
+ #include "Wait.h"
31
+ #include "WaitImpl.h"
32
+ #include "Log.h"
33
+
34
+ using namespace OpenZWave;
35
+
36
+ //-----------------------------------------------------------------------------
37
+ // <WaitImpl::WaitImpl>
38
+ // Constructor
39
+ //-----------------------------------------------------------------------------
40
+ WaitImpl::WaitImpl
41
+ (
42
+ Wait* _owner
43
+ ):
44
+ m_owner( _owner )
45
+ {
46
+ InitializeCriticalSection( &m_criticalSection );
47
+ }
48
+
49
+ //-----------------------------------------------------------------------------
50
+ // <WaitImpl::~WaitImpl>
51
+ // Destructor
52
+ //-----------------------------------------------------------------------------
53
+ WaitImpl::~WaitImpl
54
+ (
55
+ )
56
+ {
57
+ DeleteCriticalSection( &m_criticalSection );
58
+ }
59
+
60
+ //-----------------------------------------------------------------------------
61
+ // <WaitImpl::AddWatcher>
62
+ // Add a watcher to our object.
63
+ //-----------------------------------------------------------------------------
64
+ void WaitImpl::AddWatcher
65
+ (
66
+ Wait::pfnWaitNotification_t _callback,
67
+ void* _context
68
+ )
69
+ {
70
+ // Add the watcher to our list
71
+ Watcher watcher;
72
+ watcher.m_callback = _callback;
73
+ watcher.m_context = _context;
74
+
75
+ EnterCriticalSection( &m_criticalSection );
76
+
77
+ m_watchers.push_back( watcher );
78
+
79
+ LeaveCriticalSection( &m_criticalSection );
80
+
81
+ // If the object is already in a signalled state, notify the watcher immediately
82
+ if( m_owner->IsSignalled() )
83
+ {
84
+ _callback( _context );
85
+ }
86
+
87
+ }
88
+
89
+ //-----------------------------------------------------------------------------
90
+ // <WaitImpl::RemoveWatcher>
91
+ // Remove a watcher from our object.
92
+ //-----------------------------------------------------------------------------
93
+ bool WaitImpl::RemoveWatcher
94
+ (
95
+ Wait::pfnWaitNotification_t _callback,
96
+ void* _context
97
+ )
98
+ {
99
+ bool res = false;
100
+ EnterCriticalSection( &m_criticalSection );
101
+
102
+ for( list<Watcher>::iterator it=m_watchers.begin(); it!=m_watchers.end(); ++it )
103
+ {
104
+ Watcher const& watcher = *it;
105
+ if( ( watcher.m_callback == _callback ) && ( watcher.m_context == _context ) )
106
+ {
107
+ m_watchers.erase( it );
108
+ res = true;
109
+ break;
110
+ }
111
+ }
112
+
113
+ LeaveCriticalSection( &m_criticalSection );
114
+ return res;
115
+ }
116
+
117
+ //-----------------------------------------------------------------------------
118
+ // <WaitImpl::Notify>
119
+ // Notify all the watchers that the object has become signalled
120
+ //-----------------------------------------------------------------------------
121
+ void WaitImpl::Notify
122
+ (
123
+ )
124
+ {
125
+ EnterCriticalSection( &m_criticalSection );
126
+
127
+ for( list<Watcher>::iterator it=m_watchers.begin(); it!=m_watchers.end(); ++it )
128
+ {
129
+ Watcher const& watcher = *it;
130
+ watcher.m_callback( watcher.m_context );
131
+ }
132
+
133
+ LeaveCriticalSection( &m_criticalSection );
134
+ }
@@ -0,0 +1,73 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // WaitImpl.h
4
+ //
5
+ // Windows implementation of a base class for objects we
6
+ // want to be able to wait for.
7
+ //
8
+ // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
9
+ // All rights reserved.
10
+ //
11
+ // SOFTWARE NOTICE AND LICENSE
12
+ //
13
+ // This file is part of OpenZWave.
14
+ //
15
+ // OpenZWave is free software: you can redistribute it and/or modify
16
+ // it under the terms of the GNU Lesser General Public License as published
17
+ // by the Free Software Foundation, either version 3 of the License,
18
+ // or (at your option) any later version.
19
+ //
20
+ // OpenZWave is distributed in the hope that it will be useful,
21
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ // GNU Lesser General Public License for more details.
24
+ //
25
+ // You should have received a copy of the GNU Lesser General Public License
26
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
27
+ //
28
+ //-----------------------------------------------------------------------------
29
+ #ifndef _WaitImpl_H
30
+ #define _WaitImpl_H
31
+
32
+ #include <windows.h>
33
+ #include <list>
34
+ #include "Defs.h"
35
+ #include "Ref.h"
36
+ #include "Wait.h"
37
+
38
+ namespace OpenZWave
39
+ {
40
+ /** \brief Windows specific implementation of Wait objects.
41
+ */
42
+ class WaitImpl
43
+ {
44
+ private:
45
+ friend class Wait;
46
+
47
+ WaitImpl( Wait* _owner );
48
+ virtual ~WaitImpl();
49
+
50
+ void AddWatcher( Wait::pfnWaitNotification_t _callback, void* _context );
51
+ bool RemoveWatcher( Wait::pfnWaitNotification_t _callback, void* _context );
52
+ void Notify();
53
+
54
+ static int32 Multiple( Wait** _objects, uint32 _numObjects, int32 _timeout = -1 );
55
+
56
+ WaitImpl( Wait const& ); // prevent copy
57
+ WaitImpl& operator = ( WaitImpl const& ); // prevent assignment
58
+
59
+ struct Watcher
60
+ {
61
+ Wait::pfnWaitNotification_t m_callback;
62
+ void* m_context;
63
+ };
64
+
65
+ list<Watcher> m_watchers;
66
+ Wait* m_owner;
67
+ CRITICAL_SECTION m_criticalSection;
68
+ };
69
+
70
+ } // namespace OpenZWave
71
+
72
+ #endif //_WaitImpl_H
73
+
@@ -0,0 +1,283 @@
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
+ {
39
+ /** \brief Provides a unique ID for a value reported by a Z-Wave device.
40
+ *
41
+ * The ValueID is used to uniquely identify a value reported by a
42
+ * Z-Wave device.
43
+ * <p>
44
+ * The ID is built by packing various identifying characteristics into a single
45
+ * 32-bit number - the Z-Wave driver index, device node ID, the command class and
46
+ * command class instance that handles the value, plus an index for the value
47
+ * to distinguish it among all the other values managed by that command class
48
+ * instance. The type (bool, byte, string etc) of the value is also stored.
49
+ * <p>
50
+ * The packing of the ID is such that a list of Values sorted by ValueID
51
+ * will be in a sensible order for display to the user.
52
+ */
53
+ class 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:
66
+ /**
67
+ * Value Genres
68
+ * The classification of a value to enable low level system or configuration parameters to be filtered by the application.
69
+ * \see GetGenre
70
+ */
71
+ enum ValueGenre
72
+ {
73
+ ValueGenre_Basic = 0, /**< The 'level' as controlled by basic commands. Usually duplicated by another command class. */
74
+ ValueGenre_User, /**< Basic values an ordinary user would be interested in. */
75
+ ValueGenre_Config, /**< Device-specific configuration parameters. These cannot be automatically discovered via Z-Wave, and are usually described in the user manual instead. */
76
+ ValueGenre_System, /**< Values of significance only to users who understand the Z-Wave protocol */
77
+ ValueGenre_Count /**< A count of the number of genres defined. Not to be used as a genre itself. */
78
+ };
79
+
80
+ /**
81
+ * Value Types
82
+ * The type of data represented by the value object.
83
+ * \see GetType
84
+ */
85
+ enum ValueType
86
+ {
87
+ ValueType_Bool = 0, /**< Boolean, true or false */
88
+ ValueType_Byte, /**< 8-bit unsigned value */
89
+ ValueType_Decimal, /**< Represents a non-integer value as a string, to avoid floating point accuracy issues. */
90
+ ValueType_Int, /**< 32-bit signed value */
91
+ ValueType_List, /**< List from which one item can be selected */
92
+ ValueType_Schedule, /**< Complex type used with the Climate Control Schedule command class */
93
+ ValueType_Short, /**< 16-bit signed value */
94
+ ValueType_String, /**< Text string */
95
+ ValueType_Button, /**< A write-only value that is the equivalent of pressing a button to send a command to a device */
96
+ ValueType_Max = ValueType_Button /**< The highest-number type defined. Not to be used as a type itself. */
97
+ };
98
+
99
+ /**
100
+ * Get the Home ID of the driver that controls the node containing the value.
101
+ * \return the Home ID.
102
+ */
103
+ uint32 GetHomeId()const{ return m_homeId; }
104
+
105
+ /**
106
+ * Get the Home ID of the driver that controls the node containing the value.
107
+ * \return the node id.
108
+ */
109
+ uint8 GetNodeId()const{ return( (uint8)( (m_id & 0xff000000) >> 24 ) ); }
110
+
111
+ /**
112
+ * Get the genre of the value. The genre classifies a value to enable
113
+ * low-level system or configuration parameters to be filtered out by the application
114
+ * \return the value's genre.
115
+ * \see ValueGenre
116
+ */
117
+ ValueGenre GetGenre()const{ return( (ValueGenre)( (m_id & 0x00c00000) >> 22 ) ); }
118
+
119
+ /**
120
+ * Get the Z-Wave command class that created and manages this value. Knowledge of
121
+ * command classes is not required to use OpenZWave, but this information is
122
+ * exposed in case it is of interest.
123
+ * \return the value's command class.
124
+ */
125
+ uint8 GetCommandClassId()const{ return( (uint8)( (m_id & 0x003fc000) >> 14 ) ); }
126
+
127
+ /**
128
+ * Get the command class instance of this value. It is possible for there to be
129
+ * multiple instances of a command class, although currently it appears that
130
+ * only the SensorMultilevel command class ever does this. Knowledge of
131
+ * instances and command classes is not required to use OpenZWave, but this
132
+ * information is exposed in case it is of interest.
133
+ * \return the instance of the value's command class.
134
+ */
135
+ uint8 GetInstance()const{ return( (uint8)( ( (m_id1 & 0xff000000) ) >> 24 ) ); }
136
+
137
+ /**
138
+ * Get the value index. The index is used to identify one of multiple
139
+ * values created and managed by a command class. In the case of configurable
140
+ * parameters (handled by the configuration command class), the index is the
141
+ * same as the parameter ID. Knowledge of command classes is not required
142
+ * to use OpenZWave, but this information is exposed in case it is of interest.
143
+ * \return the value index within the command class.
144
+ */
145
+ uint8 GetIndex()const{ return( (uint8)( (m_id & 0x00000ff0) >> 4 ) ); }
146
+
147
+ /**
148
+ * Get the type of the value. The type describes the data held by the value
149
+ * and enables the user to select the correct value accessor method in the
150
+ * Manager class.
151
+ * \return the value's type.
152
+ * \see ValueType, Manager::GetValueAsBool, Manager::GetValueAsByte, Manager::GetValueAsFloat, Manager::GetValueAsInt, Manager::GetValueAsShort, Manager::GetValueAsString, Manager::GetValueListSelection.
153
+ */
154
+ ValueType GetType()const{ return( (ValueType)( m_id & 0x0000000f ) ); }
155
+
156
+ uint64 GetId()const{ return (uint64) ( ( (uint64)m_id1 << 32 ) | m_id );}
157
+
158
+ // Comparison Operators
159
+ bool operator == ( ValueID const& _other )const{ return( ( m_homeId == _other.m_homeId ) && ( m_id == _other.m_id ) && ( m_id1 == _other.m_id1 ) ); }
160
+ bool operator != ( ValueID const& _other )const{ return( ( m_homeId != _other.m_homeId ) || ( m_id != _other.m_id ) || ( m_id1 != _other.m_id1 ) ); }
161
+ bool operator < ( ValueID const& _other )const
162
+ {
163
+ if( m_homeId == _other.m_homeId )
164
+ {
165
+ if( m_id == _other.m_id )
166
+ {
167
+ return( m_id1 < _other.m_id1 );
168
+ }
169
+ else
170
+ {
171
+ return( m_id < _other.m_id );
172
+ }
173
+ }
174
+ else
175
+ {
176
+ return( m_homeId < _other.m_homeId );
177
+ }
178
+ }
179
+ bool operator > ( ValueID const& _other )const
180
+ {
181
+ if( m_homeId == _other.m_homeId )
182
+ {
183
+ if( m_id == _other.m_id )
184
+ {
185
+ return( m_id1 > _other.m_id1 );
186
+ }
187
+ else
188
+ {
189
+ return( m_id > _other.m_id );
190
+ }
191
+ }
192
+ else
193
+ {
194
+ return( m_homeId > _other.m_homeId );
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Construct a value ID from its component parts.
200
+ * This method is public only to allow ValueIDs to be saved and recreated by the application.
201
+ * Only ValueIDs that have been reported by OpenZWave notifications should ever be used.
202
+ * \param _homeId Home ID of the PC Z-Wave Controller that manages the device.
203
+ * \param _nodeId Node ID of the device reporting the value.
204
+ * \param _genre classification of the value to enable low level system or configuration parameters to be filtered out.
205
+ * \param _commandClassId ID of command class that creates and manages this value.
206
+ * \param _instance Instance index of the command class.
207
+ * \param _valueIndex Index of the value within all the values created by the command class instance.
208
+ * \param _type Type of value (bool, byte, string etc).
209
+ * \return The ValueID.
210
+ * \see ValueID
211
+ */
212
+ ValueID
213
+ (
214
+ uint32 const _homeId,
215
+ uint8 const _nodeId,
216
+ ValueGenre const _genre,
217
+ uint8 const _commandClassId,
218
+ uint8 const _instance,
219
+ uint8 const _valueIndex,
220
+ ValueType const _type
221
+ ):
222
+ m_homeId( _homeId )
223
+ {
224
+ m_id = (((uint32)_nodeId)<<24)
225
+ | (((uint32)_genre)<<22)
226
+ | (((uint32)_commandClassId)<<14)
227
+ | (((uint32)_valueIndex)<<4)
228
+ | ((uint32)_type);
229
+ m_id1 = (((uint32)_instance)<<24);
230
+ }
231
+
232
+ private:
233
+ // Construct a value id for use in notifications
234
+ ValueID( uint32 const _homeId, uint8 const _nodeId ): m_id1( 0 ),m_homeId( _homeId ){ m_id = ((uint32)_nodeId)<<24; }
235
+
236
+ // Default constructor
237
+ ValueID():m_id(0),m_id1(0),m_homeId(0){}
238
+
239
+ // Not all parts of the ValueID are necessary to uniquely identify the value. In the case of a
240
+ // Node's ValueStore, we can ignore the home ID, node ID, genre and type and still be left with
241
+ // a unique integer than can be used as a key to look up values. The two GetValueStoreKey methods
242
+ // below are helpers to enable command classes to easily access their values from the ValueStore.
243
+
244
+ // Get the key from our own m_id
245
+ uint32 GetValueStoreKey()const
246
+ {
247
+ return ( ( m_id & 0x003ffff0 ) | ( m_id1 & 0xff000000 ) );
248
+ }
249
+
250
+ // Generate a key from its component parts
251
+ static uint32 GetValueStoreKey( uint8 const _commandClassId, uint8 const _instance, uint8 const _valueIndex )
252
+ {
253
+
254
+ uint32 key = (((uint32)_instance)<<24)
255
+ | (((uint32)_commandClassId)<<14)
256
+ | (((uint32)_valueIndex)<<4);
257
+
258
+ return key;
259
+ }
260
+
261
+ // ID Packing:
262
+ // Bits
263
+ // 24-31: 8 bits. Node ID of device
264
+ // 22-23: 2 bits. genre of value (see ValueGenre enum).
265
+ // 14-21: 8 bits. ID of command class that created and manages this value.
266
+ // 12-13: 2 bits. Unused.
267
+ // 04-11: 8 bits. Index of value within all the value created by the command class
268
+ // instance (in configuration parameters, this is also the parameter ID).
269
+ // 00-03: 4 bits. Type of value (bool, byte, string etc).
270
+ uint32 m_id;
271
+
272
+ // ID1 Packing:
273
+ // Bits
274
+ // 24-31 8 bits. Instance Index of the command class.
275
+ uint32 m_id1;
276
+
277
+ // Unique PC interface identifier
278
+ uint32 m_homeId;
279
+ };
280
+
281
+ } // namespace OpenZWave
282
+
283
+ #endif