Open Lighting Architecture: plugins/usbpro/RobeDevice.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
29namespace ola {
30namespace plugin {
31namespace 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 std::string &name,
42 RobeWidget *widget);
43
44 std::string DeviceId() const { return m_device_id; }
45
46 private:
47 std::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 */
56 class RobeInputPort: public BasicInputPort {
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 std::string Description() const { return ""; }
78
79 private:
80 std::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 */
89 class RobeOutputPort: public BasicOutputPort {
90 public:
91 RobeOutputPort(RobeDevice *parent, RobeWidget *widget);
92
93 std::string Description() const { return ""; }
94 bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
95
96 void SendRDMRequest(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_
DmxBuffer.h
A class used to hold a single universe of DMX data.
ola::AbstractPlugin
Definition Plugin.h:38
ola::BasicInputPort::BasicInputPort
BasicInputPort(AbstractDevice *parent, unsigned int port_id, const PluginAdaptor *plugin_adaptor, bool supports_rdm=false)
Create a new basic input port.
Definition Port.cpp:38
ola::BasicInputPort::DmxChanged
void DmxChanged()
Called when there is new data for this port.
Definition Port.cpp:83
ola::BasicOutputPort::BasicOutputPort
BasicOutputPort(AbstractDevice *parent, unsigned int port_id, bool start_rdm_discovery_on_patch=false, bool supports_rdm=false)
Create a new BasicOutputPort.
Definition Port.cpp:120
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::PluginAdaptor
Definition PluginAdaptor.h:41
ola::Universe
Definition Universe.h:46
ola::plugin::usbpro::RobeDevice
Definition RobeDevice.h:37
ola::plugin::usbpro::RobeDevice::DeviceId
std::string DeviceId() const
The device ID.
Definition RobeDevice.h:44
ola::plugin::usbpro::RobeInputPort
Definition RobeDevice.h:56
ola::plugin::usbpro::RobeInputPort::Description
std::string Description() const
Fetch the string description for a Port.
Definition RobeDevice.h:77
ola::plugin::usbpro::RobeOutputPort
Definition RobeDevice.h:89
ola::plugin::usbpro::RobeOutputPort::SendRDMRequest
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *callback)
Handle an RDMRequest, subclasses can implement this to support RDM.
Definition RobeDevice.h:96
ola::plugin::usbpro::RobeOutputPort::RobeOutputPort
RobeOutputPort(RobeDevice *parent, RobeWidget *widget)
Definition RobeDevice.cpp:57
ola::plugin::usbpro::RobeOutputPort::RunIncrementalDiscovery
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
This is a noop for ports that don't support RDM.
Definition RobeDevice.h:105
ola::plugin::usbpro::RobeOutputPort::WriteDMX
bool WriteDMX(const DmxBuffer &buffer, uint8_t priority)
Definition RobeDevice.cpp:67
ola::plugin::usbpro::RobeOutputPort::RunFullDiscovery
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
This is a noop for ports that don't support RDM.
Definition RobeDevice.h:101
ola::plugin::usbpro::RobeOutputPort::Description
std::string Description() const
Fetch the string description for a Port.
Definition RobeDevice.h:93
ola::plugin::usbpro::RobeWidget
Definition RobeWidget.h:116
ola::rdm::RDMRequest
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
ola::NewCallback
Callback0< ReturnType > * NewCallback(ReturnType(*callback)())
A helper function to create a new Callback with 0 create-time arguments and 0 execution time argument...
Definition Callback.h:211
ola::plugin::usbpro
Code for Enttec USB Pro devices and others using the same protocol.
ola::plugin
Code for supported devices and protocols.
ola::rdm::RDMCallback
ola::BaseCallback1< void, RDMReply * > RDMCallback
The callback run when a RDM request completes.
Definition RDMControllerInterface.h:52
ola::rdm::RDMDiscoveryCallback
ola::BaseCallback1< void, const ola::rdm::UIDSet & > RDMDiscoveryCallback
The callback run when a discovery operation completes.
Definition RDMControllerInterface.h:68
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44