Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 ArtNet 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 ArtNet 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_