Open Lighting Architecture: plugins/osc/OSCPort.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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
31namespace ola {
32namespace plugin {
33namespace osc {
34
42 class OSCInputPort: public BasicInputPort {
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
90 class OSCOutputPort: public BasicOutputPort {
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_
ola::BasicInputPort::BasicInputPort
BasicInputPort(AbstractDevice *parent, unsigned int port_id, const PluginAdaptor *plugin_adaptor, bool supports_rdm=false)
Create a new basic input port.
Definition Port.cpp:38
ola::BasicOutputPort::BasicOutputPort
BasicOutputPort(AbstractDevice *parent, unsigned int port_id, bool start_rdm_discovery_on_patch=false, bool supports_rdm=false)
Create a new BasicOutputPort.
Definition Port.cpp:120
ola::BasicOutputPort::PortId
unsigned int PortId() const
Get the Port ID. This is the index within the device.
Definition Port.h:293
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::PluginAdaptor
Definition PluginAdaptor.h:41
ola::Universe
Definition Universe.h:46
ola::plugin::osc::OSCDevice
Definition OSCDevice.h:40
ola::plugin::osc::OSCInputPort::PreSetUniverse
bool PreSetUniverse(Universe *old_universe, Universe *new_universe)
Definition OSCPort.cpp:51
ola::plugin::osc::OSCInputPort::Description
std::string Description() const
Definition OSCPort.h:72
ola::plugin::osc::OSCInputPort::OSCInputPort
OSCInputPort(OSCDevice *parent, unsigned int port_id, PluginAdaptor *plugin_adaptor, OSCNode *node, const std::string &address)
Definition OSCPort.cpp:39
ola::plugin::osc::OSCInputPort::ReadDMX
const DmxBuffer & ReadDMX() const
Definition OSCPort.h:61
ola::plugin::osc::OSCNode
Definition OSCNode.h:69
ola::plugin::osc::OSCOutputPort::OSCOutputPort
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
ola::plugin::osc::OSCOutputPort::PreSetUniverse
bool PreSetUniverse(Universe *old_universe, Universe *new_universe)
Definition OSCPort.cpp:99
ola::plugin::osc::OSCOutputPort::WriteDMX
bool WriteDMX(const DmxBuffer &buffer, uint8_t)
Send this DMX buffer using OSC. The second argument (priority) is not used.
Definition OSCPort.h:118
ola::plugin::osc::OSCOutputPort::Description
std::string Description() const
Definition OSCPort.h:125
ola::plugin::osc
Code for the OSC protocol.
ola::plugin
Code for supported devices and protocols.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44