Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * Dmx4LinuxPort.h
17  * The Dmx4Linux plugin for ola
18  * Copyright (C) 2006-2008 Simon Newton
19  */
20 
21 #ifndef PLUGINS_DMX4LINUX_DMX4LINUXPORT_H_
22 #define PLUGINS_DMX4LINUX_DMX4LINUXPORT_H_
23 
24 #include <string>
25 #include "ola/BaseTypes.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 
70  const DmxBuffer &ReadDMX() const;
71  bool UpdateData(const uint8_t *in_buffer, unsigned int length);
72  string Description() const { return ""; }
73 
74  private:
75  DmxBuffer m_read_buffer;
76 };
77 } // namespace dmx4linux
78 } // namespace plugin
79 } // namespace ola
80 #endif // PLUGINS_DMX4LINUX_DMX4LINUXPORT_H_