Open Lighting Architecture  Latest Git
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 "libs/acn/E131Node.h"
28 #include "ola/acn/CID.h"
29 #include "olad/Device.h"
30 #include "olad/Plugin.h"
31 #include "plugins/e131/messages/E131ConfigMessages.pb.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace e131 {
36 
37 class E131InputPort;
38 class E131OutputPort;
39 
40 class E131Device: public ola::Device {
41  public:
43  public:
46  input_ports(0),
47  output_ports(0) {
48  }
49  unsigned int input_ports;
50  unsigned int output_ports;
51  };
52 
53  E131Device(ola::Plugin *owner,
54  const ola::acn::CID &cid,
55  std::string ip_addr,
56  class PluginAdaptor *plugin_adaptor,
57  const E131DeviceOptions &options);
58 
59  std::string DeviceId() const { return "1"; }
60 
61  void Configure(ola::rpc::RpcController *controller,
62  const std::string &request,
63  std::string *response,
64  ConfigureCallback *done);
65 
66  protected:
67  bool StartHook();
68  void PrePortStop();
69  void PostPortStop();
70 
71  private:
72  class PluginAdaptor *m_plugin_adaptor;
73  std::auto_ptr<ola::acn::E131Node> m_node;
74  const E131DeviceOptions m_options;
75  std::vector<E131InputPort*> m_input_ports;
76  std::vector<E131OutputPort*> m_output_ports;
77  std::string m_ip_addr;
78  ola::acn::CID m_cid;
79 
80  void HandlePreviewMode(const ola::plugin::e131::Request *request,
81  std::string *response);
82  void HandlePortStatusRequest(std::string *response);
83  void HandleSourceListRequest(const ola::plugin::e131::Request *request,
84  std::string *response);
85 
86  E131InputPort *GetE131InputPort(unsigned int port_id);
87  E131OutputPort *GetE131OutputPort(unsigned int port_id);
88 
89  static const char DEVICE_NAME[];
90 };
91 } // namespace e131
92 } // namespace plugin
93 } // namespace ola
94 #endif // PLUGINS_E131_E131DEVICE_H_
Definition: E131Port.h:42
std::string DeviceId() const
The device ID.
Definition: E131Device.h:59
bool StartHook()
Called during Start().
Definition: E131Device.cpp:74
Definition: Device.h:95
Options for the E131Node.
Definition: E131Node.h:55
Definition: E131Device.h:40
The ACN component identifier.
The ACN component identifier.
Definition: CID.h:47
Definition: Plugin.h:118
Definition: PluginAdaptor.h:41
Definition: E131Port.h:71
void Configure(ola::rpc::RpcController *controller, const std::string &request, std::string *response, ConfigureCallback *done)
Configure this Device.
Definition: E131Device.cpp:130
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
A RpcController object is passed every time an RPC is invoked and is used to indicate the success or ...
Definition: RpcController.h:42