Open Lighting Architecture  0.9.5
 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),
50  }
51 
52  bool PreSetUniverse(Universe *old_universe, Universe *new_universe) {
53  return m_helper.PreSetUniverse(old_universe, new_universe);
54  }
55  void PostSetUniverse(Universe *old_universe, Universe *new_universe);
56  std::string Description() const {
57  return m_helper.Description(GetUniverse());
58  }
59  const ola::DmxBuffer &ReadDMX() const { return m_buffer; }
60  bool SupportsPriorities() const { return true; }
61  uint8_t InheritedPriority() const { return m_priority; }
62 
63  private:
64  ola::DmxBuffer m_buffer;
65  E131Node *m_node;
66  E131PortHelper m_helper;
67  uint8_t m_priority;
68 };
69 
70 
72  public:
73  E131OutputPort(E131Device *parent, int id, E131Node *node)
74  : BasicOutputPort(parent, id),
75  m_preview_on(false),
76  m_node(node) {
77  m_last_priority = GetPriority();
78  }
79 
80  ~E131OutputPort();
81 
82  bool PreSetUniverse(Universe *old_universe, Universe *new_universe) {
83  return m_helper.PreSetUniverse(old_universe, new_universe);
84  }
85  void PostSetUniverse(Universe *old_universe, Universe *new_universe);
86  std::string Description() const {
87  return m_helper.Description(GetUniverse());
88  }
89 
90  bool WriteDMX(const ola::DmxBuffer &buffer, uint8_t priority);
91 
92  void SetPreviewMode(bool preview_mode) { m_preview_on = preview_mode; }
93  bool PreviewMode() const { return m_preview_on; }
94  bool SupportsPriorities() const { return true; }
95 
96  private:
97  bool m_preview_on;
98  uint8_t m_last_priority;
99  ola::DmxBuffer m_buffer;
100  E131Node *m_node;
101  E131PortHelper m_helper;
102 };
103 } // namespace e131
104 } // namespace plugin
105 } // namespace ola
106 #endif // PLUGINS_E131_E131PORT_H_