Open Lighting Architecture
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * ArtNetDevice.h
17  * Interface for the ArtNet device
18  * Copyright (C) 2005-2009 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 using google::protobuf::RpcController;
38 using ola::Device;
39 using ola::plugin::artnet::Request;
40 using std::string;
41 
42 class ArtNetDevice: public Device {
43  public:
45  class Preferences *preferences,
46  class PluginAdaptor *plugin_adaptor);
47 
48  // only one ArtNet device
49  string DeviceId() const { return "1"; }
50 
51  void EnterConfigurationMode() { m_node->EnterConfigurationMode(); }
52  void ExitConfigurationMode() { m_node->ExitConfigurationMode(); }
53 
54  void Configure(RpcController *controller,
55  const string &request,
56  string *response,
57  google::protobuf::Closure *done);
58 
59  static const char K_ALWAYS_BROADCAST_KEY[];
60  static const char K_DEVICE_NAME[];
61  static const char K_IP_KEY[];
62  static const char K_LIMITED_BROADCAST_KEY[];
63  static const char K_LONG_NAME_KEY[];
64  static const char K_LOOPBACK_KEY[];
65  static const char K_NET_KEY[];
66  static const char K_OUTPUT_PORT_KEY[];
67  static const char K_SHORT_NAME_KEY[];
68  static const char K_SUBNET_KEY[];
69  // 10s between polls when we're sending data, DMX-workshop uses 8s;
70  static const unsigned int POLL_INTERVAL = 10000;
71 
72  protected:
73  bool StartHook();
74  void PrePortStop();
75  void PostPortStop();
76 
77  private:
78  class Preferences *m_preferences;
79  ArtNetNode *m_node;
80  class PluginAdaptor *m_plugin_adaptor;
81  ola::thread::timeout_id m_timeout_id;
82 
83  void HandleOptions(Request *request, string *response);
84  void HandleNodeList(Request *request,
85  string *response,
86  RpcController *controller);
87 };
88 } // namespace artnet
89 } // namespace plugin
90 } // namespace ola
91 #endif // PLUGINS_ARTNET_ARTNETDEVICE_H_