Open Lighting Architecture  Latest Git
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"
33 #include "ola/rdm/UIDSet.h"
34 #include "plugins/usbpro/GenericUsbProWidget.h"
35 
36 class EnttecUsbProWidgetTest;
37 
38 namespace ola {
39 namespace plugin {
40 namespace usbpro {
41 
42 
43 class EnttecPortImpl;
44 
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
65  ola::rdm::RDMCallback *on_complete);
66 
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  */
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  */
93 
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 
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 
122  ola::io::ConnectedDescriptor *descriptor,
123  const EnttecUsbProWidgetOptions &options);
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_
Definitions and Interfaces to implement an RDMController that sends a single message at a time...
EnttecPort(EnttecPortImpl *impl, unsigned int queue_size, bool enable_rdm)
Definition: EnttecUsbProWidget.cpp:656
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition: EnttecUsbProWidget.cpp:708
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition: Descriptor.h:282
The interface that can send RDM commands, as well as perform discovery operations.
Definition: RDMControllerInterface.h:104
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:234
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
Definition: EnttecUsbProWidget.cpp:726
A set of UIDs.
A class used to hold a single universe of DMX data.
Definition: EnttecUsbProWidgetImpl.h:81
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition: EnttecUsbProWidget.cpp:699
An RDM Controller that queues messages and only sends a single message at a time. ...
Definition: SerialWidgetInterface.h:38
The base class for all 1 argument callbacks.
Definition: Callback.h:982
Definition: EnttecUsbProWidget.h:49
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition: EnttecUsbProWidget.cpp:689
Definition: EnttecUsbProWidget.h:83
A 3 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:2850
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Implements the RDM Discovery algorithm.
Allows Callbacks to be scheduled to run after a specified interval.
Definition: SchedulerInterface.h:46
A 2 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:1907