Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_