OpenZWave Library  1.6.887
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  namespace Internal
41  {
42  namespace CC
43  {
44  class Association;
45  class MultiChannelAssociation;
46  }
47  }
48 
49  class Node;
50 
51  typedef struct InstanceAssociation
52  {
56 
59  class Group
60  {
61  friend class Node;
64 
65  //-----------------------------------------------------------------------------
66  // Construction
67  //-----------------------------------------------------------------------------
68  public:
69  Group(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _maxAssociations);
70  Group(uint32 const _homeId, uint8 const _nodeId, TiXmlElement const* _valueElement);
72  {
73  }
74 
75  void WriteXML(TiXmlElement* _groupElement);
76 
77  //-----------------------------------------------------------------------------
78  // Association methods (COMMAND_CLASS_ASSOCIATION)
79  //-----------------------------------------------------------------------------
80  public:
81  string const& GetLabel() const
82  {
83  return m_label;
84  }
85  uint32 GetAssociations(uint8** o_associations);
86  uint32 GetAssociations(InstanceAssociation** o_associations);
88  {
89  return m_maxAssociations;
90  }
91  uint8 GetIdx() const
92  {
93  return m_groupIdx;
94  }
95  bool Contains(uint8 const _nodeId, uint8 const _instance = 0x00);
96  bool IsMultiInstance() const
97  {
98  return m_multiInstance;
99  }
100 
101  private:
102  bool IsAuto() const
103  {
104  return m_auto;
105  }
106  void SetAuto(bool const _state)
107  {
108  m_auto = _state;
109  }
110  void CheckAuto();
111 
112  void SetMultiInstance(bool const _state)
113  {
114  m_multiInstance = _state;
115  }
116 
117  void AddAssociation(uint8 const _nodeId, uint8 const _instance = 0x00);
118  void RemoveAssociation(uint8 const _nodeId, uint8 const _instance = 0x00);
119  void OnGroupChanged(vector<uint8> const& _associations);
120  void OnGroupChanged(vector<InstanceAssociation> const& _associations);
121 
122  //-----------------------------------------------------------------------------
123  // Command methods (COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION)
124  //-----------------------------------------------------------------------------
125  public:
126  bool ClearCommands(uint8 const _nodeId, uint8 const _instance = 0x00);
127  bool AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const* _data, uint8 const _instance = 0x00);
128 
129  private:
130  class AssociationCommand
131  {
132  public:
133  AssociationCommand(uint8 const _length, uint8 const* _data);
134  ~AssociationCommand();
135 
136  private:
137  uint8* m_data;
138  };
139 
140  typedef vector<AssociationCommand> AssociationCommandVec;
141  struct classcomp
142  {
143  bool operator()(const InstanceAssociation& lhs, const InstanceAssociation& rhs) const
144  {
145  return lhs.m_nodeId == rhs.m_nodeId ? lhs.m_instance < rhs.m_instance : lhs.m_nodeId < rhs.m_nodeId;
146  }
147  };
148 
149  //-----------------------------------------------------------------------------
150  // Member variables
151  //-----------------------------------------------------------------------------
152  private:
153  string m_label;
154  uint32 m_homeId;
155  uint8 m_nodeId;
156  uint8 m_groupIdx;
157  uint8 m_maxAssociations;
158  bool m_auto; // If true, the controller will automatically be associated with the group
159  bool m_multiInstance; // If true, the group is MultiInstance capable
160  map<InstanceAssociation, AssociationCommandVec, classcomp> m_associations;
161  };
162 
163 } //namespace OpenZWave
164 
165 #endif //_Group_H
166 
Definition: Bitfield.cpp:30
uint32 GetAssociations(uint8 **o_associations)
Definition: Group.cpp:380
uint8 m_nodeId
Definition: Group.h:53
Implements COMMAND_CLASS_ASSOCIATION (0x85), a Z-Wave device command class.
Definition: Association.h:43
Implements COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION (0x8E), a Z-Wave device command class...
Definition: MultiChannelAssociation.h:45
struct OpenZWave::InstanceAssociation InstanceAssociation
bool IsMultiInstance() const
Definition: Group.h:96
Group(uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _maxAssociations)
Definition: Group.cpp:48
uint8 m_instance
Definition: Group.h:54
string const & GetLabel() const
Definition: Group.h:81
Definition: Group.h:51
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:81
bool Contains(uint8 const _nodeId, uint8 const _instance=0x00)
Definition: Group.cpp:206
bool AddCommand(uint8 const _nodeId, uint8 const _length, uint8 const *_data, uint8 const _instance=0x00)
Definition: Group.cpp:453
unsigned int uint32
Definition: Defs.h:92
~Group()
Definition: Group.h:71
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:59
bool ClearCommands(uint8 const _nodeId, uint8 const _instance=0x00)
Definition: Group.cpp:435
uint8 GetMaxAssociations() const
Definition: Group.h:87
uint8 GetIdx() const
Definition: Group.h:91
void WriteXML(TiXmlElement *_groupElement)
Definition: Group.cpp:169
unsigned char uint8
Definition: Defs.h:86