OpenZWave Library: Group.h Source File

| OpenZWave Library 1.6.0

Group.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Group.h
4 //
5 // A set of associations in a Z-Wave device.
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 _Group_H
29 #define _Group_H
30
31 #include <string>
32 #include <vector>
33 #include <map>
34 #include "Defs.h"
35
36 class TiXmlElement;
37
38 namespace OpenZWave
39 {
40 class Node;
41
42 typedef struct InstanceAssociation {
43 uint8 m_nodeId;
44 uint8 m_instance;
45 } InstanceAssociation;
46
49 class Group
50 {
51 friend class Node;
52 friend class Association;
53 friend class MultiChannelAssociation;
54
55 //-----------------------------------------------------------------------------
56 // Construction
57 //-----------------------------------------------------------------------------
58 public:
59 Group( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _maxAssociations );
60 Group( uint32 const _homeId, uint8 const _nodeId, TiXmlElement const* _valueElement );
61 ~Group(){}
62
63 void WriteXML( TiXmlElement* _groupElement );
64
65 //-----------------------------------------------------------------------------
66 // Association methods (COMMAND_CLASS_ASSOCIATION)
67 //-----------------------------------------------------------------------------
68 public:
69 string const& GetLabel()const{ return m_label; }
70 uint32 GetAssociations( uint8** o_associations );
71 uint32 GetAssociations( InstanceAssociation** o_associations );
72 uint8 GetMaxAssociations()const{ return m_maxAssociations; }
73 uint8 GetIdx()const{ return m_groupIdx; }
74 bool Contains( uint8 const _nodeId, uint8 const _instance = 0x00 );
75 bool IsMultiInstance()const{ return m_multiInstance; }
76
77 private:
78 bool IsAuto()const{ return m_auto; }
79 void SetAuto( bool const _state ){ m_auto = _state; }
80 void CheckAuto();
81
82 void SetMultiInstance( bool const _state ){ m_multiInstance = _state; }
83
84 void AddAssociation( uint8 const _nodeId, uint8 const _instance = 0x00 );
85 void RemoveAssociation( uint8 const _nodeId, uint8 const _instance = 0x00 );
86 void OnGroupChanged( vector<uint8> const& _associations );
87 void OnGroupChanged( vector<InstanceAssociation> const& _associations );
88
89 //-----------------------------------------------------------------------------
90 // Command methods (COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION)
91 //-----------------------------------------------------------------------------
92 public:
93 bool ClearCommands( uint8 const _nodeId, uint8 const _instance = 0x00 );
94 bool AddCommand( uint8 const _nodeId, uint8 const _length, uint8 const* _data, uint8 const _instance = 0x00 );
95
96 private:
97 class AssociationCommand
98 {
99 public:
100 AssociationCommand( uint8 const _length, uint8 const* _data );
101 ~AssociationCommand();
102
103 private:
104 uint8* m_data;
105 };
106
107 typedef vector<AssociationCommand> AssociationCommandVec;
108 struct classcomp {
109 bool operator() (const InstanceAssociation& lhs, const InstanceAssociation& rhs) const
110 {return lhs.m_nodeId == rhs.m_nodeId ? lhs.m_instance < rhs.m_instance : lhs.m_nodeId < rhs.m_nodeId;}
111 };
112
113 //-----------------------------------------------------------------------------
114 // Member variables
115 //-----------------------------------------------------------------------------
116 private:
117 string m_label;
118 uint32 m_homeId;
119 uint8 m_nodeId;
120 uint8 m_groupIdx;
121 uint8 m_maxAssociations;
122 bool m_auto; // If true, the controller will automatically be associated with the group
123 bool m_multiInstance; // If true, the group is MultiInstance capable
124 map<InstanceAssociation,AssociationCommandVec,classcomp> m_associations;
125 };
126
127 } //namespace OpenZWave
128
129 #endif //_Group_H
130
OpenZWave::Association
Implements COMMAND_CLASS_ASSOCIATION (0x85), a Z-Wave device command class.
Definition: Association.h:39
OpenZWave
Definition: Bitfield.h:34
OpenZWave::Group::GetAssociations
uint32 GetAssociations(uint8 **o_associations)
Definition: Group.cpp:429
OpenZWave::InstanceAssociation::m_nodeId
uint8 m_nodeId
Definition: Group.h:43
OpenZWave::InstanceAssociation
struct OpenZWave::InstanceAssociation InstanceAssociation
OpenZWave::Group::IsMultiInstance
bool IsMultiInstance() const
Definition: Group.h:75
OpenZWave::Group::Group
Group(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _maxAssociations)
Definition: Group.cpp:50
OpenZWave::InstanceAssociation::m_instance
uint8 m_instance
Definition: Group.h:44
OpenZWave::Group::GetLabel
string const & GetLabel() const
Definition: Group.h:69
OpenZWave::InstanceAssociation
Definition: Group.h:42
OpenZWave::Node
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:65
Defs.h
OpenZWave::Group::Contains
bool Contains(uint8 const _nodeId, uint8 const _instance=0x00)
Definition: Group.cpp:237
OpenZWave::MultiChannelAssociation
Implements COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION (0x8E), a Z-Wave device command class.
Definition: MultiChannelAssociation.h:40
OpenZWave::Group::AddCommand
bool AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const *_data, uint8 const _instance=0x00)
Definition: Group.cpp:512
uint32
unsigned int uint32
Definition: Defs.h:95
OpenZWave::Group::~Group
~Group()
Definition: Group.h:61
OpenZWave::Group
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:49
OpenZWave::Group::ClearCommands
bool ClearCommands(uint8 const _nodeId, uint8 const _instance=0x00)
Definition: Group.cpp:490
OpenZWave::Group::GetMaxAssociations
uint8 GetMaxAssociations() const
Definition: Group.h:72
OpenZWave::Group::GetIdx
uint8 GetIdx() const
Definition: Group.h:73
OpenZWave::Group::WriteXML
void WriteXML(TiXmlElement *_groupElement)
Definition: Group.cpp:197
uint8
unsigned char uint8
Definition: Defs.h:89