Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Dmx4LinuxPort.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  * Dmx4LinuxPort.h
17  * The Dmx4Linux plugin for ola
18  * Copyright (C) 2006 Simon Newton
19  */
20 
21 #ifndef PLUGINS_DMX4LINUX_DMX4LINUXPORT_H_
22 #define PLUGINS_DMX4LINUX_DMX4LINUXPORT_H_
23 
24 #include <string>
25 #include "ola/Constants.h"
26 #include "ola/DmxBuffer.h"
27 #include "plugins/dmx4linux/Dmx4LinuxDevice.h"
28 #include "plugins/dmx4linux/Dmx4LinuxSocket.h"
29 
30 namespace ola {
31 namespace plugin {
32 namespace dmx4linux {
33 
34 
35 /*
36  * A Dmx4Linux output port, we only have 1 port per device so the port id is
37  * always 0.
38  */
40  public:
42  Dmx4LinuxSocket *socket,
43  int d4l_universe)
44  : BasicOutputPort(parent, 0),
45  m_socket(socket),
46  m_d4l_universe(d4l_universe) {
47  }
48 
49  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
50  string Description() const { return ""; }
51 
52  private:
53  Dmx4LinuxSocket *m_socket;
54  int m_d4l_universe; // dmx4linux universe that this maps to
55 };
56 
57 
58 /*
59  * A Dmx4Linux input port, we only have 1 port per device so the port id is
60  * always 0.
61  */
63  public:
64  explicit Dmx4LinuxInputPort(Dmx4LinuxDevice *parent,
65  class PluginAdaptor *plugin_adaptor)
66  : BasicInputPort(parent, 0, plugin_adaptor) {
67  m_read_buffer.SetRangeToValue(0, 0, DMX_UNIVERSE_SIZE);
68  }
69 
74  const DmxBuffer &ReadDMX() const;
75 
79  bool UpdateData(const uint8_t *in_buffer, unsigned int length);
80  string Description() const { return ""; }
81 
82  private:
83  DmxBuffer m_read_buffer;
84 };
85 } // namespace dmx4linux
86 } // namespace plugin
87 } // namespace ola
88 #endif // PLUGINS_DMX4LINUX_DMX4LINUXPORT_H_
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
string Description() const
Fetch the string description for a Port.
Definition: Dmx4LinuxPort.h:50
bool SetRangeToValue(unsigned int offset, uint8_t data, unsigned int length)
Set a Range of data to a single value. Calling this on an uninitialized buffer will call Blackout() f...
Definition: DmxBuffer.cpp:188
const DmxBuffer & ReadDMX() const
Definition: Dmx4LinuxPort.cpp:51
Definition: Dmx4LinuxPort.h:62
Definition: Dmx4LinuxPort.h:39
Definition: Dmx4LinuxDevice.h:31
Definition: Port.h:199
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
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
bool WriteDMX(const DmxBuffer &buffer, uint8_t priority)
Write DMX data to this port.
Definition: Dmx4LinuxPort.cpp:34
Constants used throughout OLA.
A class used to hold a single universe of DMX data.
Definition: PluginAdaptor.h:41
Definition: Constants.h:36
bool UpdateData(const uint8_t *in_buffer, unsigned int length)
Definition: Dmx4LinuxPort.cpp:55
string Description() const
Fetch the string description for a Port.
Definition: Dmx4LinuxPort.h:80
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: Port.h:282
Definition: Dmx4LinuxSocket.h:30