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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
EnttecUsbProWidget.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 * EnttecUsbProWidget.h
17 * The Enttec USB Pro Widget
18 * Copyright (C) 2010 Simon Newton
19 */
20
21#ifndef PLUGINS_USBPRO_ENTTECUSBPROWIDGET_H_
22#define PLUGINS_USBPRO_ENTTECUSBPROWIDGET_H_
23
24#include <deque>
25#include <memory>
26#include <string>
27#include "ola/Callback.h"
28#include "ola/DmxBuffer.h"
29#include "ola/thread/SchedulerInterface.h"
30#include "ola/rdm/DiscoveryAgent.h"
31#include "ola/rdm/QueueingRDMController.h"
32#include "ola/rdm/RDMControllerInterface.h"
33#include "ola/rdm/UIDSet.h"
34#include "plugins/usbpro/GenericUsbProWidget.h"
35
36class EnttecUsbProWidgetTest;
37
38namespace ola {
39namespace plugin {
40namespace usbpro {
41
42
43class EnttecPortImpl;
44
49 class EnttecPort
50 : public ola::rdm::DiscoverableRDMControllerInterface {
51 public:
52 // Ownership not transferred.
53 EnttecPort(EnttecPortImpl *impl, unsigned int queue_size, bool enable_rdm);
54
55 bool SendDMX(const DmxBuffer &buffer);
56 const DmxBuffer &FetchDMX() const;
57 void SetDMXCallback(ola::Callback0<void> *callback);
58 bool ChangeToReceiveMode(bool change_only);
59 void GetParameters(usb_pro_params_callback *callback);
60 bool SetParameters(uint8_t break_time, uint8_t mab_time, uint8_t rate);
61 bool SupportsRDM() const { return m_enable_rdm; }
62
63 // the following are from DiscoverableRDMControllerInterface
64 void SendRDMRequest(ola::rdm::RDMRequest *request,
65 ola::rdm::RDMCallback *on_complete);
66
67 void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
68 void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
69
70 // the tests access the implementation directly.
71 friend class ::EnttecUsbProWidgetTest;
72
73 private:
74 EnttecPortImpl *m_impl;
75 const bool m_enable_rdm;
76 std::auto_ptr<ola::rdm::DiscoverableQueueingRDMController> m_controller;
77};
78
79
80/*
81 * An Enttec Usb Pro Widget
82 */
83 class EnttecUsbProWidget: public SerialWidgetInterface {
84 public:
85 /*
86 * The callback to run when we receive a port assignment response
87 * @param true if this command completed ok
88 * @param DMX port 1 assignment
89 * @param DMX port 2 assignment
90 */
91 typedef ola::SingleUseCallback3<void, bool, uint8_t, uint8_t>
92 EnttecUsbProPortAssignmentCallback;
93
94 struct EnttecUsbProWidgetOptions {
95 uint16_t esta_id;
96 uint32_t serial;
97 bool dual_ports;
98 unsigned int queue_size;
99 bool enable_rdm;
100 bool no_rdm_dub_timeout;
101
102 EnttecUsbProWidgetOptions()
103 : esta_id(0),
104 serial(0),
105 dual_ports(false),
106 queue_size(20),
107 enable_rdm(false),
108 no_rdm_dub_timeout(false) {
109 }
110
111 EnttecUsbProWidgetOptions(uint16_t esta_id, uint32_t serial)
112 : esta_id(esta_id),
113 serial(serial),
114 dual_ports(false),
115 queue_size(20),
116 enable_rdm(false),
117 no_rdm_dub_timeout(false) {
118 }
119 };
120
121 EnttecUsbProWidget(ola::thread::SchedulerInterface *ss,
122 ola::io::ConnectedDescriptor *descriptor,
123 const EnttecUsbProWidgetOptions &options);
124 ~EnttecUsbProWidget();
125
126 void GetPortAssignments(EnttecUsbProPortAssignmentCallback *callback);
127
128 void Stop();
129 unsigned int PortCount() const;
130 EnttecPort *GetPort(unsigned int i);
131 ola::io::ConnectedDescriptor *GetDescriptor() const;
132
133 static const uint16_t ENTTEC_ESTA_ID;
134
135 private:
136 class EnttecUsbProWidgetImpl *m_impl;
137};
138} // namespace usbpro
139} // namespace plugin
140} // namespace ola
141#endif // PLUGINS_USBPRO_ENTTECUSBPROWIDGET_H_
Callback.h
DmxBuffer.h
A class used to hold a single universe of DMX data.
QueueingRDMController.h
An RDM Controller that queues messages and only sends a single message at a time.
RDMControllerInterface.h
Definitions and Interfaces to implement an RDMController that sends a single message at a time.
UIDSet.h
A set of UIDs.
ola::Callback0
A 0 argument callback which can be called multiple times.
Definition Callback.h:129
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::SingleUseCallback3
A 3 argument callback which deletes itself after it's run.
Definition Callback.h:2850
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::plugin::usbpro::EnttecPort
Definition EnttecUsbProWidget.h:50
ola::plugin::usbpro::EnttecPort::RunIncrementalDiscovery
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition EnttecUsbProWidget.cpp:704
ola::plugin::usbpro::EnttecPort::RunFullDiscovery
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition EnttecUsbProWidget.cpp:695
ola::plugin::usbpro::EnttecPort::EnttecPort
EnttecPort(EnttecPortImpl *impl, unsigned int queue_size, bool enable_rdm)
Definition EnttecUsbProWidget.cpp:652
ola::plugin::usbpro::EnttecPort::SendRDMRequest
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition EnttecUsbProWidget.cpp:685
ola::plugin::usbpro::EnttecPortImpl
Definition EnttecUsbProWidgetImpl.h:83
ola::plugin::usbpro::EnttecUsbProWidget::EnttecUsbProWidget
EnttecUsbProWidget(ola::thread::SchedulerInterface *ss, ola::io::ConnectedDescriptor *descriptor, const EnttecUsbProWidgetOptions &options)
Definition EnttecUsbProWidget.cpp:962
ola::plugin::usbpro::EnttecUsbProWidgetImpl
Definition EnttecUsbProWidget.cpp:722
ola::rdm::DiscoverableRDMControllerInterface
The interface that can send RDM commands, as well as perform discovery operations.
Definition RDMControllerInterface.h:104
ola::rdm::RDMRequest
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
ola::thread::SchedulerInterface
Allows Callbacks to be scheduled to run after a specified interval.
Definition SchedulerInterface.h:46
DiscoveryAgent.h
Implements the RDM Discovery algorithm.
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
ola::plugin::usbpro::EnttecUsbProWidget::EnttecUsbProWidgetOptions
Definition EnttecUsbProWidget.h:94