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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
AsyncPluginImpl.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 * AsyncPluginImpl.h
17 * The asynchronous libusb implementation.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef PLUGINS_USBDMX_ASYNCPLUGINIMPL_H_
22#define PLUGINS_USBDMX_ASYNCPLUGINIMPL_H_
23
24#include <libusb.h>
25
26#if HAVE_CONFIG_H
27#include <config.h>
28#endif // HAVE_CONFIG_H
29
30#include <map>
31#include <memory>
32#include <string>
33#include <utility>
34#include <vector>
35
36#include "libs/usb/Types.h"
37#include "libs/usb/HotplugAgent.h"
38
39#include "ola/base/Macro.h"
40#include "ola/thread/Future.h"
41#include "olad/Preferences.h"
42#include "plugins/usbdmx/PluginImplInterface.h"
43#include "plugins/usbdmx/SyncronizedWidgetObserver.h"
44#include "plugins/usbdmx/WidgetFactory.h"
45
46namespace ola {
47namespace usb {
48class LibUsbThread;
49class AsyncronousLibUsbAdaptor;
50} // namespace usb
51
52class Device;
53
54namespace plugin {
55namespace usbdmx {
56
60 class AsyncPluginImpl: public PluginImplInterface, public WidgetObserver {
61 public:
71 AsyncPluginImpl(PluginAdaptor *plugin_adaptor,
72 Plugin *plugin,
73 unsigned int debug_level,
74 Preferences *preferences);
75 ~AsyncPluginImpl();
76
77 bool Start();
78 bool Stop();
79
80 // These are all run in the main SelectServer thread.
81 bool NewWidget(class AnymauDMX *widget);
82 bool NewWidget(class DMXCProjectsNodleU1 *widget);
83 bool NewWidget(class EurolitePro *widget);
84 bool NewWidget(ola::usb::JaRuleWidget *widget);
85 bool NewWidget(class ScanlimeFadecandy *widget);
86 bool NewWidget(class Sunlite *widget);
87 bool NewWidget(class VellemanK8062 *widget);
88
89 private:
90 typedef std::vector<class WidgetFactory*> WidgetFactories;
91 typedef std::map<ola::usb::USBDeviceID, class DeviceState*> USBDeviceMap;
92
93 PluginAdaptor* const m_plugin_adaptor;
94 Plugin* const m_plugin;
95 const unsigned int m_debug_level;
96 std::auto_ptr<ola::usb::HotplugAgent> m_agent;
97 Preferences* const m_preferences;
98
99 SyncronizedWidgetObserver m_widget_observer;
100 ola::usb::AsyncronousLibUsbAdaptor *m_usb_adaptor; // not owned
101 WidgetFactories m_widget_factories;
102 USBDeviceMap m_device_map;
103
104 void DeviceEvent(ola::usb::HotplugAgent::EventType event,
105 struct libusb_device *device);
106 void SetupUSBDevice(libusb_device *device);
107
108 template <typename Widget>
109 bool StartAndRegisterDevice(Widget *widget, Device *device);
110
111 void ShutdownDevice(Device *device, ola::thread::Future<void> *f);
112
113 AsyncPluginImpl(const AsyncPluginImpl &) = delete;
114 const AsyncPluginImpl &operator=(const AsyncPluginImpl &) = delete;
115};
116} // namespace usbdmx
117} // namespace plugin
118} // namespace ola
119#endif // PLUGINS_USBDMX_ASYNCPLUGINIMPL_H_
Macro.h
Helper macros.
ola::Device
Definition Device.h:89
ola::PluginAdaptor
Definition PluginAdaptor.h:41
ola::Plugin
Definition Plugin.h:118
ola::Preferences
Definition Preferences.h:148
ola::plugin::usbdmx::AnymauDMX
The base class for Anyma Widgets.
Definition AnymauDMX.h:41
ola::plugin::usbdmx::AsyncPluginImpl::NewWidget
bool NewWidget(class AnymauDMX *widget)
Called when a new AnymauDMX is added.
Definition AsyncPluginImpl.cpp:165
ola::plugin::usbdmx::AsyncPluginImpl::Start
bool Start()
Start the implementation.
Definition AsyncPluginImpl.cpp:106
ola::plugin::usbdmx::AsyncPluginImpl::AsyncPluginImpl
AsyncPluginImpl(PluginAdaptor *plugin_adaptor, Plugin *plugin, unsigned int debug_level, Preferences *preferences)
Create a new AsyncPluginImpl.
Definition AsyncPluginImpl.cpp:90
ola::plugin::usbdmx::AsyncPluginImpl::Stop
bool Stop()
Stop the implementation.
Definition AsyncPluginImpl.cpp:140
ola::plugin::usbdmx::DMXCProjectsNodleU1
The interface for the Nodle Widgets.
Definition DMXCProjectsNodleU1.h:43
ola::plugin::usbdmx::EurolitePro
The EurolitePro Widget.
Definition EurolitePro.h:42
ola::plugin::usbdmx::PluginImplInterface
The interface for an implementation of the USB DMX plugin.
Definition PluginImplInterface.h:40
ola::plugin::usbdmx::ScanlimeFadecandy
The interface for the Fadecandy Widgets.
Definition ScanlimeFadecandy.h:49
ola::plugin::usbdmx::Sunlite
The interface for the Sunlite Widgets.
Definition Sunlite.h:40
ola::plugin::usbdmx::SyncronizedWidgetObserver
Transfers widget add/remove events to another thread.
Definition SyncronizedWidgetObserver.h:40
ola::plugin::usbdmx::VellemanK8062
The interface for the Velleman Widgets.
Definition VellemanK8062.h:41
ola::plugin::usbdmx::WidgetObserver
Receives notifications when Widgets are added or removed.
Definition WidgetFactory.h:49
ola::thread::Future
Definition Future.h:33
ola::usb::AsyncronousLibUsbAdaptor
A LibUsbAdaptor for use with Asyncronous widgets.
Definition LibUsbAdaptor.h:564
ola::usb::HotplugAgent::EventType
EventType
Definition HotplugAgent.h:47
ola::usb::JaRuleWidget
A Ja Rule hardware device (widget).
Definition JaRuleWidget.h:57
ola::usb::LibUsbThread
The base class for the dedicated libusb thread.
Definition LibUsbThread.h:55
ola::plugin::usbdmx
The plugin for hardware using libusb.
ola::plugin
Code for supported devices and protocols.
ola::usb
USB Device drivers.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44