OpenZWave Library  1.6.0
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 {
38  class UserCode: public CommandClass
39  {
40  private:
41  enum UserCodeStatus
42  {
43  UserCode_Available = 0x00,
44  UserCode_Occupied = 0x01,
45  UserCode_Reserved = 0x02,
46  UserCode_NotAvailable = 0xfe,
47  UserCode_Unset = 0xff
48  };
49  struct UserCodeEntry {
50  UserCodeStatus status;
51  uint8 usercode[10];
52  };
53  public:
54  static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new UserCode( _homeId, _nodeId ); }
55  virtual ~UserCode(){}
56 
57  static uint8 const StaticGetCommandClassId(){ return 0x63; }
58  static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_USER_CODE"; }
59 
60  // From CommandClass
61  virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
62  virtual bool RequestValue( uint32 const _requestFlags, uint16 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
63  virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
64  virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
65  virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
66  virtual bool SetValue( Value const& _value );
67 
68  protected:
69  virtual void CreateVars( uint8 const _instance );
70 
71  private:
72  UserCode( uint32 const _homeId, uint8 const _nodeId );
73 
74  string CodeStatus( uint8 const _byte )
75  {
76  switch( _byte )
77  {
78  case UserCode_Available:
79  {
80  return "Available";
81  }
82  case UserCode_Occupied:
83  {
84  return "Occupied";
85  }
86  case UserCode_Reserved:
87  {
88  return "Reserved";
89  }
90  case UserCode_NotAvailable:
91  {
92  return "Not Available";
93  }
94  case UserCode_Unset:
95  {
96  return "Unset";
97  }
98  default:
99  {
100  return "Unknown";
101  }
102  }
103  }
104 
105  bool m_queryAll; // True while we are requesting all the user codes.
106  uint16 m_currentCode;
107  std::map<uint16, UserCodeEntry> m_userCode;
108  bool m_refreshUserCodes;
109  };
110 
111 } // namespace OpenZWave
112 
113 #endif
114 
115 
virtual bool RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: UserCode.cpp:341
virtual ~UserCode()
Definition: UserCode.h:55
Definition: Bitfield.h:34
MsgQueue
Definition: Driver.h:591
virtual void CreateVars(uint8 const _instance)
Definition: UserCode.cpp:685
static string const StaticGetCommandClassName()
Definition: UserCode.h:58
unsigned short uint16
Definition: Defs.h:92
Implements COMMAND_CLASS_USER_CODE (0x63), a Z-Wave device command class.
Definition: UserCode.h:38
virtual bool HandleMsg(uint8 const *_data, uint32 const _length, uint32 const _instance=1)
Definition: UserCode.cpp:426
static CommandClass * Create(uint32 const _homeId, uint8 const _nodeId)
Definition: UserCode.h:54
virtual bool SetValue(Value const &_value)
Definition: UserCode.cpp:542
virtual uint8 const GetCommandClassId() const
Definition: UserCode.h:63
Base class for all Z-Wave command classes.
Definition: CommandClass.h:55
unsigned int uint32
Definition: Defs.h:95
static uint8 const StaticGetCommandClassId()
Definition: UserCode.h:57
virtual bool RequestValue(uint32 const _requestFlags, uint16 const _index, uint8 const _instance, Driver::MsgQueue const _queue)
Definition: UserCode.cpp:371
virtual string const GetCommandClassName() const
Definition: UserCode.h:64
Base class for values associated with a node.
Definition: Value.h:48
unsigned char uint8
Definition: Defs.h:89