OpenZWave Library: WakeUp.h Source File

| OpenZWave Library 1.6.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>
32#include "command_classes/CommandClass.h"
33#include "Driver.h"
34#include "TimerThread.h"
35
36namespace OpenZWave
37{
38 class Msg;
39 class ValueInt;
40 class Mutex;
41
45 class WakeUp: public CommandClass, private Timer
46 {
47 public:
48 static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new WakeUp( _homeId, _nodeId ); }
49 virtual ~WakeUp();
50
51 static uint8 const StaticGetCommandClassId(){ return 0x84; }
52 static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_WAKE_UP"; }
53
54 void Init(); // Starts the process of requesting node state from a sleeping device.
55 void QueueMsg( Driver::MsgQueueItem const& _item );
56
58 void SendPending();
59
61 void SendNoMoreInfo(uint32 id);
62
63 bool IsAwake()const{ return m_awake; }
64 void SetAwake( bool _state );
65 void SetPollRequired(){ m_pollRequired = true; }
66
67 // From CommandClass
68 virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
69 virtual bool RequestValue( uint32 const _requestFlags, uint16 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
70 virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
71 virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
72 virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
73 virtual bool SetValue( Value const& _value );
74 virtual void SetVersion( uint8 const _version );
75
76 virtual uint8 GetMaxVersion(){ return 2; }
77
78 protected:
79 virtual void CreateVars( uint8 const _instance );
80
81 private:
82 WakeUp( uint32 const _homeId, uint8 const _nodeId );
83
84 Mutex* m_mutex; // Serialize access to the pending queue
85 list<Driver::MsgQueueItem> m_pendingQueue; // Messages waiting to be sent when the device wakes up
86 bool m_awake;
87 bool m_pollRequired;
88 };
89
90} // namespace OpenZWave
91
92#endif
93
94
CommandClass.h
uint16
unsigned short uint16
Definition: Defs.h:92
uint32
unsigned int uint32
Definition: Defs.h:95
uint8
unsigned char uint8
Definition: Defs.h:89
Driver.h
TimerThread.h
OpenZWave::CommandClass
Base class for all Z-Wave command classes.
Definition: CommandClass.h:56
OpenZWave::Driver::MsgQueue
MsgQueue
Definition: Driver.h:592
OpenZWave::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:41
OpenZWave::Timer
Timer SubClass for automatically registering/unregistering Timer Callbacks if the instance goes out o...
Definition: TimerThread.h:129
OpenZWave::Value
Base class for values associated with a node.
Definition: Value.h:49
OpenZWave::WakeUp
Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class.
Definition: WakeUp.h:46
OpenZWave::WakeUp::IsAwake
bool IsAwake() const
Definition: WakeUp.h:63
OpenZWave::WakeUp::SendNoMoreInfo
void SendNoMoreInfo(uint32 id)
Send a no more information message.
Definition: WakeUp.cpp:499
OpenZWave::WakeUp::~WakeUp
virtual ~WakeUp()
Definition: WakeUp.cpp:83
OpenZWave::WakeUp::SendPending
void SendPending()
Send all pending messages followed by a no more information message.
Definition: WakeUp.cpp:437
OpenZWave::WakeUp::StaticGetCommandClassId
static uint8 const StaticGetCommandClassId()
Definition: WakeUp.h:51
OpenZWave::WakeUp::GetCommandClassName
virtual string const GetCommandClassName() const
Definition: WakeUp.h:71
OpenZWave::WakeUp::Init
void Init()
Definition: WakeUp.cpp:107
OpenZWave::WakeUp::SetValue
virtual bool SetValue(Value const &_value)
Definition: WakeUp.cpp:289
OpenZWave::WakeUp::GetCommandClassId
virtual uint8 const GetCommandClassId() const
Definition: WakeUp.h:70
OpenZWave::WakeUp::SetAwake
void SetAwake(bool _state)
Definition: WakeUp.cpp:343
OpenZWave::WakeUp::RequestValue
virtual bool RequestValue(uint32 const _requestFlags, uint16 const _index, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: WakeUp.cpp:155
OpenZWave::WakeUp::StaticGetCommandClassName
static string const StaticGetCommandClassName()
Definition: WakeUp.h:52
OpenZWave::WakeUp::GetMaxVersion
virtual uint8 GetMaxVersion()
Definition: WakeUp.h:76
OpenZWave::WakeUp::SetPollRequired
void SetPollRequired()
Definition: WakeUp.h:65
OpenZWave::WakeUp::CreateVars
virtual void CreateVars(uint8 const _instance)
Definition: WakeUp.cpp:517
OpenZWave::WakeUp::QueueMsg
void QueueMsg(Driver::MsgQueueItem const &_item)
Definition: WakeUp.cpp:391
OpenZWave::WakeUp::SetVersion
virtual void SetVersion(uint8 const _version)
Definition: WakeUp.cpp:330
OpenZWave::WakeUp::HandleMsg
virtual bool HandleMsg(uint8 const *_data, uint32 const _length, uint32 const _instance=1)
Definition: WakeUp.cpp:201
OpenZWave::WakeUp::RequestState
virtual bool RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: WakeUp.cpp:124
OpenZWave::WakeUp::Create
static CommandClass * Create(uint32 const _homeId, uint8 const _nodeId)
Definition: WakeUp.h:48
OpenZWave
Definition: Bitfield.h:35