Value.h
Go to the documentation of this file.
//-----------------------------------------------------------------------------
//
// Value.h
//
// Base class for all OpenZWave Value Classes
//
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _Value_H
#define _Value_H
#include <string>
#ifdef __FreeBSD__
#include <time.h>
#endif
#include "Defs.h"
#include "platform/Ref.h"
#include "value_classes/ValueID.h"
class TiXmlElement;
namespace OpenZWave
{
class Node;
class Value: public Ref
{
friend class Driver;
friend class ValueStore;
public:
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 );
Value();
virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement );
virtual void WriteXML( TiXmlElement* _valueElement );
ValueID const& GetID()const{ return m_id; }
bool IsReadOnly()const{ return m_readOnly; }
bool IsWriteOnly()const{ return m_writeOnly; }
bool IsSet()const{ return m_isSet; }
bool IsPolled()const{ return m_pollIntensity != 0; }
string const& GetLabel()const{ return m_label; }
void SetLabel( string const& _label ){ m_label = _label; }
string const& GetUnits()const{ return m_units; }
void SetUnits( string const& _units ){ m_units = _units; }
string const& GetHelp()const{ return m_help; }
void SetHelp( string const& _help ){ m_help = _help; }
uint8 const& GetPollIntensity()const{ return m_pollIntensity; }
void SetPollIntensity( uint8 const& _intensity ){ m_pollIntensity = _intensity; }
int32 GetMin()const{ return m_min; }
int32 GetMax()const{ return m_max; }
void SetChangeVerified( bool _verify ){ m_verifyChanges = _verify; }
bool GetChangeVerified() { return m_verifyChanges; }
virtual string const GetAsString() const { return ""; }
virtual bool SetFromString( string const& ) { return false; }
bool Set(); // For the user to change a value in a device
// Helpers
static ValueID::ValueGenre GetGenreEnumFromName( char const* _name );
static char const* GetGenreNameFromEnum( ValueID::ValueGenre _genre );
static ValueID::ValueType GetTypeEnumFromName( char const* _name );
static char const* GetTypeNameFromEnum( ValueID::ValueType _type );
protected:
virtual ~Value();
// void SetIsSet() { m_isSet = true; } // TODO: consider removing this...it's never called since m_isSet is set in ValueChanged and ValueRefreshed
bool IsCheckingChange()const{ return m_checkChange; }
void SetCheckingChange( bool _check ) { m_checkChange = _check; }
void OnValueRefreshed(); // A value in a device has been refreshed
void OnValueChanged(); // The refreshed value actually changed
int VerifyRefreshedValue( void* _originalValue, void* _checkValue, void* _newValue, ValueID::ValueType _type, int _originalValueLength = 0, int _checkValueLength = 0, int _newValueLength = 0 );
int32 m_min;
int32 m_max;
time_t m_refreshTime; // time_t identifying when this value was last refreshed
bool m_verifyChanges; // if true, apparent changes are verified; otherwise, they're not
private:
ValueID m_id;
string m_label;
string m_units;
string m_help;
bool m_readOnly;
bool m_writeOnly;
bool m_isSet;
uint8 m_affectsLength;
uint8* m_affects;
bool m_affectsAll;
bool m_checkChange;
uint8 m_pollIntensity;
};
} // namespace OpenZWave
#endif
OpenZWave::Value::GetChangeVerified
bool GetChangeVerified()
Definition: Value.h:81
OpenZWave
Definition: Bitfield.h:34
OpenZWave::ValueStore
Container that holds all of the values associated with a given node.
Definition: ValueStore.h:43
OpenZWave::Value::GetLabel
string const & GetLabel() const
Definition: Value.h:65
OpenZWave::Value::SetCheckingChange
void SetCheckingChange(bool _check)
Definition: Value.h:99
OpenZWave::Value::WriteXML
virtual void WriteXML(TiXmlElement *_valueElement)
Definition: Value.cpp:285
OpenZWave::Value::GetUnits
string const & GetUnits() const
Definition: Value.h:68
OpenZWave::ValueID::ValueType
ValueType
Definition: ValueID.h:85
OpenZWave::Value::SetUnits
void SetUnits(string const &_units)
Definition: Value.h:69
OpenZWave::Value::SetChangeVerified
void SetChangeVerified(bool _verify)
Definition: Value.h:80
OpenZWave::Value::GetTypeNameFromEnum
static char const * GetTypeNameFromEnum(ValueID::ValueType _type)
Definition: Value.cpp:545
OpenZWave::Value::ReadXML
virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const *_valueElement)
Definition: Value.cpp:146
OpenZWave::Value::SetPollIntensity
void SetPollIntensity(uint8 const &_intensity)
Definition: Value.h:75
OpenZWave::Value::IsWriteOnly
bool IsWriteOnly() const
Definition: Value.h:61
OpenZWave::Value::IsCheckingChange
bool IsCheckingChange() const
Definition: Value.h:98
Defs.h
OpenZWave::Value::GetMax
int32 GetMax() const
Definition: Value.h:78
OpenZWave::Value::SetHelp
void SetHelp(string const &_help)
Definition: Value.h:72
OpenZWave::Value::GetTypeEnumFromName
static ValueID::ValueType GetTypeEnumFromName(char const *_name)
Definition: Value.cpp:520
ValueID.h
OpenZWave::Value::m_max
int32 m_max
Definition: Value.h:105
OpenZWave::Value::OnValueRefreshed
void OnValueRefreshed()
Definition: Value.cpp:412
OpenZWave::Value::m_verifyChanges
bool m_verifyChanges
Definition: Value.h:108
OpenZWave::Value::~Value
virtual ~Value()
Definition: Value.cpp:132
OpenZWave::Value::GetHelp
string const & GetHelp() const
Definition: Value.h:71
OpenZWave::Value::GetID
ValueID const & GetID() const
Definition: Value.h:59
OpenZWave::Driver
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:58
int32
signed int int32
Definition: Defs.h:79
uint32
unsigned int uint32
Definition: Defs.h:80
OpenZWave::Value::GetGenreEnumFromName
static ValueID::ValueGenre GetGenreEnumFromName(char const *_name)
Definition: Value.cpp:483
OpenZWave::Value::IsReadOnly
bool IsReadOnly() const
Definition: Value.h:60
OpenZWave::Value::VerifyRefreshedValue
int VerifyRefreshedValue(void *_originalValue, void *_checkValue, void *_newValue, ValueID::ValueType _type, int _originalValueLength=0, int _checkValueLength=0, int _newValueLength=0)
Definition: Value.cpp:562
OpenZWave::Value::IsSet
bool IsSet() const
Definition: Value.h:62
OpenZWave::ValueID
Provides a unique ID for a value reported by a Z-Wave device.
Definition: ValueID.h:53
Ref.h
OpenZWave::Value::m_min
int32 m_min
Definition: Value.h:104
OpenZWave::Value::m_refreshTime
time_t m_refreshTime
Definition: Value.h:107
OpenZWave::Value::GetMin
int32 GetMin() const
Definition: Value.h:77
OpenZWave::Ref
Definition: Ref.h:45
OpenZWave::Value::IsPolled
bool IsPolled() const
Definition: Value.h:63
OpenZWave::Value
Base class for values associated with a node.
Definition: Value.h:47
OpenZWave::Value::Value
Value()
Definition: Value.cpp:110
OpenZWave::Value::SetLabel
void SetLabel(string const &_label)
Definition: Value.h:66
OpenZWave::Value::SetFromString
virtual bool SetFromString(string const &)
Definition: Value.h:84
OpenZWave::Value::Set
bool Set()
Definition: Value.cpp:350
OpenZWave::Value::GetPollIntensity
uint8 const & GetPollIntensity() const
Definition: Value.h:74
OpenZWave::ValueID::ValueGenre
ValueGenre
Definition: ValueID.h:71
OpenZWave::Value::GetGenreNameFromEnum
static char const * GetGenreNameFromEnum(ValueID::ValueGenre _genre)
Definition: Value.cpp:508
OpenZWave::Value::GetAsString
virtual string const GetAsString() const
Definition: Value.h:83
OpenZWave::Value::OnValueChanged
void OnValueChanged()
Definition: Value.cpp:442
uint8
unsigned char uint8
Definition: Defs.h:74