Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OlaCallbackClient.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * OlaCallbackClient.h
17  * This is the main client API to OLA. Unlike the OlaClient class it uses
18  * Callbacks for all notifications.
19  * Copyright (C) 2010 Simon Newton
20  */
21 
22 #ifndef OLA_OLACALLBACKCLIENT_H_
23 #define OLA_OLACALLBACKCLIENT_H_
24 
25 #include <ola/Callback.h>
26 #include <ola/DmxBuffer.h>
27 #include <ola/OlaDevice.h>
28 #include <ola/common.h>
29 #include <ola/network/Socket.h>
30 #include <ola/plugin_id.h>
32 #include <ola/rdm/UID.h>
33 #include <ola/rdm/UIDSet.h>
34 #include <ola/timecode/TimeCode.h>
35 
36 #include <string>
37 #include <vector>
38 
39 namespace ola {
40 
41 using std::string;
42 
44  public:
45  struct PluginState {
46  string name;
47  bool enabled;
48  bool active;
49  string preferences_source;
50  vector<OlaPlugin> conflicting_plugins;
51  };
52 
55 
56  explicit OlaCallbackClient(ola::io::ConnectedDescriptor *descriptor);
58 
59  bool Setup();
60  bool Stop();
61 
63 
64  // plugin methods
65  bool FetchPluginList(
66  SingleUseCallback2<void,
67  const vector<class OlaPlugin>&,
68  const string&> *callback);
69 
70  bool FetchPluginDescription(
71  ola_plugin_id plugin_id,
73 
74  bool FetchPluginState(ola_plugin_id plugin_id,
75  PluginStateCallback *callback);
76 
77  // device methods
78  bool FetchDeviceInfo(
79  ola_plugin_id filter,
80  SingleUseCallback2<void,
81  const vector <class OlaDevice>&,
82  const string&> *callback);
83 
84  bool FetchCandidatePorts(
85  unsigned int universe_id,
86  SingleUseCallback2<void,
87  const vector <class OlaDevice>&,
88  const string&> *callback);
89 
90  bool FetchCandidatePorts(
91  SingleUseCallback2<void,
92  const vector <class OlaDevice>&,
93  const string&> *callback);
94 
95  bool ConfigureDevice(
96  unsigned int device_alias,
97  const string &msg,
99 
100  // port methods
101  bool SetPortPriorityInherit(
102  unsigned int device_alias,
103  unsigned int port,
104  PortDirection port_direction,
106  bool SetPortPriorityOverride(
107  unsigned int device_alias,
108  unsigned int port,
109  PortDirection port_direction,
110  uint8_t value,
112 
113  // universe methods
114  bool FetchUniverseList(
115  SingleUseCallback2<void,
116  const vector <class OlaUniverse>&,
117  const string &> *callback);
118  bool FetchUniverseInfo(
119  unsigned int universe,
120  SingleUseCallback2<void,
121  class OlaUniverse&,
122  const string &> *callback);
123  bool SetUniverseName(
124  unsigned int uni,
125  const string &name,
127  bool SetUniverseMergeMode(
128  unsigned int uni,
129  OlaUniverse::merge_mode mode,
131 
132  // patching
133  bool Patch(
134  unsigned int device_alias,
135  unsigned int port,
136  ola::PortDirection port_direction,
137  ola::PatchAction action,
138  unsigned int uni,
140 
141  // DMX methods
142  void SetDmxCallback(
143  Callback3<void,
144  unsigned int,
145  const DmxBuffer&, const string&> *callback);
146 
147  // Similar to above, but this also passes the source priority.
148  void SetDmxCallback(
149  Callback4<void,
150  unsigned int,
151  uint8_t,
152  const DmxBuffer&, const string&> *callback);
153 
154  bool RegisterUniverse(
155  unsigned int universe,
156  ola::RegisterAction register_action,
158  bool SendDmx(
159  unsigned int universe,
160  const DmxBuffer &data,
162  bool SendDmx(
163  unsigned int universe,
164  const DmxBuffer &data,
166  // A version of SendDmx that doesn't wait for confirmation
167  bool SendDmx(unsigned int universe, const DmxBuffer &data);
168 
169  bool FetchDmx(
170  unsigned int universe,
172 
173  // rdm methods
174  bool FetchUIDList(
175  unsigned int universe,
176  SingleUseCallback2<void,
177  const ola::rdm::UIDSet&,
178  const string&> *callback);
179  bool RunDiscovery(
180  unsigned int universe,
181  bool full,
183  const ola::rdm::UIDSet&,
184  const string&> *callback);
185  bool SetSourceUID(const ola::rdm::UID &uid,
187 
188  bool RDMGet(ola::rdm::RDMAPIImplInterface::rdm_callback *callback,
189  unsigned int universe,
190  const ola::rdm::UID &uid,
191  uint16_t sub_device,
192  uint16_t pid,
193  const uint8_t *data,
194  unsigned int data_length);
196  unsigned int universe,
197  const ola::rdm::UID &uid,
198  uint16_t sub_device,
199  uint16_t pid,
200  const uint8_t *data,
201  unsigned int data_length);
202  bool RDMSet(ola::rdm::RDMAPIImplInterface::rdm_callback *callback,
203  unsigned int universe,
204  const ola::rdm::UID &uid,
205  uint16_t sub_device,
206  uint16_t pid,
207  const uint8_t *data,
208  unsigned int data_length);
210  unsigned int universe,
211  const ola::rdm::UID &uid,
212  uint16_t sub_device,
213  uint16_t pid,
214  const uint8_t *data,
215  unsigned int data_length);
216 
217  // timecode
219  const ola::timecode::TimeCode &timecode);
220 
221  private:
223  OlaCallbackClient operator=(const OlaCallbackClient&);
224 
225  class OlaClientCore *m_core;
226 };
227 } // namespace ola
228 #endif // OLA_OLACALLBACKCLIENT_H_