Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
36 namespace ola {
37 namespace plugin {
38 namespace 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 
123  DISALLOW_COPY_AND_ASSIGN(SynchronousDMXCProjectsNodleU1);
124 };
125 
130  public:
140  libusb_device *usb_device,
141  PluginAdaptor *plugin_adaptor,
142  const std::string &serial,
143  unsigned int mode);
144 
145  bool Init();
146 
147  bool SendDMX(const DmxBuffer &buffer);
148 
149  void SetDmxCallback(Callback0<void> *callback);
150  const DmxBuffer &GetDmxInBuffer();
151 
152  private:
153  std::auto_ptr<class DMXCProjectsNodleU1AsyncUsbSender> m_sender;
154  std::auto_ptr<class DMXCProjectsNodleU1AsyncUsbReceiver> m_receiver;
155  DmxBuffer m_buffer;
156 
157  DISALLOW_COPY_AND_ASSIGN(AsynchronousDMXCProjectsNodleU1);
158 };
159 } // namespace usbdmx
160 } // namespace plugin
161 } // namespace ola
162 #endif // PLUGINS_USBDMX_DMXCPROJECTSNODLEU1_H_
The interface for the Nodle Widgets.
Definition: DMXCProjectsNodleU1.h:43
Provides a wrapper for the DeviceManager and SelectServer objects so that the plugins can register de...
An Nodle widget that uses synchronous libusb operations.
Definition: DMXCProjectsNodleU1.h:95
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
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:486
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition: DMXCProjectsNodleU1.cpp:525
A class used to hold a single universe of DMX data.
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition: DMXCProjectsNodleU1.cpp:304
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
unsigned int Mode() const
Get the current mode of this widget.
Definition: DMXCProjectsNodleU1.h:68
An Nodle widget that uses asynchronous libusb operations.
Definition: DMXCProjectsNodleU1.h:129
Definition: PluginAdaptor.h:41
std::string SerialNumber() const
Get the serial number of this widget.
Definition: DMXCProjectsNodleU1.h:60
A base simple widget class.
Definition: Widget.h:66
Helper macros.
bool Init()
Initialize the widget.
Definition: DMXCProjectsNodleU1.cpp:506
SimpleWidget(ola::usb::LibUsbAdaptor *adaptor, libusb_device *usb_device)
Create a new SimpleWidget.
Definition: Widget.h:73
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
bool Init()
Initialize the widget.
Definition: DMXCProjectsNodleU1.cpp:271
Wraps calls to libusb so we can test the code.
Definition: LibUsbAdaptor.h:36