OpenZWave Library 1.7.0
Loading...
Searching...
No Matches
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 namespace Internal
40 {
41 namespace VC
42 {
43
47 class ValueDecimal: public Value
48 {
49
50 public:
51 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);
53 m_precision(0)
54 {
55 }
56 virtual ~ValueDecimal()
57 {
58 }
59
60 bool Set(string const& _value);
61 void OnValueRefreshed(string const& _value);
63 {
64 OnValueRefreshed(m_newValue);
65 };
66 void SetTargetValue(string const _target, uint32 _duration = 0);
67
68 // From Value
69 virtual string const GetAsString() const
70 {
71 return GetValue();
72 }
73 virtual bool SetFromString(string const& _value)
74 {
75 return Set(_value);
76 }
77 virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement);
78 virtual void WriteXML(TiXmlElement* _valueElement);
79
80 string GetValue() const
81 {
82 return m_value;
83 }
85 {
86 return m_precision;
87 }
88 void SetPrecision(uint8 _precision)
89 {
90 m_precision = _precision;
91 }
92
93 private:
94
95 string m_value; // the current value
96 string m_valueCheck; // the previous value (used for double-checking spurious value reads)
97 string m_newValue; // a new value to be set on the appropriate device
98 uint8 m_precision;
99 string m_targetValue; // Target Value if supported.
100 };
101 } // namespace VC
102 } // namespace Internal
103} // namespace OpenZWave
104
105#endif
106
unsigned short uint16
Definition Defs.h:88
unsigned int uint32
Definition Defs.h:91
unsigned char uint8
Definition Defs.h:85
Decimal value sent to/received from a node.
Definition ValueDecimal.h:48
void SetPrecision(uint8 _precision)
Definition ValueDecimal.h:88
virtual ~ValueDecimal()
Definition ValueDecimal.h:56
virtual void WriteXML(TiXmlElement *_valueElement)
Definition ValueDecimal.cpp:74
void SetTargetValue(string const _target, uint32 _duration=0)
Definition ValueDecimal.cpp:106
virtual bool SetFromString(string const &_value)
Definition ValueDecimal.h:73
virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const *_valueElement)
Definition ValueDecimal.cpp:55
virtual string const GetAsString() const
Definition ValueDecimal.h:69
uint8 GetPrecision() const
Definition ValueDecimal.h:84
string GetValue() const
Definition ValueDecimal.h:80
void ConfirmNewValue()
Definition ValueDecimal.h:62
ValueDecimal()
Definition ValueDecimal.h:52
Base class for values associated with a node.
Definition Value.h:55
bool Set()
Definition Value.cpp:290
void OnValueRefreshed()
Definition Value.cpp:356
ValueGenre
Definition ValueID.h:85
Definition Bitfield.cpp:31