OpenZWave Library 1.6.0
ValueDecimal.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// ValueDecimal.h
4//
5// Represents a value that may have a fractional component
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 _ValueDecimal_H
29#define _ValueDecimal_H
30
31#include <string>
32#include "Defs.h"
33#include "value_classes/Value.h"
34
35class TiXmlElement;
36
37namespace OpenZWave
38{
39 class Msg;
40 class Node;
41
45 class ValueDecimal: public Value
46 {
47 friend class EnergyProduction;
48 friend class Meter;
49 friend class SensorMultilevel;
50 friend class ThermostatSetpoint;
51
52 public:
53 ValueDecimal( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint16 const _index, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, string const& _value, uint8 const _pollIntensity );
54 ValueDecimal(): m_precision( 0 ){}
55 virtual ~ValueDecimal(){}
56
57 bool Set( string const& _value );
58 void OnValueRefreshed( string const& _value );
59
60 // From Value
61 virtual string const GetAsString() const { return GetValue(); }
62 virtual bool SetFromString( string const& _value ) { return Set( _value ); }
63 virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement );
64 virtual void WriteXML( TiXmlElement* _valueElement );
65
66 string GetValue()const{ return m_value; }
67 uint8 GetPrecision()const{ return m_precision; }
68
69 private:
70 void SetPrecision( uint8 _precision ){ m_precision = _precision; }
71
72 string m_value; // the current value
73 string m_valueCheck; // the previous value (used for double-checking spurious value reads)
74 string m_newValue; // a new value to be set on the appropriate device
75 uint8 m_precision;
76 };
77
78} // namespace OpenZWave
79
80#endif
81
82
83
unsigned short uint16
Definition: Defs.h:92
unsigned int uint32
Definition: Defs.h:95
unsigned char uint8
Definition: Defs.h:89
Implements COMMAND_CLASS_ENERGY_PRODUCTION (0x90), a Z-Wave device command class.
Definition: EnergyProduction.h:41
Implements COMMAND_CLASS_METER (0x32), a Z-Wave device command class.
Definition: Meter.h:41
Implements COMMAND_CLASS_SENSOR_MULTILEVEL (0x31), a Z-Wave device command class.
Definition: SensorMultilevel.h:41
Implements COMMAND_CLASS_THERMOSTAT_SETPOINT (0x43), a Z-Wave device command class.
Definition: ThermostatSetpoint.h:43
Decimal value sent to/received from a node.
Definition: ValueDecimal.h:46
virtual ~ValueDecimal()
Definition: ValueDecimal.h:55
uint8 GetPrecision() const
Definition: ValueDecimal.h:67
ValueDecimal()
Definition: ValueDecimal.h:54
string GetValue() const
Definition: ValueDecimal.h:66
virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const *_valueElement)
Definition: ValueDecimal.cpp:70
virtual void WriteXML(TiXmlElement *_valueElement)
Definition: ValueDecimal.cpp:95
virtual bool SetFromString(string const &_value)
Definition: ValueDecimal.h:62
virtual string const GetAsString() const
Definition: ValueDecimal.h:61
ValueGenre
Definition: ValueID.h:81
Base class for values associated with a node.
Definition: Value.h:49
void OnValueRefreshed()
Definition: Value.cpp:405
bool Set()
Definition: Value.cpp:343
Definition: Bitfield.h:35