OpenZWave Library  1.2
UserCode.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // UserCode.h
4 //
5 // Implementation of the Z-Wave COMMAND_CLASS_USER_CODE
6 //
7 // Copyright (c) 2012 Greg Satz <satz@iranger.com>
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 _UserCode_H
29 #define _UserCode_H
30 
32 
33 namespace OpenZWave
34 {
37  class UserCode: public CommandClass
38  {
39  public:
41  {
47  };
48 
49  static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new UserCode( _homeId, _nodeId ); }
50  virtual ~UserCode(){}
51 
52  static uint8 const StaticGetCommandClassId(){ return 0x63; }
53  static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_USER_CODE"; }
54 
55  // From CommandClass
56  virtual void ReadXML( TiXmlElement const* _ccElement );
57  virtual void WriteXML( TiXmlElement* _ccElement );
58  virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
59  virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
60  virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
61  virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
62  virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
63  virtual bool SetValue( Value const& _value );
64 
65  protected:
66  virtual void CreateVars( uint8 const _instance );
67 
68  private:
69  UserCode( uint32 const _homeId, uint8 const _nodeId );
70 
71  string CodeStatus( uint8 const _byte )
72  {
73  switch( _byte )
74  {
75  case UserCode_Available:
76  {
77  return "Available";
78  }
79  case UserCode_Occupied:
80  {
81  return "Occupied";
82  }
83  case UserCode_Reserved:
84  {
85  return "Reserved";
86  }
88  {
89  return "Not Available";
90  }
91  case UserCode_Unset:
92  {
93  return "Unset";
94  }
95  default:
96  {
97  return "Unknown";
98  }
99  }
100  }
101 
102  bool m_queryAll; // True while we are requesting all the user codes.
103  uint8 m_currentCode;
104  uint8 m_userCodeCount;
105  uint8 m_userCodesStatus[256];
106  bool m_refreshUserCodes;
107  };
108 
109 } // namespace OpenZWave
110 
111 #endif
112 
113 
virtual bool RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: UserCode.cpp:117
virtual ~UserCode()
Definition: UserCode.h:50
Definition: Bitfield.h:34
MsgQueue
Definition: Driver.h:583
virtual void CreateVars(uint8 const _instance)
Definition: UserCode.cpp:345
static string const StaticGetCommandClassName()
Definition: UserCode.h:53
Implements COMMAND_CLASS_USER_CODE (0x63), a Z-Wave device command class.
Definition: UserCode.h:37
virtual bool HandleMsg(uint8 const *_data, uint32 const _length, uint32 const _instance=1)
Definition: UserCode.cpp:197
UserCodeStatus
Definition: UserCode.h:40
static CommandClass * Create(uint32 const _homeId, uint8 const _nodeId)
Definition: UserCode.h:49
virtual bool SetValue(Value const &_value)
Definition: UserCode.cpp:298
virtual uint8 const GetCommandClassId() const
Definition: UserCode.h:60
Base class for all Z-Wave command classes.
Definition: CommandClass.h:46
unsigned int uint32
Definition: Defs.h:69
static uint8 const StaticGetCommandClassId()
Definition: UserCode.h:52
virtual bool RequestValue(uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: UserCode.cpp:147
virtual string const GetCommandClassName() const
Definition: UserCode.h:61
Base class for values associated with a node.
Definition: Value.h:44
Definition: UserCode.h:46
virtual void ReadXML(TiXmlElement const *_ccElement)
Definition: UserCode.cpp:83
virtual void WriteXML(TiXmlElement *_ccElement)
Definition: UserCode.cpp:101
unsigned char uint8
Definition: Defs.h:63