Open Lighting Architecture
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * E131Port.h
17  * The E1.31 port for OLA
18  * Copyright (C) 2007-2009 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 
33 using ola::DmxBuffer;
34 
35 
37  public:
38  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
39  string Description(Universe *universe) const;
40  private:
41  static const unsigned int MAX_E131_UNIVERSE = 63999;
42 };
43 
44 
46  public:
47  E131InputPort(E131Device *parent, int id, E131Node *node,
48  class PluginAdaptor *plugin_adaptor)
49  : BasicInputPort(parent, id, plugin_adaptor),
50  m_node(node) {}
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  string Description() const { return m_helper.Description(GetUniverse()); }
57  const DmxBuffer &ReadDMX() const { return m_buffer; }
58  bool SupportsPriorities() const { return true; }
59  uint8_t InheritedPriority() const { return m_priority; }
60 
61  private:
62  DmxBuffer m_buffer;
63  E131Node *m_node;
64  E131PortHelper m_helper;
65  uint8_t m_priority;
66 };
67 
68 
70  public:
71  E131OutputPort(E131Device *parent, int id, E131Node *node,
72  bool prepend_hostname)
73  : BasicOutputPort(parent, id),
74  m_prepend_hostname(prepend_hostname),
75  m_preview_on(false),
76  m_node(node) {}
77 
78  bool PreSetUniverse(Universe *old_universe, Universe *new_universe) {
79  return m_helper.PreSetUniverse(old_universe, new_universe);
80  }
81  void PostSetUniverse(Universe *old_universe, Universe *new_universe);
82  string Description() const { return m_helper.Description(GetUniverse()); }
83 
84  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
85  void UniverseNameChanged(const string &new_name);
86 
87  void SetPreviewMode(bool preview_mode) { m_preview_on = preview_mode; }
88  bool PreviewMode() const { return m_preview_on; }
89  bool SupportsPriorities() const { return true; }
90 
91  private:
92  bool m_prepend_hostname;
93  bool m_preview_on;
94  DmxBuffer m_buffer;
95  E131Node *m_node;
96  E131PortHelper m_helper;
97 };
98 } // namespace e131
99 } // namespace plugin
100 } // namespace ola
101 #endif // PLUGINS_E131_E131PORT_H_