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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
SyncPluginImpl.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 * SyncPluginImpl.h
17 * The synchronous implementation of the USB DMX plugin.
18 * Copyright (C) 2010 Simon Newton
19 */
20
21#ifndef PLUGINS_USBDMX_SYNCPLUGINIMPL_H_
22#define PLUGINS_USBDMX_SYNCPLUGINIMPL_H_
23
24#include <libusb.h>
25#include <map>
26#include <set>
27#include <string>
28#include <utility>
29#include <vector>
30
31#include "libs/usb/LibUsbAdaptor.h"
32#include "ola/base/Macro.h"
33#include "olad/Preferences.h"
34#include "plugins/usbdmx/PluginImplInterface.h"
35#include "plugins/usbdmx/Widget.h"
36#include "plugins/usbdmx/WidgetFactory.h"
37
38namespace ola {
39
40class Device;
41
42namespace plugin {
43namespace usbdmx {
44
53 class SyncPluginImpl: public PluginImplInterface, public WidgetObserver {
54 public:
64 SyncPluginImpl(PluginAdaptor *plugin_adaptor,
65 Plugin *plugin,
66 unsigned int debug_level,
67 Preferences *preferences);
68
69 ~SyncPluginImpl();
70
71 bool Start();
72 bool Stop();
73
74 bool NewWidget(class AnymauDMX *widget);
75 bool NewWidget(class DMXCProjectsNodleU1 *widget);
76 bool NewWidget(class EurolitePro *widget);
77 bool NewWidget(ola::usb::JaRuleWidget *widget);
78 bool NewWidget(class ScanlimeFadecandy *widget);
79 bool NewWidget(class Sunlite *widget);
80 bool NewWidget(class VellemanK8062 *widget);
81
82 void WidgetRemoved(OLA_UNUSED class AnymauDMX *widget) {}
83 void WidgetRemoved(OLA_UNUSED class DMXCProjectsNodleU1 *widget) {}
84 void WidgetRemoved(OLA_UNUSED class EurolitePro *widget) {}
85 void WidgetRemoved(OLA_UNUSED ola::usb::JaRuleWidget *widget) {}
86 void WidgetRemoved(OLA_UNUSED class ScanlimeFadecandy *widget) {}
87 void WidgetRemoved(OLA_UNUSED class Sunlite *widget) {}
88 void WidgetRemoved(OLA_UNUSED class VellemanK8062 *widget) {}
89
90 private:
91 typedef std::vector<class WidgetFactory*> WidgetFactories;
92 typedef std::map<class WidgetInterface*, Device*> WidgetToDeviceMap;
93
94 PluginAdaptor* const m_plugin_adaptor;
95 Plugin* const m_plugin;
96 const unsigned int m_debug_level;
97 ola::usb::SyncronousLibUsbAdaptor m_usb_adaptor;
98 Preferences* const m_preferences;
99 WidgetFactories m_widget_factories;
100
101 libusb_context *m_context;
102
103 WidgetToDeviceMap m_devices;
104 std::set<std::pair<uint8_t, uint8_t> > m_registered_devices;
105
106 unsigned int ScanForDevices();
107 void ReScanForDevices();
108 bool CheckDevice(libusb_device *device);
109
110 bool StartAndRegisterDevice(class WidgetInterface *widget, Device *device);
111
112 SyncPluginImpl(const SyncPluginImpl &) = delete;
113 const SyncPluginImpl &operator=(const SyncPluginImpl &) = delete;
114};
115} // namespace usbdmx
116} // namespace plugin
117} // namespace ola
118#endif // PLUGINS_USBDMX_SYNCPLUGINIMPL_H_
Macro.h
Helper macros.
OLA_UNUSED
#define OLA_UNUSED
Mark unused arguments & types.
Definition Macro.h:63
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::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::SyncPluginImpl::Stop
bool Stop()
Stop the implementation.
Definition SyncPluginImpl.cpp:107
ola::plugin::usbdmx::SyncPluginImpl::SyncPluginImpl
SyncPluginImpl(PluginAdaptor *plugin_adaptor, Plugin *plugin, unsigned int debug_level, Preferences *preferences)
Create a new SyncPluginImpl.
Definition SyncPluginImpl.cpp:60
ola::plugin::usbdmx::SyncPluginImpl::Start
bool Start()
Start the implementation.
Definition SyncPluginImpl.cpp:82
ola::plugin::usbdmx::SyncPluginImpl::NewWidget
bool NewWidget(class AnymauDMX *widget)
Called when a new AnymauDMX is added.
Definition SyncPluginImpl.cpp:123
ola::plugin::usbdmx::VellemanK8062
The interface for the Velleman Widgets.
Definition VellemanK8062.h:41
ola::plugin::usbdmx::WidgetInterface
The interface for a simple widget that supports a single universe of DMX.
Definition Widget.h:36
ola::plugin::usbdmx::WidgetObserver
Receives notifications when Widgets are added or removed.
Definition WidgetFactory.h:49
ola::usb::JaRuleWidget
A Ja Rule hardware device (widget).
Definition JaRuleWidget.h:57
ola::usb::SyncronousLibUsbAdaptor
A LibUsbAdaptor for use with Syncronous widgets.
Definition LibUsbAdaptor.h:540
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