Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Dmx4LinuxPlugin.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  * Dmx4LinuxPlugin.h
17  * Interface for the dmx4linux plugin class
18  * Copyright (C) 2006 Simon Newton
19  */
20 
21 #ifndef PLUGINS_DMX4LINUX_DMX4LINUXPLUGIN_H_
22 #define PLUGINS_DMX4LINUX_DMX4LINUXPLUGIN_H_
23 
24 #include <vector>
25 #include <string>
26 #include "ola/DmxBuffer.h"
27 #include "olad/Plugin.h"
28 #include "ola/network/Socket.h"
29 #include "ola/plugin_id.h"
30 #include "plugins/dmx4linux/Dmx4LinuxPort.h"
31 #include "plugins/dmx4linux/Dmx4LinuxSocket.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace dmx4linux {
36 
37 class Dmx4LinuxDevice;
38 
40  public:
41  explicit Dmx4LinuxPlugin(PluginAdaptor *plugin_adaptor):
42  Plugin(plugin_adaptor),
43  m_in_descriptor(NULL),
44  m_out_descriptor(NULL),
45  m_in_devices_count(0),
46  m_in_buffer(NULL) {}
47  ~Dmx4LinuxPlugin();
48 
49  string Name() const { return PLUGIN_NAME; }
50  string Description() const;
51  ola_plugin_id Id() const { return OLA_PLUGIN_DMX4LINUX; }
52 
53  int SocketReady();
54  string PluginPrefix() const { return PLUGIN_PREFIX; }
55 
56  private:
57  bool StartHook();
58  bool StopHook();
59  bool SetDefaultPreferences();
60 
61  bool SetupDescriptors();
62  int CleanupDescriptors();
63  bool SetupDevice(string family, int d4l_uni, int dir);
64  bool SetupDevices();
65 
66  vector<Dmx4LinuxDevice*> m_devices; // list of out devices
67  vector<Dmx4LinuxInputPort*> m_in_ports; // list of in ports
68  string m_out_dev; // path to the dmx output device
69  string m_in_dev; // path to the dmx input device
70  Dmx4LinuxSocket *m_in_descriptor;
71  Dmx4LinuxSocket *m_out_descriptor;
72  int m_in_devices_count; // number of input devices
73  uint8_t *m_in_buffer; // input buffer
74 
75  static const char DMX4LINUX_OUT_DEVICE[];
76  static const char DMX4LINUX_IN_DEVICE[];
77  static const char OUT_DEV_KEY[];
78  static const char IN_DEV_KEY[];
79  static const char PLUGIN_NAME[];
80  static const char PLUGIN_PREFIX[];
81 };
82 } // namespace dmx4linux
83 } // namespace plugin
84 } // namespace ola
85 
86 #endif // PLUGINS_DMX4LINUX_DMX4LINUXPLUGIN_H_