Open Lighting Architecture  Latest Git
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 "libs/acn/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, ola::acn::E131Node *node,
45  class PluginAdaptor *plugin_adaptor)
46  : BasicInputPort(parent, id, plugin_adaptor),
47  m_node(node),
49  SetPriorityMode(PRIORITY_MODE_INHERIT);
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  ola::acn::E131Node *m_node;
66  E131PortHelper m_helper;
67  uint8_t m_priority;
68 };
69 
70 
72  public:
73  E131OutputPort(E131Device *parent, int id, ola::acn::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  ola::acn::E131Node *m_node;
101  E131PortHelper m_helper;
102 };
103 } // namespace e131
104 } // namespace plugin
105 } // namespace ola
106 #endif // PLUGINS_E131_E131PORT_H_
Definition: PortConstants.h:46
static const uint8_t SOURCE_PRIORITY_DEFAULT
The default priority for a source.
Definition: SourcePriorities.h:41
Definition: E131Port.h:33
Definition: Universe.h:46
Definition: E131Port.h:42
Definition: Port.h:199
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
Definition: E131Device.h:40
Definition: PluginAdaptor.h:41
std::string Description() const
Fetch the string description for a Port.
Definition: E131Port.h:56
Definition: E131Port.h:71
std::string Description() const
Fetch the string description for a Port.
Definition: E131Port.h:86
Definition: E131Node.h:50
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: Port.h:282