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,65 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SensorBinary.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_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 _SensorBinary_H
|
29
|
+
#define _SensorBinary_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueBool;
|
36
|
+
|
37
|
+
/** \brief Implements COMMAND_CLASS_SENSOR_BINARY (0x30), a Z-Wave device command class.
|
38
|
+
*/
|
39
|
+
class SensorBinary: public CommandClass
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SensorBinary( _homeId, _nodeId ); }
|
43
|
+
virtual ~SensorBinary(){}
|
44
|
+
|
45
|
+
static uint8 const StaticGetCommandClassId(){ return 0x30; }
|
46
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SENSOR_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
|
+
|
55
|
+
protected:
|
56
|
+
virtual void CreateVars( uint8 const _instance );
|
57
|
+
|
58
|
+
private:
|
59
|
+
SensorBinary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
60
|
+
};
|
61
|
+
|
62
|
+
} // namespace OpenZWave
|
63
|
+
|
64
|
+
#endif
|
65
|
+
|
@@ -0,0 +1,237 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SensorMultilevel.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_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 "SensorMultilevel.h"
|
30
|
+
#include "MultiInstance.h"
|
31
|
+
#include "Defs.h"
|
32
|
+
#include "Bitfield.h"
|
33
|
+
#include "Msg.h"
|
34
|
+
#include "Node.h"
|
35
|
+
#include "Driver.h"
|
36
|
+
#include "Log.h"
|
37
|
+
|
38
|
+
#include "ValueDecimal.h"
|
39
|
+
|
40
|
+
using namespace OpenZWave;
|
41
|
+
|
42
|
+
enum SensorMultilevelCmd
|
43
|
+
{
|
44
|
+
SensorMultilevelCmd_Get = 0x04,
|
45
|
+
SensorMultilevelCmd_Report = 0x05
|
46
|
+
};
|
47
|
+
|
48
|
+
enum SensorType
|
49
|
+
{
|
50
|
+
SensorType_Temperature = 1,
|
51
|
+
SensorType_General,
|
52
|
+
SensorType_Luminance,
|
53
|
+
SensorType_Power,
|
54
|
+
SensorType_RelativeHumidity,
|
55
|
+
SensorType_Velocity,
|
56
|
+
SensorType_Direction,
|
57
|
+
SensorType_AtmosphericPressure,
|
58
|
+
SensorType_BarometricPressure,
|
59
|
+
SensorType_SolarRadiation,
|
60
|
+
SensorType_DewPoint,
|
61
|
+
SensorType_RainRate,
|
62
|
+
SensorType_TideLevel,
|
63
|
+
SensorType_Weight,
|
64
|
+
SensorType_Voltage,
|
65
|
+
SensorType_Current,
|
66
|
+
SensorType_CO2,
|
67
|
+
SensorType_AirFlow,
|
68
|
+
SensorType_TankCapacity,
|
69
|
+
SensorType_Distance
|
70
|
+
};
|
71
|
+
|
72
|
+
static char const* c_sensorTypeNames[] =
|
73
|
+
{
|
74
|
+
"Undefined",
|
75
|
+
"Temperature",
|
76
|
+
"General",
|
77
|
+
"Luminance",
|
78
|
+
"Power",
|
79
|
+
"Relative Humidity",
|
80
|
+
"Velocity",
|
81
|
+
"Direction",
|
82
|
+
"Atmospheric Pressure",
|
83
|
+
"Barometric Pressure",
|
84
|
+
"Solar Radiation",
|
85
|
+
"Dew Point",
|
86
|
+
"Rain Rate",
|
87
|
+
"Tide Level",
|
88
|
+
"Weight",
|
89
|
+
"Voltage",
|
90
|
+
"Current",
|
91
|
+
"CO2 Level",
|
92
|
+
"Air Flow",
|
93
|
+
"Tank Capacity",
|
94
|
+
"Distance"
|
95
|
+
};
|
96
|
+
|
97
|
+
static char const* c_tankCapcityUnits[] =
|
98
|
+
{
|
99
|
+
"l",
|
100
|
+
"cbm",
|
101
|
+
"gal"
|
102
|
+
};
|
103
|
+
|
104
|
+
static char const* c_distanceUnits[] =
|
105
|
+
{
|
106
|
+
"m",
|
107
|
+
"cm",
|
108
|
+
"ft"
|
109
|
+
};
|
110
|
+
|
111
|
+
//-----------------------------------------------------------------------------
|
112
|
+
// <SensorMultilevel::RequestState>
|
113
|
+
// Request current state from the device
|
114
|
+
//-----------------------------------------------------------------------------
|
115
|
+
bool SensorMultilevel::RequestState
|
116
|
+
(
|
117
|
+
uint32 const _requestFlags,
|
118
|
+
uint8 const _instance,
|
119
|
+
Driver::MsgQueue const _queue
|
120
|
+
)
|
121
|
+
{
|
122
|
+
if( _requestFlags & RequestFlag_Dynamic )
|
123
|
+
{
|
124
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
125
|
+
}
|
126
|
+
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
|
130
|
+
//-----------------------------------------------------------------------------
|
131
|
+
// <SensorMultilevel::RequestValue>
|
132
|
+
// Request current value from the device
|
133
|
+
//-----------------------------------------------------------------------------
|
134
|
+
bool SensorMultilevel::RequestValue
|
135
|
+
(
|
136
|
+
uint32 const _requestFlags,
|
137
|
+
uint8 const _dummy, // = 0 (not used)
|
138
|
+
uint8 const _instance,
|
139
|
+
Driver::MsgQueue const _queue
|
140
|
+
)
|
141
|
+
{
|
142
|
+
Msg* msg = new Msg( "SensorMultilevelCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
143
|
+
msg->SetInstance( this, _instance );
|
144
|
+
msg->Append( GetNodeId() );
|
145
|
+
msg->Append( 2 );
|
146
|
+
msg->Append( GetCommandClassId() );
|
147
|
+
msg->Append( SensorMultilevelCmd_Get );
|
148
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
149
|
+
GetDriver()->SendMsg( msg, _queue );
|
150
|
+
return true;
|
151
|
+
}
|
152
|
+
|
153
|
+
//-----------------------------------------------------------------------------
|
154
|
+
// <SensorMultilevel::HandleMsg>
|
155
|
+
// Handle a message from the Z-Wave network
|
156
|
+
//-----------------------------------------------------------------------------
|
157
|
+
bool SensorMultilevel::HandleMsg
|
158
|
+
(
|
159
|
+
uint8 const* _data,
|
160
|
+
uint32 const _length,
|
161
|
+
uint32 const _instance // = 1
|
162
|
+
)
|
163
|
+
{
|
164
|
+
if (SensorMultilevelCmd_Report == (SensorMultilevelCmd)_data[0])
|
165
|
+
{
|
166
|
+
uint8 scale;
|
167
|
+
uint8 precision = 0;
|
168
|
+
uint8 sensorType = _data[1];
|
169
|
+
string valueStr = ExtractValue( &_data[2], &scale, &precision );
|
170
|
+
|
171
|
+
Node* node = GetNodeUnsafe();
|
172
|
+
if( node != NULL )
|
173
|
+
{
|
174
|
+
char const* units = "";
|
175
|
+
switch( sensorType )
|
176
|
+
{
|
177
|
+
case SensorType_Temperature: units = scale ? "F" : "C"; break;
|
178
|
+
case SensorType_General: units = scale ? "" : "%"; break;
|
179
|
+
case SensorType_Luminance: units = scale ? "lux" : "%"; break;
|
180
|
+
case SensorType_Power: units = scale ? "BTU/h" : "W"; break;
|
181
|
+
case SensorType_RelativeHumidity: units = "%"; break;
|
182
|
+
case SensorType_Velocity: units = scale ? "mph" : "m/s"; break;
|
183
|
+
case SensorType_Direction: units = ""; break;
|
184
|
+
case SensorType_AtmosphericPressure: units = scale ? "inHg" : "kPa"; break;
|
185
|
+
case SensorType_BarometricPressure: units = scale ? "inHg" : "kPa"; break;
|
186
|
+
case SensorType_SolarRadiation: units = "W/m2"; break;
|
187
|
+
case SensorType_DewPoint: units = scale ? "in/h" : "mm/h"; break;
|
188
|
+
case SensorType_RainRate: units = scale ? "F" : "C"; break;
|
189
|
+
case SensorType_TideLevel: units = scale ? "ft" : "m"; break;
|
190
|
+
case SensorType_Weight: units = scale ? "lb" : "kg"; break;
|
191
|
+
case SensorType_Voltage: units = scale ? "mV" : "V"; break;
|
192
|
+
case SensorType_Current: units = scale ? "mA" : "A"; break;
|
193
|
+
case SensorType_CO2: units = "ppm"; break;
|
194
|
+
case SensorType_AirFlow: units = scale ? "cfm" : "m3/h"; break;
|
195
|
+
case SensorType_TankCapacity: units = c_tankCapcityUnits[scale]; break;
|
196
|
+
case SensorType_Distance: units = c_distanceUnits[scale]; break;
|
197
|
+
default: break;
|
198
|
+
}
|
199
|
+
|
200
|
+
ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, sensorType ) );
|
201
|
+
if( value == NULL)
|
202
|
+
{
|
203
|
+
node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, sensorType, c_sensorTypeNames[sensorType], units, true, false, "0.0", 0 );
|
204
|
+
value = static_cast<ValueDecimal*>( GetValue( _instance, sensorType ) );
|
205
|
+
}
|
206
|
+
else
|
207
|
+
{
|
208
|
+
value->SetUnits(units);
|
209
|
+
}
|
210
|
+
|
211
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received SensorMultiLevel report from node %d, instance %d: value=%s%s", GetNodeId(), _instance, valueStr.c_str(), value->GetUnits().c_str() );
|
212
|
+
if( value->GetPrecision() != precision )
|
213
|
+
{
|
214
|
+
value->SetPrecision( precision );
|
215
|
+
}
|
216
|
+
value->OnValueRefreshed( valueStr );
|
217
|
+
value->Release();
|
218
|
+
return true;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
return false;
|
222
|
+
}
|
223
|
+
|
224
|
+
//-----------------------------------------------------------------------------
|
225
|
+
// <SensorMultilevel::CreateVars>
|
226
|
+
// Create the values managed by this command class
|
227
|
+
//-----------------------------------------------------------------------------
|
228
|
+
void SensorMultilevel::CreateVars
|
229
|
+
(
|
230
|
+
uint8 const _instance
|
231
|
+
)
|
232
|
+
{
|
233
|
+
// Don't create anything here. We do it in the report.
|
234
|
+
}
|
235
|
+
|
236
|
+
|
237
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SensorMultilevel.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_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 _SensorMultilevel_H
|
29
|
+
#define _SensorMultilevel_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueDecimal;
|
36
|
+
|
37
|
+
/** \brief Implements COMMAND_CLASS_SENSOR_MULTILEVEL (0x31), a Z-Wave device command class.
|
38
|
+
*/
|
39
|
+
class SensorMultilevel: public CommandClass
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SensorMultilevel( _homeId, _nodeId ); }
|
43
|
+
virtual ~SensorMultilevel(){}
|
44
|
+
|
45
|
+
static uint8 const StaticGetCommandClassId(){ return 0x31; }
|
46
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SENSOR_MULTILEVEL"; }
|
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 _dummy, 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
|
+
|
55
|
+
// We return 1 instead of 3 because the latter versions only introduce new
|
56
|
+
// sensor types, with no new message format changes. Setting this to 1 prevents
|
57
|
+
// OpenZWave from making an unecessary version requests.
|
58
|
+
virtual uint8 GetMaxVersion(){ return 1; }
|
59
|
+
|
60
|
+
protected:
|
61
|
+
virtual void CreateVars( uint8 const _instance );
|
62
|
+
|
63
|
+
private:
|
64
|
+
SensorMultilevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
65
|
+
};
|
66
|
+
|
67
|
+
} // namespace OpenZWave
|
68
|
+
|
69
|
+
|
70
|
+
#endif
|
71
|
+
|
@@ -0,0 +1,219 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SwitchAll.cpp
|
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
|
+
#include "CommandClasses.h"
|
29
|
+
#include "SwitchAll.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Node.h"
|
33
|
+
#include "Driver.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
#include "ValueList.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum SwitchAllCmd
|
41
|
+
{
|
42
|
+
SwitchAllCmd_Set = 0x01,
|
43
|
+
SwitchAllCmd_Get = 0x02,
|
44
|
+
SwitchAllCmd_Report = 0x03,
|
45
|
+
SwitchAllCmd_On = 0x04,
|
46
|
+
SwitchAllCmd_Off = 0x05
|
47
|
+
};
|
48
|
+
|
49
|
+
static char const* c_switchAllStateName[] =
|
50
|
+
{
|
51
|
+
"Disabled",
|
52
|
+
"Off Enabled",
|
53
|
+
"On Enabled",
|
54
|
+
"On and Off Enabled"
|
55
|
+
};
|
56
|
+
|
57
|
+
//-----------------------------------------------------------------------------
|
58
|
+
// <SwitchAll::RequestState>
|
59
|
+
// Request current state from the device
|
60
|
+
//-----------------------------------------------------------------------------
|
61
|
+
bool SwitchAll::RequestState
|
62
|
+
(
|
63
|
+
uint32 const _requestFlags,
|
64
|
+
uint8 const _instance,
|
65
|
+
Driver::MsgQueue const _queue
|
66
|
+
)
|
67
|
+
{
|
68
|
+
if( _requestFlags & RequestFlag_Session )
|
69
|
+
{
|
70
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
71
|
+
}
|
72
|
+
|
73
|
+
return false;
|
74
|
+
}
|
75
|
+
|
76
|
+
//-----------------------------------------------------------------------------
|
77
|
+
// <SwitchAll::RequestValue>
|
78
|
+
// Request current value from the device
|
79
|
+
//-----------------------------------------------------------------------------
|
80
|
+
bool SwitchAll::RequestValue
|
81
|
+
(
|
82
|
+
uint32 const _requestFlags,
|
83
|
+
uint8 const _dummy1, // = 0 (not used)
|
84
|
+
uint8 const _instance,
|
85
|
+
Driver::MsgQueue const _queue
|
86
|
+
)
|
87
|
+
{
|
88
|
+
Msg* msg = new Msg( "SwitchAllCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
89
|
+
msg->SetInstance( this, _instance );
|
90
|
+
msg->Append( GetNodeId() );
|
91
|
+
msg->Append( 2 );
|
92
|
+
msg->Append( GetCommandClassId() );
|
93
|
+
msg->Append( SwitchAllCmd_Get );
|
94
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
95
|
+
GetDriver()->SendMsg( msg, _queue );
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
|
99
|
+
//-----------------------------------------------------------------------------
|
100
|
+
// <SwitchAll::HandleMsg>
|
101
|
+
// Handle a message from the Z-Wave network
|
102
|
+
//-----------------------------------------------------------------------------
|
103
|
+
bool SwitchAll::HandleMsg
|
104
|
+
(
|
105
|
+
uint8 const* _data,
|
106
|
+
uint32 const _length,
|
107
|
+
uint32 const _instance // = 1
|
108
|
+
)
|
109
|
+
{
|
110
|
+
if (SwitchAllCmd_Report == (SwitchAllCmd)_data[0])
|
111
|
+
{
|
112
|
+
if( ValueList* value = static_cast<ValueList*>( GetValue( _instance, 0 ) ) )
|
113
|
+
{
|
114
|
+
value->OnValueRefreshed( (int32)_data[1] );
|
115
|
+
value->Release();
|
116
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchAll report from node %d: %s", GetNodeId(), value->GetItem().m_label.c_str() );
|
117
|
+
}
|
118
|
+
return true;
|
119
|
+
}
|
120
|
+
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
|
124
|
+
//-----------------------------------------------------------------------------
|
125
|
+
// <SwitchAll::SetValue>
|
126
|
+
// Set the device's response to SWITCH_ALL commands
|
127
|
+
//-----------------------------------------------------------------------------
|
128
|
+
bool SwitchAll::SetValue
|
129
|
+
(
|
130
|
+
Value const& _value
|
131
|
+
)
|
132
|
+
{
|
133
|
+
if( ValueID::ValueType_List == _value.GetID().GetType() )
|
134
|
+
{
|
135
|
+
ValueList const* value = static_cast<ValueList const*>(&_value);
|
136
|
+
ValueList::Item const& item = value->GetItem();
|
137
|
+
|
138
|
+
Log::Write( LogLevel_Info, GetNodeId(), "SwitchAll::Set - %s on node %d", item.m_label.c_str(), GetNodeId() );
|
139
|
+
Msg* msg = new Msg( "SwitchAllCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
140
|
+
msg->SetInstance( this, _value.GetID().GetInstance() );
|
141
|
+
msg->Append( GetNodeId() );
|
142
|
+
msg->Append( 3 );
|
143
|
+
msg->Append( GetCommandClassId() );
|
144
|
+
msg->Append( SwitchAllCmd_Set );
|
145
|
+
msg->Append( (uint8)item.m_value );
|
146
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
147
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
148
|
+
return true;
|
149
|
+
}
|
150
|
+
|
151
|
+
return false;
|
152
|
+
}
|
153
|
+
|
154
|
+
//-----------------------------------------------------------------------------
|
155
|
+
// <SwitchAll::Off>
|
156
|
+
// Send a command to switch all devices off
|
157
|
+
//-----------------------------------------------------------------------------
|
158
|
+
void SwitchAll::Off
|
159
|
+
(
|
160
|
+
Driver* _driver,
|
161
|
+
uint8 const _nodeId
|
162
|
+
)
|
163
|
+
{
|
164
|
+
Log::Write( LogLevel_Info, _nodeId, "SwitchAll::Off (Node=%d)", _nodeId );
|
165
|
+
Msg* msg = new Msg( "SwitchAllCmd_Off", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
166
|
+
msg->Append( _nodeId );
|
167
|
+
msg->Append( 2 );
|
168
|
+
msg->Append( StaticGetCommandClassId() );
|
169
|
+
msg->Append( SwitchAllCmd_Off );
|
170
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
171
|
+
_driver->SendMsg( msg, Driver::MsgQueue_Send );
|
172
|
+
}
|
173
|
+
|
174
|
+
//-----------------------------------------------------------------------------
|
175
|
+
// <SwitchAll::On>
|
176
|
+
// Send a command to switch all devices on
|
177
|
+
//-----------------------------------------------------------------------------
|
178
|
+
void SwitchAll::On
|
179
|
+
(
|
180
|
+
Driver* _driver,
|
181
|
+
uint8 const _nodeId
|
182
|
+
)
|
183
|
+
{
|
184
|
+
Log::Write( LogLevel_Info, _nodeId, "SwitchAll::On (Node=%d)", _nodeId );
|
185
|
+
Msg* msg = new Msg( "SwitchAllCmd_On", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
186
|
+
msg->Append( _nodeId );
|
187
|
+
msg->Append( 2 );
|
188
|
+
msg->Append( StaticGetCommandClassId() );
|
189
|
+
msg->Append( SwitchAllCmd_On );
|
190
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
191
|
+
_driver->SendMsg( msg, Driver::MsgQueue_Send );
|
192
|
+
}
|
193
|
+
|
194
|
+
//-----------------------------------------------------------------------------
|
195
|
+
// <SwitchAll::CreateVars>
|
196
|
+
// Create the values managed by this command class
|
197
|
+
//-----------------------------------------------------------------------------
|
198
|
+
void SwitchAll::CreateVars
|
199
|
+
(
|
200
|
+
uint8 const _instance
|
201
|
+
)
|
202
|
+
{
|
203
|
+
if( Node* node = GetNodeUnsafe() )
|
204
|
+
{
|
205
|
+
vector<ValueList::Item> items;
|
206
|
+
for( int i=0; i<4; ++i )
|
207
|
+
{
|
208
|
+
ValueList::Item item;
|
209
|
+
item.m_label = c_switchAllStateName[i];
|
210
|
+
item.m_value = (i==3) ? 0x000000ff : i;
|
211
|
+
items.push_back( item );
|
212
|
+
}
|
213
|
+
|
214
|
+
node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 0, "Switch All", "", false, false, 1, items, 0, 0 );
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
|
219
|
+
|