Open Lighting Architecture  0.9.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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
64  void SendRDMRequest(const ola::rdm::RDMRequest *request,
65  ola::rdm::RDMCallback *on_complete);
66 
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  */
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  const EnttecUsbProWidgetOptions &options);
121 
122  void GetPortAssignments(EnttecUsbProPortAssignmentCallback *callback);
123 
124  void Stop();
125  unsigned int PortCount() const;
126  EnttecPort *GetPort(unsigned int i);
127  ola::io::ConnectedDescriptor *GetDescriptor() const;
128 
129  static const uint16_t ENTTEC_ESTA_ID;
130 
131  private:
132  class EnttecUsbProWidgetImpl *m_impl;
133 };
134 } // namespace usbpro
135 } // namespace plugin
136 } // namespace ola
137 #endif // PLUGINS_USBPRO_ENTTECUSBPROWIDGET_H_