Open Lighting Architecture  0.9.2
 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 
21 #ifndef PLUGINS_ARTNET_ARTNETDEVICE_H_
22 #define PLUGINS_ARTNET_ARTNETDEVICE_H_
23 
24 #include <string>
25 
26 #include "olad/Device.h"
27 #include "plugins/artnet/messages/ArtNetConfigMessages.pb.h"
28 #include "plugins/artnet/ArtNetNode.h"
29 
30 namespace ola {
31 
32 class Preferences;
33 
34 namespace plugin {
35 namespace artnet {
36 
37 class ArtNetDevice: public Device {
38  public:
40  class Preferences *preferences,
41  class PluginAdaptor *plugin_adaptor);
42 
43  // only one ArtNet device
44  std::string DeviceId() const { return "1"; }
45 
46  void EnterConfigurationMode() { m_node->EnterConfigurationMode(); }
47  void ExitConfigurationMode() { m_node->ExitConfigurationMode(); }
48 
49  void Configure(ola::rpc::RpcController *controller,
50  const std::string &request,
51  std::string *response,
52  ConfigureCallback *done);
53 
54  static const char K_ALWAYS_BROADCAST_KEY[];
55  static const char K_DEVICE_NAME[];
56  static const char K_IP_KEY[];
57  static const char K_LIMITED_BROADCAST_KEY[];
58  static const char K_LONG_NAME_KEY[];
59  static const char K_LOOPBACK_KEY[];
60  static const char K_NET_KEY[];
61  static const char K_OUTPUT_PORT_KEY[];
62  static const char K_SHORT_NAME_KEY[];
63  static const char K_SUBNET_KEY[];
64  // 10s between polls when we're sending data, DMX-workshop uses 8s;
65  static const unsigned int POLL_INTERVAL = 10000;
66 
67  protected:
68  bool StartHook();
69  void PrePortStop();
70  void PostPortStop();
71 
72  private:
73  class Preferences *m_preferences;
74  ArtNetNode *m_node;
75  class PluginAdaptor *m_plugin_adaptor;
76  ola::thread::timeout_id m_timeout_id;
77 
78  void HandleOptions(Request *request, std::string *response);
79  void HandleNodeList(Request *request,
80  std::string *response,
81  ola::rpc::RpcController *controller);
82 };
83 } // namespace artnet
84 } // namespace plugin
85 } // namespace ola
86 #endif // PLUGINS_ARTNET_ARTNETDEVICE_H_