ansible4ozw 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ansible.rb +12 -9
- data/lib/ansible/ansible_device.rb +1 -1
- data/lib/ansible/ansible_value.rb +1 -1
- data/lib/ansible/config.rb +8 -5
- data/lib/ansible/devices.rb +1 -0
- data/lib/ansible/knx.rb +0 -0
- data/lib/ansible/knx/dpt/tests/test_dpt10.rb~ +45 -0
- data/lib/ansible/knx/dpt/tests/test_dpt9.rb~ +55 -0
- data/lib/ansible/transceiver.rb +0 -3
- data/lib/ansible/version.rb +3 -0
- data/lib/ansible/zwave.rb +1 -0
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_constants.rb +1 -2
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_headers.rb +2 -6
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_remote_manager.rb +0 -3
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_types.rb +0 -0
- data/lib/ansible/zwave/openzwave/src/Driver.h +695 -0
- data/lib/ansible/zwave/openzwave/src/Notification.h +165 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.cpp +142 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.h +69 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.cpp +93 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.h +57 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Association.cpp +385 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Association.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.cpp +277 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.h +70 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Basic.cpp +212 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Basic.h +72 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.cpp +118 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.h +64 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Battery.cpp +141 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Battery.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.cpp +415 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Clock.cpp +227 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Clock.h +67 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.cpp +546 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.h +145 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.cpp +291 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.h +79 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.cpp +258 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.h +67 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.cpp +142 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.h +63 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.cpp +163 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Hail.cpp +68 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Hail.h +58 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.cpp +159 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Language.cpp +159 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Language.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Lock.cpp +159 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Lock.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.cpp +439 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.h +116 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Meter.cpp +541 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Meter.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.cpp +137 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.cpp +77 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.h +63 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.cpp +568 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.h +96 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.cpp +61 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.h +59 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.cpp +525 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.cpp +157 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.h +82 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.cpp +62 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.h +58 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Protection.cpp +177 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Protection.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.cpp +208 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.h +77 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.cpp +134 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.cpp +237 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.cpp +219 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.h +69 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.cpp +157 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.cpp +559 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.h +83 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.cpp +151 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.cpp +195 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.h +75 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.cpp +332 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.h +77 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.cpp +149 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.cpp +373 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.h +76 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.cpp +147 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.cpp +317 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Version.cpp +255 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Version.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.cpp +391 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.h +85 -0
- data/lib/ansible/zwave/openzwave/src/platform/Controller.cpp +68 -0
- data/lib/ansible/zwave/openzwave/src/platform/Controller.h +106 -0
- data/lib/ansible/zwave/openzwave/src/platform/Event.cpp +102 -0
- data/lib/ansible/zwave/openzwave/src/platform/Event.h +91 -0
- data/lib/ansible/zwave/openzwave/src/platform/HidController.cpp +539 -0
- data/lib/ansible/zwave/openzwave/src/platform/HidController.h +147 -0
- data/lib/ansible/zwave/openzwave/src/platform/Log.cpp +310 -0
- data/lib/ansible/zwave/openzwave/src/platform/Log.h +184 -0
- data/lib/ansible/zwave/openzwave/src/platform/Mutex.cpp +96 -0
- data/lib/ansible/zwave/openzwave/src/platform/Mutex.h +88 -0
- data/lib/ansible/zwave/openzwave/src/platform/Ref.h +91 -0
- data/lib/ansible/zwave/openzwave/src/platform/SerialController.cpp +180 -0
- data/lib/ansible/zwave/openzwave/src/platform/SerialController.h +138 -0
- data/lib/ansible/zwave/openzwave/src/platform/Stream.cpp +229 -0
- data/lib/ansible/zwave/openzwave/src/platform/Stream.h +135 -0
- data/lib/ansible/zwave/openzwave/src/platform/Thread.cpp +118 -0
- data/lib/ansible/zwave/openzwave/src/platform/Thread.h +101 -0
- data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.cpp +92 -0
- data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.h +85 -0
- data/lib/ansible/zwave/openzwave/src/platform/Wait.cpp +176 -0
- data/lib/ansible/zwave/openzwave/src/platform/Wait.h +113 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.cpp +262 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.h +62 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.cpp +304 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.h +70 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.cpp +136 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.h +56 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.cpp +368 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.h +74 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.cpp +181 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.h +67 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.cpp +121 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.h +84 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.cpp +160 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.h +74 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.cpp +102 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.h +60 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.cpp +302 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.h +71 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.cpp +114 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.h +58 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.cpp +410 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.h +66 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.cpp +158 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.h +71 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.cpp +95 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.h +83 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.cpp +134 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.h +73 -0
- data/lib/ansible/zwave/openzwave/src/value_classes/ValueID.h +283 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_bool.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_button.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_byte.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_decimal.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_int.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_list.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_short.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_string.rb +0 -0
- data/lib/ansible/zwave/zwave_transceiver.rb +2 -8
- data/lib/ansible/zwave/zwave_value.rb +6 -10
- metadata +159 -17
- data/lib/ansible/zwave/zwave_node.rb +0 -5
@@ -0,0 +1,145 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// CommandClass.h
|
4
|
+
//
|
5
|
+
// Base class for all Z-Wave Command Classes
|
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 _CommandClass_H
|
29
|
+
#define _CommandClass_H
|
30
|
+
|
31
|
+
#include <string>
|
32
|
+
#include <vector>
|
33
|
+
#include "tinyxml.h"
|
34
|
+
#include "Defs.h"
|
35
|
+
#include "Bitfield.h"
|
36
|
+
#include "Driver.h"
|
37
|
+
|
38
|
+
namespace OpenZWave
|
39
|
+
{
|
40
|
+
class Msg;
|
41
|
+
class Node;
|
42
|
+
class Value;
|
43
|
+
|
44
|
+
/** \brief Base class for all Z-Wave command classes.
|
45
|
+
*/
|
46
|
+
class CommandClass
|
47
|
+
{
|
48
|
+
public:
|
49
|
+
enum
|
50
|
+
{
|
51
|
+
RequestFlag_Static = 0x00000001, /**< Values that never change. */
|
52
|
+
RequestFlag_Session = 0x00000002, /**< Values that change infrequently, and so only need to be requested at start up, or via a manual refresh. */
|
53
|
+
RequestFlag_Dynamic = 0x00000004, /**< Values that change and will be requested if polling is enabled on the node. */
|
54
|
+
RequestFlag_LowPriority = 0x00000008 /**< Indictates that the request should be made with low priority messages */
|
55
|
+
};
|
56
|
+
|
57
|
+
CommandClass( uint32 const _homeId, uint8 const _nodeId );
|
58
|
+
virtual ~CommandClass(){}
|
59
|
+
|
60
|
+
virtual void ReadXML( TiXmlElement const* _ccElement );
|
61
|
+
virtual void WriteXML( TiXmlElement* _ccElement );
|
62
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue ){ return false; }
|
63
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue ) { return false; }
|
64
|
+
|
65
|
+
virtual uint8 const GetCommandClassId()const = 0;
|
66
|
+
virtual string const GetCommandClassName()const = 0;
|
67
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 ) = 0;
|
68
|
+
virtual bool SetValue( Value const& _value ){ return false; }
|
69
|
+
virtual void SetVersion( uint8 const _version ){ m_version = _version; }
|
70
|
+
|
71
|
+
bool RequestStateForAllInstances( uint32 const _requestFlags, Driver::MsgQueue const _queue );
|
72
|
+
|
73
|
+
// The highest version number of the command class implemented by OpenZWave. We only need
|
74
|
+
// to do version gets on command classes that override this with a number greater than one.
|
75
|
+
virtual uint8 GetMaxVersion(){ return 1; }
|
76
|
+
|
77
|
+
uint8 GetVersion()const{ return m_version; }
|
78
|
+
Bitfield const* GetInstances()const{ return &m_instances; }
|
79
|
+
uint32 GetHomeId()const{ return m_homeId; }
|
80
|
+
uint8 GetNodeId()const{ return m_nodeId; }
|
81
|
+
Driver* GetDriver()const;
|
82
|
+
Node* GetNodeUnsafe()const;
|
83
|
+
Value* GetValue( uint8 const _instance, uint8 const _index );
|
84
|
+
|
85
|
+
void SetInstances( uint8 const _instances );
|
86
|
+
void SetInstance( uint8 const _endPoint );
|
87
|
+
void SetAfterMark(){ m_afterMark = true; }
|
88
|
+
bool IsAfterMark()const{ return m_afterMark; }
|
89
|
+
bool IsCreateVars()const{ return m_createVars; }
|
90
|
+
|
91
|
+
// Helper methods
|
92
|
+
string ExtractValue( uint8 const* _data, uint8* _scale, uint8* _precision, uint8 _valueOffset = 1 )const;
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Append a floating-point value to a message.
|
96
|
+
* \param _msg The message to which the value should be appended.
|
97
|
+
* \param _value A string containing a decimal number to be appended.
|
98
|
+
* \param _scale A byte indicating the scale corresponding to this value (e.g., 1=F and 0=C for temperatures).
|
99
|
+
* \see Msg
|
100
|
+
*/
|
101
|
+
void AppendValue( Msg* _msg, string const& _value, uint8 const _scale )const;
|
102
|
+
uint8 const GetAppendValueSize( string const& _value )const;
|
103
|
+
int32 ValueToInteger( string const& _value, uint8* o_precision, uint8* o_size )const;
|
104
|
+
|
105
|
+
protected:
|
106
|
+
virtual void CreateVars( uint8 const _instance ){}
|
107
|
+
|
108
|
+
public:
|
109
|
+
virtual void CreateVars( uint8 const _instance, uint8 const _index ){}
|
110
|
+
|
111
|
+
|
112
|
+
private:
|
113
|
+
uint32 m_homeId;
|
114
|
+
uint8 m_nodeId;
|
115
|
+
uint8 m_version;
|
116
|
+
Bitfield m_instances;
|
117
|
+
bool m_afterMark; // Set to true if the command class is listed after COMMAND_CLASS_MARK, and should not create any values.
|
118
|
+
bool m_createVars; // Do we want to create variables
|
119
|
+
int8 m_overridePrecision;// Override precision when writing values if >=0
|
120
|
+
|
121
|
+
//-----------------------------------------------------------------------------
|
122
|
+
// Record which items of static data have been read from the device
|
123
|
+
//-----------------------------------------------------------------------------
|
124
|
+
public:
|
125
|
+
enum StaticRequest
|
126
|
+
{
|
127
|
+
StaticRequest_Instances = 0x01,
|
128
|
+
StaticRequest_Values = 0x02,
|
129
|
+
StaticRequest_Version = 0x04
|
130
|
+
};
|
131
|
+
|
132
|
+
bool HasStaticRequest( uint8 _request )const{ return( (m_staticRequests & _request) != 0 ); }
|
133
|
+
void SetStaticRequest( uint8 _request ){ m_staticRequests |= _request; }
|
134
|
+
void ClearStaticRequest( uint8 _request );
|
135
|
+
|
136
|
+
private:
|
137
|
+
uint8 m_staticRequests;
|
138
|
+
};
|
139
|
+
|
140
|
+
} // namespace OpenZWave
|
141
|
+
|
142
|
+
#endif
|
143
|
+
|
144
|
+
|
145
|
+
|
@@ -0,0 +1,291 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// CommandClasses.cpp
|
4
|
+
//
|
5
|
+
// Singleton holding methods to create each command class object
|
6
|
+
//
|
7
|
+
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
|
8
|
+
//
|
9
|
+
// SOFTWARE NOTICE AND LICENSE
|
10
|
+
//
|
11
|
+
// This file is part of OpenZWave.
|
12
|
+
//
|
13
|
+
// OpenZWave is free software: you can redistribute it and/or modify
|
14
|
+
// it under the terms of the GNU Lesser General Public License as published
|
15
|
+
// by the Free Software Foundation, either version 3 of the License,
|
16
|
+
// or (at your option) any later version.
|
17
|
+
//
|
18
|
+
// OpenZWave is distributed in the hope that it will be useful,
|
19
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
// GNU Lesser General Public License for more details.
|
22
|
+
//
|
23
|
+
// You should have received a copy of the GNU Lesser General Public License
|
24
|
+
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
|
25
|
+
//
|
26
|
+
//-----------------------------------------------------------------------------
|
27
|
+
|
28
|
+
#include <string.h>
|
29
|
+
|
30
|
+
#include "CommandClasses.h"
|
31
|
+
|
32
|
+
using namespace OpenZWave;
|
33
|
+
|
34
|
+
#include "Alarm.h"
|
35
|
+
#include "ApplicationStatus.h"
|
36
|
+
#include "Association.h"
|
37
|
+
#include "AssociationCommandConfiguration.h"
|
38
|
+
#include "Basic.h"
|
39
|
+
#include "BasicWindowCovering.h"
|
40
|
+
#include "Battery.h"
|
41
|
+
#include "ClimateControlSchedule.h"
|
42
|
+
#include "Clock.h"
|
43
|
+
#include "Configuration.h"
|
44
|
+
#include "ControllerReplication.h"
|
45
|
+
#include "EnergyProduction.h"
|
46
|
+
#include "Hail.h"
|
47
|
+
#include "Indicator.h"
|
48
|
+
#include "Language.h"
|
49
|
+
#include "Lock.h"
|
50
|
+
#include "ManufacturerSpecific.h"
|
51
|
+
#include "Meter.h"
|
52
|
+
#include "MeterPulse.h"
|
53
|
+
#include "MultiCmd.h"
|
54
|
+
#include "MultiInstance.h"
|
55
|
+
#include "MultiInstanceAssociation.h"
|
56
|
+
#include "NodeNaming.h"
|
57
|
+
#include "Powerlevel.h"
|
58
|
+
#include "Proprietary.h"
|
59
|
+
#include "Protection.h"
|
60
|
+
#include "SensorAlarm.h"
|
61
|
+
#include "SensorBinary.h"
|
62
|
+
#include "SensorMultilevel.h"
|
63
|
+
#include "SwitchAll.h"
|
64
|
+
#include "SwitchBinary.h"
|
65
|
+
#include "SwitchMultilevel.h"
|
66
|
+
#include "SwitchToggleBinary.h"
|
67
|
+
#include "SwitchToggleMultilevel.h"
|
68
|
+
#include "ThermostatFanMode.h"
|
69
|
+
#include "ThermostatFanState.h"
|
70
|
+
#include "ThermostatMode.h"
|
71
|
+
#include "ThermostatOperatingState.h"
|
72
|
+
#include "ThermostatSetpoint.h"
|
73
|
+
#include "Version.h"
|
74
|
+
#include "WakeUp.h"
|
75
|
+
|
76
|
+
#include "ValueBool.h"
|
77
|
+
#include "ValueButton.h"
|
78
|
+
#include "ValueByte.h"
|
79
|
+
#include "ValueDecimal.h"
|
80
|
+
#include "ValueInt.h"
|
81
|
+
#include "ValueList.h"
|
82
|
+
#include "ValueSchedule.h"
|
83
|
+
#include "ValueShort.h"
|
84
|
+
#include "ValueString.h"
|
85
|
+
|
86
|
+
#include "Manager.h"
|
87
|
+
#include "Options.h"
|
88
|
+
#include "Utils.h"
|
89
|
+
|
90
|
+
//-----------------------------------------------------------------------------
|
91
|
+
// <CommandClasses::CommandClasses>
|
92
|
+
// Constructor
|
93
|
+
//-----------------------------------------------------------------------------
|
94
|
+
CommandClasses::CommandClasses
|
95
|
+
(
|
96
|
+
)
|
97
|
+
{
|
98
|
+
memset( m_commandClassCreators, 0, sizeof(pfnCreateCommandClass_t)*256 );
|
99
|
+
memset( m_supportedCommandClasses, 0, sizeof(uint32)*8 );
|
100
|
+
}
|
101
|
+
|
102
|
+
//-----------------------------------------------------------------------------
|
103
|
+
// <CommandClasses::IsSupported>
|
104
|
+
// Static method to determine whether a command class is supported
|
105
|
+
//-----------------------------------------------------------------------------
|
106
|
+
bool CommandClasses::IsSupported
|
107
|
+
(
|
108
|
+
uint8 const _commandClassId
|
109
|
+
)
|
110
|
+
{
|
111
|
+
// Test the bit representing the command class
|
112
|
+
return( (Get().m_supportedCommandClasses[_commandClassId>>5] & (1u<<(_commandClassId&0x1f))) != 0 );
|
113
|
+
}
|
114
|
+
|
115
|
+
//-----------------------------------------------------------------------------
|
116
|
+
// <CommandClasses::Register>
|
117
|
+
// Static method to register a command class creator method
|
118
|
+
//-----------------------------------------------------------------------------
|
119
|
+
void CommandClasses::Register
|
120
|
+
(
|
121
|
+
uint8 const _commandClassId,
|
122
|
+
string const& _commandClassName,
|
123
|
+
pfnCreateCommandClass_t _creator
|
124
|
+
)
|
125
|
+
{
|
126
|
+
m_commandClassCreators[_commandClassId] = _creator;
|
127
|
+
|
128
|
+
// Set the bit representing the command class
|
129
|
+
Get().m_supportedCommandClasses[_commandClassId>>5] |= (1u<<(_commandClassId&0x1f));
|
130
|
+
|
131
|
+
m_namesToIDs[_commandClassName] = _commandClassId;
|
132
|
+
}
|
133
|
+
|
134
|
+
//-----------------------------------------------------------------------------
|
135
|
+
// <CommandClasses::CreateCommandClass>
|
136
|
+
// Create a command class object using the registered method
|
137
|
+
//-----------------------------------------------------------------------------
|
138
|
+
CommandClass* CommandClasses::CreateCommandClass
|
139
|
+
(
|
140
|
+
uint8 const _commandClassId,
|
141
|
+
uint32 const _homeId,
|
142
|
+
uint8 const _nodeId
|
143
|
+
)
|
144
|
+
{
|
145
|
+
// Get a pointer to the required CommandClass's Create method
|
146
|
+
pfnCreateCommandClass_t creator = Get().m_commandClassCreators[_commandClassId];
|
147
|
+
if( NULL == creator )
|
148
|
+
{
|
149
|
+
return NULL;
|
150
|
+
}
|
151
|
+
|
152
|
+
// Create an instance of the command class
|
153
|
+
return creator( _homeId, _nodeId );
|
154
|
+
}
|
155
|
+
|
156
|
+
//-----------------------------------------------------------------------------
|
157
|
+
// <CommandClasses::RegisterCommandClasses>
|
158
|
+
// Register all our implemented command classes
|
159
|
+
//-----------------------------------------------------------------------------
|
160
|
+
void CommandClasses::RegisterCommandClasses
|
161
|
+
(
|
162
|
+
)
|
163
|
+
{
|
164
|
+
CommandClasses& cc = Get();
|
165
|
+
cc.Register( Alarm::StaticGetCommandClassId(), Alarm::StaticGetCommandClassName(), Alarm::Create );
|
166
|
+
cc.Register( ApplicationStatus::StaticGetCommandClassId(), ApplicationStatus::StaticGetCommandClassName(), ApplicationStatus::Create );
|
167
|
+
cc.Register( Association::StaticGetCommandClassId(), Association::StaticGetCommandClassName(), Association::Create );
|
168
|
+
cc.Register( AssociationCommandConfiguration::StaticGetCommandClassId(), AssociationCommandConfiguration::StaticGetCommandClassName(), AssociationCommandConfiguration::Create );
|
169
|
+
cc.Register( Basic::StaticGetCommandClassId(), Basic::StaticGetCommandClassName(), Basic::Create );
|
170
|
+
cc.Register( BasicWindowCovering::StaticGetCommandClassId(), BasicWindowCovering::StaticGetCommandClassName(), BasicWindowCovering::Create );
|
171
|
+
cc.Register( Battery::StaticGetCommandClassId(), Battery::StaticGetCommandClassName(), Battery::Create );
|
172
|
+
cc.Register( ClimateControlSchedule::StaticGetCommandClassId(), ClimateControlSchedule::StaticGetCommandClassName(), ClimateControlSchedule::Create );
|
173
|
+
cc.Register( Clock::StaticGetCommandClassId(), Clock::StaticGetCommandClassName(), Clock::Create );
|
174
|
+
cc.Register( Configuration::StaticGetCommandClassId(), Configuration::StaticGetCommandClassName(), Configuration::Create );
|
175
|
+
cc.Register( ControllerReplication::StaticGetCommandClassId(), ControllerReplication::StaticGetCommandClassName(), ControllerReplication::Create );
|
176
|
+
cc.Register( EnergyProduction::StaticGetCommandClassId(), EnergyProduction::StaticGetCommandClassName(), EnergyProduction::Create );
|
177
|
+
cc.Register( Hail::StaticGetCommandClassId(), Hail::StaticGetCommandClassName(), Hail::Create );
|
178
|
+
cc.Register( Indicator::StaticGetCommandClassId(), Indicator::StaticGetCommandClassName(), Indicator::Create );
|
179
|
+
cc.Register( Language::StaticGetCommandClassId(), Language::StaticGetCommandClassName(), Language::Create );
|
180
|
+
cc.Register( Lock::StaticGetCommandClassId(), Lock::StaticGetCommandClassName(), Lock::Create );
|
181
|
+
cc.Register( ManufacturerSpecific::StaticGetCommandClassId(), ManufacturerSpecific::StaticGetCommandClassName(), ManufacturerSpecific::Create );
|
182
|
+
cc.Register( Meter::StaticGetCommandClassId(), Meter::StaticGetCommandClassName(), Meter::Create );
|
183
|
+
cc.Register( MeterPulse::StaticGetCommandClassId(), MeterPulse::StaticGetCommandClassName(), MeterPulse::Create );
|
184
|
+
cc.Register( MultiCmd::StaticGetCommandClassId(), MultiCmd::StaticGetCommandClassName(), MultiCmd::Create );
|
185
|
+
cc.Register( MultiInstance::StaticGetCommandClassId(), MultiInstance::StaticGetCommandClassName(), MultiInstance::Create );
|
186
|
+
cc.Register( MultiInstanceAssociation::StaticGetCommandClassId(), MultiInstanceAssociation::StaticGetCommandClassName(), MultiInstanceAssociation::Create );
|
187
|
+
cc.Register( NodeNaming::StaticGetCommandClassId(), NodeNaming::StaticGetCommandClassName(), NodeNaming::Create );
|
188
|
+
cc.Register( Powerlevel::StaticGetCommandClassId(), Powerlevel::StaticGetCommandClassName(), Powerlevel::Create );
|
189
|
+
cc.Register( Proprietary::StaticGetCommandClassId(), Proprietary::StaticGetCommandClassName(), Proprietary::Create );
|
190
|
+
cc.Register( Protection::StaticGetCommandClassId(), Protection::StaticGetCommandClassName(), Protection::Create );
|
191
|
+
cc.Register( SensorAlarm::StaticGetCommandClassId(), SensorAlarm::StaticGetCommandClassName(), SensorAlarm::Create );
|
192
|
+
cc.Register( SensorBinary::StaticGetCommandClassId(), SensorBinary::StaticGetCommandClassName(), SensorBinary::Create );
|
193
|
+
cc.Register( SensorMultilevel::StaticGetCommandClassId(), SensorMultilevel::StaticGetCommandClassName(), SensorMultilevel::Create );
|
194
|
+
cc.Register( SwitchAll::StaticGetCommandClassId(), SwitchAll::StaticGetCommandClassName(), SwitchAll::Create );
|
195
|
+
cc.Register( SwitchBinary::StaticGetCommandClassId(), SwitchBinary::StaticGetCommandClassName(), SwitchBinary::Create );
|
196
|
+
cc.Register( SwitchMultilevel::StaticGetCommandClassId(), SwitchMultilevel::StaticGetCommandClassName(), SwitchMultilevel::Create );
|
197
|
+
cc.Register( SwitchToggleBinary::StaticGetCommandClassId(), SwitchToggleBinary::StaticGetCommandClassName(), SwitchToggleBinary::Create );
|
198
|
+
cc.Register( SwitchToggleMultilevel::StaticGetCommandClassId(), SwitchToggleMultilevel::StaticGetCommandClassName(), SwitchToggleMultilevel::Create );
|
199
|
+
cc.Register( ThermostatFanMode::StaticGetCommandClassId(), ThermostatFanMode::StaticGetCommandClassName(), ThermostatFanMode::Create );
|
200
|
+
cc.Register( ThermostatFanState::StaticGetCommandClassId(), ThermostatFanState::StaticGetCommandClassName(), ThermostatFanState::Create );
|
201
|
+
cc.Register( ThermostatMode::StaticGetCommandClassId(), ThermostatMode::StaticGetCommandClassName(), ThermostatMode::Create );
|
202
|
+
cc.Register( ThermostatOperatingState::StaticGetCommandClassId(), ThermostatOperatingState::StaticGetCommandClassName(), ThermostatOperatingState::Create );
|
203
|
+
cc.Register( ThermostatSetpoint::StaticGetCommandClassId(), ThermostatSetpoint::StaticGetCommandClassName(), ThermostatSetpoint::Create );
|
204
|
+
cc.Register( Version::StaticGetCommandClassId(), Version::StaticGetCommandClassName(), Version::Create );
|
205
|
+
cc.Register( WakeUp::StaticGetCommandClassId(), WakeUp::StaticGetCommandClassName(), WakeUp::Create );
|
206
|
+
|
207
|
+
// Now all the command classes have been registered, we can modify the
|
208
|
+
// supported command classes array according to the program options.
|
209
|
+
string str;
|
210
|
+
Options::Get()->GetOptionAsString( "Include", &str );
|
211
|
+
if( str != "" )
|
212
|
+
{
|
213
|
+
// The include list has entries, so we assume that it is a
|
214
|
+
// complete list of what should be supported.
|
215
|
+
// Any existing support is cleared first.
|
216
|
+
memset( cc.m_supportedCommandClasses, 0, sizeof(uint32)*8 );
|
217
|
+
cc.ParseCommandClassOption( str, true );
|
218
|
+
}
|
219
|
+
|
220
|
+
// Apply the excluded command class option
|
221
|
+
Options::Get()->GetOptionAsString( "Exclude", &str );
|
222
|
+
if( str != "" )
|
223
|
+
{
|
224
|
+
cc.ParseCommandClassOption( str, false );
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
//-----------------------------------------------------------------------------
|
229
|
+
// <CommandClasses::ParseCommandClassOption>
|
230
|
+
// Parse a comma delimited list of included/excluded command classes
|
231
|
+
//-----------------------------------------------------------------------------
|
232
|
+
void CommandClasses::ParseCommandClassOption
|
233
|
+
(
|
234
|
+
string const& _optionStr,
|
235
|
+
bool const _include
|
236
|
+
)
|
237
|
+
{
|
238
|
+
size_t pos = 0;
|
239
|
+
uint8 start = 0;
|
240
|
+
bool parsing = true;
|
241
|
+
while( parsing )
|
242
|
+
{
|
243
|
+
string ccStr;
|
244
|
+
|
245
|
+
pos = _optionStr.find_first_of( ",", start );
|
246
|
+
if( string::npos == pos )
|
247
|
+
{
|
248
|
+
ccStr = _optionStr.substr( start );
|
249
|
+
parsing = false;
|
250
|
+
}
|
251
|
+
else
|
252
|
+
{
|
253
|
+
ccStr = _optionStr.substr( start, pos-start );
|
254
|
+
start = pos + 1;
|
255
|
+
}
|
256
|
+
|
257
|
+
if( ccStr != "" )
|
258
|
+
{
|
259
|
+
uint8 ccIdx = GetCommandClassId( ccStr );
|
260
|
+
if( _include )
|
261
|
+
{
|
262
|
+
m_supportedCommandClasses[ccIdx>>5] |= (1u<<(ccIdx&0x1f));
|
263
|
+
}
|
264
|
+
else
|
265
|
+
{
|
266
|
+
m_supportedCommandClasses[ccIdx>>5] &= ~(1u<<(ccIdx&0x1f));
|
267
|
+
}
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
//-----------------------------------------------------------------------------
|
273
|
+
// <CommandClasses::GetCommandClassId>
|
274
|
+
// Convert a command class name (e.g COMMAND_CLASS_BASIC) into its 8-bit ID
|
275
|
+
//-----------------------------------------------------------------------------
|
276
|
+
uint8 CommandClasses::GetCommandClassId
|
277
|
+
(
|
278
|
+
string const& _name
|
279
|
+
)
|
280
|
+
{
|
281
|
+
string upperName = ToUpper( _name );
|
282
|
+
map<string,uint8>::iterator it = m_namesToIDs.find( upperName );
|
283
|
+
if( it != m_namesToIDs.end() )
|
284
|
+
{
|
285
|
+
return it->second;
|
286
|
+
}
|
287
|
+
|
288
|
+
return 0xff;
|
289
|
+
}
|
290
|
+
|
291
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// CommandClasses.h
|
4
|
+
//
|
5
|
+
// Singleton holding methods to create each command class object
|
6
|
+
//
|
7
|
+
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
|
8
|
+
//
|
9
|
+
// SOFTWARE NOTICE AND LICENSE
|
10
|
+
//
|
11
|
+
// This file is part of OpenZWave.
|
12
|
+
//
|
13
|
+
// OpenZWave is free software: you can redistribute it and/or modify
|
14
|
+
// it under the terms of the GNU Lesser General Public License as published
|
15
|
+
// by the Free Software Foundation, either version 3 of the License,
|
16
|
+
// or (at your option) any later version.
|
17
|
+
//
|
18
|
+
// OpenZWave is distributed in the hope that it will be useful,
|
19
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
// GNU Lesser General Public License for more details.
|
22
|
+
//
|
23
|
+
// You should have received a copy of the GNU Lesser General Public License
|
24
|
+
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
|
25
|
+
//
|
26
|
+
//-----------------------------------------------------------------------------
|
27
|
+
|
28
|
+
#ifndef _CommandClasses_H
|
29
|
+
#define _CommandClasses_H
|
30
|
+
|
31
|
+
#include <string>
|
32
|
+
#include <map>
|
33
|
+
#include "Defs.h"
|
34
|
+
|
35
|
+
namespace OpenZWave
|
36
|
+
{
|
37
|
+
class CommandClass;
|
38
|
+
|
39
|
+
/** \brief Manages a map of command classes supported by a specific Z-Wave node.
|
40
|
+
*/
|
41
|
+
class CommandClasses
|
42
|
+
{
|
43
|
+
public:
|
44
|
+
typedef CommandClass* (*pfnCreateCommandClass_t)( uint32 const _homeId, uint8 const _nodeId );
|
45
|
+
|
46
|
+
static void RegisterCommandClasses();
|
47
|
+
static CommandClass* CreateCommandClass( uint8 const _commandClassId, uint32 const _homeId, uint8 const _nodeId );
|
48
|
+
|
49
|
+
static bool IsSupported( uint8 const _commandClassId );
|
50
|
+
|
51
|
+
private:
|
52
|
+
CommandClasses();
|
53
|
+
CommandClasses( CommandClasses const& ); // prevent copy
|
54
|
+
CommandClasses& operator = ( CommandClasses const& ); // prevent assignment
|
55
|
+
|
56
|
+
static CommandClasses& Get()
|
57
|
+
{
|
58
|
+
static CommandClasses instance;
|
59
|
+
return instance;
|
60
|
+
}
|
61
|
+
|
62
|
+
void Register( uint8 const _commandClassId, string const& _commandClassName, pfnCreateCommandClass_t _create );
|
63
|
+
void ParseCommandClassOption( string const& _optionStr, bool const _include );
|
64
|
+
uint8 GetCommandClassId( string const& _name );
|
65
|
+
|
66
|
+
pfnCreateCommandClass_t m_commandClassCreators[256];
|
67
|
+
map<string,uint8> m_namesToIDs;
|
68
|
+
|
69
|
+
// m_supportedCommandClasses uses single bits to mark whether OpenZWave supports a command class
|
70
|
+
// Checking this is not the same as looking for non-NULL entried in m_commandClassCreators, since
|
71
|
+
// this may be modified by the program options --Include and --Ingnore to filter out support
|
72
|
+
// for unwanted command classes.
|
73
|
+
uint32 m_supportedCommandClasses[8];
|
74
|
+
};
|
75
|
+
|
76
|
+
} // namespace OpenZWave
|
77
|
+
|
78
|
+
|
79
|
+
#endif
|