Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AdvancedDimmerResponder.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * AdvancedDimmerResponder.h
17  * Copyright (C) 2013 Simon Newton
18  */
19 
28 #ifndef INCLUDE_OLA_RDM_ADVANCEDDIMMERRESPONDER_H_
29 #define INCLUDE_OLA_RDM_ADVANCEDDIMMERRESPONDER_H_
30 
31 #include <ola/base/Macro.h>
33 #include <ola/rdm/ResponderOps.h>
34 #include <ola/rdm/ResponderPersonality.h>
35 #include <ola/rdm/ResponderSettings.h>
36 #include <ola/rdm/UID.h>
37 #include <memory>
38 #include <string>
39 #include <vector>
40 
41 namespace ola {
42 namespace rdm {
43 
48  public:
49  explicit AdvancedDimmerResponder(const UID &uid);
50 
51  void SendRDMRequest(RDMRequest *request, RDMCallback *callback);
52 
53  private:
57  class RDMOps : public ResponderOps<AdvancedDimmerResponder> {
58  public:
59  static RDMOps *Instance() {
60  if (!instance)
61  instance = new RDMOps();
62  return instance;
63  }
64 
65  private:
66  RDMOps() : ResponderOps<AdvancedDimmerResponder>(PARAM_HANDLERS) {}
67  static RDMOps *instance;
68  };
69 
73  class Personalities : public PersonalityCollection {
74  public:
75  static const Personalities *Instance();
76 
77  private:
78  explicit Personalities(const PersonalityList &personalities) :
79  PersonalityCollection(personalities) {
80  }
81 
82  static Personalities *instance;
83  };
84 
85  class LockManager: public BasicSettingManager {
86  public:
87  explicit LockManager(const SettingCollection<BasicSetting> *settings)
88  : BasicSettingManager(settings) {
89  }
90 
91  RDMResponse *SetWithPin(const RDMRequest *request, uint16_t pin);
92  };
93 
94  PACK(
95  struct min_level_s {
96  uint16_t min_level_increasing;
97  uint16_t min_level_decreasing;
98  uint8_t on_below_min;
99  });
100 
101  PACK(
102  struct preset_playback_s {
103  uint16_t mode;
104  uint8_t level;
105  });
106 
107  PACK(
108  struct preset_status_s {
109  uint16_t scene;
110  uint16_t fade_up_time;
111  uint16_t fade_down_time;
112  uint16_t wait_time;
113  uint8_t programmed;
114  });
115 
116  PACK(
117  struct fail_mode_s {
118  uint16_t scene;
119  uint16_t delay;
120  uint16_t hold_time;
121  uint8_t level;
122  });
123 
124  typedef fail_mode_s startup_mode_s;
125 
126  /*
127  * Represents a preset
128  */
129  class Preset {
130  public:
131  Preset()
132  : fade_up_time(0),
133  fade_down_time(0),
134  wait_time(0),
135  programmed(PRESET_NOT_PROGRAMMED) {
136  }
137 
138  // Times are in 1/0ths of a second.
139  uint16_t fade_up_time;
140  uint16_t fade_down_time;
141  uint16_t wait_time;
142  rdm_preset_programmed_mode programmed;
143  };
144 
145  const UID m_uid;
146  bool m_identify_state;
147  uint16_t m_start_address;
148  uint16_t m_lock_pin;
149  uint16_t m_maximum_level;
150  min_level_s m_min_level;
151  rdm_identify_mode m_identify_mode;
152  uint8_t m_burn_in;
153  bool m_power_on_self_test;
154  PersonalityManager m_personality_manager;
155  BasicSettingManager m_curve_settings;
156  BasicSettingManager m_response_time_settings;
157  LockManager m_lock_settings;
158  SettingManager<FrequencyModulationSetting> m_frequency_settings;
159  std::vector<Preset> m_presets;
160  uint16_t m_preset_scene;
161  uint8_t m_preset_level;
162  rdm_preset_mergemode m_preset_mergemode;
163  fail_mode_s m_fail_mode;
164  startup_mode_s m_startup_mode;
165 
166  // Helpers
167  bool ValueBetweenRange(const uint16_t value,
168  const uint16_t lower,
169  const uint16_t upper);
170 
171  // Pids
172  RDMResponse *GetDeviceInfo(const RDMRequest *request);
173  RDMResponse *GetProductDetailList(const RDMRequest *request);
174  RDMResponse *GetDeviceModelDescription(const RDMRequest *request);
175  RDMResponse *GetManufacturerLabel(const RDMRequest *request);
176  RDMResponse *GetDeviceLabel(const RDMRequest *request);
177  RDMResponse *GetSoftwareVersionLabel(const RDMRequest *request);
178  RDMResponse *GetPersonality(const RDMRequest *request);
179  RDMResponse *SetPersonality(const RDMRequest *request);
180  RDMResponse *GetPersonalityDescription(const RDMRequest *request);
181  RDMResponse *GetDmxStartAddress(const RDMRequest *request);
182  RDMResponse *SetDmxStartAddress(const RDMRequest *request);
183  RDMResponse *GetDimmerInfo(const RDMRequest *request);
184  RDMResponse *GetMinimumLevel(const RDMRequest *request);
185  RDMResponse *SetMinimumLevel(const RDMRequest *request);
186  RDMResponse *GetMaximumLevel(const RDMRequest *request);
187  RDMResponse *SetMaximumLevel(const RDMRequest *request);
188  RDMResponse *GetIdentify(const RDMRequest *request);
189  RDMResponse *SetIdentify(const RDMRequest *request);
190  RDMResponse *SetCapturePreset(const RDMRequest *request);
191  RDMResponse *GetPresetPlayback(const RDMRequest *request);
192  RDMResponse *SetPresetPlayback(const RDMRequest *request);
193  RDMResponse *GetPresetStatus(const RDMRequest *request);
194  RDMResponse *SetPresetStatus(const RDMRequest *request);
195  RDMResponse *GetPresetMergeMode(const RDMRequest *request);
196  RDMResponse *SetPresetMergeMode(const RDMRequest *request);
197  RDMResponse *GetPresetInfo(const RDMRequest *request);
198  RDMResponse *GetFailMode(const RDMRequest *request);
199  RDMResponse *SetFailMode(const RDMRequest *request);
200  RDMResponse *GetStartUpMode(const RDMRequest *request);
201  RDMResponse *SetStartUpMode(const RDMRequest *request);
202  RDMResponse *GetIdentifyMode(const RDMRequest *request);
203  RDMResponse *SetIdentifyMode(const RDMRequest *request);
204  RDMResponse *GetBurnIn(const RDMRequest *request);
205  RDMResponse *SetBurnIn(const RDMRequest *request);
206  RDMResponse *GetCurve(const RDMRequest *request);
207  RDMResponse *SetCurve(const RDMRequest *request);
208  RDMResponse *GetCurveDescription(const RDMRequest *request);
209  RDMResponse *GetResponseTime(const RDMRequest *request);
210  RDMResponse *SetResponseTime(const RDMRequest *request);
211  RDMResponse *GetResponseTimeDescription(const RDMRequest *request);
212  RDMResponse *GetPWMFrequency(const RDMRequest *request);
213  RDMResponse *SetPWMFrequency(const RDMRequest *request);
214  RDMResponse *GetPWMFrequencyDescription(const RDMRequest *request);
215  RDMResponse *GetLockState(const RDMRequest *request);
216  RDMResponse *SetLockState(const RDMRequest *request);
217  RDMResponse *GetLockStateDescription(const RDMRequest *request);
218  RDMResponse *GetLockPin(const RDMRequest *request);
219  RDMResponse *SetLockPin(const RDMRequest *request);
220  RDMResponse *GetPowerOnSelfTest(const RDMRequest *request);
221  RDMResponse *SetPowerOnSelfTest(const RDMRequest *request);
222 
223  static const uint8_t DIMMER_RESOLUTION;
224  static const uint16_t LOWER_MIN_LEVEL;
225  static const uint16_t UPPER_MIN_LEVEL;
226  static const uint16_t LOWER_MAX_LEVEL;
227  static const uint16_t UPPER_MAX_LEVEL;
228  static const unsigned int PRESET_COUNT;
229 
230  static const uint16_t MIN_FAIL_DELAY_TIME;
231  static const uint16_t MIN_FAIL_HOLD_TIME;
232  static const uint16_t MAX_FAIL_DELAY_TIME;
233  static const uint16_t MAX_FAIL_HOLD_TIME;
234  static const uint16_t MIN_STARTUP_DELAY_TIME;
235  static const uint16_t MIN_STARTUP_HOLD_TIME;
236  static const uint16_t MAX_STARTUP_DELAY_TIME;
237  static const uint16_t MAX_STARTUP_HOLD_TIME;
238  static const uint16_t INFINITE_TIME;
239 
241  PARAM_HANDLERS[];
242  static const char* CURVES[];
243  static const char* RESPONSE_TIMES[];
244  static const char* LOCK_STATES[];
246  PWM_FREQUENCIES[];
247 
248  static const SettingCollection<BasicSetting> CurveSettings;
249  static const SettingCollection<BasicSetting> ResponseTimeSettings;
251  FrequencySettings;
252  static const SettingCollection<BasicSetting> LockSettings;
253 };
254 } // namespace rdm
255 } // namespace ola
256 #endif // INCLUDE_OLA_RDM_ADVANCEDDIMMERRESPONDER_H_
Definitions and Interfaces to implement an RDMController that sends a single message at a time...
Definition: ResponderPersonality.h:65
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition: RDMCommand.h:456
void SendRDMRequest(RDMRequest *request, RDMCallback *callback)
Send a RDM command.
Definition: AdvancedDimmerResponder.cpp:290
AdvancedDimmerResponder(const UID &uid)
Definition: AdvancedDimmerResponder.cpp:252
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:233
A RDM unique identifier (UID).
The constructor argument for the FrequencyModulationSetting.
Definition: ResponderSettings.h:106
A class which dispatches RDM requests to registered PID handlers.
Definition: ResponderOps.h:60
Definition: AdvancedDimmerResponder.h:47
Definition: ResponderPersonality.h:89
The base class for all 1 argument callbacks.
Definition: Callback.h:982
Helper macros.
The interface that can send RDMRequest.
Definition: RDMControllerInterface.h:73
A framework for building RDM responders.
Represents a RDM UID.
Definition: UID.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44