Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsbSerialPlugin.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  * UsbSerialPlugin.h
17  * Interface for the usbpro plugin class
18  * Copyright (C) 2006 Simon Newton
19  */
20 
21 #ifndef PLUGINS_USBPRO_USBSERIALPLUGIN_H_
22 #define PLUGINS_USBPRO_USBSERIALPLUGIN_H_
23 
24 #include <string>
25 #include <vector>
26 #include "ola/io/Descriptor.h"
27 #include "ola/plugin_id.h"
28 #include "olad/Plugin.h"
29 #include "plugins/usbpro/UsbSerialDevice.h"
30 #include "plugins/usbpro/WidgetDetectorThread.h"
31 
32 namespace ola {
33 namespace plugin {
34 namespace usbpro {
35 
37  public:
38  explicit UsbSerialPlugin(PluginAdaptor *plugin_adaptor);
39 
40  std::string Name() const { return PLUGIN_NAME; }
41  std::string Description() const;
42  ola_plugin_id Id() const { return OLA_PLUGIN_USBPRO; }
43  void DeviceRemoved(UsbSerialDevice *device);
44  std::string PluginPrefix() const { return PLUGIN_PREFIX; }
45 
46  void NewWidget(ArduinoWidget *widget,
47  const UsbProWidgetInformation &information);
48  void NewWidget(EnttecUsbProWidget *widget,
49  const UsbProWidgetInformation &information);
50  void NewWidget(DmxTriWidget *widget,
51  const UsbProWidgetInformation &information);
52  void NewWidget(DmxterWidget *widget,
53  const UsbProWidgetInformation &information);
54  void NewWidget(RobeWidget *widget,
55  const RobeWidgetInformation &information);
56  void NewWidget(UltraDMXProWidget *widget,
57  const UsbProWidgetInformation &information);
58 
59  private:
60  void AddDevice(UsbSerialDevice *device);
61  bool StartHook();
62  bool StopHook();
63  bool SetDefaultPreferences();
64  void DeleteDevice(UsbSerialDevice *device);
65  std::string GetDeviceName(const UsbProWidgetInformation &information);
66  unsigned int GetProFrameLimit();
67  unsigned int GetDmxTriFrameLimit();
68  unsigned int GetUltraDMXProFrameLimit();
69 
70  std::vector<UsbSerialDevice*> m_devices; // list of our devices
71  WidgetDetectorThread m_detector_thread;
72 
73  static const char DEFAULT_DEVICE_DIR[];
74  static const char DEFAULT_PRO_FPS_LIMIT[];
75  static const char DEFAULT_ULTRA_FPS_LIMIT[];
76  static const char DEVICE_DIR_KEY[];
77  static const char DEVICE_PREFIX_KEY[];
78  static const char IGNORED_DEVICES_KEY[];
79  static const char LINUX_DEVICE_PREFIX[];
80  static const char BSD_DEVICE_PREFIX[];
81  static const char MAC_DEVICE_PREFIX[];
82  static const char PLUGIN_NAME[];
83  static const char PLUGIN_PREFIX[];
84  static const char ROBE_DEVICE_NAME[];
85  static const char TRI_USE_RAW_RDM_KEY[];
86  static const char USBPRO_DEVICE_NAME[];
87  static const char USB_PRO_FPS_LIMIT_KEY[];
88  static const char ULTRA_FPS_LIMIT_KEY[];
89  static const unsigned int MAX_PRO_FPS_LIMIT = 1000;
90  static const unsigned int MAX_ULTRA_FPS_LIMIT = 1000;
91 };
92 } // namespace usbpro
93 } // namespace plugin
94 } // namespace ola
95 #endif // PLUGINS_USBPRO_USBSERIALPLUGIN_H_