Open Lighting Architecture  0.9.4
 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 <memory>
25 #include <string>
26 #include <vector>
27 #include "ola/acn/CID.h"
28 #include "olad/Device.h"
29 #include "olad/Plugin.h"
30 #include "plugins/e131/messages/E131ConfigMessages.pb.h"
31 #include "plugins/e131/e131/E131Node.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace e131 {
36 
37 
38 class E131InputPort;
39 class E131OutputPort;
40 
41 class E131Device: public ola::Device {
42  public:
44  public:
47  input_ports(0),
48  output_ports(0) {
49  }
50  unsigned int input_ports;
51  unsigned int output_ports;
52  };
53 
54  E131Device(ola::Plugin *owner,
55  const ola::acn::CID &cid,
56  std::string ip_addr,
57  class PluginAdaptor *plugin_adaptor,
58  const E131DeviceOptions &options);
59 
60  std::string DeviceId() const { return "1"; }
61 
62  void Configure(ola::rpc::RpcController *controller,
63  const std::string &request,
64  std::string *response,
65  ConfigureCallback *done);
66 
67  protected:
68  bool StartHook();
69  void PrePortStop();
70  void PostPortStop();
71 
72  private:
73  class PluginAdaptor *m_plugin_adaptor;
74  std::auto_ptr<E131Node> m_node;
75  const E131DeviceOptions m_options;
76  std::vector<E131InputPort*> m_input_ports;
77  std::vector<E131OutputPort*> m_output_ports;
78  std::string m_ip_addr;
79  ola::acn::CID m_cid;
80 
81  void HandlePreviewMode(const ola::plugin::e131::Request *request,
82  std::string *response);
83  void HandlePortStatusRequest(std::string *response);
84  void HandleSourceListRequest(const ola::plugin::e131::Request *request,
85  std::string *response);
86 
87  E131InputPort *GetE131InputPort(unsigned int port_id);
88  E131OutputPort *GetE131OutputPort(unsigned int port_id);
89 
90  static const char DEVICE_NAME[];
91 };
92 } // namespace e131
93 } // namespace plugin
94 } // namespace ola
95 #endif // PLUGINS_E131_E131DEVICE_H_