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