Open Lighting Architecture  Latest Git
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 AVLdiyD512 *widget);
76  bool NewWidget(class DMXCProjectsNodleU1 *widget);
77  bool NewWidget(class DMXCreator512Basic *widget);
78  bool NewWidget(class EurolitePro *widget);
79  bool NewWidget(ola::usb::JaRuleWidget *widget);
80  bool NewWidget(class ScanlimeFadecandy *widget);
81  bool NewWidget(class ShowJockeyDMXU1 *widget);
82  bool NewWidget(class Sunlite *widget);
83  bool NewWidget(class VellemanK8062 *widget);
84 
85  void WidgetRemoved(OLA_UNUSED class AnymauDMX *widget) {}
86  void WidgetRemoved(OLA_UNUSED class AVLdiyD512 *widget) {}
87  void WidgetRemoved(OLA_UNUSED class DMXCProjectsNodleU1 *widget) {}
88  void WidgetRemoved(OLA_UNUSED class DMXCreator512Basic *widget) {}
89  void WidgetRemoved(OLA_UNUSED class EurolitePro *widget) {}
90  void WidgetRemoved(OLA_UNUSED ola::usb::JaRuleWidget *widget) {}
91  void WidgetRemoved(OLA_UNUSED class ScanlimeFadecandy *widget) {}
92  void WidgetRemoved(OLA_UNUSED class ShowJockeyDMXU1 *widget) {}
93  void WidgetRemoved(OLA_UNUSED class Sunlite *widget) {}
94  void WidgetRemoved(OLA_UNUSED class VellemanK8062 *widget) {}
95 
96  private:
97  typedef std::vector<class WidgetFactory*> WidgetFactories;
98  typedef std::map<class WidgetInterface*, Device*> WidgetToDeviceMap;
99 
100  PluginAdaptor* const m_plugin_adaptor;
101  Plugin* const m_plugin;
102  const unsigned int m_debug_level;
104  Preferences* const m_preferences;
105  WidgetFactories m_widget_factories;
106 
107  libusb_context *m_context;
108 
109  WidgetToDeviceMap m_devices;
110  std::set<std::pair<uint8_t, uint8_t> > m_registered_devices;
111 
112  unsigned int ScanForDevices();
113  void ReScanForDevices();
114  bool CheckDevice(libusb_device *device);
115 
116  bool StartAndRegisterDevice(class WidgetInterface *widget, Device *device);
117 
118  DISALLOW_COPY_AND_ASSIGN(SyncPluginImpl);
119 };
120 } // namespace usbdmx
121 } // namespace plugin
122 } // namespace ola
123 #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
Definition: Device.h:95
A Ja Rule hardware device (widget).
Definition: JaRuleWidget.h:57
bool Start()
Start the implementation.
Definition: SyncPluginImpl.cpp:92
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:133
The base class for AVLdiy Widgets.
Definition: AVLdiyD512.h:41
The interface for the Velleman Widgets.
Definition: VellemanK8062.h:41
Definition: Preferences.h:147
Helper macros.
The ShowJockey-DMX-U1 Widget.
Definition: ShowJockeyDMXU1.h:54
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Receives notifications when Widgets are added or removed.
Definition: WidgetFactory.h:49
A LibUsbAdaptor for use with Synchronous widgets.
Definition: LibUsbAdaptor.h:540
The base class for DMXCreator512Basic Widgets.
Definition: DMXCreator512Basic.h:41
SyncPluginImpl(PluginAdaptor *plugin_adaptor, Plugin *plugin, unsigned int debug_level, Preferences *preferences)
Create a new SyncPluginImpl.
Definition: SyncPluginImpl.cpp:66
bool Stop()
Stop the implementation.
Definition: SyncPluginImpl.cpp:117
The base class for Anyma Widgets.
Definition: AnymauDMX.h:41