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