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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
DmxterWidget.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 * DmxterWidget.h
17 * The Goddard Design Dmxter RDM and miniDmxter
18 * Copyright (C) 2010 Simon Newton
19 */
20
21#ifndef PLUGINS_USBPRO_DMXTERWIDGET_H_
22#define PLUGINS_USBPRO_DMXTERWIDGET_H_
23
24#include <memory>
25#include "ola/io/SelectServerInterface.h"
26#include "ola/rdm/UID.h"
27#include "ola/rdm/UIDSet.h"
28#include "ola/rdm/RDMControllerInterface.h"
29#include "ola/rdm/QueueingRDMController.h"
30#include "plugins/usbpro/BaseUsbProWidget.h"
31
32namespace ola {
33namespace plugin {
34namespace usbpro {
35
36
37/*
38 * A DMXter Widget implementation. We separate the Widget from the
39 * implementation so we can leverage the QueueingRDMController.
40 */
41 class DmxterWidgetImpl: public BaseUsbProWidget,
42 public ola::rdm::DiscoverableRDMControllerInterface {
43 public:
44 DmxterWidgetImpl(ola::io::ConnectedDescriptor *descriptor,
45 uint16_t esta_id,
46 uint32_t serial);
47 ~DmxterWidgetImpl();
48
49 void Stop();
50
51 void SendRDMRequest(ola::rdm::RDMRequest *request_ptr,
52 ola::rdm::RDMCallback *on_complete);
53
54 void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
55 void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
56
57 private:
58 ola::rdm::UID m_uid;
59 ola::rdm::UIDSet m_uids;
60 ola::rdm::RDMDiscoveryCallback *m_discovery_callback;
61 std::auto_ptr<const ola::rdm::RDMRequest> m_pending_request;
62 ola::rdm::RDMCallback *m_rdm_request_callback;
63 uint8_t m_transaction_number;
64
65 void HandleMessage(uint8_t label,
66 const uint8_t *data,
67 unsigned int length);
68 void HandleTodResponse(const uint8_t *data, unsigned int length);
69 void HandleRDMResponse(const uint8_t *data,
70 unsigned int length);
71 void HandleBroadcastRDMResponse(const uint8_t *data, unsigned int length);
72 void HandleShutdown(const uint8_t *data, unsigned int length);
73
74 static const uint8_t RDM_REQUEST_LABEL;
75 static const uint8_t RDM_BCAST_REQUEST_LABEL;
76 static const uint8_t TOD_LABEL;
77 static const uint8_t DISCOVERY_BRANCH_LABEL;
78 static const uint8_t FULL_DISCOVERY_LABEL;
79 static const uint8_t INCREMENTAL_DISCOVERY_LABEL;
80 static const uint8_t SHUTDOWN_LABAEL;
81
82 typedef enum {
83 RC_CHECKSUM_ERROR = 1,
84 RC_FRAMING_ERROR = 2,
85 RC_FRAMING_ERROR2 = 3,
86 RC_BAD_STARTCODE = 4,
87 RC_BAD_SUB_STARTCODE = 5,
88 RC_WRONG_PDL = 6,
89 RC_BAD_PDL = 7,
90 RC_PACKET_TOO_SHORT = 8,
91 RC_PACKET_TOO_LONG = 9,
92 RC_PHYSICAL_LENGTH_MISMATCH = 10,
93 RC_PDL_LENGTH_MISMATCH = 11,
94 RC_TRANSACTION_MISMATCH = 12,
95 RC_BAD_RESPONSE_TYPE = 13,
96 RC_GOOD_RESPONSE = 14,
97 RC_ACK_TIMER = 15,
98 RC_ACK_OVERFLOW = 16,
99 RC_TIMED_OUT = 17,
100 RC_IDLE_LEVEL = 18,
101 RC_GOOD_LEVEL = 19,
102 RC_BAD_LEVEL = 20,
103 RC_BROADCAST = 21,
104 RC_VENDORCAST = 22,
105 RC_NACK = 23,
106 RC_NACK_UNKNOWN_PID = 24,
107 RC_NACK_FORMAT_ERROR = 25,
108 RC_NACK_HARDWARE_FAULT = 26,
109 RC_NACK_PROXY_REJECT = 27,
110 RC_NACK_WRITE_PROECT = 28,
111 RC_NACK_COMMAND_CLASS = 29,
112 RC_NACK_DATA_RANGE = 30,
113 RC_NACK_BUFFER_FULL = 31,
114 RC_NACK_PACKET_SIZE = 32,
115 RC_NACK_SUB_DEVICE_RANGE = 33,
116 RC_NACK_PROXY_QUEUE_BUFFER_FULL = 34,
117 RC_DEST_UID_MISMATCH = 40,
118 RC_SRC_UID_MISMATCH = 41,
119 RC_SUBDEVICE_MISMATCH = 42,
120 RC_COMMAND_CLASS_MISMATCH = 43,
121 RC_PARAM_ID_MISMATCH = 44,
122 RC_DATA_RECEIVED_NO_BREAK = 46,
123 } response_code;
124};
125
126
127/*
128 * A DMXter Widget. This mostly just wraps the implementation.
129 */
130 class DmxterWidget: public SerialWidgetInterface,
131 public ola::rdm::DiscoverableRDMControllerInterface {
132 public:
133 DmxterWidget(ola::io::ConnectedDescriptor *descriptor,
134 uint16_t esta_id,
135 uint32_t serial,
136 unsigned int queue_size = 20);
137 ~DmxterWidget();
138
139 void Stop() { m_impl->Stop(); }
140
141 void SendRDMRequest(ola::rdm::RDMRequest *request,
142 ola::rdm::RDMCallback *on_complete) {
143 m_controller->SendRDMRequest(request, on_complete);
144 }
145
146 void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
147 m_controller->RunFullDiscovery(callback);
148 }
149
150 void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
151 m_controller->RunIncrementalDiscovery(callback);
152 }
153
154 ola::io::ConnectedDescriptor *GetDescriptor() const {
155 return m_impl->GetDescriptor();
156 }
157
158 private:
159 // we need to control the order of construction & destruction here so these
160 // are pointers.
161 DmxterWidgetImpl *m_impl;
162 ola::rdm::DiscoverableQueueingRDMController *m_controller;
163};
164} // namespace usbpro
165} // namespace plugin
166} // namespace ola
167#endif // PLUGINS_USBPRO_DMXTERWIDGET_H_
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.
UID.h
A RDM unique identifier (UID).
UIDSet.h
A set of UIDs.
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::plugin::usbpro::DmxterWidget::RunIncrementalDiscovery
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition DmxterWidget.h:150
ola::plugin::usbpro::DmxterWidget::RunFullDiscovery
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition DmxterWidget.h:146
ola::plugin::usbpro::DmxterWidget::SendRDMRequest
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition DmxterWidget.h:141
ola::plugin::usbpro::DmxterWidget::DmxterWidget
DmxterWidget(ola::io::ConnectedDescriptor *descriptor, uint16_t esta_id, uint32_t serial, unsigned int queue_size=20)
Definition DmxterWidget.cpp:430
ola::plugin::usbpro::DmxterWidgetImpl::SendRDMRequest
void SendRDMRequest(ola::rdm::RDMRequest *request_ptr, ola::rdm::RDMCallback *on_complete)
Definition DmxterWidget.cpp:109
ola::plugin::usbpro::DmxterWidgetImpl::RunFullDiscovery
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Definition DmxterWidget.cpp:152
ola::plugin::usbpro::DmxterWidgetImpl::RunIncrementalDiscovery
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Definition DmxterWidget.cpp:167
ola::plugin::usbpro::DmxterWidgetImpl::~DmxterWidgetImpl
~DmxterWidgetImpl()
Definition DmxterWidget.cpp:78
ola::plugin::usbpro::DmxterWidgetImpl::Stop
void Stop()
Definition DmxterWidget.cpp:86
ola::rdm::DiscoverableQueueingRDMController
Definition QueueingRDMController.h:88
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::rdm::UID
Represents a RDM UID.
Definition UID.h:57
ola::rdm::UIDSet
Represents a set of RDM UIDs.
Definition UIDSet.h:48
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