Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DimmerSubDevice.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * DimmerSubDevice.h
17  * Copyright (C) 2013 Simon Newton
18  */
19 
28 #ifndef INCLUDE_OLA_RDM_DIMMERSUBDEVICE_H_
29 #define INCLUDE_OLA_RDM_DIMMERSUBDEVICE_H_
30 
32 #include <ola/rdm/RDMEnums.h>
33 #include <ola/rdm/ResponderOps.h>
34 #include <ola/rdm/ResponderPersonality.h>
35 #include <ola/rdm/UID.h>
36 
37 #include <string>
38 
39 namespace ola {
40 namespace rdm {
41 
46  public:
52  DimmerSubDevice(const UID &uid, uint16_t sub_device_number,
53  uint16_t total_sub_devices);
54 
55  void SendRDMRequest(const RDMRequest *request, RDMCallback *callback);
56 
57  uint16_t Footprint() const {
58  return m_personality_manager.ActivePersonalityFootprint();
59  }
60 
61  bool SetDmxStartAddress(uint16_t start_address);
62 
63  uint16_t GetDmxStartAddress() const {
64  return m_start_address;
65  }
66 
67  private:
71  class RDMOps : public ResponderOps<DimmerSubDevice> {
72  public:
73  static RDMOps *Instance() {
74  if (!instance)
75  instance = new RDMOps();
76  return instance;
77  }
78 
79  private:
80  RDMOps() : ResponderOps<DimmerSubDevice>(PARAM_HANDLERS, true) {}
81 
82  static RDMOps *instance;
83  };
84 
88  class Personalities : public PersonalityCollection {
89  public:
90  static const Personalities *Instance();
91 
92  private:
93  explicit Personalities(const PersonalityList &personalities) :
94  PersonalityCollection(personalities) {
95  }
96 
97  static Personalities *instance;
98  };
99 
100  const UID m_uid;
101  const uint16_t m_sub_device_number;
102  const uint16_t m_sub_device_count;
103  uint16_t m_start_address;
104  bool m_identify_on;
105  uint8_t m_identify_mode;
106  PersonalityManager m_personality_manager;
107 
108  const RDMResponse *GetDeviceInfo(const RDMRequest *request);
109  const RDMResponse *GetProductDetailList(const RDMRequest *request);
110  const RDMResponse *GetPersonality(const RDMRequest *request);
111  const RDMResponse *SetPersonality(const RDMRequest *request);
112  const RDMResponse *GetPersonalityDescription(const RDMRequest *request);
113  const RDMResponse *GetDmxStartAddress(const RDMRequest *request);
114  const RDMResponse *SetDmxStartAddress(const RDMRequest *request);
115  const RDMResponse *GetIdentify(const RDMRequest *request);
116  const RDMResponse *SetIdentify(const RDMRequest *request);
117  const RDMResponse *SetIdentifyMode(const RDMRequest *request);
118  const RDMResponse *GetIdentifyMode(const RDMRequest *request);
119  const RDMResponse *GetRealTimeClock(const RDMRequest *request);
120  const RDMResponse *GetManufacturerLabel(const RDMRequest *request);
121  const RDMResponse *GetDeviceLabel(const RDMRequest *request);
122  const RDMResponse *GetDeviceModelDescription(const RDMRequest *request);
123  const RDMResponse *GetSoftwareVersionLabel(const RDMRequest *request);
124 
125  static const ResponderOps<DimmerSubDevice>::ParamHandler PARAM_HANDLERS[];
126 };
127 } // namespace rdm
128 } // namespace ola
129 #endif // INCLUDE_OLA_RDM_DIMMERSUBDEVICE_H_