Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
E131Port.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  * E131Port.h
17  * The E1.31 port for OLA
18  * Copyright (C) 2007 Simon Newton
19  */
20 
21 #ifndef PLUGINS_E131_E131PORT_H_
22 #define PLUGINS_E131_E131PORT_H_
23 
24 #include <string>
25 #include "olad/Port.h"
26 #include "plugins/e131/E131Device.h"
27 #include "plugins/e131/e131/E131Node.h"
28 
29 namespace ola {
30 namespace plugin {
31 namespace e131 {
32 
34  public:
35  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
36  std::string Description(Universe *universe) const;
37  private:
38  static const unsigned int MAX_E131_UNIVERSE = 63999;
39 };
40 
41 
43  public:
44  E131InputPort(E131Device *parent, int id, E131Node *node,
45  class PluginAdaptor *plugin_adaptor)
46  : BasicInputPort(parent, id, plugin_adaptor),
47  m_node(node) {
48  SetPriorityMode(PRIORITY_MODE_INHERIT);
49  }
50 
51  bool PreSetUniverse(Universe *old_universe, Universe *new_universe) {
52  return m_helper.PreSetUniverse(old_universe, new_universe);
53  }
54  void PostSetUniverse(Universe *old_universe, Universe *new_universe);
55  std::string Description() const {
56  return m_helper.Description(GetUniverse());
57  }
58  const ola::DmxBuffer &ReadDMX() const { return m_buffer; }
59  bool SupportsPriorities() const { return true; }
60  uint8_t InheritedPriority() const { return m_priority; }
61 
62  private:
63  ola::DmxBuffer m_buffer;
64  E131Node *m_node;
65  E131PortHelper m_helper;
66  uint8_t m_priority;
67 };
68 
69 
71  public:
72  E131OutputPort(E131Device *parent, int id, E131Node *node,
73  bool prepend_hostname)
74  : BasicOutputPort(parent, id),
75  m_prepend_hostname(prepend_hostname),
76  m_preview_on(false),
77  m_node(node) {}
78 
79  bool PreSetUniverse(Universe *old_universe, Universe *new_universe) {
80  return m_helper.PreSetUniverse(old_universe, new_universe);
81  }
82  void PostSetUniverse(Universe *old_universe, Universe *new_universe);
83  std::string Description() const {
84  return m_helper.Description(GetUniverse());
85  }
86 
87  bool WriteDMX(const ola::DmxBuffer &buffer, uint8_t priority);
88  void UniverseNameChanged(const std::string &new_name);
89 
90  void SetPreviewMode(bool preview_mode) { m_preview_on = preview_mode; }
91  bool PreviewMode() const { return m_preview_on; }
92  bool SupportsPriorities() const { return true; }
93 
94  private:
95  bool m_prepend_hostname;
96  bool m_preview_on;
97  ola::DmxBuffer m_buffer;
98  E131Node *m_node;
99  E131PortHelper m_helper;
100 };
101 } // namespace e131
102 } // namespace plugin
103 } // namespace ola
104 #endif // PLUGINS_E131_E131PORT_H_