Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
E131Device.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  * E131Device.h
17  * Interface for the E1.31 device
18  * Copyright (C) 2007 Simon Newton
19  */
20 
21 #ifndef PLUGINS_E131_E131DEVICE_H_
22 #define PLUGINS_E131_E131DEVICE_H_
23 
24 #include <string>
25 #include <vector>
26 #include "ola/acn/CID.h"
27 #include "olad/Device.h"
28 #include "olad/Plugin.h"
29 #include "plugins/e131/messages/E131ConfigMessages.pb.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace e131 {
34 
35 
36 class E131InputPort;
37 class E131OutputPort;
38 
39 class E131Device: public ola::Device {
40  public:
42  unsigned int input_ports;
43  unsigned int output_ports;
44  bool use_rev2;
45  bool prepend_hostname;
46  bool ignore_preview;
47  uint8_t dscp;
48 
50  : input_ports(0),
51  output_ports(0),
52  use_rev2(false),
53  prepend_hostname(true),
54  ignore_preview(true),
55  dscp(0) {
56  }
57  };
58 
59  E131Device(ola::Plugin *owner,
60  const ola::acn::CID &cid,
61  std::string ip_addr,
62  class PluginAdaptor *plugin_adaptor,
63  const E131DeviceOptions &options);
64 
65  std::string DeviceId() const { return "1"; }
66 
67  void Configure(ola::rpc::RpcController *controller,
68  const std::string &request,
69  std::string *response,
70  ConfigureCallback *done);
71 
72  protected:
73  bool StartHook();
74  void PrePortStop();
75  void PostPortStop();
76 
77  private:
78  class PluginAdaptor *m_plugin_adaptor;
79  class E131Node *m_node;
80  bool m_use_rev2;
81  bool m_prepend_hostname;
82  bool m_ignore_preview;
83  uint8_t m_dscp;
84  const unsigned int m_input_port_count, m_output_port_count;
85  std::vector<E131InputPort*> m_input_ports;
86  std::vector<E131OutputPort*> m_output_ports;
87  std::string m_ip_addr;
88  ola::acn::CID m_cid;
89 
90  void HandlePreviewMode(ola::plugin::e131::Request *request,
91  std::string *response);
92 
93  void HandlePortStatusRequest(std::string *response);
94  E131InputPort *GetE131InputPort(unsigned int port_id);
95  E131OutputPort *GetE131OutputPort(unsigned int port_id);
96 
97  static const char DEVICE_NAME[];
98 };
99 } // namespace e131
100 } // namespace plugin
101 } // namespace ola
102 #endif // PLUGINS_E131_E131DEVICE_H_