Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UartDmxPlugin.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  * UartDmxPlugin.h
17  * The DMX through a UART plugin for ola
18  * Copyright (C) 2011 Rui Barreiros
19  * Copyright (C) 2014 Richard Ash
20  */
21 
22 #ifndef PLUGINS_UARTDMX_UARTDMXPLUGIN_H_
23 #define PLUGINS_UARTDMX_UARTDMXPLUGIN_H_
24 
25 #include <set>
26 #include <string>
27 #include <vector>
28 
29 #include "olad/Plugin.h"
30 #include "ola/plugin_id.h"
31 
32 #include "plugins/uartdmx/UartDmxDevice.h"
33 
34 namespace ola {
35 namespace plugin {
36 namespace uartdmx {
37 
38 class UartDmxPlugin : public Plugin {
39  public:
40  explicit UartDmxPlugin(ola::PluginAdaptor *plugin_adaptor)
41  : Plugin(plugin_adaptor) {
42  }
43 
44  ola_plugin_id Id() const { return OLA_PLUGIN_UARTDMX; }
45  std::string Name() const { return PLUGIN_NAME; }
46  std::string PluginPrefix() const { return PLUGIN_PREFIX; }
47  // This plugin is disabled unless explicitly enabled by a user.
48  bool DefaultMode() const { return false; }
49 
50  std::string Description() const;
51 
52  private:
53  typedef std::vector<UartDmxDevice*> UartDeviceVector;
54  UartDeviceVector m_devices;
55 
56  void AddDevice(UartDmxDevice *device);
57  bool StartHook();
58  bool StopHook();
59  bool SetDefaultPreferences();
60  unsigned int GetBreak();
61  unsigned int GetMalf();
62 
63  static const char PLUGIN_NAME[];
64  static const char PLUGIN_PREFIX[];
65  static const char K_DEVICE[];
66  static const char DEFAULT_DEVICE[];
67 
68  DISALLOW_COPY_AND_ASSIGN(UartDmxPlugin);
69 };
70 } // namespace uartdmx
71 } // namespace plugin
72 } // namespace ola
73 #endif // PLUGINS_UARTDMX_UARTDMXPLUGIN_H_