OpenZWave Library  1.2
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 
44  class Group
45  {
46  friend class Node;
47  friend class Association;
48 
49  //-----------------------------------------------------------------------------
50  // Construction
51  //-----------------------------------------------------------------------------
52  public:
53  Group( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _maxAssociations );
54  Group( uint32 const _homeId, uint8 const _nodeId, TiXmlElement const* _valueElement );
55  ~Group(){}
56 
57  void WriteXML( TiXmlElement* _groupElement );
58 
59  //-----------------------------------------------------------------------------
60  // Association methods (COMMAND_CLASS_ASSOCIATION)
61  //-----------------------------------------------------------------------------
62  public:
63  string const& GetLabel()const{ return m_label; }
64  uint32 GetAssociations( uint8** o_associations );
65  uint8 GetMaxAssociations()const{ return m_maxAssociations; }
66  uint8 GetIdx()const{ return m_groupIdx; }
67  bool Contains( uint8 const _nodeId );
68 
69  private:
70  bool IsAuto()const{ return m_auto; }
71  void SetAuto( bool const _state ){ m_auto = _state; }
72 
73  void AddAssociation( uint8 const _nodeId );
74  void RemoveAssociation( uint8 const _nodeId );
75  void OnGroupChanged( vector<uint8> const& _associations );
76 
77  //-----------------------------------------------------------------------------
78  // Command methods (COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION)
79  //-----------------------------------------------------------------------------
80  public:
81  bool ClearCommands( uint8 const _nodeId );
82  bool AddCommand( uint8 const _nodeId, uint8 const _length, uint8 const* _data );
83 
84  private:
85  class AssociationCommand
86  {
87  public:
88  AssociationCommand( uint8 const _length, uint8 const* _data );
89  ~AssociationCommand();
90 
91  private:
92  uint8 m_length;
93  uint8* m_data;
94  };
95 
96  typedef vector<AssociationCommand> AssociationCommandVec;
97 
98  //-----------------------------------------------------------------------------
99  // Member variables
100  //-----------------------------------------------------------------------------
101  private:
102  string m_label;
103  uint32 m_homeId;
104  uint8 m_nodeId;
105  uint8 m_groupIdx;
106  uint8 m_maxAssociations;
107  bool m_auto; // If true, the controller will automatically be associated with the group
108  map<uint8,AssociationCommandVec> m_associations;
109  };
110 
111 } //namespace OpenZWave
112 
113 #endif //_Group_H
114 
Implements COMMAND_CLASS_ASSOCIATION (0x85), a Z-Wave device command class.
Definition: Association.h:38
Definition: Bitfield.h:34
uint32 GetAssociations(uint8 **o_associations)
Definition: Group.cpp:330
Group(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _maxAssociations)
Definition: Group.cpp:48
string const & GetLabel() const
Definition: Group.h:63
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:63
bool AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const *_data)
Definition: Group.cpp:380
unsigned int uint32
Definition: Defs.h:69
~Group()
Definition: Group.h:55
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:44
bool Contains(uint8 const _nodeId)
Definition: Group.cpp:189
uint8 GetMaxAssociations() const
Definition: Group.h:65
uint8 GetIdx() const
Definition: Group.h:66
bool ClearCommands(uint8 const _nodeId)
Definition: Group.cpp:361
void WriteXML(TiXmlElement *_groupElement)
Definition: Group.cpp:158
unsigned char uint8
Definition: Defs.h:63