1 //-----------------------------------------------------------------------------
2 //
3 //	ValueShort.h
4 //
5 //	Represents a 16-bit value
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 _ValueShort_H
29 #define _ValueShort_H
30 
31 #include <string>
32 #include "Defs.h"
33 #include "value_classes/Value.h"
34 
35 class TiXmlElement;
36 
37 namespace OpenZWave
38 {
39 	namespace Internal
40 	{
41 		namespace VC
42 		{
43 
44 			/** \brief Short value sent to/received from a node.
45 			 * \ingroup ValueID
46 			 */
47 			class ValueShort: public Value
48 			{
49 				public:
50 					ValueShort(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, int16 const _value, uint8 const _pollIntensity);
51 					ValueShort();
~ValueShort()52 					virtual ~ValueShort()
53 					{
54 					}
55 
56 					bool Set(int16 const _value);
57 					void OnValueRefreshed(int16 const _value);
58 
59 					// From Value
60 					virtual string const GetAsString() const;
61 					virtual bool SetFromString(string const& _value);
62 					virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement);
63 					virtual void WriteXML(TiXmlElement* _valueElement);
64 
GetValue()65 					int16 GetValue() const
66 					{
67 						return m_value;
68 					}
69 
70 				private:
71 					int16 m_value;				// the current value
72 					int16 m_valueCheck;			// the previous value (used for double-checking spurious value reads)
73 			};
74 		} // namespace VC
75 	} // namespace Internal
76 } // namespace OpenZWave
77 
78 #endif
79