Open Lighting Architecture  Latest Git
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_
Represents a set of RDM UIDs.
Definition: UIDSet.h:48
Definitions and Interfaces to implement an RDMController that sends a single message at a time...
A 0 arg, single use callback that returns void.
Definition: Callback.h:157
Definition: Universe.h:46
void GetPluginDescription(ola::rpc::RpcController *controller, const ola::proto::PluginDescriptionRequest *request, ola::proto::PluginDescriptionReply *response, ola::rpc::RpcService::CompletionCallback *done)
Return the description for a plugin.
Definition: OlaServerServiceImpl.cpp:444
void ReloadPlugins(ola::rpc::RpcController *controller, const ola::proto::PluginReloadRequest *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Reload the plugins.
Definition: OlaServerServiceImpl.cpp:431
void GetDmx(ola::rpc::RpcController *controller, const ola::proto::UniverseRequest *request, ola::proto::DmxData *response, ola::rpc::RpcService::CompletionCallback *done)
Returns the current DMX values for a particular universe.
Definition: OlaServerServiceImpl.cpp:130
The manager of plugins.
Definition: PluginManager.h:52
A RDM unique identifier (UID).
Maintains a collection of Universe objects.
Definition: UniverseStore.h:39
A set of UIDs.
Callback0< void > ReloadPluginsCallback
A Callback used to reload all the plugins.
Definition: OlaServerServiceImpl.h:55
Responsible for performing Port operations.
Definition: PortManager.h:37
void RDMDiscoveryCommand(ola::rpc::RpcController *controller, const ::ola::proto::RDMDiscoveryRequest *request, ola::proto::RDMResponse *response, ola::rpc::RpcService::CompletionCallback *done)
Handle an RDM Discovery Command.
Definition: OlaServerServiceImpl.cpp:767
The interface for a Device.
Definition: Device.h:44
void RegisterForDmx(ola::rpc::RpcController *controller, const ola::proto::RegisterDmxRequest *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Register a client to receive DMX data.
Definition: OlaServerServiceImpl.cpp:146
Keeps track of OLA&#39;s devices.
Definition: DeviceManager.h:61
void UpdateDmxData(ola::rpc::RpcController *controller, const ola::proto::DmxData *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Update the DMX values for a single universe.
Definition: OlaServerServiceImpl.cpp:166
void SetSourceUID(ola::rpc::RpcController *controller, const ::ola::proto::UID *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Set this client&#39;s source UID.
Definition: OlaServerServiceImpl.cpp:809
void StreamDmxData(ola::rpc::RpcController *controller, const ::ola::proto::DmxData *request, ::ola::proto::STREAMING_NO_RESPONSE *response, ola::rpc::RpcService::CompletionCallback *done)
Handle a streaming DMX update, no response is sent.
Definition: OlaServerServiceImpl.cpp:194
void ForceDiscovery(ola::rpc::RpcController *controller, const ola::proto::DiscoveryRequest *request, ola::proto::UIDListReply *response, ola::rpc::RpcService::CompletionCallback *done)
Force RDM discovery for a universe.
Definition: OlaServerServiceImpl.cpp:687
void SetMergeMode(ola::rpc::RpcController *controller, const ola::proto::MergeModeRequest *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Set the merge mode for a universe.
Definition: OlaServerServiceImpl.cpp:236
Handles async client operations.
Definition: ClientBroker.h:52
void SetPortPriority(ola::rpc::RpcController *controller, const ola::proto::PortPriorityRequest *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Set the priority of one or more ports.
Definition: OlaServerServiceImpl.cpp:295
void ConfigureDevice(ola::rpc::RpcController *controller, const ola::proto::DeviceConfigRequest *request, ola::proto::DeviceConfigReply *response, ola::rpc::RpcService::CompletionCallback *done)
Handle a ConfigureDevice request.
Definition: OlaServerServiceImpl.cpp:648
Holds the final state of an RDM request.
Definition: RDMReply.h:43
void GetPlugins(ola::rpc::RpcController *controller, const ola::proto::PluginListRequest *request, ola::proto::PluginListReply *response, ola::rpc::RpcService::CompletionCallback *done)
Return info on available plugins.
Definition: OlaServerServiceImpl.cpp:415
void GetCandidatePorts(ola::rpc::RpcController *controller, const ola::proto::OptionalUniverseRequest *request, ola::proto::DeviceInfoReply *response, ola::rpc::RpcService::CompletionCallback *done)
Handle a GetCandidatePorts request.
Definition: OlaServerServiceImpl.cpp:530
Represents a connected OLA client on the OLA server side.
Definition: Client.h:46
void GetUniverseInfo(ola::rpc::RpcController *controller, const ola::proto::OptionalUniverseRequest *request, ola::proto::UniverseInfoReply *response, ola::rpc::RpcService::CompletionCallback *done)
Returns information on the active universes.
Definition: OlaServerServiceImpl.cpp:388
void SetPluginState(ola::rpc::RpcController *controller, const ola::proto::PluginStateChangeRequest *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Change the state of plugins.
Definition: OlaServerServiceImpl.cpp:487
Represents a RDM UID.
Definition: UID.h:57
OlaServerServiceImpl(class UniverseStore *universe_store, class DeviceManager *device_manager, class PluginManager *plugin_manager, class PortManager *port_manager, class ClientBroker *broker, const class TimeStamp *wake_up_time, ReloadPluginsCallback *reload_plugins_callback)
Create a new OlaServerServiceImpl.
Definition: OlaServerServiceImpl.cpp:113
void PatchPort(ola::rpc::RpcController *controller, const ola::proto::PatchPortRequest *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Patch a port to a universe.
Definition: OlaServerServiceImpl.cpp:252
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
A RpcController object is passed every time an RPC is invoked and is used to indicate the success or ...
Definition: RpcController.h:42
void GetUIDs(ola::rpc::RpcController *controller, const ola::proto::UniverseRequest *request, ola::proto::UIDListReply *response, ola::rpc::RpcService::CompletionCallback *done)
Fetch the UID list for a universe.
Definition: OlaServerServiceImpl.cpp:665
Represents a point in time with microsecond accuracy.
Definition: Clock.h:191
void GetPluginState(ola::rpc::RpcController *controller, const ola::proto::PluginStateRequest *request, ola::proto::PluginStateReply *response, ola::rpc::RpcService::CompletionCallback *done)
Return the state for a plugin.
Definition: OlaServerServiceImpl.cpp:461
void SendTimeCode(ola::rpc::RpcController *controller, const ::ola::proto::TimeCode *request, ::ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Send Timecode.
Definition: OlaServerServiceImpl.cpp:820
void RDMCommand(ola::rpc::RpcController *controller, const ::ola::proto::RDMRequest *request, ola::proto::RDMResponse *response, ola::rpc::RpcService::CompletionCallback *done)
Handle an RDM Command.
Definition: OlaServerServiceImpl.cpp:711
Definition: Plugin.h:38
void GetDeviceInfo(ola::rpc::RpcController *controller, const ola::proto::DeviceInfoRequest *request, ola::proto::DeviceInfoReply *response, ola::rpc::RpcService::CompletionCallback *done)
Return information on available devices.
Definition: OlaServerServiceImpl.cpp:509
void SetUniverseName(ola::rpc::RpcController *controller, const ola::proto::UniverseNameRequest *request, ola::proto::Ack *response, ola::rpc::RpcService::CompletionCallback *done)
Sets the name of a universe.
Definition: OlaServerServiceImpl.cpp:222
The OLA Server RPC methods.
Definition: OlaServerServiceImpl.h:50
Classes that represent RDM commands.