Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * OlaClient.h
17  * Interface to the OLA Client class
18  * Copyright (C) 2005-2008 Simon Newton
19  *
20  * This is the legacy client which uses an Observer object. It suffers from the
21  * de-multiplexing problem and API additions break old code, so it's
22  * recommended to use the OlaCallbackClient instead.
23  *
24  * As of Feb 2013 the OlaClient is deprecated, and will be removed in a future
25  * release.
26  */
27 
28 #ifndef OLA_OLACLIENT_H_
29 #define OLA_OLACLIENT_H_
30 
31 #include <ola/BaseTypes.h>
32 #include <ola/Callback.h>
33 #include <ola/DmxBuffer.h>
34 #include <ola/OlaDevice.h>
35 #include <ola/common.h>
36 #include <ola/plugin_id.h>
38 #include <ola/rdm/UIDSet.h>
39 #include <olad/PortConstants.h>
40 #include <string>
41 #include <vector>
42 
43 namespace ola {
44 
45 namespace io {
46 class ConnectedDescriptor;
47 }
48 
49 using std::string;
50 using std::vector;
51 using ola::rdm::UID;
52 
53 class OlaClientCore;
54 
55 
57  public:
58  virtual ~OlaClientObserver() {}
59 
60  virtual void NewDmx(unsigned int universe,
61  const DmxBuffer &data,
62  const string &error) {
63  (void) universe;
64  (void) data;
65  (void) error;
66  }
67  virtual void Plugins(const vector<class OlaPlugin> &plugins,
68  const string &error) {
69  (void) plugins;
70  (void) error;
71  }
72 
73  virtual void PluginDescription(ola_plugin_id plugin_id,
74  const string &description,
75  const string &error) {
76  (void) plugin_id;
77  (void) description;
78  (void) error;
79  }
80  virtual void Devices(const vector <class OlaDevice> &devices,
81  const string &error) {
82  (void) devices;
83  (void) error;
84  }
85  virtual void Universes(const vector <class OlaUniverse> &universes,
86  const string &error) {
87  (void) universes;
88  (void) error;
89  }
90  virtual void DeviceConfig(unsigned int device_alias,
91  const string &reply,
92  const string &error) {
93  (void) device_alias;
94  (void) reply;
95  (void) error;
96  }
97 
98  virtual void PatchComplete(unsigned int device_alias,
99  unsigned int port,
100  PortDirection port_direction,
101  const string &error) {
102  (void) device_alias;
103  (void) port;
104  (void) port_direction;
105  (void) error;
106  }
107  virtual void UniverseNameComplete(unsigned int universe,
108  const string &error) {
109  (void) universe;
110  (void) error;
111  }
112  virtual void UniverseMergeModeComplete(unsigned int universe,
113  const string &error) {
114  (void) universe;
115  (void) error;
116  }
117  virtual void SendDmxComplete(unsigned int universe,
118  const string &error) {
119  (void) universe;
120  (void) error;
121  }
122  virtual void SetPortPriorityComplete(
123  unsigned int device_alias,
124  unsigned int port,
125  PortDirection port_direction,
126  const string &error) {
127  (void) device_alias;
128  (void) port;
129  (void) port_direction;
130  (void) error;
131  }
132 
133  // RDM methods
134  virtual void UIDList(unsigned int universe,
135  const ola::rdm::UIDSet &uids,
136  const string &error) {
137  (void) universe;
138  (void) uids;
139  (void) error;
140  }
141  virtual void RDMDiscoveryComplete(unsigned int universe,
142  const ola::rdm::UIDSet &uids,
143  const string &error) {
144  (void) universe;
145  (void) uids;
146  (void) error;
147  }
148  virtual void SetSourceUIDComplete(const string &error) {
149  (void) error;
150  }
151 
152  virtual void RegistrationComplete(unsigned int universe,
153  const string &error) {
154  (void) universe;
155  (void) error;
156  }
157 };
158 
159 
160 /*
161  * OlaClient is just a wrapper around OlaClientCore
162  */
164  public:
165  explicit OlaClient(ola::io::ConnectedDescriptor *descriptor);
166  ~OlaClient();
167 
168  bool Setup();
169  bool Stop();
170  void SetObserver(OlaClientObserver *observer);
172 
173  bool FetchPluginList();
174  bool FetchPluginDescription(ola_plugin_id plugin_id);
175  bool FetchDeviceInfo(ola_plugin_id filter = ola::OLA_PLUGIN_ALL);
176  bool FetchUniverseInfo();
177 
178  // dmx methods
179  bool SendDmx(unsigned int universe, const DmxBuffer &data);
180  bool FetchDmx(unsigned int uni);
181 
182  // rdm methods
183  bool FetchUIDList(unsigned int universe);
184  bool RunDiscovery(unsigned int universe, bool full = true);
185  bool SetSourceUID(const UID &uid);
186 
187  bool RDMGet(rdm_callback *callback,
188  unsigned int universe,
189  const UID &uid,
190  uint16_t sub_device,
191  uint16_t pid,
192  const uint8_t *data = NULL,
193  unsigned int data_length = 0);
194  bool RDMGet(rdm_pid_callback *callback,
195  unsigned int universe,
196  const UID &uid,
197  uint16_t sub_device,
198  uint16_t pid,
199  const uint8_t *data = NULL,
200  unsigned int data_length = 0);
201  bool RDMSet(rdm_callback *callback,
202  unsigned int universe,
203  const UID &uid,
204  uint16_t sub_device,
205  uint16_t pid,
206  const uint8_t *data,
207  unsigned int data_length);
208 
209  bool SetUniverseName(unsigned int uni, const string &name);
210  bool SetUniverseMergeMode(unsigned int uni, OlaUniverse::merge_mode mode);
211 
212  bool RegisterUniverse(unsigned int universe, ola::RegisterAction action);
213 
214  bool Patch(unsigned int device_alias,
215  unsigned int port,
216  PortDirection port_direction,
217  ola::PatchAction action,
218  unsigned int uni);
219 
220  bool SetPortPriorityInherit(unsigned int device_alias,
221  unsigned int port,
222  PortDirection port_direction);
223  bool SetPortPriorityOverride(unsigned int device_alias,
224  unsigned int port,
225  PortDirection port_direction,
226  uint8_t value);
227 
228  bool ConfigureDevice(unsigned int device_alias, const string &msg);
229 
230  private:
231  OlaClient(const OlaClient&);
232  OlaClient operator=(const OlaClient&);
233 
234  OlaClientCore *m_core;
235  OlaClientObserver *m_observer;
236 };
237 } // namespace ola
238 #endif // OLA_OLACLIENT_H_