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,63 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ControllerReplication.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_CONTROLLER_REPLICATION
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 _ControllerReplication_H
29
+ #define _ControllerReplication_H
30
+
31
+ #include "CommandClass.h"
32
+
33
+ namespace OpenZWave
34
+ {
35
+ /** \brief Implements COMMAND_CLASS_CONTROLLER_REPLICATION (0x21), a Z-Wave device command class.
36
+ */
37
+ class ControllerReplication: public CommandClass
38
+ {
39
+ public:
40
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ControllerReplication( _homeId, _nodeId ); }
41
+ virtual ~ControllerReplication(){}
42
+
43
+ static uint8 const StaticGetCommandClassId(){ return 0x21; }
44
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CONTROLLER_REPLICATION"; }
45
+
46
+ void StartReplication( uint8 const _targetNodeId, uint8 const _funcId );
47
+ void SendNextData( uint8 const _targetNodeId );
48
+
49
+ // From CommandClass
50
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
51
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
52
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
53
+
54
+ private:
55
+ ControllerReplication( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
56
+
57
+ uint8 m_funcId;
58
+ };
59
+
60
+ } // namespace OpenZWave
61
+
62
+ #endif
63
+
@@ -0,0 +1,163 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // EnergyProduction.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_ENERGY_PRODUCTION
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
+ #include "CommandClasses.h"
29
+ #include "EnergyProduction.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Node.h"
33
+ #include "Driver.h"
34
+ #include "Log.h"
35
+
36
+ #include "ValueDecimal.h"
37
+
38
+ using namespace OpenZWave;
39
+
40
+ enum EnergyProductionCmd
41
+ {
42
+ EnergyProductionCmd_Get = 0x02,
43
+ EnergyProductionCmd_Report = 0x03
44
+ };
45
+
46
+ enum
47
+ {
48
+ EnergyProductionIndex_Instant = 0,
49
+ EnergyProductionIndex_Total,
50
+ EnergyProductionIndex_Today,
51
+ EnergyProductionIndex_Time
52
+ };
53
+
54
+ static char const* c_energyParameterNames[] =
55
+ {
56
+ "Instant energy production",
57
+ "Total energy production",
58
+ "Energy production today",
59
+ "Total production time"
60
+ };
61
+
62
+ //-----------------------------------------------------------------------------
63
+ // <EnergyProduction::RequestState>
64
+ // Request current state from the device
65
+ //-----------------------------------------------------------------------------
66
+ bool EnergyProduction::RequestState
67
+ (
68
+ uint32 const _requestFlags,
69
+ uint8 const _instance,
70
+ Driver::MsgQueue const _queue
71
+ )
72
+ {
73
+ bool request = false;
74
+ if( _requestFlags & RequestFlag_Dynamic )
75
+ {
76
+ // Request each of the production values
77
+ request |= RequestValue( _requestFlags, EnergyProductionIndex_Instant, _instance, _queue );
78
+ request |= RequestValue( _requestFlags, EnergyProductionIndex_Total, _instance, _queue );
79
+ request |= RequestValue( _requestFlags, EnergyProductionIndex_Today, _instance, _queue );
80
+ request |= RequestValue( _requestFlags, EnergyProductionIndex_Time, _instance, _queue );
81
+ }
82
+
83
+ return request;
84
+ }
85
+
86
+ //-----------------------------------------------------------------------------
87
+ // <EnergyProduction::RequestValue>
88
+ // Request current production from the device
89
+ //-----------------------------------------------------------------------------
90
+ bool EnergyProduction::RequestValue
91
+ (
92
+ uint32 const _requestFlags,
93
+ uint8 const _valueEnum, // one of EnergyProductionIndex enums
94
+ uint8 const _instance,
95
+ Driver::MsgQueue const _queue
96
+ )
97
+ {
98
+ Log::Write( LogLevel_Info, GetNodeId(), "Requesting the %s value", c_energyParameterNames[_valueEnum] );
99
+ Msg* msg = new Msg( "EnergyProductionCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
100
+ msg->SetInstance( this, _instance );
101
+ msg->Append( GetNodeId() );
102
+ msg->Append( 3 );
103
+ msg->Append( GetCommandClassId() );
104
+ msg->Append( EnergyProductionCmd_Get );
105
+ msg->Append( _valueEnum );
106
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
107
+ GetDriver()->SendMsg( msg, _queue );
108
+ return true;
109
+ }
110
+
111
+ //-----------------------------------------------------------------------------
112
+ // <EnergyProduction::HandleMsg>
113
+ // Handle a message from the Z-Wave network
114
+ //-----------------------------------------------------------------------------
115
+ bool EnergyProduction::HandleMsg
116
+ (
117
+ uint8 const* _data,
118
+ uint32 const _length,
119
+ uint32 const _instance // = 1
120
+ )
121
+ {
122
+ if (EnergyProductionCmd_Report == (EnergyProductionCmd)_data[0])
123
+ {
124
+ uint8 scale;
125
+ uint8 precision = 0;
126
+ string value = ExtractValue( &_data[2], &scale, &precision );
127
+
128
+ Log::Write( LogLevel_Info, GetNodeId(), "Received an Energy production report: %s = %s", c_energyParameterNames[_data[1]], value.c_str() );
129
+ if( ValueDecimal* decimalValue = static_cast<ValueDecimal*>( GetValue( _instance, _data[1] ) ) )
130
+ {
131
+ decimalValue->OnValueRefreshed( value );
132
+ if( decimalValue->GetPrecision() != precision )
133
+ {
134
+ decimalValue->SetPrecision( precision );
135
+ }
136
+ decimalValue->Release();
137
+ }
138
+ return true;
139
+ }
140
+
141
+ return false;
142
+ }
143
+
144
+ //-----------------------------------------------------------------------------
145
+ // <EnergyProduction::CreateVars>
146
+ // Create the values managed by this command class
147
+ //-----------------------------------------------------------------------------
148
+ void EnergyProduction::CreateVars
149
+ (
150
+ uint8 const _instance
151
+ )
152
+ {
153
+ if( Node* node = GetNodeUnsafe() )
154
+ {
155
+ node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Instant, c_energyParameterNames[EnergyProductionIndex_Instant], "W", true, false, "0.0", 0 );
156
+ node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Total, c_energyParameterNames[EnergyProductionIndex_Total], "kWh", true, false, "0.0", 0 );
157
+ node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Today, c_energyParameterNames[EnergyProductionIndex_Today], "kWh", true, false, "0.0", 0 );
158
+ node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, (uint8)EnergyProductionIndex_Time, c_energyParameterNames[EnergyProductionIndex_Time], "", true, false, "0.0", 0 );
159
+ }
160
+ }
161
+
162
+
163
+
@@ -0,0 +1,65 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // EnergyProduction.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_ENERGY_PRODUCTION
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 _EnergyProduction_H
29
+ #define _EnergyProduction_H
30
+
31
+ #include "CommandClass.h"
32
+
33
+ namespace OpenZWave
34
+ {
35
+ class ValueDecimal;
36
+
37
+ /** \brief Implements COMMAND_CLASS_ENERGY_PRODUCTION (0x90), a Z-Wave device command class.
38
+ */
39
+ class EnergyProduction: public CommandClass
40
+ {
41
+ public:
42
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new EnergyProduction( _homeId, _nodeId ); }
43
+ virtual ~EnergyProduction(){}
44
+
45
+ static uint8 const StaticGetCommandClassId(){ return 0x90; }
46
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_ENERGY_PRODUCTION"; }
47
+
48
+ // From CommandClass
49
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
50
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _valueEnum, uint8 const _dummy, Driver::MsgQueue const _queue );
51
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
52
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
53
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
54
+
55
+ protected:
56
+ virtual void CreateVars( uint8 const _instance );
57
+
58
+ private:
59
+ EnergyProduction( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
60
+ };
61
+
62
+ } // namespace OpenZWave
63
+
64
+ #endif
65
+
@@ -0,0 +1,68 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Hail.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_HAIL
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
+ #include "CommandClasses.h"
29
+ #include "Hail.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Node.h"
33
+ #include "Driver.h"
34
+ #include "Log.h"
35
+
36
+ using namespace OpenZWave;
37
+
38
+ enum HailCmdEnum
39
+ {
40
+ HailCmd_Hail = 1
41
+ };
42
+
43
+
44
+ //-----------------------------------------------------------------------------
45
+ // <Hail::HandleMsg>
46
+ // Handle a message from the Z-Wave network
47
+ //-----------------------------------------------------------------------------
48
+ bool Hail::HandleMsg
49
+ (
50
+ uint8 const* _data,
51
+ uint32 const _length,
52
+ uint32 const _instance // = 1
53
+ )
54
+ {
55
+ if( HailCmd_Hail == _data[0] )
56
+ {
57
+ // We have received a hail from the Z-Wave device.
58
+ // Request an update of the dynamic values.
59
+ Log::Write( LogLevel_Info, GetNodeId(), "Received Hail command from node %d", GetNodeId() );
60
+ if( Node* node = GetNodeUnsafe() )
61
+ {
62
+ node->RequestDynamicValues();
63
+ }
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+
@@ -0,0 +1,58 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Hail.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_HAIL
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 _Hail_H
29
+ #define _Hail_H
30
+
31
+ #include "CommandClass.h"
32
+
33
+ namespace OpenZWave
34
+ {
35
+ /** \brief Implements COMMAND_CLASS_HAIL (0x82), a Z-Wave device command class.
36
+ */
37
+ class Hail: public CommandClass
38
+ {
39
+ public:
40
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Hail( _homeId, _nodeId ); }
41
+ virtual ~Hail(){}
42
+
43
+ static uint8 const StaticGetCommandClassId(){ return 0x82; }
44
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_HAIL"; }
45
+
46
+ // From CommandClass
47
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
48
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
49
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
50
+
51
+ private:
52
+ Hail( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
53
+ };
54
+
55
+ } // namespace OpenZWave
56
+
57
+ #endif
58
+
@@ -0,0 +1,159 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Indicator.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_INDICATOR
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
+ #include "CommandClasses.h"
29
+ #include "Indicator.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Node.h"
33
+ #include "Driver.h"
34
+ #include "Log.h"
35
+
36
+ #include "ValueByte.h"
37
+
38
+ using namespace OpenZWave;
39
+
40
+ enum IndicatorCmd
41
+ {
42
+ IndicatorCmd_Set = 0x01,
43
+ IndicatorCmd_Get = 0x02,
44
+ IndicatorCmd_Report = 0x03
45
+ };
46
+
47
+ //-----------------------------------------------------------------------------
48
+ // <Indicator::RequestState>
49
+ // Request current state from the device
50
+ //-----------------------------------------------------------------------------
51
+ bool Indicator::RequestState
52
+ (
53
+ uint32 const _requestFlags,
54
+ uint8 const _instance,
55
+ Driver::MsgQueue const _queue
56
+ )
57
+ {
58
+ if( _requestFlags & RequestFlag_Dynamic )
59
+ {
60
+ return RequestValue( _requestFlags, 0, _instance, _queue );
61
+ }
62
+
63
+ return false;
64
+ }
65
+
66
+ //-----------------------------------------------------------------------------
67
+ // <Indicator::RequestValue>
68
+ // Request current value from the device
69
+ //-----------------------------------------------------------------------------
70
+ bool Indicator::RequestValue
71
+ (
72
+ uint32 const _requestFlags,
73
+ uint8 const _dummy1, // = 0 (not used)
74
+ uint8 const _instance,
75
+ Driver::MsgQueue const _queue
76
+ )
77
+ {
78
+ Msg* msg = new Msg( "IndicatorCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
79
+ msg->SetInstance( this, _instance );
80
+ msg->Append( GetNodeId() );
81
+ msg->Append( 2 );
82
+ msg->Append( GetCommandClassId() );
83
+ msg->Append( IndicatorCmd_Get );
84
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
85
+ GetDriver()->SendMsg( msg, _queue );
86
+ return true;
87
+ }
88
+
89
+ //-----------------------------------------------------------------------------
90
+ // <Indicator::HandleMsg>
91
+ // Handle a message from the Z-Wave network
92
+ //-----------------------------------------------------------------------------
93
+ bool Indicator::HandleMsg
94
+ (
95
+ uint8 const* _data,
96
+ uint32 const _length,
97
+ uint32 const _instance // = 1
98
+ )
99
+ {
100
+ if( IndicatorCmd_Report == (IndicatorCmd)_data[0] )
101
+ {
102
+ Log::Write( LogLevel_Info, GetNodeId(), "Received an Indicator report: Indicator=%d", _data[1] );
103
+
104
+ if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
105
+ {
106
+ value->OnValueRefreshed( _data[1] != 0 );
107
+ value->Release();
108
+ }
109
+ return true;
110
+ }
111
+
112
+ return false;
113
+ }
114
+
115
+ //-----------------------------------------------------------------------------
116
+ // <Indicator::SetValue>
117
+ // Set the device's indicator value
118
+ //-----------------------------------------------------------------------------
119
+ bool Indicator::SetValue
120
+ (
121
+ Value const& _value
122
+ )
123
+ {
124
+ if( ValueID::ValueType_Byte == _value.GetID().GetType() )
125
+ {
126
+ ValueByte const* value = static_cast<ValueByte const*>(&_value);
127
+
128
+ Log::Write( LogLevel_Info, GetNodeId(), "Indicator::SetValue - Setting indicator to %d", value->GetValue());
129
+ Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
130
+ msg->SetInstance( this, _value.GetID().GetInstance() );
131
+ msg->Append( GetNodeId() );
132
+ msg->Append( 3 );
133
+ msg->Append( GetCommandClassId() );
134
+ msg->Append( IndicatorCmd_Set );
135
+ msg->Append( value->GetValue() );
136
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
137
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
138
+ return true;
139
+ }
140
+
141
+ return false;
142
+ }
143
+
144
+ //-----------------------------------------------------------------------------
145
+ // <Indicator::CreateVars>
146
+ // Create the values managed by this command class
147
+ //-----------------------------------------------------------------------------
148
+ void Indicator::CreateVars
149
+ (
150
+ uint8 const _instance
151
+ )
152
+ {
153
+ if( Node* node = GetNodeUnsafe() )
154
+ {
155
+ node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Indicator", "", false, false, false, 0 );
156
+ }
157
+ }
158
+
159
+