Open Lighting Architecture  0.9.5
 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"
28 #include "ola/rdm/UID.h"
29 #include "ola/rdm/UIDSet.h"
30 
31 #ifndef OLAD_OLASERVERSERVICEIMPL_H_
32 #define OLAD_OLASERVERSERVICEIMPL_H_
33 
34 namespace ola {
35 
47 class OlaServerServiceImpl : public ola::proto::OlaServerService {
48  public:
53 
57  OlaServerServiceImpl(class UniverseStore *universe_store,
58  class DeviceManager *device_manager,
59  class PluginManager *plugin_manager,
60  class PortManager *port_manager,
61  class ClientBroker *broker,
62  const class TimeStamp *wake_up_time,
63  ReloadPluginsCallback *reload_plugins_callback);
64 
66 
70  void GetDmx(ola::rpc::RpcController* controller,
71  const ola::proto::UniverseRequest* request,
72  ola::proto::DmxData* response,
74 
75 
79  void RegisterForDmx(ola::rpc::RpcController* controller,
80  const ola::proto::RegisterDmxRequest* request,
81  ola::proto::Ack* response,
83 
87  void UpdateDmxData(ola::rpc::RpcController* controller,
88  const ola::proto::DmxData* request,
89  ola::proto::Ack* response,
94  void StreamDmxData(ola::rpc::RpcController* controller,
95  const ::ola::proto::DmxData* request,
96  ::ola::proto::STREAMING_NO_RESPONSE* response,
98 
99 
103  void SetUniverseName(ola::rpc::RpcController* controller,
104  const ola::proto::UniverseNameRequest* request,
105  ola::proto::Ack* response,
107 
111  void SetMergeMode(ola::rpc::RpcController* controller,
112  const ola::proto::MergeModeRequest* request,
113  ola::proto::Ack* response,
115 
119  void PatchPort(ola::rpc::RpcController* controller,
120  const ola::proto::PatchPortRequest* request,
121  ola::proto::Ack* response,
123 
127  void SetPortPriority(ola::rpc::RpcController* controller,
128  const ola::proto::PortPriorityRequest* request,
129  ola::proto::Ack* response,
131 
135  void GetUniverseInfo(ola::rpc::RpcController* controller,
136  const ola::proto::OptionalUniverseRequest* request,
137  ola::proto::UniverseInfoReply* response,
139 
143  void GetPlugins(ola::rpc::RpcController* controller,
144  const ola::proto::PluginListRequest* request,
145  ola::proto::PluginListReply* response,
147 
151  void ReloadPlugins(ola::rpc::RpcController* controller,
152  const ::ola::proto::PluginReloadRequest* request,
153  ::ola::proto::Ack* response,
155 
160  ola::rpc::RpcController* controller,
161  const ola::proto::PluginDescriptionRequest* request,
162  ola::proto::PluginDescriptionReply* response,
164 
168  void GetPluginState(
169  ola::rpc::RpcController* controller,
170  const ola::proto::PluginStateRequest* request,
171  ola::proto::PluginStateReply* response,
173 
177  void GetDeviceInfo(ola::rpc::RpcController* controller,
178  const ola::proto::DeviceInfoRequest* request,
179  ola::proto::DeviceInfoReply* response,
181 
186  const ola::proto::OptionalUniverseRequest* request,
187  ola::proto::DeviceInfoReply* response,
189 
193  void ConfigureDevice(ola::rpc::RpcController* controller,
194  const ola::proto::DeviceConfigRequest* request,
195  ola::proto::DeviceConfigReply* response,
197 
201  void GetUIDs(ola::rpc::RpcController* controller,
202  const ola::proto::UniverseRequest* request,
203  ola::proto::UIDListReply* response,
205 
209  void ForceDiscovery(ola::rpc::RpcController* controller,
210  const ola::proto::DiscoveryRequest* request,
211  ola::proto::UIDListReply* response,
213 
217  void RDMCommand(ola::rpc::RpcController* controller,
218  const ::ola::proto::RDMRequest* request,
219  ola::proto::RDMResponse* response,
221 
222 
230  const ::ola::proto::RDMDiscoveryRequest* request,
231  ola::proto::RDMResponse* response,
233 
237  void SetSourceUID(ola::rpc::RpcController* controller,
238  const ::ola::proto::UID* request,
239  ola::proto::Ack* response,
241 
245  void SendTimeCode(ola::rpc::RpcController* controller,
246  const ::ola::proto::TimeCode* request,
247  ::ola::proto::Ack* response,
249 
250  private:
251  void HandleRDMResponse(ola::proto::RDMResponse* response,
253  bool include_raw_packets,
254  ola::rdm::rdm_response_code code,
255  const ola::rdm::RDMResponse *rdm_response,
256  const std::vector<std::string> &packets);
257  void RDMDiscoveryComplete(unsigned int universe,
259  ola::proto::UIDListReply *response,
260  const ola::rdm::UIDSet &uids);
261 
262  void MissingUniverseError(ola::rpc::RpcController* controller);
263  void MissingPluginError(ola::rpc::RpcController* controller);
264  void MissingDeviceError(ola::rpc::RpcController* controller);
265  void MissingPortError(ola::rpc::RpcController* controller);
266 
267  void AddPlugin(class AbstractPlugin *plugin,
268  ola::proto::PluginInfo *plugin_info) const;
269  void AddDevice(class AbstractDevice *device,
270  unsigned int alias,
271  ola::proto::DeviceInfoReply* response) const;
272 
273  template <class PortClass>
274  void PopulatePort(const PortClass &port,
275  ola::proto::PortInfo *port_info) const;
276 
277  void SetProtoUID(const ola::rdm::UID &uid, ola::proto::UID *pb_uid);
278 
279  class Client* GetClient(ola::rpc::RpcController *controller);
280 
281  UniverseStore *m_universe_store;
282  DeviceManager *m_device_manager;
283  class PluginManager *m_plugin_manager;
284  class PortManager *m_port_manager;
285  class ClientBroker *m_broker;
286  const class TimeStamp *m_wake_up_time;
287  std::auto_ptr<ReloadPluginsCallback> m_reload_plugins_callback;
288 };
289 } // namespace ola
290 #endif // OLAD_OLASERVERSERVICEIMPL_H_