Open Lighting Architecture
 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 
31 #include <string>
33 #include "ola/rdm/RDMEnums.h"
34 #include "ola/rdm/ResponderOps.h"
35 #include "ola/rdm/ResponderPersonality.h"
36 #include "ola/rdm/UID.h"
37 
38 namespace ola {
39 namespace rdm {
40 
45  public:
51  DimmerSubDevice(const UID &uid, uint16_t sub_device_number,
52  uint16_t total_sub_devices);
53 
54  void SendRDMRequest(const RDMRequest *request, RDMCallback *callback);
55 
56  uint16_t Footprint() const {
57  return m_personality_manager.ActivePersonalityFootprint();
58  }
59 
60  bool SetDmxStartAddress(uint16_t start_address);
61 
62  uint16_t GetDmxStartAddress() const {
63  return m_start_address;
64  }
65 
66  private:
70  class RDMOps : public ResponderOps<DimmerSubDevice> {
71  public:
72  static RDMOps *Instance() {
73  if (!instance)
74  instance = new RDMOps();
75  return instance;
76  }
77 
78  private:
79  RDMOps() : ResponderOps<DimmerSubDevice>(PARAM_HANDLERS, true) {}
80 
81  static RDMOps *instance;
82  };
83 
87  class Personalities : public PersonalityCollection {
88  public:
89  static const Personalities *Instance();
90 
91  private:
92  explicit Personalities(const PersonalityList &personalities) :
93  PersonalityCollection(personalities) {
94  }
95 
96  static Personalities *instance;
97  };
98 
99  const UID m_uid;
100  const uint16_t m_sub_device_number;
101  const uint16_t m_sub_device_count;
102  uint16_t m_start_address;
103  bool m_identify_on;
104  uint8_t m_identify_mode;
105  PersonalityManager m_personality_manager;
106 
107  const RDMResponse *GetDeviceInfo(const RDMRequest *request);
108  const RDMResponse *GetProductDetailList(const RDMRequest *request);
109  const RDMResponse *GetPersonality(const RDMRequest *request);
110  const RDMResponse *SetPersonality(const RDMRequest *request);
111  const RDMResponse *GetPersonalityDescription(const RDMRequest *request);
112  const RDMResponse *GetDmxStartAddress(const RDMRequest *request);
113  const RDMResponse *SetDmxStartAddress(const RDMRequest *request);
114  const RDMResponse *GetIdentify(const RDMRequest *request);
115  const RDMResponse *SetIdentify(const RDMRequest *request);
116  const RDMResponse *SetIdentifyMode(const RDMRequest *request);
117  const RDMResponse *GetIdentifyMode(const RDMRequest *request);
118  const RDMResponse *GetRealTimeClock(const RDMRequest *request);
119  const RDMResponse *GetManufacturerLabel(const RDMRequest *request);
120  const RDMResponse *GetDeviceLabel(const RDMRequest *request);
121  const RDMResponse *GetDeviceModelDescription(const RDMRequest *request);
122  const RDMResponse *GetSoftwareVersionLabel(const RDMRequest *request);
123 
124  static const ResponderOps<DimmerSubDevice>::ParamHandler PARAM_HANDLERS[];
125 };
126 } // namespace rdm
127 } // namespace ola
128 #endif // INCLUDE_OLA_RDM_DIMMERSUBDEVICE_H_