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,69 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // SwitchAll.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_SWITCH_ALL
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 _SwitchAll_H
29
+ #define _SwitchAll_H
30
+
31
+ #include "CommandClass.h"
32
+
33
+ namespace OpenZWave
34
+ {
35
+ class ValueList;
36
+
37
+ /** \brief Implements COMMAND_CLASS_SWITCH_ALL (0x27), a Z-Wave device command class.
38
+ */
39
+ class SwitchAll: public CommandClass
40
+ {
41
+ public:
42
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchAll( _homeId, _nodeId ); }
43
+ virtual ~SwitchAll(){}
44
+
45
+ static uint8 const StaticGetCommandClassId(){ return 0x27; }
46
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_ALL"; }
47
+
48
+ static void On( Driver* _driver, uint8 const _nodeId );
49
+ static void Off( Driver* _driver, uint8 const _nodeId );
50
+
51
+ // From CommandClass
52
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
53
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
54
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
55
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
56
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
57
+ virtual bool SetValue( Value const& _value );
58
+
59
+ protected:
60
+ virtual void CreateVars( uint8 const _instance );
61
+
62
+ private:
63
+ SwitchAll( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
64
+ };
65
+
66
+ } // namespace OpenZWave
67
+
68
+ #endif
69
+
@@ -0,0 +1,157 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // SwitchBinary.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_SWITCH_BINARY
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 "SwitchBinary.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Driver.h"
33
+ #include "Node.h"
34
+ #include "Log.h"
35
+
36
+ #include "ValueBool.h"
37
+
38
+ using namespace OpenZWave;
39
+
40
+ enum SwitchBinaryCmd
41
+ {
42
+ SwitchBinaryCmd_Set = 0x01,
43
+ SwitchBinaryCmd_Get = 0x02,
44
+ SwitchBinaryCmd_Report = 0x03
45
+ };
46
+
47
+ //-----------------------------------------------------------------------------
48
+ // <SwitchBinary::RequestState>
49
+ // Request current state from the device
50
+ //-----------------------------------------------------------------------------
51
+ bool SwitchBinary::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
+ // <SwitchBinary::RequestValue>
68
+ // Request current value from the device
69
+ //-----------------------------------------------------------------------------
70
+ bool SwitchBinary::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( "SwitchBinaryCmd_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( SwitchBinaryCmd_Get );
84
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
85
+ GetDriver()->SendMsg( msg, _queue );
86
+ return true;
87
+ }
88
+
89
+ //-----------------------------------------------------------------------------
90
+ // <SwitchBinary::HandleMsg>
91
+ // Handle a message from the Z-Wave network
92
+ //-----------------------------------------------------------------------------
93
+ bool SwitchBinary::HandleMsg
94
+ (
95
+ uint8 const* _data,
96
+ uint32 const _length,
97
+ uint32 const _instance // = 1
98
+ )
99
+ {
100
+ if (SwitchBinaryCmd_Report == (SwitchBinaryCmd)_data[0])
101
+ {
102
+ Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchBinary report from node %d: level=%s", GetNodeId(), _data[1] ? "On" : "Off" );
103
+
104
+ if( ValueBool* value = static_cast<ValueBool*>( 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
+ // <SwitchBinary::SetValue>
117
+ // Set the state of the switch
118
+ //-----------------------------------------------------------------------------
119
+ bool SwitchBinary::SetValue
120
+ (
121
+ Value const& _value
122
+ )
123
+ {
124
+ if( ValueID::ValueType_Bool == _value.GetID().GetType() )
125
+ {
126
+ ValueBool const* value = static_cast<ValueBool const*>(&_value);
127
+
128
+ Log::Write( LogLevel_Info, GetNodeId(), "SwitchBinary::Set - Setting node %d to %s", GetNodeId(), value->GetValue() ? "On" : "Off" );
129
+ Msg* msg = new Msg( "SwitchBinary 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( SwitchBinaryCmd_Set );
135
+ msg->Append( value->GetValue() ? 0xff : 0x00 );
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
+ // <SwitchBinary::CreateVars>
146
+ // Create the values managed by this command class
147
+ //-----------------------------------------------------------------------------
148
+ void SwitchBinary::CreateVars
149
+ (
150
+ uint8 const _instance
151
+ )
152
+ {
153
+ if( Node* node = GetNodeUnsafe() )
154
+ {
155
+ node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Switch", "", false, false, false, 0 );
156
+ }
157
+ }
@@ -0,0 +1,66 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // SwitchBinary.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_SWITCH_BINARY
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 _SwitchBinary_H
29
+ #define _SwitchBinary_H
30
+
31
+ #include "CommandClass.h"
32
+
33
+ namespace OpenZWave
34
+ {
35
+ class ValueBool;
36
+
37
+ /** \brief Implements COMMAND_CLASS_SWITCH_BINARY (0x25), a Z-Wave device command class.
38
+ */
39
+ class SwitchBinary: public CommandClass
40
+ {
41
+ public:
42
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchBinary( _homeId, _nodeId ); }
43
+ virtual ~SwitchBinary(){}
44
+
45
+ static uint8 const StaticGetCommandClassId(){ return 0x25; }
46
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_BINARY"; }
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 _index, uint8 const _instance, 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
+ virtual bool SetValue( Value const& _value );
55
+
56
+ protected:
57
+ virtual void CreateVars( uint8 const _instance );
58
+
59
+ private:
60
+ SwitchBinary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
61
+ };
62
+
63
+ } // namespace OpenZWave
64
+
65
+ #endif
66
+
@@ -0,0 +1,559 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // SwitchMultilevel.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_SWITCH_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
+ #include "CommandClasses.h"
29
+ #include "SwitchMultilevel.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Driver.h"
33
+ #include "Node.h"
34
+ #include "Log.h"
35
+
36
+ #include "ValueBool.h"
37
+ #include "ValueButton.h"
38
+ #include "ValueByte.h"
39
+
40
+ using namespace OpenZWave;
41
+
42
+ enum SwitchMultilevelCmd
43
+ {
44
+ SwitchMultilevelCmd_Set = 0x01,
45
+ SwitchMultilevelCmd_Get = 0x02,
46
+ SwitchMultilevelCmd_Report = 0x03,
47
+ SwitchMultilevelCmd_StartLevelChange = 0x04,
48
+ SwitchMultilevelCmd_StopLevelChange = 0x05,
49
+ SwitchMultilevelCmd_SupportedGet = 0x06,
50
+ SwitchMultilevelCmd_SupportedReport = 0x07
51
+ };
52
+
53
+ enum
54
+ {
55
+ SwitchMultilevelIndex_Level = 0,
56
+ SwitchMultilevelIndex_Bright,
57
+ SwitchMultilevelIndex_Dim,
58
+ SwitchMultilevelIndex_IgnoreStartLevel,
59
+ SwitchMultilevelIndex_StartLevel,
60
+ SwitchMultilevelIndex_Duration,
61
+ SwitchMultilevelIndex_Step,
62
+ SwitchMultilevelIndex_Inc,
63
+ SwitchMultilevelIndex_Dec
64
+ };
65
+
66
+ static uint8 c_directionParams[] =
67
+ {
68
+ 0x18,
69
+ 0x58,
70
+ 0xc0,
71
+ 0xc8
72
+ };
73
+
74
+ static char const* c_directionDebugLabels[] =
75
+ {
76
+ "Up",
77
+ "Down",
78
+ "Inc",
79
+ "Dec"
80
+ };
81
+
82
+ static char const* c_switchLabelsPos[] =
83
+ {
84
+ "Undefined",
85
+ "On",
86
+ "Up",
87
+ "Open",
88
+ "Clockwise",
89
+ "Right",
90
+ "Forward",
91
+ "Push"
92
+ };
93
+
94
+ static char const* c_switchLabelsNeg[] =
95
+ {
96
+ "Undefined",
97
+ "Off",
98
+ "Down",
99
+ "Close",
100
+ "Counter-Clockwise",
101
+ "Left",
102
+ "Reverse",
103
+ "Pull"
104
+ };
105
+
106
+ //-----------------------------------------------------------------------------
107
+ // <SwitchMultilevel::RequestState>
108
+ // Request current state from the device
109
+ //-----------------------------------------------------------------------------
110
+ bool SwitchMultilevel::RequestState
111
+ (
112
+ uint32 const _requestFlags,
113
+ uint8 const _instance,
114
+ Driver::MsgQueue const _queue
115
+ )
116
+ {
117
+ if( _requestFlags & RequestFlag_Dynamic )
118
+ {
119
+ return RequestValue( _requestFlags, 0, _instance, _queue );
120
+ }
121
+
122
+ return false;
123
+ }
124
+
125
+ //-----------------------------------------------------------------------------
126
+ // <SwitchMultilevel::RequestValue>
127
+ // Request current value from the device
128
+ //-----------------------------------------------------------------------------
129
+ bool SwitchMultilevel::RequestValue
130
+ (
131
+ uint32 const _requestFlags,
132
+ uint8 const _dummy1, // = 0 (not used)
133
+ uint8 const _instance,
134
+ Driver::MsgQueue const _queue
135
+ )
136
+ {
137
+ Msg* msg = new Msg( "SwitchMultilevelCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
138
+ msg->SetInstance( this, _instance );
139
+ msg->Append( GetNodeId() );
140
+ msg->Append( 2 );
141
+ msg->Append( GetCommandClassId() );
142
+ msg->Append( SwitchMultilevelCmd_Get );
143
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
144
+ GetDriver()->SendMsg( msg, _queue );
145
+ return true;
146
+ }
147
+
148
+ //-----------------------------------------------------------------------------
149
+ // <SwitchMultilevel::HandleMsg>
150
+ // Handle a message from the Z-Wave network
151
+ //-----------------------------------------------------------------------------
152
+ bool SwitchMultilevel::HandleMsg
153
+ (
154
+ uint8 const* _data,
155
+ uint32 const _length,
156
+ uint32 const _instance // = 1
157
+ )
158
+ {
159
+ if( SwitchMultilevelCmd_Report == (SwitchMultilevelCmd)_data[0] )
160
+ {
161
+ Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchMultiLevel report: level=%d", _data[1] );
162
+
163
+ if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_Level ) ) )
164
+ {
165
+ value->OnValueRefreshed( _data[1] );
166
+ value->Release();
167
+ }
168
+ return true;
169
+ }
170
+
171
+ if( SwitchMultilevelCmd_SupportedReport == (SwitchMultilevelCmd)_data[0] )
172
+ {
173
+ uint8 switchType1 = _data[1] & 0x1f;
174
+ uint8 switchType2 = _data[2] & 0x1f;
175
+
176
+ Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchMultiLevel supported report: Switch1=%s/%s, Switch2=%s/%s", c_switchLabelsPos[switchType1], c_switchLabelsNeg[switchType1], c_switchLabelsPos[switchType2], c_switchLabelsNeg[switchType2] );
177
+ ClearStaticRequest( StaticRequest_Version );
178
+
179
+ // Set the labels on the values
180
+ ValueButton* button;
181
+
182
+ if( switchType1 )
183
+ {
184
+ if( NULL != ( button = static_cast<ValueButton*>( GetValue( _instance, SwitchMultilevelIndex_Bright ) ) ) )
185
+ {
186
+ button->SetLabel( c_switchLabelsPos[switchType1] );
187
+ button->Release();
188
+ }
189
+ if( NULL != ( button = static_cast<ValueButton*>( GetValue( _instance, SwitchMultilevelIndex_Dim ) ) ) )
190
+ {
191
+ button->SetLabel( c_switchLabelsNeg[switchType1] );
192
+ button->Release();
193
+ }
194
+ }
195
+
196
+ if( switchType2 )
197
+ {
198
+ if( NULL != ( button = static_cast<ValueButton*>( GetValue( _instance, SwitchMultilevelIndex_Inc ) ) ) )
199
+ {
200
+ button->SetLabel( c_switchLabelsPos[switchType2] );
201
+ button->Release();
202
+ }
203
+ if( NULL != ( button = static_cast<ValueButton*>( GetValue( _instance, SwitchMultilevelIndex_Dec ) ) ) )
204
+ {
205
+ button->SetLabel( c_switchLabelsNeg[switchType2] );
206
+ button->Release();
207
+ }
208
+ }
209
+ return true;
210
+ }
211
+
212
+ return false;
213
+ }
214
+
215
+ //-----------------------------------------------------------------------------
216
+ // <SwitchMultilevel::SetVersion>
217
+ // Set the command class version
218
+ //-----------------------------------------------------------------------------
219
+ void SwitchMultilevel::SetVersion
220
+ (
221
+ uint8 const _version
222
+ )
223
+ {
224
+ CommandClass::SetVersion( _version );
225
+
226
+ if( _version == 3 )
227
+ {
228
+ // Request the supported switch types
229
+ Msg* msg = new Msg( "SwitchMultilevelCmd_SupportedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
230
+ msg->Append( GetNodeId() );
231
+ msg->Append( 2 );
232
+ msg->Append( GetCommandClassId() );
233
+ msg->Append( SwitchMultilevelCmd_SupportedGet );
234
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
235
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
236
+
237
+ // Set the request flag again - it will be cleared when we get a
238
+ // response to the SwitchMultilevelCmd_SupportedGet message.
239
+ SetStaticRequest( StaticRequest_Version );
240
+ }
241
+ }
242
+
243
+ //-----------------------------------------------------------------------------
244
+ // <SwitchMultilevel::SetValue>
245
+ // Set the level on a device
246
+ //-----------------------------------------------------------------------------
247
+ bool SwitchMultilevel::SetValue
248
+ (
249
+ Value const& _value
250
+ )
251
+ {
252
+ bool res = false;
253
+ uint8 instance = _value.GetID().GetInstance();
254
+
255
+ switch( _value.GetID().GetIndex() )
256
+ {
257
+ case 0:
258
+ {
259
+ // Level
260
+ if( ValueByte* value = static_cast<ValueByte*>( GetValue( instance, SwitchMultilevelIndex_Level ) ) )
261
+ {
262
+ res = SetLevel( instance, (static_cast<ValueByte const*>(&_value))->GetValue() );
263
+ value->Release();
264
+ }
265
+ break;
266
+ }
267
+ case 1:
268
+ {
269
+ // Bright
270
+ if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, SwitchMultilevelIndex_Bright ) ) )
271
+ {
272
+ if( button->IsPressed() )
273
+ {
274
+ res = StartLevelChange( instance, SwitchMultilevelDirection_Up );
275
+ }
276
+ else
277
+ {
278
+ res = StopLevelChange( instance );
279
+ }
280
+ button->Release();
281
+ }
282
+ break;
283
+ }
284
+ case 2:
285
+ {
286
+ // Dim
287
+ if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, SwitchMultilevelIndex_Dim ) ) )
288
+ {
289
+ if( button->IsPressed() )
290
+ {
291
+ res = StartLevelChange( instance, SwitchMultilevelDirection_Down );
292
+ }
293
+ else
294
+ {
295
+ res = StopLevelChange( instance );
296
+ }
297
+ button->Release();
298
+ }
299
+ break;
300
+ }
301
+ case 3:
302
+ {
303
+ // Ignore Start Level
304
+ // Nothing to do. State is set within the value, and
305
+ // is not separately transmitted to the device.
306
+ break;
307
+ }
308
+ case 4:
309
+ {
310
+ // Start level
311
+ // Nothing to do. State is set within the value, and
312
+ // is not separately transmitted to the device.
313
+ break;
314
+ }
315
+ case 5:
316
+ {
317
+ // Dimming Duration
318
+ // Nothing to do. State is set within the value, and
319
+ // is not separately transmitted to the device.
320
+ break;
321
+ }
322
+ case 6:
323
+ {
324
+ // Step Size
325
+ // Nothing to do. State is set within the value, and
326
+ // is not separately transmitted to the device.
327
+ break;
328
+ }
329
+ case 7:
330
+ {
331
+ // Inc
332
+ if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, SwitchMultilevelIndex_Inc ) ) )
333
+ {
334
+ if( button->IsPressed() )
335
+ {
336
+ res = StartLevelChange( instance, SwitchMultilevelDirection_Inc );
337
+ }
338
+ else
339
+ {
340
+ res = StopLevelChange( instance );
341
+ }
342
+ button->Release();
343
+ }
344
+ break;
345
+ }
346
+ case 8:
347
+ {
348
+ // Dec
349
+ if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, SwitchMultilevelIndex_Dec ) ) )
350
+ {
351
+ if( button->IsPressed() )
352
+ {
353
+ res = StartLevelChange( instance, SwitchMultilevelDirection_Dec );
354
+ }
355
+ else
356
+ {
357
+ res = StopLevelChange( instance );
358
+ }
359
+ button->Release();
360
+ }
361
+ break;
362
+ }
363
+ }
364
+
365
+ return res;
366
+ }
367
+
368
+ //-----------------------------------------------------------------------------
369
+ // <SwitchMultilevel::SetLevel>
370
+ // Set a new level for the switch
371
+ //-----------------------------------------------------------------------------
372
+ bool SwitchMultilevel::SetLevel
373
+ (
374
+ uint8 const _instance,
375
+ uint8 const _level
376
+ )
377
+ {
378
+ Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::Set - Setting to level %d", _level );
379
+ Msg* msg = new Msg( "SwitchMultiLevel Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
380
+ msg->SetInstance( this, _instance );
381
+ msg->Append( GetNodeId() );
382
+
383
+ if( ValueByte* durationValue = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_Duration ) ) )
384
+ {
385
+ uint8 duration = durationValue->GetValue();
386
+ durationValue->Release();
387
+ if( duration == 0xff )
388
+ {
389
+ Log::Write( LogLevel_Info, GetNodeId(), " Duration: Default" );
390
+ }
391
+ else if( duration >= 0x80 )
392
+ {
393
+ Log::Write( LogLevel_Info, GetNodeId(), " Duration: %d minutes", duration - 0x7f );
394
+ }
395
+ else
396
+ {
397
+ Log::Write( LogLevel_Info, GetNodeId(), " Duration: %d seconds", duration );
398
+ }
399
+
400
+ msg->Append( 4 );
401
+ msg->Append( GetCommandClassId() );
402
+ msg->Append( SwitchMultilevelCmd_Set );
403
+ msg->Append( _level );
404
+ msg->Append( duration );
405
+ }
406
+ else
407
+ {
408
+ msg->Append( 3 );
409
+ msg->Append( GetCommandClassId() );
410
+ msg->Append( SwitchMultilevelCmd_Set );
411
+ msg->Append( _level );
412
+ }
413
+
414
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
415
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
416
+ return true;
417
+ }
418
+
419
+ //-----------------------------------------------------------------------------
420
+ // <SwitchMultilevel::SwitchMultilevelCmd_StartLevelChange>
421
+ // Start the level changing
422
+ //-----------------------------------------------------------------------------
423
+ bool SwitchMultilevel::StartLevelChange
424
+ (
425
+ uint8 const _instance,
426
+ SwitchMultilevelDirection const _direction
427
+ )
428
+ {
429
+ Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::StartLevelChange - Starting a level change" );
430
+
431
+ uint8 length = 4;
432
+ uint8 direction = c_directionParams[_direction];
433
+ Log::Write( LogLevel_Info, GetNodeId(), " Direction: %s", c_directionDebugLabels[_direction] );
434
+
435
+ if( ValueBool* ignoreStartLevel = static_cast<ValueBool*>( GetValue( _instance, SwitchMultilevelIndex_IgnoreStartLevel ) ) )
436
+ {
437
+ if( ignoreStartLevel->GetValue() )
438
+ {
439
+ ignoreStartLevel->Release();
440
+ // Set the ignore start level flag
441
+ direction |= 0x20;
442
+ }
443
+ }
444
+ Log::Write( LogLevel_Info, GetNodeId(), " Ignore Start Level: %s", (direction & 0x20) ? "True" : "False" );
445
+
446
+ uint8 startLevel = 0;
447
+ if( ValueByte* startLevelValue = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_StartLevel ) ) )
448
+ {
449
+ startLevel = startLevelValue->GetValue();
450
+ startLevelValue->Release();
451
+ }
452
+ Log::Write( LogLevel_Info, GetNodeId(), " Start Level: %d", startLevel );
453
+
454
+ uint8 duration = 0;
455
+ if( ValueByte* durationValue = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_Duration ) ) )
456
+ {
457
+ length = 5;
458
+ duration = durationValue->GetValue();
459
+ durationValue->Release();
460
+ Log::Write( LogLevel_Info, GetNodeId(), " Duration: %d", duration );
461
+ }
462
+
463
+ uint8 step = 0;
464
+ if( ( SwitchMultilevelDirection_Inc == _direction ) || ( SwitchMultilevelDirection_Dec == _direction ) )
465
+ {
466
+ if( ValueByte* stepValue = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_Step ) ) )
467
+ {
468
+ length = 6;
469
+ step = stepValue->GetValue();
470
+ stepValue->Release();
471
+ Log::Write( LogLevel_Info, GetNodeId(), " Step Size: %d", step );
472
+ }
473
+ }
474
+
475
+ Msg* msg = new Msg( "SwitchMultilevel StartLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
476
+ msg->SetInstance( this, _instance );
477
+ msg->Append( GetNodeId() );
478
+ msg->Append( length );
479
+ msg->Append( GetCommandClassId() );
480
+ msg->Append( SwitchMultilevelCmd_StartLevelChange );
481
+ msg->Append( direction );
482
+ msg->Append( startLevel );
483
+
484
+ if( length >= 5 )
485
+ {
486
+ msg->Append( duration );
487
+ }
488
+
489
+ if( length == 6 )
490
+ {
491
+ msg->Append( step );
492
+ }
493
+
494
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
495
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
496
+ return true;
497
+ }
498
+
499
+ //-----------------------------------------------------------------------------
500
+ // <SwitchMultilevel::StopLevelChange>
501
+ // Stop the level changing
502
+ //-----------------------------------------------------------------------------
503
+ bool SwitchMultilevel::StopLevelChange
504
+ (
505
+ uint8 const _instance
506
+ )
507
+ {
508
+ Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::StopLevelChange - Stopping the level change" );
509
+ Msg* msg = new Msg( "SwitchMultilevel StopLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
510
+ msg->SetInstance( this, _instance );
511
+ msg->Append( GetNodeId() );
512
+ msg->Append( 2 );
513
+ msg->Append( GetCommandClassId() );
514
+ msg->Append( SwitchMultilevelCmd_StopLevelChange );
515
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
516
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
517
+ return true;
518
+ }
519
+
520
+ //-----------------------------------------------------------------------------
521
+ // <SwitchMultilevel::CreateVars>
522
+ // Create the values managed by this command class
523
+ //-----------------------------------------------------------------------------
524
+ void SwitchMultilevel::CreateVars
525
+ (
526
+ uint8 const _instance
527
+ )
528
+ {
529
+ if( Node* node = GetNodeUnsafe() )
530
+ {
531
+ switch( GetVersion() )
532
+ {
533
+ case 3:
534
+ {
535
+ node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Step, "Step Size", "", false, false, 0, 0 );
536
+ node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Inc, "Inc", 0 );
537
+ node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Dec, "Dec", 0 );
538
+ // Fall through to version 2
539
+ }
540
+ case 2:
541
+ {
542
+ node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, SwitchMultilevelIndex_Duration, "Dimming Duration", "", false, false, 0xff, 0 );
543
+ // Fall through to version 1
544
+ }
545
+ case 1:
546
+ {
547
+ node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Level, "Level", "", false, false, 0, 0 );
548
+ node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Bright, "Bright", 0 );
549
+ node->CreateValueButton( ValueID::ValueGenre_User, GetCommandClassId(), _instance, SwitchMultilevelIndex_Dim, "Dim", 0 );
550
+ node->CreateValueBool( ValueID::ValueGenre_System, GetCommandClassId(), _instance, SwitchMultilevelIndex_IgnoreStartLevel, "Ignore Start Level", "", false, false, true, 0 );
551
+ node->CreateValueByte( ValueID::ValueGenre_System, GetCommandClassId(), _instance, SwitchMultilevelIndex_StartLevel, "Start Level", "", false, false, 0, 0 );
552
+ break;
553
+ }
554
+ }
555
+ }
556
+ }
557
+
558
+
559
+