OpenZWave Library 1.4.0
Loading...
Searching...
No Matches
Value.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// Value.h
4//
5// Base class for all OpenZWave Value 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 _Value_H
29#define _Value_H
30
31#include <string>
32#ifdef __FreeBSD__
33#include <time.h>
34#endif
35#include "Defs.h"
36#include "platform/Ref.h"
38
39class TiXmlElement;
40
41namespace OpenZWave
42{
43 class Node;
44
47 class Value: public Ref
48 {
49 friend class Driver;
50 friend class ValueStore;
51
52 public:
53 Value( uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, ValueID::ValueType const _type, string const& _label, string const& _units, bool const _readOnly, bool const _writeOnly, bool const _isset, uint8 const _pollIntensity );
54 Value();
55
56 virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement );
57 virtual void WriteXML( TiXmlElement* _valueElement );
58
59 ValueID const& GetID()const{ return m_id; }
60 bool IsReadOnly()const{ return m_readOnly; }
61 bool IsWriteOnly()const{ return m_writeOnly; }
62 bool IsSet()const{ return m_isSet; }
63 bool IsPolled()const{ return m_pollIntensity != 0; }
64
65 string const& GetLabel()const{ return m_label; }
66 void SetLabel( string const& _label ){ m_label = _label; }
67
68 string const& GetUnits()const{ return m_units; }
69 void SetUnits( string const& _units ){ m_units = _units; }
70
71 string const& GetHelp()const{ return m_help; }
72 void SetHelp( string const& _help ){ m_help = _help; }
73
74 uint8 const& GetPollIntensity()const{ return m_pollIntensity; }
75 void SetPollIntensity( uint8 const& _intensity ){ m_pollIntensity = _intensity; }
76
77 int32 GetMin()const{ return m_min; }
78 int32 GetMax()const{ return m_max; }
79
80 void SetChangeVerified( bool _verify ){ m_verifyChanges = _verify; }
82
83 virtual string const GetAsString() const { return ""; }
84 virtual bool SetFromString( string const& ) { return false; }
85
86 bool Set(); // For the user to change a value in a device
87
88 // Helpers
89 static ValueID::ValueGenre GetGenreEnumFromName( char const* _name );
90 static char const* GetGenreNameFromEnum( ValueID::ValueGenre _genre );
91 static ValueID::ValueType GetTypeEnumFromName( char const* _name );
92 static char const* GetTypeNameFromEnum( ValueID::ValueType _type );
93
94 protected:
95 virtual ~Value();
96
97// void SetIsSet() { m_isSet = true; } // TODO: consider removing this...it's never called since m_isSet is set in ValueChanged and ValueRefreshed
98 bool IsCheckingChange()const{ return m_checkChange; }
99 void SetCheckingChange( bool _check ) { m_checkChange = _check; }
100 void OnValueRefreshed(); // A value in a device has been refreshed
101 void OnValueChanged(); // The refreshed value actually changed
102 int VerifyRefreshedValue( void* _originalValue, void* _checkValue, void* _newValue, ValueID::ValueType _type, int _originalValueLength = 0, int _checkValueLength = 0, int _newValueLength = 0 );
103
106
107 time_t m_refreshTime; // time_t identifying when this value was last refreshed
108 bool m_verifyChanges; // if true, apparent changes are verified; otherwise, they're not
109
110 private:
111 ValueID m_id;
112 string m_label;
113 string m_units;
114 string m_help;
115 bool m_readOnly;
116 bool m_writeOnly;
117 bool m_isSet;
118 uint8 m_affectsLength;
119 uint8* m_affects;
120 bool m_affectsAll;
121 bool m_checkChange;
122 uint8 m_pollIntensity;
123 };
124
125} // namespace OpenZWave
126
127#endif
128
129
130
unsigned int uint32
Definition Defs.h:80
signed int int32
Definition Defs.h:79
unsigned char uint8
Definition Defs.h:74
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition Node.h:65
Ref()
Definition Ref.h:53
Provides a unique ID for a value reported by a Z-Wave device.
Definition ValueID.h:54
ValueType
Definition ValueID.h:86
ValueGenre
Definition ValueID.h:72
int VerifyRefreshedValue(void *_originalValue, void *_checkValue, void *_newValue, ValueID::ValueType _type, int _originalValueLength=0, int _checkValueLength=0, int _newValueLength=0)
Definition Value.cpp:562
static ValueID::ValueType GetTypeEnumFromName(char const *_name)
Definition Value.cpp:520
void OnValueChanged()
Definition Value.cpp:442
void SetLabel(string const &_label)
Definition Value.h:66
void SetPollIntensity(uint8 const &_intensity)
Definition Value.h:75
string const & GetUnits() const
Definition Value.h:68
uint8 const & GetPollIntensity() const
Definition Value.h:74
string const & GetLabel() const
Definition Value.h:65
virtual ~Value()
Definition Value.cpp:132
bool IsReadOnly() const
Definition Value.h:60
void SetCheckingChange(bool _check)
Definition Value.h:99
void OnValueRefreshed()
Definition Value.cpp:412
virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const *_valueElement)
Definition Value.cpp:146
virtual void WriteXML(TiXmlElement *_valueElement)
Definition Value.cpp:285
bool m_verifyChanges
Definition Value.h:108
Value(uint32 const _homeId, uint8 const _nodeId, ValueID::ValueGenre const _genre, uint8 const _commandClassId, uint8 const _instance, uint8 const _index, ValueID::ValueType const _type, string const &_label, string const &_units, bool const _readOnly, bool const _writeOnly, bool const _isset, uint8 const _pollIntensity)
Definition Value.cpp:71
time_t m_refreshTime
Definition Value.h:107
ValueID const & GetID() const
Definition Value.h:59
virtual bool SetFromString(string const &)
Definition Value.h:84
string const & GetHelp() const
Definition Value.h:71
bool IsWriteOnly() const
Definition Value.h:61
static ValueID::ValueGenre GetGenreEnumFromName(char const *_name)
Definition Value.cpp:483
bool IsSet() const
Definition Value.h:62
static char const * GetGenreNameFromEnum(ValueID::ValueGenre _genre)
Definition Value.cpp:508
friend class Driver
Definition Value.h:49
int32 GetMin() const
Definition Value.h:77
bool IsPolled() const
Definition Value.h:63
bool Set()
Definition Value.cpp:350
friend class ValueStore
Definition Value.h:50
Value()
Definition Value.cpp:110
static char const * GetTypeNameFromEnum(ValueID::ValueType _type)
Definition Value.cpp:545
int32 m_max
Definition Value.h:105
void SetHelp(string const &_help)
Definition Value.h:72
int32 GetMax() const
Definition Value.h:78
virtual string const GetAsString() const
Definition Value.h:83
int32 m_min
Definition Value.h:104
bool IsCheckingChange() const
Definition Value.h:98
void SetChangeVerified(bool _verify)
Definition Value.h:80
void SetUnits(string const &_units)
Definition Value.h:69
bool GetChangeVerified()
Definition Value.h:81
Definition Bitfield.h:35