OpenZWave Library  1.5.0
Notification.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Notification.h
4 //
5 // Contains details of a Z-Wave event reported to the user
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 _Notification_H
29 #define _Notification_H
30 
31 #include <iostream>
32 
33 #include "Defs.h"
34 #include "value_classes/ValueID.h"
35 
36 namespace OpenZWave
37 {
45  {
46  friend class Manager;
47  friend class Driver;
48  friend class Node;
49  friend class Group;
50  friend class Value;
51  friend class ValueStore;
52  friend class Basic;
53  friend class ManufacturerSpecific;
54  friend class NodeNaming;
55  friend class NoOperation;
56  friend class SceneActivation;
57  friend class WakeUp;
58  friend class ManufacturerSpecificDB;
59  /* allow us to Stream a Notification */
60  //friend std::ostream &operator<<(std::ostream &os, const Notification &dt);
61 
62 
63  public:
72  {
73  Type_ValueAdded = 0,
101  Type_ControllerCommand,
105  Type_ManufacturerSpecificDBReady
106  };
107 
114  {
115  Code_MsgComplete = 0,
121  Code_Alive
122  };
123 
129  {
136  Alert_UnsupportedController
137  };
138 
144  NotificationType GetType()const{ return m_type; }
145 
150  uint32 GetHomeId()const{ return m_valueId.GetHomeId(); }
151 
156  uint8 GetNodeId()const{ return m_valueId.GetNodeId(); }
157 
162  ValueID const& GetValueID()const{ return m_valueId; }
163 
168  uint8 GetGroupIdx()const{ assert(Type_Group==m_type); return m_byte; }
169 
174  uint8 GetEvent()const{ assert((Type_NodeEvent==m_type) || (Type_ControllerCommand == m_type)); return m_event; }
175 
181  uint8 GetButtonId()const{ assert(Type_CreateButton==m_type || Type_DeleteButton==m_type || Type_ButtonOn==m_type || Type_ButtonOff==m_type); return m_byte; }
182 
187  uint8 GetSceneId()const{ assert(Type_SceneEvent==m_type); return m_byte; }
188 
193  uint8 GetNotification()const{ assert((Type_Notification==m_type) || (Type_ControllerCommand == m_type)); return m_byte; }
194 
199  uint8 GetCommand()const{ assert(Type_ControllerCommand == m_type); return m_command; }
200 
205  uint8 GetByte()const{ return m_byte; }
206 
211  string GetAsString()const;
212 
217  UserAlertNofification GetUserAlertType()const {return m_useralerttype;};
218 
223  string GetComPort()const { return m_comport; };
224 
225  private:
226  Notification( NotificationType _type ): m_type( _type ), m_byte(0), m_event(0), m_command(0), m_useralerttype(Alert_None) {}
227  ~Notification(){}
228 
229  void SetHomeAndNodeIds( uint32 const _homeId, uint8 const _nodeId ){ m_valueId = ValueID( _homeId, _nodeId ); }
230  void SetHomeNodeIdAndInstance ( uint32 const _homeId, uint8 const _nodeId, uint32 const _instance ){ m_valueId = ValueID( _homeId, _nodeId, _instance ); }
231  void SetValueId( ValueID const& _valueId ){ m_valueId = _valueId; }
232  void SetGroupIdx( uint8 const _groupIdx ){ assert(Type_Group==m_type); m_byte = _groupIdx; }
233  void SetEvent( uint8 const _event ){ assert(Type_NodeEvent==m_type || Type_ControllerCommand == m_type); m_event = _event; }
234  void SetSceneId( uint8 const _sceneId ){ assert(Type_SceneEvent==m_type); m_byte = _sceneId; }
235  void SetButtonId( uint8 const _buttonId ){ assert(Type_CreateButton==m_type||Type_DeleteButton==m_type||Type_ButtonOn==m_type||Type_ButtonOff==m_type); m_byte = _buttonId; }
236  void SetNotification( uint8 const _noteId ){ assert((Type_Notification==m_type) || (Type_ControllerCommand == m_type)); m_byte = _noteId; }
237  void SetUserAlertNofification(UserAlertNofification const alerttype){ assert(Type_UserAlerts==m_type); m_useralerttype = alerttype; }
238  void SetCommand( uint8 const _command ){ assert(Type_ControllerCommand == m_type); m_command = _command; }
239  void SetComPort( string comport) { assert(Type_DriverFailed == m_type); m_comport = comport; }
240 
241  NotificationType m_type;
242  ValueID m_valueId;
243  uint8 m_byte;
244  uint8 m_event;
245  uint8 m_command;
246  UserAlertNofification m_useralerttype;
247  string m_comport;
248  };
249 
250 } //namespace OpenZWave
251 
252 std::ostream& operator<<(std::ostream &os, const OpenZWave::Notification &dt);
253 std::ostream& operator<<(std::ostream &os, const OpenZWave::Notification *dt);
254 
255 #endif //_Notification_H
256 
Implements COMMAND_CLASS_NO_OPERATION (0x00), a Z-Wave device command class.
Definition: NoOperation.h:38
Definition: Notification.h:130
Definition: Bitfield.h:34
Container that holds all of the values associated with a given node.
Definition: ValueStore.h:44
#define OPENZWAVE_EXPORT
Definition: Defs.h:52
Implements COMMAND_CLASS_MANUFACTURER_SPECIFIC (0x72), a Z-Wave device command class.
Definition: ManufacturerSpecific.h:39
Definition: Notification.h:88
UserAlertNofification GetUserAlertType() const
Definition: Notification.h:217
uint8 GetCommand() const
Definition: Notification.h:199
The _ManufacturerSpecificDB class handles the Config File Database that we use to configure devices.
Definition: ManufacturerSpecificDB.h:106
Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class.
Definition: WakeUp.h:44
The main public interface to OpenZWave.
Definition: Manager.h:110
ValueID const & GetValueID() const
Definition: Notification.h:162
uint8 GetSceneId() const
Definition: Notification.h:187
uint8 GetNodeId() const
Definition: Notification.h:156
Definition: Notification.h:83
uint32 GetHomeId() const
Definition: Notification.h:150
Definition: Notification.h:117
Definition: Notification.h:90
string GetComPort() const
Definition: Notification.h:223
Definition: Notification.h:79
Definition: Notification.h:99
Definition: Notification.h:80
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:65
NotificationType
Definition: Notification.h:71
UserAlertNofification
Definition: Notification.h:128
Definition: Notification.h:74
Definition: Notification.h:89
Definition: Notification.h:132
Definition: Notification.h:77
Definition: Notification.h:120
std::ostream & operator<<(std::ostream &os, const OpenZWave::Notification &dt)
Definition: Notification.cpp:317
NotificationType GetType() const
Definition: Notification.h:144
Definition: Notification.h:86
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:63
Implements COMMAND_CLASS_SCENEACTIVATION (0x2B), a Z-Wave device command class.
Definition: SceneActivation.h:40
Definition: Notification.h:134
unsigned int uint32
Definition: Defs.h:96
uint8 GetByte() const
Definition: Notification.h:205
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:49
Definition: Notification.h:93
Definition: Notification.h:103
uint8 GetButtonId() const
Definition: Notification.h:181
Definition: Notification.h:82
Provides a container for data sent via the notification callback handler installed by a call to Manag...
Definition: Notification.h:44
Provides a unique ID for a value reported by a Z-Wave device.The ValueID is used to uniquely identify...
Definition: ValueID.h:62
Definition: Notification.h:87
Definition: Notification.h:75
uint8 GetGroupIdx() const
Definition: Notification.h:168
uint8 GetNotification() const
Definition: Notification.h:193
Definition: Notification.h:78
NotificationCode
Definition: Notification.h:113
Definition: Notification.h:116
uint8 GetEvent() const
Definition: Notification.h:174
Base class for values associated with a node.
Definition: Value.h:48
Definition: Notification.h:104
Implements COMMAND_CLASS_NODE_NAMING (0x77), a Z-Wave device command class.
Definition: NodeNaming.h:54
Definition: Notification.h:119
Definition: Notification.h:118
Definition: Notification.h:100
Implements COMMAND_CLASS_BASIC (0x20), a Z-Wave device command class.
Definition: Basic.h:40
Definition: Notification.h:92
Definition: Notification.h:91
unsigned char uint8
Definition: Defs.h:90