OpenZWave Library  1.5.0
WakeUp.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // WakeUp.h
4 //
5 // Implementation of the Z-Wave COMMAND_CLASS_WAKE_UP
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 _WakeUp_H
29 #define _WakeUp_H
30 
31 #include <list>
33 #include "Driver.h"
34 
35 namespace OpenZWave
36 {
37  class Msg;
38  class ValueInt;
39  class Mutex;
40 
43  class WakeUp: public CommandClass
44  {
45  public:
46  static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new WakeUp( _homeId, _nodeId ); }
47  virtual ~WakeUp();
48 
49  static uint8 const StaticGetCommandClassId(){ return 0x84; }
50  static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_WAKE_UP"; }
51 
52  void Init(); // Starts the process of requesting node state from a sleeping device.
53  void QueueMsg( Driver::MsgQueueItem const& _item );
54  void SendPending();
55  bool IsAwake()const{ return m_awake; }
56  void SetAwake( bool _state );
57  void SetPollRequired(){ m_pollRequired = true; }
58 
59  // From CommandClass
60  virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
61  virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
62  virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
63  virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
64  virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
65  virtual bool SetValue( Value const& _value );
66  virtual void SetVersion( uint8 const _version );
67 
68  virtual uint8 GetMaxVersion(){ return 2; }
69 
70  protected:
71  virtual void CreateVars( uint8 const _instance );
72 
73  private:
74  WakeUp( uint32 const _homeId, uint8 const _nodeId );
75 
76  Mutex* m_mutex; // Serialize access to the pending queue
77  list<Driver::MsgQueueItem> m_pendingQueue; // Messages waiting to be sent when the device wakes up
78  bool m_awake;
79  bool m_pollRequired;
80  };
81 
82 } // namespace OpenZWave
83 
84 #endif
85 
86 
virtual void SetVersion(uint8 const _version)
Definition: WakeUp.cpp:326
Definition: Bitfield.h:34
MsgQueue
Definition: Driver.h:565
bool IsAwake() const
Definition: WakeUp.h:55
virtual bool RequestValue(uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: WakeUp.cpp:151
virtual bool SetValue(Value const &_value)
Definition: WakeUp.cpp:285
virtual uint8 GetMaxVersion()
Definition: WakeUp.h:68
static uint8 const StaticGetCommandClassId()
Definition: WakeUp.h:49
void SendPending()
Definition: WakeUp.cpp:423
Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class.
Definition: WakeUp.h:43
virtual bool HandleMsg(uint8 const *_data, uint32 const _length, uint32 const _instance=1)
Definition: WakeUp.cpp:197
virtual void CreateVars(uint8 const _instance)
Definition: WakeUp.cpp:478
void Init()
Definition: WakeUp.cpp:103
virtual string const GetCommandClassName() const
Definition: WakeUp.h:63
Base class for all Z-Wave command classes.
Definition: CommandClass.h:46
void QueueMsg(Driver::MsgQueueItem const &_item)
Definition: WakeUp.cpp:377
static string const StaticGetCommandClassName()
Definition: WakeUp.h:50
void SetPollRequired()
Definition: WakeUp.h:57
unsigned int uint32
Definition: Defs.h:80
void SetAwake(bool _state)
Definition: WakeUp.cpp:339
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:39
static CommandClass * Create(uint32 const _homeId, uint8 const _nodeId)
Definition: WakeUp.h:46
Base class for values associated with a node.
Definition: Value.h:47
virtual bool RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: WakeUp.cpp:120
virtual uint8 const GetCommandClassId() const
Definition: WakeUp.h:62
virtual ~WakeUp()
Definition: WakeUp.cpp:79
unsigned char uint8
Definition: Defs.h:74