Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RobeDevice.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  * RobeDevice.h
17  * The Robe Universal Interface Device.
18  * Copyright (C) 2011 Simon Newton
19  */
20 
21 #ifndef PLUGINS_USBPRO_ROBEDEVICE_H_
22 #define PLUGINS_USBPRO_ROBEDEVICE_H_
23 
24 #include <string>
25 #include "ola/DmxBuffer.h"
26 #include "plugins/usbpro/RobeWidget.h"
27 #include "plugins/usbpro/UsbSerialDevice.h"
28 
29 namespace ola {
30 namespace plugin {
31 namespace usbpro {
32 
33 
34 /*
35  * The device for a Robe Universe Interface.
36  */
37 class RobeDevice: public UsbSerialDevice {
38  public:
39  RobeDevice(ola::PluginAdaptor *plugin_adaptor,
40  ola::AbstractPlugin *owner,
41  const string &name,
42  RobeWidget *widget);
43 
44  string DeviceId() const { return m_device_id; }
45 
46  private:
47  string m_device_id;
48  class RobeOutputPort *m_output_port;
49  class RobeInputPort *m_input_port;
50 };
51 
52 
53 /*
54  * The Input port
55  */
57  public:
58  RobeInputPort(RobeDevice *parent,
59  RobeWidget *widget,
60  ola::PluginAdaptor *plugin_adaptor)
61  : BasicInputPort(parent, 0, plugin_adaptor),
62  m_widget(widget) {
63  m_widget->SetDmxCallback(NewCallback(
64  static_cast<BasicInputPort*>(this),
65  &BasicInputPort::DmxChanged));
66  }
67 
68  const DmxBuffer &ReadDMX() const {
69  return m_widget->FetchDMX();
70  }
71 
72  void PostSetUniverse(Universe*, Universe *new_universe) {
73  if (new_universe)
74  m_widget->ChangeToReceiveMode();
75  }
76 
77  string Description() const { return ""; }
78 
79  private:
80  string m_path;
81  RobeWidget *m_widget;
82 };
83 
84 
85 /*
86  * For now we just support a single port per device. Some devices may have two
87  * ports, but I haven't figured out how to use that yet.
88  */
90  public:
91  RobeOutputPort(RobeDevice *parent, RobeWidget *widget);
92 
93  string Description() const { return ""; }
94  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
95 
96  void SendRDMRequest(const ola::rdm::RDMRequest *request,
97  ola::rdm::RDMCallback *callback) {
98  m_widget->SendRDMRequest(request, callback);
99  }
100 
101  void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
102  m_widget->RunFullDiscovery(callback);
103  }
104 
105  void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
106  m_widget->RunIncrementalDiscovery(callback);
107  }
108 
109  private:
110  RobeWidget *m_widget;
111 };
112 } // namespace usbpro
113 } // namespace plugin
114 } // namespace ola
115 #endif // PLUGINS_USBPRO_ROBEDEVICE_H_