Open Lighting Architecture  Latest Git
ShowJockeyDMXU1.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  * ShowJockeyDMXU1.h
17  * The synchronous and asynchronous ShowJockeyDMXU1 widgets.
18 
19  * Adapted from SJ-DMX, p3root - Patrik Pfaffenbauer,
21  * https://github.com/p3root/SJ-DMX.git
22  *
23  * by Nicolas Bertrand, [email protected]
24  *
25  * Copyright (C) 2016 Nicolas Bertrand
26  */
27 
28 #ifndef PLUGINS_USBDMX_SHOWJOCKEYDMXU1_H_
29 #define PLUGINS_USBDMX_SHOWJOCKEYDMXU1_H_
30 
31 #include <libusb.h>
32 #include <memory>
33 #include <string>
34 #include "libs/usb/LibUsbAdaptor.h"
35 #include "ola/DmxBuffer.h"
36 #include "ola/base/Macro.h"
37 #include "ola/thread/Mutex.h"
38 #include "plugins/usbdmx/Widget.h"
39 
40 namespace ola {
41 namespace plugin {
42 namespace usbdmx {
43 
44 class ShowJockeyDMXU1ThreadedSender;
45 
54 class ShowJockeyDMXU1 : public SimpleWidget {
55  public:
63  libusb_device *usb_device,
64  const std::string &serial)
65  : SimpleWidget(adaptor, usb_device),
66  m_serial(serial) {}
67 
72  std::string SerialNumber() const {
73  return m_serial;
74  }
75 
76  protected:
77  std::string m_serial;
78 };
79 
80 
87  public:
95  libusb_device *usb_device,
96  const std::string &serial);
97 
98  bool Init();
99 
100  bool SendDMX(const DmxBuffer &buffer);
101 
102  private:
103  std::auto_ptr<class ShowJockeyDMXU1ThreadedSender> m_sender;
104 
106 };
107 
112  public:
120  libusb_device *usb_device,
121  const std::string &serial);
122 
123  bool Init();
124 
125  bool SendDMX(const DmxBuffer &buffer);
126 
127  private:
128  std::auto_ptr<class ShowJockeyDMXU1AsyncUsbSender> m_sender;
129 
131 };
132 } // namespace usbdmx
133 } // namespace plugin
134 } // namespace ola
135 #endif // PLUGINS_USBDMX_SHOWJOCKEYDMXU1_H_
virtual bool SendDMX(const DmxBuffer &buffer)=0
Send DMX data from this widget.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
virtual bool Init()=0
Initialize the widget.
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
A class used to hold a single universe of DMX data.
A ShowJockeyDMXU1 widget that uses asynchronous libusb operations.
Definition: ShowJockeyDMXU1.h:111
A base simple widget class.
Definition: Widget.h:66
A ShowJockeyDMXU1 widget that uses synchronous libusb operations.
Definition: ShowJockeyDMXU1.h:86
ShowJockeyDMXU1(ola::usb::LibUsbAdaptor *adaptor, libusb_device *usb_device, const std::string &serial)
Create a new ShowJockeyDMXU1.
Definition: ShowJockeyDMXU1.h:62
Helper macros.
std::string SerialNumber() const
Get the serial number of this widget.
Definition: ShowJockeyDMXU1.h:72
The ShowJockey-DMX-U1 Widget.
Definition: ShowJockeyDMXU1.h:54
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Wraps calls to libusb so we can test the code.
Definition: LibUsbAdaptor.h:36