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
44 public:
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
96 public:
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
124 const SynchronousDMXCProjectsNodleU1 &operator=(const SynchronousDMXCProjectsNodleU1 &) = delete;
125};
126
131 public:
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
159 const AsynchronousDMXCProjectsNodleU1 &operator=(const AsynchronousDMXCProjectsNodleU1 &) = delete;
160};
161} // namespace usbdmx
162} // namespace plugin
163} // namespace ola
164#endif // PLUGINS_USBDMX_DMXCPROJECTSNODLEU1_H_
A class used to hold a single universe of DMX data.
Helper macros.
Provides a wrapper for the DeviceManager and SelectServer objects so that the plugins can register de...
A 0 argument callback which can be called multiple times.
Definition Callback.h:129
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
Definition PluginAdaptor.h:41
An Nodle widget that uses asynchronous libusb operations.
Definition DMXCProjectsNodleU1.h:130
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition DMXCProjectsNodleU1.cpp:527
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
bool Init()
Initialize the widget.
Definition DMXCProjectsNodleU1.cpp:508
The interface for the Nodle Widgets.
Definition DMXCProjectsNodleU1.h:43
unsigned int Mode() const
Get the current mode of this widget.
Definition DMXCProjectsNodleU1.h:68
std::string SerialNumber() const
Get the serial number of this widget.
Definition DMXCProjectsNodleU1.h:60
A base simple widget class.
Definition Widget.h:66
SimpleWidget(ola::usb::LibUsbAdaptor *adaptor, libusb_device *usb_device)
Create a new SimpleWidget.
Definition Widget.h:73
An Nodle widget that uses synchronous libusb operations.
Definition DMXCProjectsNodleU1.h:95
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition DMXCProjectsNodleU1.cpp:304
bool Init()
Initialize the widget.
Definition DMXCProjectsNodleU1.cpp:271
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
Wraps calls to libusb so we can test the code.
Definition LibUsbAdaptor.h:36
The namespace containing all OLA symbols.
Definition Credentials.cpp:44