Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OSCPort.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  * OSCPort.h
17  * The OSCInputPort and OSCOutputPort classes.
18  * Copyright (C) 2012 Simon Newton
19  */
20 
21 #ifndef PLUGINS_OSC_OSCPORT_H_
22 #define PLUGINS_OSC_OSCPORT_H_
23 
24 #include <string>
25 #include <vector>
26 #include "olad/Port.h"
27 #include "plugins/osc/OSCAddressTemplate.h"
28 #include "plugins/osc/OSCDevice.h"
29 #include "plugins/osc/OSCNode.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace osc {
34 
43  public:
52  OSCInputPort(OSCDevice *parent,
53  unsigned int port_id,
54  PluginAdaptor *plugin_adaptor,
55  OSCNode *node,
56  const std::string &address);
57 
61  const DmxBuffer &ReadDMX() const { return m_buffer; }
62 
67  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
68 
72  std::string Description() const { return m_actual_address; }
73 
74  private:
75  OSCNode *m_node;
76  DmxBuffer m_buffer;
77  const std::string m_address;
78  std::string m_actual_address;
79 
83  void NewDMXData(const DmxBuffer &data);
84 };
85 
86 
91  public:
100  OSCOutputPort(OSCDevice *device,
101  unsigned int port_id,
102  OSCNode *node,
103  const std::vector<OSCTarget> &targets,
104  OSCNode::DataFormat data_format);
105  ~OSCOutputPort();
106 
111  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
112 
118  bool WriteDMX(const DmxBuffer &buffer, uint8_t) {
119  return m_node->SendData(this->PortId(), m_data_format, buffer);
120  }
121 
125  std::string Description() const { return m_description; }
126 
127  private:
128  OSCNode *m_node;
129  const std::vector<OSCTarget> m_template_targets;
130  std::vector<OSCTarget> m_registered_targets;
131  std::string m_description;
132  OSCNode::DataFormat m_data_format;
133 
134  void RemoveTargets();
135  void SetUnpatchedDescription();
136 };
137 } // namespace osc
138 } // namespace plugin
139 } // namespace ola
140 #endif // PLUGINS_OSC_OSCPORT_H_
bool PreSetUniverse(Universe *old_universe, Universe *new_universe)
Definition: OSCPort.cpp:99
Definition: OSCPort.h:90
Definition: Universe.h:45
Definition: OSCDevice.h:40
Definition: Port.h:199
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
Definition: OSCNode.h:69
OSCOutputPort(OSCDevice *device, unsigned int port_id, OSCNode *node, const std::vector< OSCTarget > &targets, OSCNode::DataFormat data_format)
Create an OSCOutputPort.
Definition: OSCPort.cpp:82
std::string Description() const
Definition: OSCPort.h:125
const DmxBuffer & ReadDMX() const
Definition: OSCPort.h:61
The Input Port class, for receiving DMX via OSC.
Definition: OSCPort.h:42
Definition: PluginAdaptor.h:41
std::string Description() const
Definition: OSCPort.h:72
bool WriteDMX(const DmxBuffer &buffer, uint8_t)
Send this DMX buffer using OSC. The second argument (priority) is not used.
Definition: OSCPort.h:118
OSCInputPort(OSCDevice *parent, unsigned int port_id, PluginAdaptor *plugin_adaptor, OSCNode *node, const std::string &address)
Definition: OSCPort.cpp:39
bool SendData(unsigned int group, DataFormat data_format, const ola::DmxBuffer &data)
Definition: OSCNode.cpp:371
bool PreSetUniverse(Universe *old_universe, Universe *new_universe)
Definition: OSCPort.cpp:51
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
unsigned int PortId() const
Get the Port ID. This is the index within the device.
Definition: Port.h:292
Definition: Port.h:282