Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
102  : esta_id(0),
103  serial(0),
104  dual_ports(false),
105  queue_size(20),
106  enable_rdm(false) {
107  }
108 
109  EnttecUsbProWidgetOptions(uint16_t esta_id, uint32_t serial)
110  : esta_id(esta_id),
111  serial(serial),
112  dual_ports(false),
113  queue_size(20),
114  enable_rdm(false) {
115  }
116  };
117 
119  ola::io::ConnectedDescriptor *descriptor,
120  const EnttecUsbProWidgetOptions &options);
122 
123  void GetPortAssignments(EnttecUsbProPortAssignmentCallback *callback);
124 
125  void Stop();
126  unsigned int PortCount() const;
127  EnttecPort *GetPort(unsigned int i);
128  ola::io::ConnectedDescriptor *GetDescriptor() const;
129 
130  static const uint16_t ENTTEC_ESTA_ID;
131 
132  private:
133  class EnttecUsbProWidgetImpl *m_impl;
134 };
135 } // namespace usbpro
136 } // namespace plugin
137 } // namespace ola
138 #endif // PLUGINS_USBPRO_ENTTECUSBPROWIDGET_H_
EnttecUsbProWidget(ola::thread::SchedulerInterface *ss, ola::io::ConnectedDescriptor *descriptor, const EnttecUsbProWidgetOptions &options)
Definition: EnttecUsbProWidget.cpp:949
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:643
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition: EnttecUsbProWidget.cpp:695
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:233
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
Definition: EnttecUsbProWidget.cpp:713
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:686
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:676
Definition: EnttecUsbProWidget.h:83
A 3 argument callback which deletes itself after it'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's run.
Definition: Callback.h:1907