Open Lighting Architecture  0.9.2
 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(const RDMRequest *request,
230  std::string *value,
231  uint8_t queued_message_count = 0);
232  static const RDMResponse *GetBoolValue(
233  const RDMRequest *request, bool value,
234  uint8_t queued_message_count = 0);
235  static const RDMResponse *SetBoolValue(
236  const RDMRequest *request, bool *value,
237  uint8_t queued_message_count = 0);
238 
239  static const RDMResponse *GetUInt8Value(
240  const RDMRequest *request, uint8_t value,
241  uint8_t queued_message_count = 0);
242  static const RDMResponse *GetUInt16Value(
243  const RDMRequest *request, uint16_t value,
244  uint8_t queued_message_count = 0);
245  static const RDMResponse *GetUInt32Value(
246  const RDMRequest *request, uint32_t value,
247  uint8_t queued_message_count = 0);
248  static const RDMResponse *SetUInt8Value(
249  const RDMRequest *request, uint8_t *value,
250  uint8_t queued_message_count = 0);
251  static const RDMResponse *SetUInt16Value(
252  const RDMRequest *request, uint16_t *value,
253  uint8_t queued_message_count = 0);
254  static const RDMResponse *SetUInt32Value(
255  const RDMRequest *request, uint32_t *value,
256  uint8_t queued_message_count = 0);
257 
258  PACK(
259  struct sensor_value_s {
260  uint8_t sensor;
261  int16_t value;
262  int16_t lowest;
263  int16_t highest;
264  int16_t recorded;
265  });
266 
267  private:
268  static bool FindInterface(
269  const NetworkManagerInterface *network_manager,
270  ola::network::Interface *interface,
271  uint32_t index);
272 };
273 } // namespace rdm
274 } // namespace ola
275 #endif // INCLUDE_OLA_RDM_RESPONDERHELPER_H_