Open Lighting Architecture: plugins/usbdmx/DMXCProjectsNodleU1.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
DMXCProjectsNodleU1.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 * DMXCProjectsNodleU1.h
17 * The synchronous and asynchronous Nodle widgets.
18 * Copyright (C) 2015 Stefan Krupop
19 */
20
21#ifndef PLUGINS_USBDMX_DMXCPROJECTSNODLEU1_H_
22#define PLUGINS_USBDMX_DMXCPROJECTSNODLEU1_H_
23
24#include <libusb.h>
25#include <memory>
26#include <string>
27
28#include "libs/usb/LibUsbAdaptor.h"
29#include "ola/Callback.h"
30#include "ola/DmxBuffer.h"
31#include "ola/base/Macro.h"
32#include "ola/thread/Mutex.h"
33#include "olad/PluginAdaptor.h"
34#include "plugins/usbdmx/Widget.h"
35
36namespace ola {
37namespace plugin {
38namespace usbdmx {
39
43 class DMXCProjectsNodleU1: public SimpleWidget {
44 public:
45 explicit DMXCProjectsNodleU1(ola::usb::LibUsbAdaptor *adaptor,
46 libusb_device *usb_device,
47 PluginAdaptor *plugin_adaptor,
48 const std::string &serial,
49 unsigned int mode)
50 : SimpleWidget(adaptor, usb_device),
51 m_serial(serial),
52 m_mode(mode),
53 m_plugin_adaptor(plugin_adaptor) {
54 }
55
60 std::string SerialNumber() const {
61 return m_serial;
62 }
63
68 unsigned int Mode() const {
69 return m_mode;
70 }
71
72 virtual void SetDmxCallback(Callback0<void> *callback) = 0;
73 virtual const DmxBuffer &GetDmxInBuffer() = 0;
74
75 static int NODLE_DEFAULT_MODE;
76 static int NODLE_MIN_MODE;
77 static int NODLE_MAX_MODE;
78
79 static int OUTPUT_ENABLE_MASK;
80 static int INPUT_ENABLE_MASK;
81
82 private:
83 std::string m_serial;
84
85 protected:
86 unsigned int m_mode;
87 PluginAdaptor *m_plugin_adaptor;
88};
89
95 class SynchronousDMXCProjectsNodleU1: public DMXCProjectsNodleU1 {
96 public:
105 SynchronousDMXCProjectsNodleU1(ola::usb::LibUsbAdaptor *adaptor,
106 libusb_device *usb_device,
107 PluginAdaptor *plugin_adaptor,
108 const std::string &serial,
109 unsigned int mode);
110
111 bool Init();
112
113 bool SendDMX(const DmxBuffer &buffer);
114
115 void SetDmxCallback(Callback0<void> *callback);
116 const DmxBuffer &GetDmxInBuffer();
117
118 private:
119 libusb_device* const m_usb_device;
120 std::auto_ptr<class DMXCProjectsNodleU1ThreadedSender> m_sender;
121 std::auto_ptr<class DMXCProjectsNodleU1ThreadedReceiver> m_receiver;
122
123 SynchronousDMXCProjectsNodleU1(const SynchronousDMXCProjectsNodleU1 &) = delete;
124 const SynchronousDMXCProjectsNodleU1 &operator=(const SynchronousDMXCProjectsNodleU1 &) = delete;
125};
126
130 class AsynchronousDMXCProjectsNodleU1 : public DMXCProjectsNodleU1 {
131 public:
140 AsynchronousDMXCProjectsNodleU1(ola::usb::LibUsbAdaptor *adaptor,
141 libusb_device *usb_device,
142 PluginAdaptor *plugin_adaptor,
143 const std::string &serial,
144 unsigned int mode);
145
146 bool Init();
147
148 bool SendDMX(const DmxBuffer &buffer);
149
150 void SetDmxCallback(Callback0<void> *callback);
151 const DmxBuffer &GetDmxInBuffer();
152
153 private:
154 std::auto_ptr<class DMXCProjectsNodleU1AsyncUsbSender> m_sender;
155 std::auto_ptr<class DMXCProjectsNodleU1AsyncUsbReceiver> m_receiver;
156 DmxBuffer m_buffer;
157
158 AsynchronousDMXCProjectsNodleU1(const AsynchronousDMXCProjectsNodleU1 &) = delete;
159 const AsynchronousDMXCProjectsNodleU1 &operator=(const AsynchronousDMXCProjectsNodleU1 &) = delete;
160};
161} // namespace usbdmx
162} // namespace plugin
163} // namespace ola
164#endif // PLUGINS_USBDMX_DMXCPROJECTSNODLEU1_H_
Callback.h
DmxBuffer.h
A class used to hold a single universe of DMX data.
Macro.h
Helper macros.
PluginAdaptor.h
Provides a wrapper for the DeviceManager and SelectServer objects so that the plugins can register de...
ola::Callback0
A 0 argument callback which can be called multiple times.
Definition Callback.h:129
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::PluginAdaptor
Definition PluginAdaptor.h:41
ola::plugin::usbdmx::AsynchronousDMXCProjectsNodleU1::SendDMX
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition DMXCProjectsNodleU1.cpp:527
ola::plugin::usbdmx::AsynchronousDMXCProjectsNodleU1::AsynchronousDMXCProjectsNodleU1
AsynchronousDMXCProjectsNodleU1(ola::usb::LibUsbAdaptor *adaptor, libusb_device *usb_device, PluginAdaptor *plugin_adaptor, const std::string &serial, unsigned int mode)
Create a new AsynchronousDMXCProjectsNodleU1.
Definition DMXCProjectsNodleU1.cpp:488
ola::plugin::usbdmx::AsynchronousDMXCProjectsNodleU1::Init
bool Init()
Initialize the widget.
Definition DMXCProjectsNodleU1.cpp:508
ola::plugin::usbdmx::DMXCProjectsNodleU1::Mode
unsigned int Mode() const
Get the current mode of this widget.
Definition DMXCProjectsNodleU1.h:68
ola::plugin::usbdmx::DMXCProjectsNodleU1::SerialNumber
std::string SerialNumber() const
Get the serial number of this widget.
Definition DMXCProjectsNodleU1.h:60
ola::plugin::usbdmx::SimpleWidget::SimpleWidget
SimpleWidget(ola::usb::LibUsbAdaptor *adaptor, libusb_device *usb_device)
Create a new SimpleWidget.
Definition Widget.h:73
ola::plugin::usbdmx::SynchronousDMXCProjectsNodleU1::SendDMX
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition DMXCProjectsNodleU1.cpp:304
ola::plugin::usbdmx::SynchronousDMXCProjectsNodleU1::Init
bool Init()
Initialize the widget.
Definition DMXCProjectsNodleU1.cpp:271
ola::plugin::usbdmx::SynchronousDMXCProjectsNodleU1::SynchronousDMXCProjectsNodleU1
SynchronousDMXCProjectsNodleU1(ola::usb::LibUsbAdaptor *adaptor, libusb_device *usb_device, PluginAdaptor *plugin_adaptor, const std::string &serial, unsigned int mode)
Create a new SynchronousDMXCProjectsNodleU1.
Definition DMXCProjectsNodleU1.cpp:261
ola::usb::LibUsbAdaptor
Wraps calls to libusb so we can test the code.
Definition LibUsbAdaptor.h:36
ola::plugin::usbdmx
The plugin for hardware using libusb.
ola::plugin
Code for supported devices and protocols.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44