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,75 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // SwitchToggleMultilevel.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL
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 _SwitchToggleMultilevel_H
29
+ #define _SwitchToggleMultilevel_H
30
+
31
+ #include "CommandClass.h"
32
+
33
+ namespace OpenZWave
34
+ {
35
+ class ValueByte;
36
+
37
+ /** \brief Implements COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL (0x29), a Z-Wave device command class.
38
+ */
39
+ class SwitchToggleMultilevel: public CommandClass
40
+ {
41
+ public:
42
+ enum SwitchToggleMultilevelDirection
43
+ {
44
+ SwitchToggleMultilevelDirection_Up = 0x00,
45
+ SwitchToggleMultilevelDirection_Down = 0x40
46
+ };
47
+
48
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchToggleMultilevel( _homeId, _nodeId ); }
49
+ virtual ~SwitchToggleMultilevel(){}
50
+
51
+ static uint8 const StaticGetCommandClassId(){ return 0x29; }
52
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL"; }
53
+
54
+ void StartLevelChange( SwitchToggleMultilevelDirection const _direction, bool const _bIgnoreStartLevel, bool const _bRollover );
55
+ void StopLevelChange();
56
+
57
+ // From CommandClass
58
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
59
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
60
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
61
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
62
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
63
+ virtual bool SetValue( Value const& _value );
64
+
65
+ protected:
66
+ virtual void CreateVars( uint8 const _instance );
67
+
68
+ private:
69
+ SwitchToggleMultilevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
70
+ };
71
+
72
+ } // namespace OpenZWave
73
+
74
+ #endif
75
+
@@ -0,0 +1,332 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ThermostatFanMode.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_FAN_MODE
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 <string>
29
+ #include "CommandClasses.h"
30
+ #include "ThermostatFanMode.h"
31
+ #include "Defs.h"
32
+ #include "Msg.h"
33
+ #include "Node.h"
34
+ #include "Driver.h"
35
+ #include "Log.h"
36
+
37
+ #include "ValueList.h"
38
+
39
+ using namespace OpenZWave;
40
+
41
+ enum ThermostatFanModeCmd
42
+ {
43
+ ThermostatFanModeCmd_Set = 0x01,
44
+ ThermostatFanModeCmd_Get = 0x02,
45
+ ThermostatFanModeCmd_Report = 0x03,
46
+ ThermostatFanModeCmd_SupportedGet = 0x04,
47
+ ThermostatFanModeCmd_SupportedReport = 0x05
48
+ };
49
+
50
+ static string const c_modeName[] =
51
+ {
52
+ "Auto Low",
53
+ "On Low",
54
+ "Auto High",
55
+ "On High",
56
+ "Unknown 4",
57
+ "Unknown 5",
58
+ "Circulate"
59
+ };
60
+
61
+ //-----------------------------------------------------------------------------
62
+ // <ThermostatFanMode::ReadXML>
63
+ // Read the supported modes
64
+ //-----------------------------------------------------------------------------
65
+ void ThermostatFanMode::ReadXML
66
+ (
67
+ TiXmlElement const* _ccElement
68
+ )
69
+ {
70
+ CommandClass::ReadXML( _ccElement );
71
+
72
+ if( Node* node = GetNodeUnsafe() )
73
+ {
74
+ node = node;
75
+ vector<ValueList::Item> supportedModes;
76
+
77
+ TiXmlElement const* supportedModesElement = _ccElement->FirstChildElement( "SupportedModes" );
78
+ if( supportedModesElement )
79
+ {
80
+ TiXmlElement const* modeElement = supportedModesElement->FirstChildElement();
81
+ while( modeElement )
82
+ {
83
+ char const* str = modeElement->Value();
84
+ if( str && !strcmp( str, "Mode" ) )
85
+ {
86
+ int index;
87
+ if( TIXML_SUCCESS == modeElement->QueryIntAttribute( "index", &index ) )
88
+ {
89
+ ValueList::Item item;
90
+ item.m_value = index;
91
+ item.m_label = c_modeName[index];
92
+ supportedModes.push_back( item );
93
+ }
94
+ }
95
+
96
+ modeElement = modeElement->NextSiblingElement();
97
+ }
98
+ }
99
+
100
+ if( !supportedModes.empty() )
101
+ {
102
+ m_supportedModes = supportedModes;
103
+ ClearStaticRequest( StaticRequest_Values );
104
+ CreateVars( 1 );
105
+ }
106
+ }
107
+ }
108
+
109
+ //-----------------------------------------------------------------------------
110
+ // <ThermostatFanMode::WriteXML>
111
+ // Save the supported modes
112
+ //-----------------------------------------------------------------------------
113
+ void ThermostatFanMode::WriteXML
114
+ (
115
+ TiXmlElement* _ccElement
116
+ )
117
+ {
118
+ CommandClass::WriteXML( _ccElement );
119
+
120
+ if( Node* node = GetNodeUnsafe() )
121
+ {
122
+ node = node;
123
+ TiXmlElement* supportedModesElement = new TiXmlElement( "SupportedModes" );
124
+ _ccElement->LinkEndChild( supportedModesElement );
125
+
126
+ for( vector<ValueList::Item>::iterator it = m_supportedModes.begin(); it != m_supportedModes.end(); ++it )
127
+ {
128
+ ValueList::Item const& item = *it;
129
+
130
+ TiXmlElement* modeElement = new TiXmlElement( "Mode" );
131
+ supportedModesElement->LinkEndChild( modeElement );
132
+
133
+ char str[8];
134
+ snprintf( str, 8, "%d", item.m_value );
135
+ modeElement->SetAttribute( "index", str );
136
+ modeElement->SetAttribute( "label", item.m_label.c_str() );
137
+ }
138
+ }
139
+ }
140
+
141
+ //-----------------------------------------------------------------------------
142
+ // <ThermostatFanMode::RequestState>
143
+ // Get the static thermostat fan mode details from the device
144
+ //-----------------------------------------------------------------------------
145
+ bool ThermostatFanMode::RequestState
146
+ (
147
+ uint32 const _requestFlags,
148
+ uint8 const _instance,
149
+ Driver::MsgQueue const _queue
150
+ )
151
+ {
152
+ bool requests = false;
153
+ if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) )
154
+ {
155
+ // Request the supported modes
156
+ requests |= RequestValue( _requestFlags, ThermostatFanModeCmd_SupportedGet, _instance, _queue );
157
+ }
158
+
159
+ if( _requestFlags & RequestFlag_Dynamic )
160
+ {
161
+ // Request the current fan mode
162
+ requests |= RequestValue( _requestFlags, ThermostatFanModeCmd_Get, _instance, _queue );
163
+ }
164
+
165
+ return requests;
166
+ }
167
+
168
+ //-----------------------------------------------------------------------------
169
+ // <ThermostatFanMode::RequestValue>
170
+ // Get the thermostat fan mode details from the device
171
+ //-----------------------------------------------------------------------------
172
+ bool ThermostatFanMode::RequestValue
173
+ (
174
+ uint32 const _requestFlags,
175
+ uint8 const _getTypeEnum,
176
+ uint8 const _instance,
177
+ Driver::MsgQueue const _queue
178
+ )
179
+ {
180
+ if( _getTypeEnum == ThermostatFanModeCmd_SupportedGet )
181
+ {
182
+ // Request the supported modes
183
+ Msg* msg = new Msg( "Request Supported Thermostat Fan Modes", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
184
+ msg->SetInstance( this, _instance );
185
+ msg->Append( GetNodeId() );
186
+ msg->Append( 2 );
187
+ msg->Append( GetCommandClassId() );
188
+ msg->Append( ThermostatFanModeCmd_SupportedGet );
189
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
190
+ GetDriver()->SendMsg( msg, _queue );
191
+ return true;
192
+ }
193
+
194
+ if( _getTypeEnum == ThermostatFanModeCmd_Get || _getTypeEnum == 0 )
195
+ {
196
+ // Request the current fan mode
197
+ Msg* msg = new Msg( "Request Current Thermostat Fan Mode", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
198
+ msg->SetInstance( this, _instance );
199
+ msg->Append( GetNodeId() );
200
+ msg->Append( 2 );
201
+ msg->Append( GetCommandClassId() );
202
+ msg->Append( ThermostatFanModeCmd_Get );
203
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
204
+ GetDriver()->SendMsg( msg, _queue );
205
+ return true;
206
+ }
207
+ return false;
208
+ }
209
+
210
+ //-----------------------------------------------------------------------------
211
+ // <ThermostatFanMode::HandleMsg>
212
+ // Handle a message from the Z-Wave network
213
+ //-----------------------------------------------------------------------------
214
+ bool ThermostatFanMode::HandleMsg
215
+ (
216
+ uint8 const* _data,
217
+ uint32 const _length,
218
+ uint32 const _instance // = 1
219
+ )
220
+ {
221
+ if( ThermostatFanModeCmd_Report == (ThermostatFanModeCmd)_data[0] )
222
+ {
223
+ uint8 mode = (int32)_data[1];
224
+
225
+ if( mode < m_supportedModes.size() )
226
+ {
227
+ // We have received the thermostat mode from the Z-Wave device
228
+ if( ValueList* valueList = static_cast<ValueList*>( GetValue( _instance, 0 ) ) )
229
+ {
230
+ valueList->OnValueRefreshed( (int32)_data[1] );
231
+ Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat fan mode: %s", valueList->GetItem().m_label.c_str() );
232
+ valueList->Release();
233
+ }
234
+ else
235
+ {
236
+ Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat fan mode: index %d", mode );
237
+ }
238
+ }
239
+ else
240
+ {
241
+ Log::Write( LogLevel_Info, GetNodeId(), "Received unknown thermostat fan mode: %d", mode );
242
+ }
243
+ return true;
244
+ }
245
+
246
+ if( ThermostatFanModeCmd_SupportedReport == (ThermostatFanModeCmd)_data[0] )
247
+ {
248
+ // We have received the supported thermostat fan modes from the Z-Wave device
249
+ Log::Write( LogLevel_Info, GetNodeId(), "Received supported thermostat fan modes" );
250
+
251
+ m_supportedModes.clear();
252
+ for( uint32 i=1; i<_length-1; ++i )
253
+ {
254
+ for( int32 bit=0; bit<8; ++bit )
255
+ {
256
+ if( ( _data[i] & (1<<bit) ) != 0 )
257
+ {
258
+ ValueList::Item item;
259
+ item.m_value = (int32)((i-1)<<3) + bit;
260
+
261
+ if ((size_t)item.m_value >= sizeof(c_modeName)/sizeof(*c_modeName))
262
+ {
263
+ Log::Write( LogLevel_Info, GetNodeId(), "Received unknown fan mode: 0x%x", item.m_value);
264
+ }
265
+ else
266
+ {
267
+ item.m_label = c_modeName[item.m_value];
268
+ m_supportedModes.push_back( item );
269
+
270
+ Log::Write( LogLevel_Info, GetNodeId(), " Added fan mode: %s", c_modeName[item.m_value].c_str() );
271
+ }
272
+ }
273
+ }
274
+ }
275
+
276
+ ClearStaticRequest( StaticRequest_Values );
277
+ CreateVars( _instance );
278
+ return true;
279
+ }
280
+
281
+ return false;
282
+ }
283
+
284
+ //-----------------------------------------------------------------------------
285
+ // <ThermostatFanMode::SetValue>
286
+ // Set the device's thermostat fan mode
287
+ //-----------------------------------------------------------------------------
288
+ bool ThermostatFanMode::SetValue
289
+ (
290
+ Value const& _value
291
+ )
292
+ {
293
+ if( ValueID::ValueType_List == _value.GetID().GetType() )
294
+ {
295
+ ValueList const* value = static_cast<ValueList const*>(&_value);
296
+ uint8 state = (uint8)value->GetNewItem().m_value;
297
+
298
+ Msg* msg = new Msg( "Set Thermostat Fan Mode", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
299
+ msg->SetInstance( this, _value.GetID().GetInstance() );
300
+ msg->Append( GetNodeId() );
301
+ msg->Append( 3 );
302
+ msg->Append( GetCommandClassId() );
303
+ msg->Append( ThermostatFanModeCmd_Set );
304
+ msg->Append( state );
305
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
306
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
307
+ return true;
308
+ }
309
+
310
+ return false;
311
+ }
312
+
313
+ //-----------------------------------------------------------------------------
314
+ // <ThermostatFanMode::CreateVars>
315
+ // Create the values managed by this command class
316
+ //-----------------------------------------------------------------------------
317
+ void ThermostatFanMode::CreateVars
318
+ (
319
+ uint8 const _instance
320
+ )
321
+ {
322
+ if( m_supportedModes.empty() )
323
+ {
324
+ return;
325
+ }
326
+
327
+ if( Node* node = GetNodeUnsafe() )
328
+ {
329
+ node->CreateValueList( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Fan Mode", "", false, false, 1, m_supportedModes, m_supportedModes[0].m_value, 0 );
330
+ }
331
+ }
332
+
@@ -0,0 +1,77 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ThermostatFanMode.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_FAN_MODE
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 _ThermostatFanMode_H
29
+ #define _ThermostatFanMode_H
30
+
31
+ #include <vector>
32
+ #include <string>
33
+ #include "CommandClass.h"
34
+ #include "ValueList.h"
35
+
36
+ namespace OpenZWave
37
+ {
38
+ class ValueList;
39
+
40
+ /** \brief Implements COMMAND_CLASS_THERMOSTAT_FAN_MODE (0x44), a Z-Wave device command class.
41
+ */
42
+ class ThermostatFanMode: public CommandClass
43
+ {
44
+ public:
45
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatFanMode( _homeId, _nodeId ); }
46
+ virtual ~ThermostatFanMode(){}
47
+
48
+ static uint8 const StaticGetCommandClassId(){ return 0x44; }
49
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_FAN_MODE"; }
50
+
51
+ // From CommandClass
52
+ virtual void ReadXML( TiXmlElement const* _ccElement );
53
+ virtual void WriteXML( TiXmlElement* _ccElement );
54
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
55
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _getTypeEnum, uint8 const _dummy, Driver::MsgQueue const _queue );
56
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
57
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
58
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
59
+ virtual bool SetValue( Value const& _value );
60
+
61
+ protected:
62
+ virtual void CreateVars( uint8 const _instance );
63
+
64
+ private:
65
+ ThermostatFanMode( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){ SetStaticRequest( StaticRequest_Values ); }
66
+
67
+ vector<ValueList::Item> m_supportedModes;
68
+ };
69
+
70
+ } // namespace OpenZWave
71
+
72
+ #endif
73
+
74
+
75
+
76
+
77
+