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 );
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
unsigned short uint16
Definition: Defs.h:92
unsigned int uint32
Definition: Defs.h:95
unsigned char uint8
Definition: Defs.h:89
Definition: Bitfield.h:37
BitSet value sent to/received from a node.
Definition: ValueBitSet.h:49
virtual string const GetAsBinaryString() const
Definition: ValueBitSet.cpp:87
virtual void WriteXML(TiXmlElement *_valueElement)
Definition: ValueBitSet.cpp:196
void SetSize(uint8 size)
Definition: ValueBitSet.cpp:396
string GetBitHelp(uint8 _idx)
Definition: ValueBitSet.cpp:327
bool SetBitHelp(uint8 _idx, string help)
Definition: ValueBitSet.cpp:339
bool ClearBit(uint8 const _idx)
Definition: ValueBitSet.cpp:286
uint32 GetBitMask() const
Definition: ValueBitSet.cpp:320
virtual ~ValueBitSet()
Definition: ValueBitSet.h:53
string GetBitLabel(uint8 _idx)
Definition: ValueBitSet.cpp:363
uint8 GetSize() const
Definition: ValueBitSet.cpp:390
virtual void ReadXML(uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId, TiXmlElement const *_valueElement)
Definition: ValueBitSet.cpp:121
bool SetBit(uint8 const _idx)
Definition: ValueBitSet.cpp:262
virtual string const GetAsString() const
Definition: ValueBitSet.cpp:78
ValueBitSet()
Definition: ValueBitSet.h:52
virtual bool SetFromString(string const &_value)
Definition: ValueBitSet.cpp:69
uint32 GetValue() const
Definition: ValueBitSet.cpp:97
bool GetBit(uint8 _idx) const
Definition: ValueBitSet.cpp:103
bool SetBitLabel(uint8 _idx, string label)
Definition: ValueBitSet.cpp:375
bool SetBitMask(uint32 _bitMask)
Definition: ValueBitSet.cpp:311
ValueGenre
Definition: ValueID.h:81
Base class for values associated with a node.
Definition: Value.h:49
void OnValueRefreshed()
Definition: Value.cpp:405
bool Set()
Definition: Value.cpp:343
Definition: Bitfield.h:35