Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OlaServerServiceImpl.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * OlaServerServiceImpl.h
17  * Implementation of the OlaService interface
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #include <memory>
22 #include <string>
23 #include <vector>
24 #include "common/protocol/Ola.pb.h"
25 #include "common/protocol/OlaService.pb.h"
26 #include "ola/Callback.h"
27 #include "ola/rdm/RDMCommand.h"
29 #include "ola/rdm/UID.h"
30 #include "ola/rdm/UIDSet.h"
31 
32 #ifndef OLAD_OLASERVERSERVICEIMPL_H_
33 #define OLAD_OLASERVERSERVICEIMPL_H_
34 
35 namespace ola {
36 
37 class Universe;
38 
50 class OlaServerServiceImpl : public ola::proto::OlaServerService {
51  public:
56 
60  OlaServerServiceImpl(class UniverseStore *universe_store,
61  class DeviceManager *device_manager,
62  class PluginManager *plugin_manager,
63  class PortManager *port_manager,
64  class ClientBroker *broker,
65  const class TimeStamp *wake_up_time,
66  ReloadPluginsCallback *reload_plugins_callback);
67 
69 
73  void GetDmx(ola::rpc::RpcController* controller,
74  const ola::proto::UniverseRequest* request,
75  ola::proto::DmxData* response,
77 
78 
82  void RegisterForDmx(ola::rpc::RpcController* controller,
83  const ola::proto::RegisterDmxRequest* request,
84  ola::proto::Ack* response,
86 
90  void UpdateDmxData(ola::rpc::RpcController* controller,
91  const ola::proto::DmxData* request,
92  ola::proto::Ack* response,
97  void StreamDmxData(ola::rpc::RpcController* controller,
98  const ::ola::proto::DmxData* request,
99  ::ola::proto::STREAMING_NO_RESPONSE* response,
101 
102 
106  void SetUniverseName(ola::rpc::RpcController* controller,
107  const ola::proto::UniverseNameRequest* request,
108  ola::proto::Ack* response,
110 
114  void SetMergeMode(ola::rpc::RpcController* controller,
115  const ola::proto::MergeModeRequest* request,
116  ola::proto::Ack* response,
118 
122  void PatchPort(ola::rpc::RpcController* controller,
123  const ola::proto::PatchPortRequest* request,
124  ola::proto::Ack* response,
126 
130  void SetPortPriority(ola::rpc::RpcController* controller,
131  const ola::proto::PortPriorityRequest* request,
132  ola::proto::Ack* response,
134 
138  void GetUniverseInfo(ola::rpc::RpcController* controller,
139  const ola::proto::OptionalUniverseRequest* request,
140  ola::proto::UniverseInfoReply* response,
142 
146  void GetPlugins(ola::rpc::RpcController* controller,
147  const ola::proto::PluginListRequest* request,
148  ola::proto::PluginListReply* response,
150 
154  void ReloadPlugins(ola::rpc::RpcController* controller,
155  const ola::proto::PluginReloadRequest* request,
156  ola::proto::Ack* response,
158 
163  ola::rpc::RpcController* controller,
164  const ola::proto::PluginDescriptionRequest* request,
165  ola::proto::PluginDescriptionReply* response,
167 
171  void GetPluginState(
172  ola::rpc::RpcController* controller,
173  const ola::proto::PluginStateRequest* request,
174  ola::proto::PluginStateReply* response,
176 
180  void SetPluginState(
181  ola::rpc::RpcController* controller,
182  const ola::proto::PluginStateChangeRequest* request,
183  ola::proto::Ack* response,
185 
189  void GetDeviceInfo(ola::rpc::RpcController* controller,
190  const ola::proto::DeviceInfoRequest* request,
191  ola::proto::DeviceInfoReply* response,
193 
198  const ola::proto::OptionalUniverseRequest* request,
199  ola::proto::DeviceInfoReply* response,
201 
205  void ConfigureDevice(ola::rpc::RpcController* controller,
206  const ola::proto::DeviceConfigRequest* request,
207  ola::proto::DeviceConfigReply* response,
209 
213  void GetUIDs(ola::rpc::RpcController* controller,
214  const ola::proto::UniverseRequest* request,
215  ola::proto::UIDListReply* response,
217 
221  void ForceDiscovery(ola::rpc::RpcController* controller,
222  const ola::proto::DiscoveryRequest* request,
223  ola::proto::UIDListReply* response,
225 
229  void RDMCommand(ola::rpc::RpcController* controller,
230  const ::ola::proto::RDMRequest* request,
231  ola::proto::RDMResponse* response,
233 
234 
242  const ::ola::proto::RDMDiscoveryRequest* request,
243  ola::proto::RDMResponse* response,
245 
249  void SetSourceUID(ola::rpc::RpcController* controller,
250  const ::ola::proto::UID* request,
251  ola::proto::Ack* response,
253 
257  void SendTimeCode(ola::rpc::RpcController* controller,
258  const ::ola::proto::TimeCode* request,
259  ::ola::proto::Ack* response,
261 
262  private:
263  void HandleRDMResponse(ola::proto::RDMResponse* response,
265  bool include_raw_packets,
266  ola::rdm::RDMReply *reply);
267  void RDMDiscoveryComplete(unsigned int universe,
269  ola::proto::UIDListReply *response,
270  const ola::rdm::UIDSet &uids);
271 
272  void MissingUniverseError(ola::rpc::RpcController* controller);
273  void MissingPluginError(ola::rpc::RpcController* controller);
274  void MissingDeviceError(ola::rpc::RpcController* controller);
275  void MissingPortError(ola::rpc::RpcController* controller);
276 
277  void AddPlugin(class AbstractPlugin *plugin,
278  ola::proto::PluginInfo *plugin_info) const;
279  void AddDevice(class AbstractDevice *device,
280  unsigned int alias,
281  ola::proto::DeviceInfoReply* response) const;
282  void AddUniverse(const Universe *universe,
283  ola::proto::UniverseInfoReply *universe_info_reply) const;
284 
285  template <class PortClass>
286  void PopulatePort(const PortClass &port,
287  ola::proto::PortInfo *port_info) const;
288 
289  void SetProtoUID(const ola::rdm::UID &uid, ola::proto::UID *pb_uid);
290 
291  class Client* GetClient(ola::rpc::RpcController *controller);
292 
293  UniverseStore *m_universe_store;
294  DeviceManager *m_device_manager;
295  class PluginManager *m_plugin_manager;
296  class PortManager *m_port_manager;
297  class ClientBroker *m_broker;
298  const class TimeStamp *m_wake_up_time;
299  std::auto_ptr<ReloadPluginsCallback> m_reload_plugins_callback;
300 };
301 } // namespace ola
302 #endif // OLAD_OLASERVERSERVICEIMPL_H_