Open Lighting Architecture: include/ola/rdm/ResponderHelper.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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>
31#include <ola/network/IPV4Address.h>
32#include <ola/network/Interface.h>
33#include <ola/rdm/NetworkManagerInterface.h>
34#include <ola/rdm/RDMCommand.h>
35#include <ola/rdm/ResponderPersonality.h>
36#include <ola/rdm/ResponderSensor.h>
37
38#include <string>
39#include <vector>
40
41namespace ola {
42namespace rdm {
43
48 class ResponderHelper {
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 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 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 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 RDMResponse *GetPersonality(
87 const RDMRequest *request,
88 const PersonalityManager *personality_manager,
89 uint8_t queued_message_count = 0);
90 static 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 RDMResponse *GetPersonalityDescription(
97 const RDMRequest *request,
98 const PersonalityManager *personality_manager,
99 uint8_t queued_message_count = 0);
100
101 static RDMResponse *GetSlotInfo(
102 const RDMRequest *request,
103 const PersonalityManager *personality_manager,
104 uint8_t queued_message_count = 0);
105
106 static RDMResponse *GetSlotDescription(
107 const RDMRequest *request,
108 const PersonalityManager *personality_manager,
109 uint8_t queued_message_count = 0);
110
111 static RDMResponse *GetSlotDefaultValues(
112 const RDMRequest *request,
113 const PersonalityManager *personality_manager,
114 uint8_t queued_message_count = 0);
115
116 static 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 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 RDMResponse *GetSensorDefinition(
128 const RDMRequest *request, const Sensors &sensor_list);
129
130 static RDMResponse *GetSensorValue(
131 const RDMRequest *request, const Sensors &sensor_list);
132 static RDMResponse *SetSensorValue(
133 const RDMRequest *request, const Sensors &sensor_list);
134
135 static RDMResponse *RecordSensor(
136 const RDMRequest *request, const Sensors &sensor_list);
137
138 static 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 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 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 RDMResponse *GetRealTimeClock(
166 const RDMRequest *request,
167 uint8_t queued_message_count = 0);
168
169 // E1.37-2 Helpers
170 static RDMResponse *GetListInterfaces(
171 const RDMRequest *request,
172 const NetworkManagerInterface *network_manager,
173 uint8_t queued_message_count = 0);
174
175 static RDMResponse *GetInterfaceLabel(
176 const RDMRequest *request,
177 const NetworkManagerInterface *network_manager,
178 uint8_t queued_message_count = 0);
179
180 static RDMResponse *GetInterfaceHardwareAddressType1(
181 const RDMRequest *request,
182 const NetworkManagerInterface *network_manager,
183 uint8_t queued_message_count = 0);
184
185 static RDMResponse *GetIPV4CurrentAddress(
186 const RDMRequest *request,
187 const NetworkManagerInterface *network_manager,
188 uint8_t queued_message_count = 0);
189
190 static RDMResponse *GetIPV4DefaultRoute(
191 const RDMRequest *request,
192 const NetworkManagerInterface *network_manager,
193 uint8_t queued_message_count = 0);
194
195 static RDMResponse *GetDNSHostname(
196 const RDMRequest *request,
197 const NetworkManagerInterface *network_manager,
198 uint8_t queued_message_count = 0);
199
200 static RDMResponse *GetDNSDomainName(
201 const RDMRequest *request,
202 const NetworkManagerInterface *network_manager,
203 uint8_t queued_message_count = 0);
204
205 static RDMResponse *GetDNSNameServer(
206 const RDMRequest *request,
207 const NetworkManagerInterface *network_manager,
208 uint8_t queued_message_count = 0);
209
210 static 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 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 RDMResponse *EmptyGetResponse(
223 const RDMRequest *request,
224 uint8_t queued_message_count = 0);
225 static RDMResponse *EmptySetResponse(
226 const RDMRequest *request,
227 uint8_t queued_message_count = 0);
228
229 static 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 RDMResponse *GetBoolValue(
235 const RDMRequest *request, bool value,
236 uint8_t queued_message_count = 0);
237 static RDMResponse *SetBoolValue(
238 const RDMRequest *request, bool *value,
239 uint8_t queued_message_count = 0);
240
241 static RDMResponse *GetUInt8Value(
242 const RDMRequest *request, uint8_t value,
243 uint8_t queued_message_count = 0);
244 static RDMResponse *GetUInt16Value(
245 const RDMRequest *request, uint16_t value,
246 uint8_t queued_message_count = 0);
247 static RDMResponse *GetUInt32Value(
248 const RDMRequest *request, uint32_t value,
249 uint8_t queued_message_count = 0);
250 static RDMResponse *SetUInt8Value(
251 const RDMRequest *request, uint8_t *value,
252 uint8_t queued_message_count = 0);
253 static RDMResponse *SetUInt16Value(
254 const RDMRequest *request, uint16_t *value,
255 uint8_t queued_message_count = 0);
256 static 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 static bool IsInterfaceIndexValid(uint32_t index);
275 static bool IsInterfaceIndexValidInterface(ola::network::Interface interface);
276};
277} // namespace rdm
278} // namespace ola
279#endif // INCLUDE_OLA_RDM_RESPONDERHELPER_H_
IPV4Address.h
Represents an IPv4 Address.
Macro.h
Helper macros.
PACK
#define PACK(__Declaration__)
Pack structures.
Definition Macro.h:171
NetworkManagerInterface.h
The interface for the NetworkManager.
RDMCommand.h
Classes that represent RDM commands.
ResponderSensor.h
Holds the information about a sensor.
ola::network::IPV4Address
Represents a IPv4 Address.
Definition IPV4Address.h:55
ola::network::Interface
Definition Interface.h:35
ola::rdm::PersonalityManager
Definition ResponderPersonality.h:91
ola::rdm::RDMRequest
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
ola::rdm::RDMResponse
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
ola::rdm::ResponderHelper
Definition ResponderHelper.h:48
ola::rdm::ResponderHelper::GetSensorDefinition
static RDMResponse * GetSensorDefinition(const RDMRequest *request, const Sensors &sensor_list)
Definition ResponderHelper.cpp:452
ola::rdm::ResponderHelper::GetRealTimeClock
static RDMResponse * GetRealTimeClock(const RDMRequest *request, uint8_t queued_message_count=0)
Definition ResponderHelper.cpp:593
ola::rdm::ResponderHelper::SetSensorValue
static RDMResponse * SetSensorValue(const RDMRequest *request, const Sensors &sensor_list)
Definition ResponderHelper.cpp:530
ola::rdm::ResponderHelper::SetDmxAddress
static RDMResponse * SetDmxAddress(const RDMRequest *request, const PersonalityManager *personality_manager, uint16_t *dmx_address, uint8_t queued_message_count=0)
Definition ResponderHelper.cpp:427
ola::rdm::ResponderHelper::GetSlotInfo
static RDMResponse * GetSlotInfo(const RDMRequest *request, const PersonalityManager *personality_manager, uint8_t queued_message_count=0)
Definition ResponderHelper.cpp:277
ola::rdm::ResponderHelper::RecordSensor
static RDMResponse * RecordSensor(const RDMRequest *request, const Sensors &sensor_list)
Definition ResponderHelper.cpp:568
ola::rdm::ResponderHelper::GetDmxAddress
static RDMResponse * GetDmxAddress(const RDMRequest *request, const PersonalityManager *personality_manager, uint16_t start_address, uint8_t queued_message_count=0)
Definition ResponderHelper.cpp:412
ola::rdm::ResponderHelper::GetSensorValue
static RDMResponse * GetSensorValue(const RDMRequest *request, const Sensors &sensor_list)
Definition ResponderHelper.cpp:501
ola::rdm::ResponderHelper::GetSlotDefaultValues
static RDMResponse * GetSlotDefaultValues(const RDMRequest *request, const PersonalityManager *personality_manager, uint8_t queued_message_count=0)
Definition ResponderHelper.cpp:370
ola::rdm::ResponderHelper::GetSlotDescription
static RDMResponse * GetSlotDescription(const RDMRequest *request, const PersonalityManager *personality_manager, uint8_t queued_message_count=0)
Definition ResponderHelper.cpp:320
ola::rdm::ResponderHelper::GetString
static RDMResponse * GetString(const RDMRequest *request, const std::string &value, uint8_t queued_message_count=0, uint8_t max_length=MAX_RDM_STRING_LENGTH)
Handle a request that returns a string.
Definition ResponderHelper.cpp:1060
ola::rdm
PLASA E1.20 Remote Device Management.
Definition AckTimerResponder.cpp:38
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44