Open Lighting Architecture  Latest Git
ArtNetDevice.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  * ArtNetDevice.h
17  * Interface for the Art-Net device
18  * Copyright (C) 2005 Simon Newton
19  */
20 
31 #ifndef PLUGINS_ARTNET_ARTNETDEVICE_H_
32 #define PLUGINS_ARTNET_ARTNETDEVICE_H_
33 
34 #include <string>
35 
36 #include "olad/Device.h"
37 #include "plugins/artnet/messages/ArtNetConfigMessages.pb.h"
38 #include "plugins/artnet/ArtNetNode.h"
39 
40 namespace ola {
41 
42 class Preferences;
43 
44 namespace plugin {
45 namespace artnet {
46 
47 class ArtNetDevice: public Device {
48  public:
53  class Preferences *preferences,
54  class PluginAdaptor *plugin_adaptor);
55 
56  // only one Art-Net device
57  std::string DeviceId() const { return "1"; }
58 
59  void EnterConfigurationMode() { m_node->EnterConfigurationMode(); }
60  void ExitConfigurationMode() { m_node->ExitConfigurationMode(); }
61 
69  void Configure(ola::rpc::RpcController *controller,
70  const std::string &request,
71  std::string *response,
72  ConfigureCallback *done);
73 
74  static const char K_ALWAYS_BROADCAST_KEY[];
75  static const char K_DEVICE_NAME[];
76  static const char K_IP_KEY[];
77  static const char K_LIMITED_BROADCAST_KEY[];
78  static const char K_LONG_NAME_KEY[];
79  static const char K_LOOPBACK_KEY[];
80  static const char K_NET_KEY[];
81  static const char K_OUTPUT_PORT_KEY[];
82  static const char K_SHORT_NAME_KEY[];
83  static const char K_SUBNET_KEY[];
84  static const unsigned int K_ARTNET_NET;
85  static const unsigned int K_ARTNET_SUBNET;
86  static const unsigned int K_DEFAULT_OUTPUT_PORT_COUNT;
87  // 10s between polls when we're sending data, DMX-workshop uses 8s;
88  static const unsigned int POLL_INTERVAL = 10000;
89 
90  protected:
95  bool StartHook();
96 
100  void PrePortStop();
101 
105  void PostPortStop();
106 
107  private:
108  class Preferences *m_preferences;
109  ArtNetNode *m_node;
110  class PluginAdaptor *m_plugin_adaptor;
111  ola::thread::timeout_id m_timeout_id;
112 
116  void HandleOptions(Request *request, std::string *response);
117 
121  void HandleNodeList(Request *request,
122  std::string *response,
123  ola::rpc::RpcController *controller);
124 };
125 } // namespace artnet
126 } // namespace plugin
127 } // namespace ola
128 #endif // PLUGINS_ARTNET_ARTNETDEVICE_H_
std::string DeviceId() const
The device ID.
Definition: ArtNetDevice.h:57
ArtNetDevice(AbstractPlugin *owner, class Preferences *preferences, class PluginAdaptor *plugin_adaptor)
Definition: ArtNetDevice.cpp:73
void PostPortStop()
Definition: ArtNetDevice.cpp:151
Definition: Device.h:95
Definition: ArtNetDevice.h:47
void * timeout_id
A timeout handle which can later be used to cancel a timeout.
Definition: SchedulerInterface.h:34
Definition: PluginAdaptor.h:41
The actual Art-Net Node.
Definition: ArtNetNode.h:697
void Configure(ola::rpc::RpcController *controller, const std::string &request, std::string *response, ConfigureCallback *done)
Definition: ArtNetDevice.cpp:156
Definition: Preferences.h:147
bool StartHook()
Definition: ArtNetDevice.cpp:83
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
void PrePortStop()
Definition: ArtNetDevice.cpp:143
A RpcController object is passed every time an RPC is invoked and is used to indicate the success or ...
Definition: RpcController.h:42
Definition: Plugin.h:38