Open Lighting Architecture: ola/OlaCallbackClient.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
OlaCallbackClient.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 * OlaCallbackClient.h
17 * The legacy callback client.
18 * Copyright (C) 2010 Simon Newton
19 */
20
21#ifndef OLA_OLACALLBACKCLIENT_H_
22#define OLA_OLACALLBACKCLIENT_H_
23
24#include <ola/Callback.h>
25#include <ola/DmxBuffer.h>
26#include <ola/OlaDevice.h>
27#include <ola/client/Result.h>
28#include <ola/base/Macro.h>
29#include <ola/network/Socket.h>
30#include <ola/plugin_id.h>
31#include <ola/rdm/RDMAPIImplInterface.h>
32#include <ola/rdm/RDMCommand.h>
33#include <ola/rdm/UID.h>
34#include <ola/rdm/UIDSet.h>
35#include <ola/timecode/TimeCode.h>
36
37#include <memory>
38#include <string>
39#include <vector>
40
46
47namespace ola {
48
49namespace client {
50class OlaClientCore;
51}
52
53enum PatchAction {PATCH, UNPATCH};
54enum RegisterAction {REGISTER, UNREGISTER};
55enum PortDirection {INPUT_PORT, OUTPUT_PORT};
56
61 class OlaCallbackClient: public ola::rdm::RDMAPIImplInterface {
62 public:
63 struct PluginState {
64 std::string name;
65 bool enabled;
66 bool active;
67 std::string preferences_source;
68 std::vector<OlaPlugin> conflicting_plugins;
69 };
70
71 typedef SingleUseCallback2<void, const PluginState&, const std::string&>
72 PluginStateCallback;
73
74 typedef Callback3<void, unsigned int, const DmxBuffer&, const std::string&>
75 DMXCallback;
76
77 typedef Callback4<void, unsigned int, uint8_t, const DmxBuffer&,
78 const std::string&> DMXCallbackWithPriority;
79
80 explicit OlaCallbackClient(ola::io::ConnectedDescriptor *descriptor);
81 ~OlaCallbackClient();
82
83 bool Setup();
84 bool Stop();
85
86 void SetCloseHandler(ola::SingleUseCallback0<void> *callback);
87
88 // plugin methods
89 bool FetchPluginList(
90 SingleUseCallback2<void,
91 const std::vector<OlaPlugin>&,
92 const std::string&> *callback);
93
94 bool FetchPluginDescription(
95 ola_plugin_id plugin_id,
96 SingleUseCallback2<void,
97 const std::string&,
98 const std::string&> *callback);
99
100 bool FetchPluginState(ola_plugin_id plugin_id,
101 PluginStateCallback *callback);
102
103 // device methods
104 bool FetchDeviceInfo(
105 ola_plugin_id filter,
106 SingleUseCallback2<void,
107 const std::vector<OlaDevice>&,
108 const std::string&> *callback);
109
110 bool FetchCandidatePorts(
111 unsigned int universe_id,
112 SingleUseCallback2<void,
113 const std::vector<OlaDevice>&,
114 const std::string&> *callback);
115
116 bool FetchCandidatePorts(
117 SingleUseCallback2<void,
118 const std::vector<OlaDevice>&,
119 const std::string&> *callback);
120
121 bool ConfigureDevice(
122 unsigned int device_alias,
123 const std::string &msg,
124 SingleUseCallback2<void, const std::string&,
125 const std::string&> *callback);
126
127 // port methods
128 bool SetPortPriorityInherit(
129 unsigned int device_alias,
130 unsigned int port,
131 PortDirection port_direction,
132 SingleUseCallback1<void, const std::string&> *callback);
133 bool SetPortPriorityOverride(
134 unsigned int device_alias,
135 unsigned int port,
136 PortDirection port_direction,
137 uint8_t value,
138 SingleUseCallback1<void, const std::string&> *callback);
139
140 // universe methods
141 bool FetchUniverseList(
142 SingleUseCallback2<void,
143 const std::vector<OlaUniverse>&,
144 const std::string &> *callback);
145 bool FetchUniverseInfo(
146 unsigned int universe,
147 SingleUseCallback2<void, OlaUniverse&, const std::string &> *callback);
148 bool SetUniverseName(
149 unsigned int uni,
150 const std::string &name,
151 SingleUseCallback1<void, const std::string&> *callback);
152 bool SetUniverseMergeMode(
153 unsigned int uni,
154 OlaUniverse::merge_mode mode,
155 SingleUseCallback1<void, const std::string&> *callback);
156
157 // patching
158 bool Patch(
159 unsigned int device_alias,
160 unsigned int port,
161 ola::PortDirection port_direction,
162 ola::PatchAction action,
163 unsigned int uni,
164 SingleUseCallback1<void, const std::string&> *callback);
165
166 // DMX methods
167 void SetDmxCallback(
168 Callback3<void,
169 unsigned int,
170 const DmxBuffer&, const std::string&> *callback);
171
172 // Similar to above, but this also passes the source priority.
173 void SetDmxCallback(
174 Callback4<void,
175 unsigned int,
176 uint8_t,
177 const DmxBuffer&, const std::string&> *callback);
178
179 bool RegisterUniverse(
180 unsigned int universe,
181 ola::RegisterAction register_action,
182 SingleUseCallback1<void, const std::string&> *callback);
183 bool SendDmx(
184 unsigned int universe,
185 const DmxBuffer &data,
186 SingleUseCallback1<void, const std::string&> *callback);
187 bool SendDmx(
188 unsigned int universe,
189 const DmxBuffer &data,
190 Callback1<void, const std::string&> *callback);
191 // A version of SendDmx that doesn't wait for confirmation
192 bool SendDmx(unsigned int universe, const DmxBuffer &data);
193
194 bool FetchDmx(
195 unsigned int universe,
196 SingleUseCallback2<void, const DmxBuffer&,
197 const std::string&> *callback);
198
199 // rdm methods
200 bool FetchUIDList(
201 unsigned int universe,
202 SingleUseCallback2<void,
203 const ola::rdm::UIDSet&,
204 const std::string&> *callback);
205 bool RunDiscovery(
206 unsigned int universe,
207 bool full,
208 ola::SingleUseCallback2<void,
209 const ola::rdm::UIDSet&,
210 const std::string&> *callback);
211 bool SetSourceUID(const ola::rdm::UID &uid,
212 ola::SingleUseCallback1<void,
213 const std::string&> *callback);
214
215 bool RDMGet(ola::rdm::RDMAPIImplInterface::rdm_callback *callback,
216 unsigned int universe,
217 const ola::rdm::UID &uid,
218 uint16_t sub_device,
219 uint16_t pid,
220 const uint8_t *data,
221 unsigned int data_length);
222 bool RDMGet(ola::rdm::RDMAPIImplInterface::rdm_pid_callback *callback,
223 unsigned int universe,
224 const ola::rdm::UID &uid,
225 uint16_t sub_device,
226 uint16_t pid,
227 const uint8_t *data,
228 unsigned int data_length);
229 bool RDMSet(ola::rdm::RDMAPIImplInterface::rdm_callback *callback,
230 unsigned int universe,
231 const ola::rdm::UID &uid,
232 uint16_t sub_device,
233 uint16_t pid,
234 const uint8_t *data,
235 unsigned int data_length);
236 bool RDMSet(ola::rdm::RDMAPIImplInterface::rdm_pid_callback *callback,
237 unsigned int universe,
238 const ola::rdm::UID &uid,
239 uint16_t sub_device,
240 uint16_t pid,
241 const uint8_t *data,
242 unsigned int data_length);
243
244 // timecode
245 bool SendTimeCode(ola::SingleUseCallback1<void,
246 const std::string&> *callback,
247 const ola::timecode::TimeCode &timecode);
248
249 private:
250 std::auto_ptr<client::OlaClientCore> m_core;
251 std::auto_ptr<DMXCallback> m_dmx_callback;
252 std::auto_ptr<DMXCallbackWithPriority> m_priority_dmx_callback;
253
254 void HandlePluginList(
255 SingleUseCallback2<void, const std::vector<OlaPlugin>&,
256 const std::string&> *callback,
257 const client::Result &result,
258 const std::vector<OlaPlugin> &plugins);
259
260 void HandlePluginDescription(
261 SingleUseCallback2<void,
262 const std::string&,
263 const std::string&> *callback,
264 const client::Result &result,
265 const std::string &description);
266
267 void HandlePluginState(
268 PluginStateCallback *callback,
269 const client::Result &result,
270 const client::PluginState &state);
271
272 void HandleDeviceInfo(
273 SingleUseCallback2<void,
274 const std::vector<OlaDevice>&,
275 const std::string&> *callback,
276 const client::Result &result,
277 const std::vector<OlaDevice> &devices);
278
279 void HandleConfigureDevice(
280 SingleUseCallback2<void,
281 const std::string&,
282 const std::string&> *callback,
283 const client::Result &result,
284 const std::string &reply);
285
286 void HandleUniverseList(
287 SingleUseCallback2<void, const std::vector<OlaUniverse>&,
288 const std::string &> *callback,
289 const client::Result &result,
290 const std::vector<OlaUniverse> &universes);
291
292 void HandleUniverseInfo(
293 SingleUseCallback2<void, OlaUniverse&, const std::string&> *callback,
294 const client::Result &result,
295 const OlaUniverse &universe);
296
297 void HandleFetchDmx(
298 SingleUseCallback2<void,
299 const DmxBuffer&,
300 const std::string&> *callback,
301 const client::Result &result,
302 const client::DMXMetadata &metadata,
303 const DmxBuffer &data);
304
305 void HandleDiscovery(
306 ola::SingleUseCallback2<void,
307 const ola::rdm::UIDSet&,
308 const std::string&> *callback,
309 const client::Result &result,
310 const ola::rdm::UIDSet &uids);
311
312 void HandleSetCallback(
313 ola::SingleUseCallback1<void, const std::string&> *callback,
314 const client::Result &result);
315
316 void HandleRepeatableSetCallback(
317 ola::Callback1<void, const std::string&> *callback,
318 const client::Result &result);
319
320 void HandleDMX(const client::DMXMetadata &metadata,
321 const DmxBuffer &data);
322
323 void HandleRDMResponse(
324 ola::rdm::RDMAPIImplInterface::rdm_callback *callback,
325 const client::Result &result,
326 const client::RDMMetadata &metadata,
327 const ola::rdm::RDMResponse *response);
328
329 void HandleRDMResponseWithPid(
330 ola::rdm::RDMAPIImplInterface::rdm_pid_callback *callback,
331 const client::Result &result,
332 const client::RDMMetadata &metadata,
333 const ola::rdm::RDMResponse *response);
334
335 void GetResponseStatusAndData(
336 const client::Result &result,
337 ola::rdm::rdm_response_code response_code,
338 const ola::rdm::RDMResponse *response,
339 rdm::ResponseStatus *response_status,
340 std::string *data);
341
342 void GetParamFromReply(
343 const std::string &message_type,
344 const ola::rdm::RDMResponse *response,
345 ola::rdm::ResponseStatus *new_status);
346
347 OlaCallbackClient(const OlaCallbackClient &) = delete;
348 const OlaCallbackClient &operator=(const OlaCallbackClient &) = delete;
349};
350} // namespace ola
351#endif // OLA_OLACALLBACKCLIENT_H_
Callback.h
DmxBuffer.h
A class used to hold a single universe of DMX data.
Macro.h
Helper macros.
OlaDevice.h
RDMAPIImplInterface.h
The interface for an RDM API Implementation.
RDMCommand.h
Classes that represent RDM commands.
Result.h
The Result object passed to OLA client callbacks.
UID.h
A RDM unique identifier (UID).
UIDSet.h
A set of UIDs.
ola::Callback1
A 1 argument callback which can be called multiple times.
Definition Callback.h:992
ola::Callback3
A 3 argument callback which can be called multiple times.
Definition Callback.h:2838
ola::Callback4
A 4 argument callback which can be called multiple times.
Definition Callback.h:3821
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::SingleUseCallback0
A 0 argument callback which deletes itself after it's run.
Definition Callback.h:141
ola::SingleUseCallback1
A 1 argument callback which deletes itself after it's run.
Definition Callback.h:1004
ola::SingleUseCallback2
A 2 argument callback which deletes itself after it's run.
Definition Callback.h:1907
ola::client::OlaClientCore
The low level C++ API to olad. Clients shouldn't use this directly. Instead use ola::client::OlaClien...
Definition OlaClientCore.h:56
ola::client::OlaUniverse
Represents a universe.
Definition ClientTypes.h:264
ola::client::Result
Indicates the result of a OLA API call.
Definition Result.h:52
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::rdm::RDMAPIImplInterface
This is the interface for an RDMAPI implementation.
Definition RDMAPIImplInterface.h:83
ola::rdm::RDMResponse
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
ola::rdm::ResponseStatus
Represents the state of a response and/or any error codes.
Definition RDMAPIImplInterface.h:51
ola::rdm::UID
Represents a RDM UID.
Definition UID.h:57
ola::rdm::UIDSet
Represents a set of RDM UIDs.
Definition UIDSet.h:48
ola::timecode::TimeCode
Definition TimeCode.h:33
ola::client
OLA C++ API.
ola::rdm::rdm_response_code
RDMStatusCode rdm_response_code
Definition RDMResponseCodes.h:71
ola::timecode
Timecode.
Definition TimeCode.cpp:30
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::OlaCallbackClient::PluginState
Definition OlaCallbackClient.h:63
ola::client::DMXMetadata
Metadata that accompanies DMX packets.
Definition ClientTypes.h:311
ola::client::PluginState
The state of a plugin. This information can be used to detect conflicts between plugins.
Definition ClientTypes.h:93
ola::client::RDMMetadata
Metadata that accompanies RDM Responses.
Definition ClientTypes.h:332