Open Lighting Architecture
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <string>
26 #include "ola/Callback.h"
27 #include "ola/DmxBuffer.h"
28 #include "ola/thread/SchedulerInterface.h"
29 #include "ola/rdm/DiscoveryAgent.h"
32 #include "ola/rdm/UIDSet.h"
33 #include "plugins/usbpro/GenericUsbProWidget.h"
34 
35 class EnttecUsbProWidgetTest;
36 
37 namespace ola {
38 namespace plugin {
39 namespace usbpro {
40 
41 
42 class EnttecPortImpl;
43 
50  public:
51  // Ownership not transferred.
52  EnttecPort(EnttecPortImpl *impl, unsigned int queue_size);
53  ~EnttecPort();
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 
62  // the following are from DiscoverableRDMControllerInterface
63  void SendRDMRequest(const ola::rdm::RDMRequest *request,
64  ola::rdm::RDMCallback *on_complete) {
65  m_controller->SendRDMRequest(request, on_complete);
66  }
67 
69  m_controller->RunFullDiscovery(callback);
70  }
71 
72  void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
73  m_controller->RunIncrementalDiscovery(callback);
74  }
75 
76  // the tests access the implementation directly.
77  friend class ::EnttecUsbProWidgetTest;
78 
79  private:
80  EnttecPortImpl *m_impl;
82 };
83 
84 
85 /*
86  * An Enttec Usb Pro Widget
87  */
89  public:
90  /*
91  * The callback to run when we receive a port assignment response
92  * @param true if this command completed ok
93  * @param DMX port 1 assignment
94  * @param DMX port 2 assignment
95  */
98 
100  uint16_t esta_id;
101  uint32_t serial;
102  bool dual_ports;
103  unsigned int queue_size;
104 
106  : esta_id(0),
107  serial(0),
108  dual_ports(false),
109  queue_size(20) {
110  }
111 
112  EnttecUsbProWidgetOptions(uint16_t esta_id, uint32_t serial)
113  : esta_id(esta_id),
114  serial(serial),
115  dual_ports(false),
116  queue_size(20) {
117  }
118  };
119 
121  const EnttecUsbProWidgetOptions &options);
123 
124  void GetPortAssignments(EnttecUsbProPortAssignmentCallback *callback);
125 
126  void Stop();
127  unsigned int PortCount() const;
128  EnttecPort *GetPort(unsigned int i);
129  ola::io::ConnectedDescriptor *GetDescriptor() const;
130 
131  static const uint16_t ENTTEC_ESTA_ID;
132 
133  private:
134  class EnttecUsbProWidgetImpl *m_impl;
135 };
136 } // namespace usbpro
137 } // namespace plugin
138 } // namespace ola
139 #endif // PLUGINS_USBPRO_ENTTECUSBPROWIDGET_H_