Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
38 namespace ola {
39 
40 class Device;
41 
42 namespace plugin {
43 namespace usbdmx {
44 
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;
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  DISALLOW_COPY_AND_ASSIGN(SyncPluginImpl);
113 };
114 } // namespace usbdmx
115 } // namespace plugin
116 } // namespace ola
117 #endif // PLUGINS_USBDMX_SYNCPLUGINIMPL_H_
The interface for the Nodle Widgets.
Definition: DMXCProjectsNodleU1.h:43
The EurolitePro Widget.
Definition: EurolitePro.h:42
The legacy implementation.
Definition: SyncPluginImpl.h:53
A LibUsbAdaptor for use with Syncronous widgets.
Definition: LibUsbAdaptor.h:540
Definition: Device.h:89
A Ja Rule hardware device (widget).
Definition: JaRuleWidget.h:57
bool Start()
Start the implementation.
Definition: SyncPluginImpl.cpp:82
The interface for the Fadecandy Widgets.
Definition: ScanlimeFadecandy.h:49
Definition: Plugin.h:118
#define OLA_UNUSED
Mark unused arguments & types.
Definition: Macro.h:62
Definition: PluginAdaptor.h:41
The interface for the Sunlite Widgets.
Definition: Sunlite.h:40
The interface for an implementation of the USB DMX plugin.
Definition: PluginImplInterface.h:40
The interface for a simple widget that supports a single universe of DMX.
Definition: Widget.h:36
bool NewWidget(class AnymauDMX *widget)
Called when a new AnymauDMX is added.
Definition: SyncPluginImpl.cpp:119
The interface for the Velleman Widgets.
Definition: VellemanK8062.h:41
Definition: Preferences.h:145
Helper macros.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Receives notifications when Widgets are added or removed.
Definition: WidgetFactory.h:49
SyncPluginImpl(PluginAdaptor *plugin_adaptor, Plugin *plugin, unsigned int debug_level, Preferences *preferences)
Create a new SyncPluginImpl.
Definition: SyncPluginImpl.cpp:60
bool Stop()
Stop the implementation.
Definition: SyncPluginImpl.cpp:103
The base class for Anyma Widgets.
Definition: AnymauDMX.h:41