Open Lighting Architecture  0.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FtdiDmxPort.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  * FtdiDmxPort.h
17  * The FTDI usb chipset DMX plugin for ola
18  * Copyright (C) 2011 Rui Barreiros
19  */
20 
21 #ifndef PLUGINS_FTDIDMX_FTDIDMXPORT_H_
22 #define PLUGINS_FTDIDMX_FTDIDMXPORT_H_
23 
24 #include <string>
25 
26 #include "ola/DmxBuffer.h"
27 #include "olad/Port.h"
28 #include "olad/Preferences.h"
29 #include "plugins/ftdidmx/FtdiDmxDevice.h"
30 #include "plugins/ftdidmx/FtdiWidget.h"
31 #include "plugins/ftdidmx/FtdiDmxThread.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace ftdidmx {
36 
38  public:
40  FtdiWidget *device,
41  unsigned int id,
42  unsigned int freq)
43  : BasicOutputPort(parent, id),
44  m_device(device),
45  m_thread(device, freq) {
46  m_thread.Start();
47  }
48  ~FtdiDmxOutputPort() { m_thread.Stop(); }
49 
50  bool WriteDMX(const ola::DmxBuffer &buffer, uint8_t) {
51  return m_thread.WriteDMX(buffer);
52  }
53 
54  std::string Description() const { return m_device->Description(); }
55 
56  private:
57  FtdiWidget *m_device;
58  FtdiDmxThread m_thread;
59 };
60 } // namespace ftdidmx
61 } // namespace plugin
62 } // namespace ola
63 #endif // PLUGINS_FTDIDMX_FTDIDMXPORT_H_