Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UartDmxPort.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  * UartDmxPort.h
17  * The DMX through a UART plugin for ola
18  * Copyright (C) 2011 Rui Barreiros
19  * Copyright (C) 2014 Richard Ash
20  */
21 
22 #ifndef PLUGINS_UARTDMX_UARTDMXPORT_H_
23 #define PLUGINS_UARTDMX_UARTDMXPORT_H_
24 
25 #include <string>
26 
27 #include "ola/DmxBuffer.h"
28 #include "olad/Port.h"
29 #include "olad/Preferences.h"
30 #include "plugins/uartdmx/UartDmxDevice.h"
31 #include "plugins/uartdmx/UartWidget.h"
32 #include "plugins/uartdmx/UartDmxThread.h"
33 
34 namespace ola {
35 namespace plugin {
36 namespace uartdmx {
37 
39  public:
41  unsigned int id,
42  UartWidget *widget,
43  unsigned int breakt,
44  unsigned int malft)
45  : BasicOutputPort(parent, id),
46  m_widget(widget),
47  m_thread(widget, breakt, malft) {
48  m_thread.Start();
49  }
50  ~UartDmxOutputPort() { m_thread.Stop(); }
51 
52  bool WriteDMX(const ola::DmxBuffer &buffer, uint8_t) {
53  return m_thread.WriteDMX(buffer);
54  }
55 
56  std::string Description() const { return m_widget->Description(); }
57 
58  private:
59  UartWidget *m_widget;
60  UartDmxThread m_thread;
61 
62  DISALLOW_COPY_AND_ASSIGN(UartDmxOutputPort);
63 };
64 } // namespace uartdmx
65 } // namespace plugin
66 } // namespace ola
67 #endif // PLUGINS_UARTDMX_UARTDMXPORT_H_
Definition: UartDmxDevice.h:37
std::string Description() const
Fetch the string description for a Port.
Definition: UartDmxPort.h:56
bool WriteDMX(const DmxBuffer &buffer)
Definition: UartDmxThread.cpp:64
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
A class used to hold a single universe of DMX data.
virtual bool Start()
Start the thread and wait for the thread to be running.
Definition: Thread.cpp:84
Definition: UartDmxThread.h:32
bool WriteDMX(const ola::DmxBuffer &buffer, uint8_t)
Write DMX data to this port.
Definition: UartDmxPort.h:52
Definition: UartWidget.h:46
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: UartDmxPort.h:38
Definition: Port.h:282
bool Stop()
Definition: UartDmxThread.cpp:52