OpenZWave Library: ValueBitSet.h Source File

| OpenZWave Library 1.6.0

Loading...
Searching...
No Matches
ValueBitSet.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// ValueBitSet.h
4//
5// Represents a Range of Bits
6//
7// Copyright (c) 2017 Justin Hammond <justin@dynam.ac>
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 _ValueBitSet_H
29#define _ValueBitSet_H
30
31#include <string>
32#include <map>
33#include "Defs.h"
34#include "value_classes/Value.h"
35#include "Bitfield.h"
36
37class TiXmlElement;
38
39namespace OpenZWave
40{
41 class Msg;
42 class Node;
43 class CommandClass;
44
48 class ValueBitSet: public Value
49 {
50 public:
51 ValueBitSet( 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, uint32 const _value, uint8 const _pollIntensity );
52 ValueBitSet(){}
53 virtual ~ValueBitSet(){}
54
55 bool Set( uint32 const _value );
56 uint32 GetValue() const;
57
58 bool SetBit( uint8 const _idx);
59 bool ClearBit(uint8 const _idx);
60 bool GetBit(uint8 _idx) const;
61
62 bool SetBitMask(uint32 _bitMask);
63 uint32 GetBitMask() const;
64
65 void OnValueRefreshed( uint32 const _value );
66
67 // From Value
68 virtual string const GetAsString() const;
69 virtual string const GetAsBinaryString() const;
70 virtual bool SetFromString( string const& _value );
71 virtual void ReadXML( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const* _valueElement );
72 virtual void WriteXML( TiXmlElement* _valueElement );
73
74 string GetBitHelp(uint8 _idx);
75 bool SetBitHelp(uint8 _idx, string help);
76 string GetBitLabel(uint8 _idx);
77 bool SetBitLabel(uint8 _idx, string label);
78
79 uint8 GetSize() const;
80 void SetSize(uint8 size);
81
82 private:
83 bool isValidBit(uint8 _idx) const;
84 Bitfield m_value; // the current index in the m_items vector
85 Bitfield m_valueCheck; // the previous value (used for double-checking spurious value reads)
86 Bitfield m_newValue; // a new value to be set on the appropriate device
87 uint32 m_BitMask; // Valid Bits
88 uint8 m_size; // Number of bytes in size
89 vector<int32> m_bits;
90 };
91
92} // namespace OpenZWave
93
94#endif
95
96
97
Bitfield.h
Defs.h
uint16
unsigned short uint16
Definition Defs.h:92
uint32
unsigned int uint32
Definition Defs.h:95
uint8
unsigned char uint8
Definition Defs.h:89
Value.h
OpenZWave::Bitfield
Definition Bitfield.h:37
OpenZWave::ValueBitSet
BitSet value sent to/received from a node.
Definition ValueBitSet.h:49
OpenZWave::ValueBitSet::GetAsBinaryString
virtual string const GetAsBinaryString() const
Definition ValueBitSet.cpp:87
OpenZWave::ValueBitSet::WriteXML
virtual void WriteXML(TiXmlElement *_valueElement)
Definition ValueBitSet.cpp:196
OpenZWave::ValueBitSet::SetSize
void SetSize(uint8 size)
Definition ValueBitSet.cpp:396
OpenZWave::ValueBitSet::GetBitHelp
string GetBitHelp(uint8 _idx)
Definition ValueBitSet.cpp:327
OpenZWave::ValueBitSet::SetBitHelp
bool SetBitHelp(uint8 _idx, string help)
Definition ValueBitSet.cpp:339
OpenZWave::ValueBitSet::ClearBit
bool ClearBit(uint8 const _idx)
Definition ValueBitSet.cpp:286
OpenZWave::ValueBitSet::GetBitMask
uint32 GetBitMask() const
Definition ValueBitSet.cpp:320
OpenZWave::ValueBitSet::~ValueBitSet
virtual ~ValueBitSet()
Definition ValueBitSet.h:53
OpenZWave::ValueBitSet::GetBitLabel
string GetBitLabel(uint8 _idx)
Definition ValueBitSet.cpp:363
OpenZWave::ValueBitSet::GetSize
uint8 GetSize() const
Definition ValueBitSet.cpp:390
OpenZWave::ValueBitSet::ReadXML
virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const *_valueElement)
Definition ValueBitSet.cpp:121
OpenZWave::ValueBitSet::SetBit
bool SetBit(uint8 const _idx)
Definition ValueBitSet.cpp:262
OpenZWave::ValueBitSet::GetAsString
virtual string const GetAsString() const
Definition ValueBitSet.cpp:78
OpenZWave::ValueBitSet::ValueBitSet
ValueBitSet()
Definition ValueBitSet.h:52
OpenZWave::ValueBitSet::SetFromString
virtual bool SetFromString(string const &_value)
Definition ValueBitSet.cpp:69
OpenZWave::ValueBitSet::GetValue
uint32 GetValue() const
Definition ValueBitSet.cpp:97
OpenZWave::ValueBitSet::GetBit
bool GetBit(uint8 _idx) const
Definition ValueBitSet.cpp:103
OpenZWave::ValueBitSet::SetBitLabel
bool SetBitLabel(uint8 _idx, string label)
Definition ValueBitSet.cpp:375
OpenZWave::ValueBitSet::SetBitMask
bool SetBitMask(uint32 _bitMask)
Definition ValueBitSet.cpp:311
OpenZWave::ValueID::ValueGenre
ValueGenre
Definition ValueID.h:81
OpenZWave::Value
Base class for values associated with a node.
Definition Value.h:49
OpenZWave::Value::OnValueRefreshed
void OnValueRefreshed()
Definition Value.cpp:405
OpenZWave::Value::Set
bool Set()
Definition Value.cpp:343
OpenZWave
Definition Bitfield.h:35