Open Lighting Architecture: ola/OlaClientCore.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
OlaClientCore.h
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 * OlaClientCore.h
17 * The OLA Client Core class
18 * Copyright (C) 2005 Simon Newton
19 */
20
21#ifndef OLA_OLACLIENTCORE_H_
22#define OLA_OLACLIENTCORE_H_
23
24#include <memory>
25#include <string>
26
27#include "common/protocol/Ola.pb.h"
28#include "common/protocol/OlaService.pb.h"
29#include "common/rpc/RpcChannel.h"
30#include "common/rpc/RpcController.h"
31#include "ola/Callback.h"
32#include "ola/DmxBuffer.h"
33#include "ola/client/CallbackTypes.h"
34#include "ola/client/ClientArgs.h"
35#include "ola/client/ClientTypes.h"
36#include "ola/base/Macro.h"
37#include "ola/dmx/SourcePriorities.h"
38#include "ola/io/Descriptor.h"
39#include "ola/plugin_id.h"
40#include "ola/rdm/UID.h"
41#include "ola/rdm/UIDSet.h"
42#include "ola/timecode/TimeCode.h"
43
44namespace ola {
45
46namespace rpc {
47class RpcSession;
48}
49
50namespace client {
51
56 class OlaClientCore: public ola::proto::OlaClientService {
57 public:
58 typedef ola::SingleUseCallback0<void> ClosedCallback;
59
60 explicit OlaClientCore(ola::io::ConnectedDescriptor *descriptor);
61 ~OlaClientCore();
62
63 bool Setup();
64 bool Stop();
65
66 void SetCloseHandler(ClosedCallback *callback);
67
75 void SetDMXCallback(RepeatableDMXCallback *callback);
76
81 void ReloadPlugins(SetCallback *callback);
82
87 void FetchPluginList(PluginListCallback *callback);
88
95 void FetchPluginDescription(ola_plugin_id plugin_id,
96 PluginDescriptionCallback *callback);
97
104 void FetchPluginState(ola_plugin_id plugin_id,
105 PluginStateCallback *callback);
106
113 void FetchDeviceInfo(ola_plugin_id plugin_filter,
114 DeviceInfoCallback *callback);
115
120 void FetchCandidatePorts(CandidatePortsCallback *callback);
121
129 void FetchCandidatePorts(unsigned int universe_id,
130 CandidatePortsCallback *callback);
131
138 void ConfigureDevice(unsigned int device_alias,
139 const std::string &msg,
140 ConfigureDeviceCallback *callback);
141
148 void SetPluginState(ola_plugin_id plugin_id,
149 bool state,
150 SetCallback *callback);
151
159 void SetPortPriorityInherit(unsigned int device_alias,
160 unsigned int port,
161 PortDirection port_direction,
162 SetCallback *callback);
163
172 void SetPortPriorityOverride(unsigned int device_alias,
173 unsigned int port,
174 PortDirection port_direction,
175 uint8_t value,
176 SetCallback *callback);
177
182 void FetchUniverseList(UniverseListCallback *callback);
183
189 void FetchUniverseInfo(unsigned int universe,
190 UniverseInfoCallback *callback);
191
198 void SetUniverseName(unsigned int universe,
199 const std::string &name,
200 SetCallback *callback);
201
208 void SetUniverseMergeMode(unsigned int universe,
209 OlaUniverse::merge_mode mode,
210 SetCallback *callback);
211
221 void Patch(unsigned int device_alias,
222 unsigned int port,
223 PortDirection port_direction,
224 PatchAction action,
225 unsigned int universe,
226 SetCallback *callback);
227
235 void RegisterUniverse(unsigned int universe,
236 RegisterAction register_action,
237 SetCallback *callback);
238
245 void SendDMX(unsigned int universe,
246 const DmxBuffer &data,
247 const SendDMXArgs &args);
248
254 void FetchDMX(unsigned int universe, DMXCallback *callback);
255
262 void RunDiscovery(unsigned int universe,
263 DiscoveryType discovery_type,
264 DiscoveryCallback *callback);
265
271 void SetSourceUID(const ola::rdm::UID &uid, SetCallback *callback);
272
283 void RDMGet(unsigned int universe,
284 const ola::rdm::UID &uid,
285 uint16_t sub_device,
286 uint16_t pid,
287 const uint8_t *data,
288 unsigned int data_length,
289 const SendRDMArgs& args);
290
301 void RDMSet(unsigned int universe,
302 const ola::rdm::UID &uid,
303 uint16_t sub_device,
304 uint16_t pid,
305 const uint8_t *data,
306 unsigned int data_length,
307 const SendRDMArgs& args);
308
314 void SendTimeCode(const ola::timecode::TimeCode &timecode,
315 SetCallback *callback);
316
320 void UpdateDmxData(ola::rpc::RpcController* controller,
321 const ola::proto::DmxData* request,
322 ola::proto::Ack* response,
323 CompletionCallback* done);
324
325 private:
326 ola::io::ConnectedDescriptor *m_descriptor;
327 std::auto_ptr<RepeatableDMXCallback> m_dmx_callback;
328 std::auto_ptr<ola::rpc::RpcChannel> m_channel;
329 std::auto_ptr<ola::proto::OlaServerService_Stub> m_stub;
330 int m_connected;
331
332 void ChannelClosed(ClosedCallback *callback, ola::rpc::RpcSession *session);
333
337 void HandlePluginList(ola::rpc::RpcController *controller_ptr,
338 ola::proto::PluginListReply *reply_ptr,
339 PluginListCallback *callback);
340
344 void HandlePluginDescription(ola::rpc::RpcController *controller,
345 ola::proto::PluginDescriptionReply *reply,
346 PluginDescriptionCallback *callback);
347
351 void HandlePluginState(ola::rpc::RpcController *controller,
352 ola::proto::PluginStateReply *reply,
353 PluginStateCallback *callback);
354
358 void HandleDeviceInfo(ola::rpc::RpcController *controller,
359 ola::proto::DeviceInfoReply *reply,
360 DeviceInfoCallback *callback);
361
365 void HandleDeviceConfig(ola::rpc::RpcController *controller,
366 ola::proto::DeviceConfigReply *reply,
367 ConfigureDeviceCallback *callback);
368
372 void HandleAck(ola::rpc::RpcController *controller,
373 ola::proto::Ack *reply,
374 SetCallback *callback);
375
379 void HandleGeneralAck(ola::rpc::RpcController *controller,
380 ola::proto::Ack *reply,
381 GeneralSetCallback *callback);
382
386 void HandleUniverseList(ola::rpc::RpcController *controller,
387 ola::proto::UniverseInfoReply *reply,
388 UniverseListCallback *callback);
389
393 void HandleUniverseInfo(ola::rpc::RpcController *controller,
394 ola::proto::UniverseInfoReply *reply,
395 UniverseInfoCallback *callback);
396
400 void HandleGetDmx(ola::rpc::RpcController *controller,
401 ola::proto::DmxData *reply,
402 DMXCallback *callback);
403
407 void HandleUIDList(ola::rpc::RpcController *controller_ptr,
408 ola::proto::UIDListReply *reply_ptr,
409 DiscoveryCallback *callback);
410
414 void HandleRDM(ola::rpc::RpcController *controller,
415 ola::proto::RDMResponse *reply,
416 RDMCallback *callback);
417
421 void GenericFetchCandidatePorts(unsigned int universe_id,
422 bool include_universe,
423 CandidatePortsCallback *callback);
424
428 void SendRDMCommand(bool is_set,
429 unsigned int universe,
430 const ola::rdm::UID &uid,
431 uint16_t sub_device,
432 uint16_t pid,
433 const uint8_t *data,
434 unsigned int data_length,
435 const SendRDMArgs &args);
436
440 ola::rdm::RDMResponse *BuildRDMResponse(
441 ola::proto::RDMResponse *reply,
442 ola::rdm::RDMStatusCode *status_code);
443
444 static const char NOT_CONNECTED_ERROR[];
445
446 OlaClientCore(const OlaClientCore &) = delete;
447 const OlaClientCore &operator=(const OlaClientCore &) = delete;
448};
449
450} // namespace client
451} // namespace ola
452#endif // OLA_OLACLIENTCORE_H_
Callback.h
CallbackTypes.h
The various callbacks used with the OLA Client.
ClientArgs.h
Types used as arguments for the OLA Client.
ClientTypes.h
Types used as return values from the OLA Client.
DmxBuffer.h
A class used to hold a single universe of DMX data.
Macro.h
Helper macros.
SourcePriorities.h
The constants for DMX source priorities.
UID.h
A RDM unique identifier (UID).
UIDSet.h
A set of UIDs.
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::client::OlaClientCore::SetUniverseName
void SetUniverseName(unsigned int universe, const std::string &name, SetCallback *callback)
Set the name of a universe.
Definition OlaClientCore.cpp:366
ola::client::OlaClientCore::FetchDMX
void FetchDMX(unsigned int universe, DMXCallback *callback)
Fetch the latest DMX data for a universe.
Definition OlaClientCore.cpp:496
ola::client::OlaClientCore::FetchUniverseList
void FetchUniverseList(UniverseListCallback *callback)
Request a list of universes.
Definition OlaClientCore.cpp:329
ola::client::OlaClientCore::RegisterUniverse
void RegisterUniverse(unsigned int universe, RegisterAction register_action, SetCallback *callback)
Register our interest in a universe. The callback set by SetDMXCallback() will be called when new DMX...
Definition OlaClientCore.cpp:442
ola::client::OlaClientCore::SetPortPriorityOverride
void SetPortPriorityOverride(unsigned int device_alias, unsigned int port, PortDirection port_direction, uint8_t value, SetCallback *callback)
Set the priority for a port to override mode.
Definition OlaClientCore.cpp:302
ola::client::OlaClientCore::UpdateDmxData
void UpdateDmxData(ola::rpc::RpcController *controller, const ola::proto::DmxData *request, ola::proto::Ack *response, CompletionCallback *done)
This is called by the channel when new DMX data arrives.
Definition OlaClientCore.cpp:622
ola::client::OlaClientCore::SendTimeCode
void SendTimeCode(const ola::timecode::TimeCode &timecode, SetCallback *callback)
Send TimeCode data.
Definition OlaClientCore.cpp:589
ola::client::OlaClientCore::FetchPluginDescription
void FetchPluginDescription(ola_plugin_id plugin_id, PluginDescriptionCallback *callback)
Fetch the description for a plugin.
Definition OlaClientCore.cpp:158
ola::client::OlaClientCore::RDMGet
void RDMGet(unsigned int universe, const ola::rdm::UID &uid, uint16_t sub_device, uint16_t pid, const uint8_t *data, unsigned int data_length, const SendRDMArgs &args)
Send an RDM Get Command.
Definition OlaClientCore.cpp:567
ola::client::OlaClientCore::ReloadPlugins
void ReloadPlugins(SetCallback *callback)
Trigger a plugin reload.
Definition OlaClientCore.cpp:124
ola::client::OlaClientCore::SetSourceUID
void SetSourceUID(const ola::rdm::UID &uid, SetCallback *callback)
Set the source UID for this client.
Definition OlaClientCore.cpp:546
ola::client::OlaClientCore::FetchUniverseInfo
void FetchUniverseInfo(unsigned int universe, UniverseInfoCallback *callback)
Fetch the information for a given universe.
Definition OlaClientCore.cpp:346
ola::client::OlaClientCore::FetchPluginState
void FetchPluginState(ola_plugin_id plugin_id, PluginStateCallback *callback)
Fetch the state of a plugin. This returns the state and the list of plugins this plugin conflicts wit...
Definition OlaClientCore.cpp:180
ola::client::OlaClientCore::SetDMXCallback
void SetDMXCallback(RepeatableDMXCallback *callback)
Set the callback to be run when new DMX data arrives. The DMX callback will be run when new data arri...
Definition OlaClientCore.cpp:120
ola::client::OlaClientCore::FetchDeviceInfo
void FetchDeviceInfo(ola_plugin_id plugin_filter, DeviceInfoCallback *callback)
Request a list of the available devices.
Definition OlaClientCore.cpp:201
ola::client::OlaClientCore::SetUniverseMergeMode
void SetUniverseMergeMode(unsigned int universe, OlaUniverse::merge_mode mode, SetCallback *callback)
Set the merge mode of a universe.
Definition OlaClientCore.cpp:388
ola::client::OlaClientCore::Patch
void Patch(unsigned int device_alias, unsigned int port, PortDirection port_direction, PatchAction action, unsigned int universe, SetCallback *callback)
Patch or unpatch a port from a universe.
Definition OlaClientCore.cpp:412
ola::client::OlaClientCore::FetchPluginList
void FetchPluginList(PluginListCallback *callback)
Fetch the list of plugins loaded.
Definition OlaClientCore.cpp:141
ola::client::OlaClientCore::SetPluginState
void SetPluginState(ola_plugin_id plugin_id, bool state, SetCallback *callback)
Set the state of a plugin.
Definition OlaClientCore.cpp:255
ola::client::OlaClientCore::ConfigureDevice
void ConfigureDevice(unsigned int device_alias, const std::string &msg, ConfigureDeviceCallback *callback)
Send a device config request.
Definition OlaClientCore.cpp:231
ola::client::OlaClientCore::RunDiscovery
void RunDiscovery(unsigned int universe, DiscoveryType discovery_type, DiscoveryCallback *callback)
Trigger discovery for a universe.
Definition OlaClientCore.cpp:516
ola::client::OlaClientCore::SetCloseHandler
void SetCloseHandler(ClosedCallback *callback)
Definition OlaClientCore.cpp:111
ola::client::OlaClientCore::SendDMX
void SendDMX(unsigned int universe, const DmxBuffer &data, const SendDMXArgs &args)
Send DMX data.
Definition OlaClientCore.cpp:467
ola::client::OlaClientCore::SetPortPriorityInherit
void SetPortPriorityInherit(unsigned int device_alias, unsigned int port, PortDirection port_direction, SetCallback *callback)
Set the priority for a port to inherit mode.
Definition OlaClientCore.cpp:277
ola::client::OlaClientCore::RDMSet
void RDMSet(unsigned int universe, const ola::rdm::UID &uid, uint16_t sub_device, uint16_t pid, const uint8_t *data, unsigned int data_length, const SendRDMArgs &args)
Send an RDM Set Command.
Definition OlaClientCore.cpp:578
ola::client::OlaClientCore::FetchCandidatePorts
void FetchCandidatePorts(CandidatePortsCallback *callback)
Definition OlaClientCore.cpp:227
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::rdm::RDMResponse
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
ola::rdm::UID
Represents a RDM UID.
Definition UID.h:57
ola::rpc::RpcController
A RpcController object is passed every time an RPC is invoked and is used to indicate the success or ...
Definition RpcController.h:42
ola::rpc::RpcSession
Represents the RPC session between a client and server.
Definition RpcSession.h:45
ola::timecode::TimeCode
Definition TimeCode.h:33
Descriptor.h
ola::client
OLA C++ API.
ola::client::PluginListCallback
SingleUseCallback2< void, const Result &, const std::vector< OlaPlugin > & > PluginListCallback
Invoked when OlaClient::FetchPluginList() completes.
Definition CallbackTypes.h:47
ola::client::DiscoveryCallback
SingleUseCallback2< void, const Result &, const ola::rdm::UIDSet & > DiscoveryCallback
Invoked when OlaClient::RunDiscovery() completes.
Definition CallbackTypes.h:124
ola::client::DiscoveryType
DiscoveryType
The type of discovery to run with OlaClient::RunDiscovery().
Definition ClientArgs.h:62
ola::client::UniverseInfoCallback
SingleUseCallback2< void, const Result &, const OlaUniverse & > UniverseInfoCallback
Invoked when OlaClient::FetchUniverseInfo() completes.
Definition CallbackTypes.h:107
ola::client::DeviceInfoCallback
SingleUseCallback2< void, const Result &, const std::vector< OlaDevice > & > DeviceInfoCallback
Invoked when OlaClient::FetchDeviceInfo() completes.
Definition CallbackTypes.h:71
ola::client::PluginDescriptionCallback
SingleUseCallback2< void, const Result &, const std::string & > PluginDescriptionCallback
Invoked when OlaClient::FetchPluginDescription() completes.
Definition CallbackTypes.h:55
ola::client::RDMCallback
SingleUseCallback3< void, const Result &, const RDMMetadata &, const ola::rdm::RDMResponse * > RDMCallback
Called when a RDM request completes. Used with OlaClient::RDMGet() and OlaClient::RDMSet().
Definition CallbackTypes.h:154
ola::client::PatchAction
PatchAction
The patch action, used with OlaClient::Patch().
Definition ClientArgs.h:38
ola::client::RepeatableDMXCallback
Callback2< void, const DMXMetadata &, const DmxBuffer & > RepeatableDMXCallback
Called when new DMX data arrives.
Definition CallbackTypes.h:142
ola::client::SetCallback
SingleUseCallback1< void, const Result & > SetCallback
Invoked when an operation completes.
Definition CallbackTypes.h:85
ola::client::PortDirection
PortDirection
The port direction.
Definition ClientArgs.h:54
ola::client::UniverseListCallback
SingleUseCallback2< void, const Result &, const std::vector< OlaUniverse > & > UniverseListCallback
Invoked when OlaClient::FetchUniverseList() completes.
Definition CallbackTypes.h:99
ola::client::RegisterAction
RegisterAction
The register action, used with OlaClient::RegisterUniverse().
Definition ClientArgs.h:46
ola::client::PluginStateCallback
SingleUseCallback2< void, const Result &, const PluginState & > PluginStateCallback
Invoked when OlaClient::FetchPluginState() completes.
Definition CallbackTypes.h:63
ola::client::CandidatePortsCallback
SingleUseCallback2< void, const Result &, const std::vector< OlaDevice > & > CandidatePortsCallback
Invoked when OlaClient::FetchDeviceInfo() completes.
Definition CallbackTypes.h:79
ola::client::GeneralSetCallback
BaseCallback1< void, const Result & > GeneralSetCallback
Invoked when an operation completes.
Definition CallbackTypes.h:91
ola::client::ConfigureDeviceCallback
SingleUseCallback2< void, const Result &, const std::string & > ConfigureDeviceCallback
Invoked when OlaClient::ConfigureDevice() completes.
Definition CallbackTypes.h:115
ola::client::DMXCallback
SingleUseCallback3< void, const Result &, const DMXMetadata &, const DmxBuffer & > DMXCallback
Called once when OlaClient::FetchDMX() completes.
Definition CallbackTypes.h:134
ola::rdm::RDMStatusCode
RDMStatusCode
RDM Status Codes.
Definition RDMResponseCodes.h:45
ola::rpc
The RPC (Remote Procedure Call) system.
Definition RpcChannel.cpp:41
ola::timecode
Timecode.
Definition TimeCode.cpp:30
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::client::SendDMXArgs
Arguments passed to the SendDMX() method.
Definition ClientArgs.h:71
ola::client::SendRDMArgs
Arguments used with OlaClient::RDMGet() and OlaClient::RDMSet() methods.
Definition ClientArgs.h:103