OpenZWave Library  1.6.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 ApplicationStatus;
59  friend class ManufacturerSpecificDB;
60  /* allow us to Stream a Notification */
61  //friend std::ostream &operator<<(std::ostream &os, const Notification &dt);
62 
63 
64  public:
73  {
74  Type_ValueAdded = 0,
102  Type_ControllerCommand,
106  Type_ManufacturerSpecificDBReady
107  };
108 
115  {
116  Code_MsgComplete = 0,
122  Code_Alive
123  };
124 
130  {
141  };
142 
148  NotificationType GetType()const{ return m_type; }
149 
154  uint32 GetHomeId()const{ return m_valueId.GetHomeId(); }
155 
160  uint8 GetNodeId()const{ return m_valueId.GetNodeId(); }
161 
166  ValueID const& GetValueID()const{ return m_valueId; }
167 
172  uint8 GetGroupIdx()const{ assert(Type_Group==m_type); return m_byte; }
173 
178  uint8 GetEvent()const{ assert((Type_NodeEvent==m_type) || (Type_ControllerCommand == m_type)); return m_event; }
179 
185  uint8 GetButtonId()const{ assert(Type_CreateButton==m_type || Type_DeleteButton==m_type || Type_ButtonOn==m_type || Type_ButtonOff==m_type); return m_byte; }
186 
192  DEPRECATED uint8 GetSceneId()const{ assert(Type_SceneEvent==m_type); return m_byte; }
193 
198  uint8 GetNotification()const{ assert((Type_Notification==m_type) || (Type_ControllerCommand == m_type)); return m_byte; }
199 
204  uint8 GetCommand()const{ assert(Type_ControllerCommand == m_type); return m_command; }
205 
210  uint8 GetByte()const{ return m_byte; }
211 
216  uint8 GetRetry()const{ assert((Type_UserAlerts == m_type) && (Alert_ApplicationStatus_Retry == m_useralerttype)); return m_byte; }
217 
222  string GetAsString()const;
223 
228  UserAlertNofification GetUserAlertType()const {return m_useralerttype;};
229 
234  string GetComPort()const { return m_comport; };
235 
236  private:
237  Notification( NotificationType _type ): m_type( _type ), m_byte(0), m_event(0), m_command(0), m_useralerttype(Alert_None) {}
238  ~Notification(){}
239 
240  void SetHomeAndNodeIds( uint32 const _homeId, uint8 const _nodeId ){ m_valueId = ValueID( _homeId, _nodeId ); }
241  void SetHomeNodeIdAndInstance ( uint32 const _homeId, uint8 const _nodeId, uint32 const _instance ){ m_valueId = ValueID( _homeId, _nodeId, _instance ); }
242  void SetValueId( ValueID const& _valueId ){ m_valueId = _valueId; }
243  void SetGroupIdx( uint8 const _groupIdx ){ assert(Type_Group==m_type); m_byte = _groupIdx; }
244  void SetEvent( uint8 const _event ){ assert(Type_NodeEvent==m_type || Type_ControllerCommand == m_type); m_event = _event; }
245  void SetSceneId( uint8 const _sceneId ){ assert(Type_SceneEvent==m_type); m_byte = _sceneId; }
246  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; }
247  void SetNotification( uint8 const _noteId ){ assert((Type_Notification==m_type) || (Type_ControllerCommand == m_type)); m_byte = _noteId; }
248  void SetUserAlertNofification(UserAlertNofification const alerttype){ assert(Type_UserAlerts==m_type); m_useralerttype = alerttype; }
249  void SetCommand( uint8 const _command ){ assert(Type_ControllerCommand == m_type); m_command = _command; }
250  void SetComPort( string comport) { assert(Type_DriverFailed == m_type); m_comport = comport; }
251  void SetRetry (uint8 const timeout) { assert(Type_UserAlerts == m_type); m_byte = timeout; }
252 
253  NotificationType m_type;
254  ValueID m_valueId;
255  uint8 m_byte;
256  uint8 m_event;
257  uint8 m_command;
258  UserAlertNofification m_useralerttype;
259  string m_comport;
260  };
261 
262 } //namespace OpenZWave
263 
264 std::ostream& operator<<(std::ostream &os, const OpenZWave::Notification &dt);
265 std::ostream& operator<<(std::ostream &os, const OpenZWave::Notification *dt);
266 
267 #endif //_Notification_H
268 
Implements COMMAND_CLASS_NO_OPERATION (0x00), a Z-Wave device command class.
Definition: NoOperation.h:38
Definition: Notification.h:131
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:51
Implements COMMAND_CLASS_MANUFACTURER_SPECIFIC (0x72), a Z-Wave device command class.
Definition: ManufacturerSpecific.h:39
Definition: Notification.h:89
UserAlertNofification GetUserAlertType() const
Definition: Notification.h:228
uint8 GetCommand() const
Definition: Notification.h:204
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:45
The main public interface to OpenZWave.
Definition: Manager.h:110
ValueID const & GetValueID() const
Definition: Notification.h:166
uint8 GetRetry() const
Definition: Notification.h:216
uint8 GetNodeId() const
Definition: Notification.h:160
Definition: Notification.h:84
#define DEPRECATED
Definition: Defs.h:62
uint32 GetHomeId() const
Definition: Notification.h:154
Definition: Notification.h:118
Definition: Notification.h:91
string GetComPort() const
Definition: Notification.h:234
Definition: Notification.h:80
Definition: Notification.h:100
Definition: Notification.h:81
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:72
UserAlertNofification
Definition: Notification.h:129
Definition: Notification.h:75
Definition: Notification.h:90
DEPRECATED uint8 GetSceneId() const
Definition: Notification.h:192
Definition: Notification.h:133
Definition: Notification.h:78
Definition: Notification.h:121
std::ostream & operator<<(std::ostream &os, const OpenZWave::Notification &dt)
Definition: Notification.cpp:324
NotificationType GetType() const
Definition: Notification.h:148
Definition: Notification.h:87
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:64
Implements COMMAND_CLASS_SCENEACTIVATION (0x2B), a Z-Wave device command class.
Definition: SceneActivation.h:41
Definition: Notification.h:135
unsigned int uint32
Definition: Defs.h:95
uint8 GetByte() const
Definition: Notification.h:210
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:49
Definition: Notification.h:94
Definition: Notification.h:104
uint8 GetButtonId() const
Definition: Notification.h:185
Definition: Notification.h:83
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:88
Definition: Notification.h:76
uint8 GetGroupIdx() const
Definition: Notification.h:172
uint8 GetNotification() const
Definition: Notification.h:198
Definition: Notification.h:79
NotificationCode
Definition: Notification.h:114
Definition: Notification.h:117
uint8 GetEvent() const
Definition: Notification.h:178
Base class for values associated with a node.
Definition: Value.h:48
Definition: Notification.h:105
Implements COMMAND_CLASS_NODE_NAMING (0x77), a Z-Wave device command class.
Definition: NodeNaming.h:54
Definition: Notification.h:120
Definition: Notification.h:119
Definition: Notification.h:101
Implements COMMAND_CLASS_BASIC (0x20), a Z-Wave device command class.
Definition: Basic.h:40
Implements COMMAND_CLASS_APPLICATION_STATUS (0x22), a Z-Wave device command class.
Definition: ApplicationStatus.h:38
Definition: Notification.h:93
Definition: Notification.h:92
unsigned char uint8
Definition: Defs.h:89