Open Lighting Architecture  0.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResponderHelper.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  * ResponderHelper.h
17  * Copyright (C) 2013 Simon Newton
18  */
19 
27 #ifndef INCLUDE_OLA_RDM_RESPONDERHELPER_H_
28 #define INCLUDE_OLA_RDM_RESPONDERHELPER_H_
29 
30 #include <ola/base/Macro.h>
32 #include <ola/network/Interface.h>
34 #include <ola/rdm/RDMCommand.h>
35 #include <ola/rdm/ResponderPersonality.h>
37 
38 #include <string>
39 #include <vector>
40 
41 namespace ola {
42 namespace rdm {
43 
49  public:
50  // Request Parsing methods
51  static bool ExtractUInt8(const RDMRequest *request, uint8_t *output);
52  static bool ExtractUInt16(const RDMRequest *request, uint16_t *output);
53  static bool ExtractUInt32(const RDMRequest *request, uint32_t *output);
54 
55  // Response Generation methods
56  // E1.20 Helpers
57  static const RDMResponse *GetDeviceInfo(
58  const RDMRequest *request,
59  uint16_t device_model,
60  rdm_product_category product_category,
61  uint32_t software_version,
62  uint16_t dmx_footprint,
63  uint8_t current_personality,
64  uint8_t personality_count,
65  uint16_t dmx_start_address,
66  uint16_t sub_device_count,
67  uint8_t sensor_count,
68  uint8_t queued_message_count = 0);
69 
70  static const RDMResponse *GetDeviceInfo(
71  const RDMRequest *request,
72  uint16_t device_model,
73  rdm_product_category product_category,
74  uint32_t software_version,
75  const PersonalityManager *personality_manager,
76  uint16_t dmx_start_address,
77  uint16_t sub_device_count,
78  uint8_t sensor_count,
79  uint8_t queued_message_count = 0);
80 
81  static const RDMResponse *GetProductDetailList(
82  const RDMRequest *request,
83  const std::vector<rdm_product_detail> &product_details,
84  uint8_t queued_message_count = 0);
85 
86  static const RDMResponse *GetPersonality(
87  const RDMRequest *request,
88  const PersonalityManager *personality_manager,
89  uint8_t queued_message_count = 0);
90  static const RDMResponse *SetPersonality(
91  const RDMRequest *request,
92  PersonalityManager *personality_manager,
93  uint16_t start_address,
94  uint8_t queued_message_count = 0);
95 
96  static const RDMResponse *GetPersonalityDescription(
97  const RDMRequest *request,
98  const PersonalityManager *personality_manager,
99  uint8_t queued_message_count = 0);
100 
101  static const RDMResponse *GetSlotInfo(
102  const RDMRequest *request,
103  const PersonalityManager *personality_manager,
104  uint8_t queued_message_count = 0);
105 
106  static const RDMResponse *GetSlotDescription(
107  const RDMRequest *request,
108  const PersonalityManager *personality_manager,
109  uint8_t queued_message_count = 0);
110 
111  static const RDMResponse *GetSlotDefaultValues(
112  const RDMRequest *request,
113  const PersonalityManager *personality_manager,
114  uint8_t queued_message_count = 0);
115 
116  static const RDMResponse *GetDmxAddress(
117  const RDMRequest *request,
118  const PersonalityManager *personality_manager,
119  uint16_t start_address,
120  uint8_t queued_message_count = 0);
121  static const RDMResponse *SetDmxAddress(
122  const RDMRequest *request,
123  const PersonalityManager *personality_manager,
124  uint16_t *dmx_address,
125  uint8_t queued_message_count = 0);
126 
127  static const RDMResponse *GetSensorDefinition(
128  const RDMRequest *request, const Sensors &sensor_list);
129 
130  static const RDMResponse *GetSensorValue(
131  const RDMRequest *request, const Sensors &sensor_list);
132  static const RDMResponse *SetSensorValue(
133  const RDMRequest *request, const Sensors &sensor_list);
134 
135  static const RDMResponse *RecordSensor(
136  const RDMRequest *request, const Sensors &sensor_list);
137 
138  static const RDMResponse *GetParamDescription(
139  const RDMRequest *request,
140  uint16_t pid,
141  uint8_t pdl_size,
142  rdm_data_type data_type,
143  rdm_command_class command_class,
144  rdm_pid_unit unit,
145  rdm_pid_prefix prefix,
146  uint32_t min_value,
147  uint32_t default_value,
148  uint32_t max_value,
149  std::string description,
150  uint8_t queued_message_count = 0);
151  static const RDMResponse *GetASCIIParamDescription(
152  const RDMRequest *request,
153  uint16_t pid,
154  rdm_command_class command_class,
155  std::string description,
156  uint8_t queued_message_count = 0);
157  static const RDMResponse *GetBitFieldParamDescription(
158  const RDMRequest *request,
159  uint16_t pid,
160  uint8_t pdl_size,
161  rdm_command_class command_class,
162  std::string description,
163  uint8_t queued_message_count = 0);
164 
165  static const RDMResponse *GetRealTimeClock(
166  const RDMRequest *request,
167  uint8_t queued_message_count = 0);
168 
169  // E1.37-2 Helpers
170  static const RDMResponse *GetListInterfaces(
171  const RDMRequest *request,
172  const NetworkManagerInterface *network_manager,
173  uint8_t queued_message_count = 0);
174 
175  static const RDMResponse *GetInterfaceLabel(
176  const RDMRequest *request,
177  const NetworkManagerInterface *network_manager,
178  uint8_t queued_message_count = 0);
179 
180  static const RDMResponse *GetInterfaceHardwareAddressType1(
181  const RDMRequest *request,
182  const NetworkManagerInterface *network_manager,
183  uint8_t queued_message_count = 0);
184 
185  static const RDMResponse *GetIPV4CurrentAddress(
186  const RDMRequest *request,
187  const NetworkManagerInterface *network_manager,
188  uint8_t queued_message_count = 0);
189 
190  static const RDMResponse *GetIPV4DefaultRoute(
191  const RDMRequest *request,
192  const NetworkManagerInterface *network_manager,
193  uint8_t queued_message_count = 0);
194 
195  static const RDMResponse *GetDNSHostname(
196  const RDMRequest *request,
197  const NetworkManagerInterface *network_manager,
198  uint8_t queued_message_count = 0);
199 
200  static const RDMResponse *GetDNSDomainName(
201  const RDMRequest *request,
202  const NetworkManagerInterface *network_manager,
203  uint8_t queued_message_count = 0);
204 
205  static const RDMResponse *GetDNSNameServer(
206  const RDMRequest *request,
207  const NetworkManagerInterface *network_manager,
208  uint8_t queued_message_count = 0);
209 
210  static const RDMResponse *GetIPV4Address(
211  const RDMRequest *request,
212  const ola::network::IPV4Address &value,
213  uint8_t queued_message_count = 0);
214 
215  // Generic Helpers.
216  static const RDMResponse *GetString(
217  const RDMRequest *request,
218  const std::string &value,
219  uint8_t queued_message_count = 0,
220  uint8_t max_length = MAX_RDM_STRING_LENGTH);
221 
222  static const RDMResponse *EmptyGetResponse(
223  const RDMRequest *request,
224  uint8_t queued_message_count = 0);
225  static const RDMResponse *EmptySetResponse(
226  const RDMRequest *request,
227  uint8_t queued_message_count = 0);
228 
229  static const RDMResponse *SetString(
230  const RDMRequest *request,
231  std::string *value,
232  uint8_t queued_message_count = 0,
233  uint8_t max_length = MAX_RDM_STRING_LENGTH);
234  static const RDMResponse *GetBoolValue(
235  const RDMRequest *request, bool value,
236  uint8_t queued_message_count = 0);
237  static const RDMResponse *SetBoolValue(
238  const RDMRequest *request, bool *value,
239  uint8_t queued_message_count = 0);
240 
241  static const RDMResponse *GetUInt8Value(
242  const RDMRequest *request, uint8_t value,
243  uint8_t queued_message_count = 0);
244  static const RDMResponse *GetUInt16Value(
245  const RDMRequest *request, uint16_t value,
246  uint8_t queued_message_count = 0);
247  static const RDMResponse *GetUInt32Value(
248  const RDMRequest *request, uint32_t value,
249  uint8_t queued_message_count = 0);
250  static const RDMResponse *SetUInt8Value(
251  const RDMRequest *request, uint8_t *value,
252  uint8_t queued_message_count = 0);
253  static const RDMResponse *SetUInt16Value(
254  const RDMRequest *request, uint16_t *value,
255  uint8_t queued_message_count = 0);
256  static const RDMResponse *SetUInt32Value(
257  const RDMRequest *request, uint32_t *value,
258  uint8_t queued_message_count = 0);
259 
260  PACK(
261  struct sensor_value_s {
262  uint8_t sensor;
263  int16_t value;
264  int16_t lowest;
265  int16_t highest;
266  int16_t recorded;
267  });
268 
269  private:
270  static bool FindInterface(
271  const NetworkManagerInterface *network_manager,
272  ola::network::Interface *interface,
273  uint32_t index);
274 };
275 } // namespace rdm
276 } // namespace ola
277 #endif // INCLUDE_OLA_RDM_RESPONDERHELPER_H_