Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OlaClient.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  * OlaClient.h
17  * This is the main client API to OLA.
18  * Copyright (C) 2010 Simon Newton
19  */
20 
21 #ifndef INCLUDE_OLA_CLIENT_OLACLIENT_H_
22 #define INCLUDE_OLA_CLIENT_OLACLIENT_H_
23 
24 #include <ola/DmxBuffer.h>
26 #include <ola/client/ClientArgs.h>
27 #include <ola/client/ClientTypes.h>
28 #include <ola/base/Macro.h>
29 #include <ola/io/Descriptor.h>
30 #include <ola/plugin_id.h>
31 #include <ola/rdm/UID.h>
32 #include <ola/rdm/UIDSet.h>
33 #include <ola/timecode/TimeCode.h>
34 
35 #include <memory>
36 #include <string>
37 
38 namespace ola {
39 namespace client {
40 
45 class OlaClient {
46  public:
47  explicit OlaClient(ola::io::ConnectedDescriptor *descriptor);
48  ~OlaClient();
49 
50  /*
51  * @brief Setup this client.
52  * @returns true on success, false on failure
53  */
54  bool Setup();
55 
56  /*
57  * @brief Close the ola connection.
58  * @return true on sucess, false on failure
59  */
60  bool Stop();
61 
66 
74  void SetDMXCallback(RepeatableDMXCallback *callback);
75 
80  void ReloadPlugins(SetCallback *callback);
81 
86  void FetchPluginList(PluginListCallback *callback);
87 
94  void FetchPluginDescription(ola_plugin_id plugin_id,
95  PluginDescriptionCallback *callback);
96 
104  void FetchPluginState(ola_plugin_id plugin_id,
105  PluginStateCallback *callback);
106 
113  void FetchDeviceInfo(ola_plugin_id plugin_filter,
114  DeviceInfoCallback *callback);
115 
121 
129  void FetchCandidatePorts(unsigned int universe_id,
130  CandidatePortsCallback *callback);
131 
138  void SetPluginState(ola_plugin_id plugin_id,
139  bool state,
140  SetCallback *callback);
141 
148  void ConfigureDevice(unsigned int device_alias,
149  const std::string &msg,
150  ConfigureDeviceCallback *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 
237  void RegisterUniverse(unsigned int universe,
238  RegisterAction register_action,
239  SetCallback *callback);
240 
247  void SendDMX(unsigned int universe,
248  const DmxBuffer &data,
249  const SendDMXArgs &args);
250 
256  void FetchDMX(unsigned int universe, DMXCallback *callback);
257 
264  void RunDiscovery(unsigned int universe,
265  DiscoveryType discovery_type,
266  DiscoveryCallback *callback);
267 
273  void SetSourceUID(const ola::rdm::UID &uid, SetCallback *callback);
274 
285  void RDMGet(unsigned int universe,
286  const ola::rdm::UID &uid,
287  uint16_t sub_device,
288  uint16_t pid,
289  const uint8_t *data,
290  unsigned int data_length,
291  const SendRDMArgs& args);
292 
303  void RDMSet(unsigned int universe,
304  const ola::rdm::UID &uid,
305  uint16_t sub_device,
306  uint16_t pid,
307  const uint8_t *data,
308  unsigned int data_length,
309  const SendRDMArgs& args);
310 
316  void SendTimeCode(const ola::timecode::TimeCode &timecode,
317  SetCallback *callback);
318 
319  private:
320  std::auto_ptr<class OlaClientCore> m_core;
321 
322  DISALLOW_COPY_AND_ASSIGN(OlaClient);
323 };
324 } // namespace client
325 } // namespace ola
326 #endif // INCLUDE_OLA_CLIENT_OLACLIENT_H_
void FetchUniverseList(UniverseListCallback *callback)
Request a list of universes.
Definition: OlaClient.cpp:125
void FetchPluginList(PluginListCallback *callback)
Fetch the list of plugins loaded.
Definition: OlaClient.cpp:69
A 0 arg, single use callback that returns void.
Definition: Callback.h:157
PortDirection
The port direction.
Definition: ClientArgs.h:54
void SendTimeCode(const ola::timecode::TimeCode &timecode, SetCallback *callback)
Send TimeCode data.
Definition: OlaClient.cpp:182
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: OlaClient.cpp:146
void SetSourceUID(const ola::rdm::UID &uid, SetCallback *callback)
Set the source UID for this client.
Definition: OlaClient.cpp:177
void FetchDMX(unsigned int universe, DMXCallback *callback)
Fetch the latest DMX data for a universe.
Definition: OlaClient.cpp:167
RegisterAction
The register action, used with OlaClient::RegisterUniverse()
Definition: ClientArgs.h:46
DiscoveryType
The type of discovery to run with OlaClient::RunDiscovery().
Definition: ClientArgs.h:62
Types used as return values from the OLA Client.
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition: Descriptor.h:282
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: OlaClient.cpp:187
void SetUniverseMergeMode(unsigned int universe, OlaUniverse::merge_mode mode, SetCallback *callback)
Set the merge mode of a universe.
Definition: OlaClient.cpp:140
void FetchPluginState(ola_plugin_id plugin_id, PluginStateCallback *callback)
Fetch the state of a plugin.
Definition: OlaClient.cpp:78
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
A RDM unique identifier (UID).
PatchAction
The patch action, used with OlaClient::Patch()
Definition: ClientArgs.h:38
The callback based C++ client for OLA.
Definition: OlaClient.h:45
A set of UIDs.
void FetchCandidatePorts(CandidatePortsCallback *callback)
Request a list of ports that could be patched to new universe.
Definition: OlaClient.cpp:88
A class used to hold a single universe of DMX data.
Arguments passed to the SendDMX() method.
Definition: ClientArgs.h:71
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: OlaClient.cpp:116
Definition: TimeCode.h:33
Types used as arguments for the OLA Client.
void SetPluginState(ola_plugin_id plugin_id, bool state, SetCallback *callback)
Set the state of a plugin.
Definition: OlaClient.cpp:103
void FetchPluginDescription(ola_plugin_id plugin_id, PluginDescriptionCallback *callback)
Fetch the description for a plugin.
Definition: OlaClient.cpp:73
void SetCloseHandler(ola::SingleUseCallback0< void > *callback)
Set the close handler.
Definition: OlaClient.cpp:57
void SendDMX(unsigned int universe, const DmxBuffer &data, const SendDMXArgs &args)
Send DMX data.
Definition: OlaClient.cpp:161
Arguments used with OlaClient::RDMGet() and OlaClient::RDMSet() methods.
Definition: ClientArgs.h:103
void SetDMXCallback(RepeatableDMXCallback *callback)
Set the callback to be run when new DMX data arrives.
Definition: OlaClient.cpp:61
void FetchUniverseInfo(unsigned int universe, UniverseInfoCallback *callback)
Fetch the information for a given universe.
Definition: OlaClient.cpp:129
void ConfigureDevice(unsigned int device_alias, const std::string &msg, ConfigureDeviceCallback *callback)
Send a device config request.
Definition: OlaClient.cpp:97
Helper macros.
A 2 argument callback which can be called multiple times.
Definition: Callback.h:1895
A 1 argument callback which deletes itself after it's run.
Definition: Callback.h:1004
A 3 argument callback which deletes itself after it's run.
Definition: Callback.h:2850
Represents a RDM UID.
Definition: UID.h:57
void ReloadPlugins(SetCallback *callback)
Trigger a plugin reload.
Definition: OlaClient.cpp:65
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
void RunDiscovery(unsigned int universe, DiscoveryType discovery_type, DiscoveryCallback *callback)
Trigger discovery for a universe.
Definition: OlaClient.cpp:171
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: OlaClient.cpp:197
void SetPortPriorityInherit(unsigned int device_alias, unsigned int port, PortDirection port_direction, SetCallback *callback)
Set the priority for a port to inherit mode.
Definition: OlaClient.cpp:109
The various callbacks used with the OLA Client.
void FetchDeviceInfo(ola_plugin_id plugin_filter, DeviceInfoCallback *callback)
Request a list of the available devices.
Definition: OlaClient.cpp:83
A 2 argument callback which deletes itself after it's run.
Definition: Callback.h:1907
void RegisterUniverse(unsigned int universe, RegisterAction register_action, SetCallback *callback)
Register our interest in a universe.
Definition: OlaClient.cpp:155
void SetUniverseName(unsigned int universe, const std::string &name, SetCallback *callback)
Set the name of a universe.
Definition: OlaClient.cpp:134