Open Lighting Architecture
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 
39  public:
40  explicit UsbSerialPlugin(PluginAdaptor *plugin_adaptor);
41 
42  string Name() const { return PLUGIN_NAME; }
43  string Description() const;
44  ola_plugin_id Id() const { return OLA_PLUGIN_USBPRO; }
45  void DeviceRemoved(UsbSerialDevice *device);
46  string PluginPrefix() const { return PLUGIN_PREFIX; }
47 
48  void NewWidget(ArduinoWidget *widget,
49  const UsbProWidgetInformation &information);
50  void NewWidget(EnttecUsbProWidget *widget,
51  const UsbProWidgetInformation &information);
52  void NewWidget(DmxTriWidget *widget,
53  const UsbProWidgetInformation &information);
54  void NewWidget(DmxterWidget *widget,
55  const UsbProWidgetInformation &information);
56  void NewWidget(RobeWidget *widget,
57  const RobeWidgetInformation &information);
58  void NewWidget(UltraDMXProWidget *widget,
59  const UsbProWidgetInformation &information);
60 
61  private:
62  void AddDevice(UsbSerialDevice *device);
63  bool StartHook();
64  bool StopHook();
65  bool SetDefaultPreferences();
66  void DeleteDevice(UsbSerialDevice *device);
67  string GetDeviceName(const UsbProWidgetInformation &information);
68  unsigned int GetProFrameLimit();
69  unsigned int GetDmxTriFrameLimit();
70  unsigned int GetUltraDMXProFrameLimit();
71 
72  vector<UsbSerialDevice*> m_devices; // list of our devices
73  WidgetDetectorThread m_detector_thread;
74 
75  static const char DEFAULT_DEVICE_DIR[];
76  static const char DEFAULT_PRO_FPS_LIMIT[];
77  static const char DEFAULT_ULTRA_FPS_LIMIT[];
78  static const char DEVICE_DIR_KEY[];
79  static const char DEVICE_PREFIX_KEY[];
80  static const char IGNORED_DEVICES_KEY[];
81  static const char LINUX_DEVICE_PREFIX[];
82  static const char BSD_DEVICE_PREFIX[];
83  static const char MAC_DEVICE_PREFIX[];
84  static const char PLUGIN_NAME[];
85  static const char PLUGIN_PREFIX[];
86  static const char ROBE_DEVICE_NAME[];
87  static const char TRI_USE_RAW_RDM_KEY[];
88  static const char USBPRO_DEVICE_NAME[];
89  static const char USB_PRO_FPS_LIMIT_KEY[];
90  static const char ULTRA_FPS_LIMIT_KEY[];
91  static const unsigned int MAX_PRO_FPS_LIMIT = 1000;
92  static const unsigned int MAX_ULTRA_FPS_LIMIT = 1000;
93 };
94 } // namespace usbpro
95 } // namespace plugin
96 } // namespace ola
97 #endif // PLUGINS_USBPRO_USBSERIALPLUGIN_H_