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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
GenericUsbProWidget.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 * GenericUsbProWidget.h
17 * This class implements a generic Usb Pro style widget, which can send and
18 * receive DMX as well and get/set widget parameters.
19 * Copyright (C) 2011 Simon Newton
20 */
21
22#ifndef PLUGINS_USBPRO_GENERICUSBPROWIDGET_H_
23#define PLUGINS_USBPRO_GENERICUSBPROWIDGET_H_
24
25#include <deque>
26#include <string>
27#include "ola/Callback.h"
28#include "ola/DmxBuffer.h"
29#include "ola/thread/SchedulerInterface.h"
30#include "plugins/usbpro/BaseUsbProWidget.h"
31
32namespace ola {
33namespace plugin {
34namespace usbpro {
35
36 typedef struct {
37 uint8_t firmware;
38 uint8_t firmware_high;
39 uint8_t break_time;
40 uint8_t mab_time;
41 uint8_t rate;
42} usb_pro_parameters;
43
44typedef ola::SingleUseCallback2<void, bool, const usb_pro_parameters&>
45 usb_pro_params_callback;
46
47
48/*
49 * An Generic DMX USB PRO Widget. This just handles the base functionality,
50 * other features like RDM, multi-universe support etc. can be layered on top
51 * of this.
52 */
53 class GenericUsbProWidget: public BaseUsbProWidget {
54 public:
55 explicit GenericUsbProWidget(ola::io::ConnectedDescriptor *descriptor);
56 ~GenericUsbProWidget();
57
58 void SetDMXCallback(ola::Callback0<void> *callback);
59 void GenericStop();
60
61 virtual bool SendDMX(const DmxBuffer &buffer);
62 bool ChangeToReceiveMode(bool change_only);
63 const DmxBuffer &FetchDMX() const;
64
65 void GetParameters(usb_pro_params_callback *callback);
66 bool SetParameters(uint8_t break_time,
67 uint8_t mab_time,
68 uint8_t rate);
69
70 static const uint8_t RECEIVED_DMX_LABEL = 5;
71
72 protected:
73 // child classes can intercept this.
74 virtual void HandleMessage(uint8_t label,
75 const uint8_t *data,
76 unsigned int length);
77 void HandleDMX(const uint8_t *data, unsigned int length);
78
79 private:
80 bool m_active;
81 DmxBuffer m_input_buffer;
82 ola::Callback0<void> *m_dmx_callback;
83 std::deque<usb_pro_params_callback*> m_outstanding_param_callbacks;
84
85 void HandleParameters(const uint8_t *data, unsigned int length);
86 void HandleDMXDiff(const uint8_t *data, unsigned int length);
87
88 static const uint8_t REPROGRAM_FIRMWARE_LABEL = 2;
89 static const uint8_t PARAMETERS_LABEL = 3;
90 static const uint8_t SET_PARAMETERS_LABEL = 4;
91 static const uint8_t DMX_RX_MODE_LABEL = 8;
92 static const uint8_t DMX_CHANGED_LABEL = 9;
93};
94} // namespace usbpro
95} // namespace plugin
96} // namespace ola
97#endif // PLUGINS_USBPRO_GENERICUSBPROWIDGET_H_
Callback.h
DmxBuffer.h
A class used to hold a single universe of DMX data.
ola::Callback0
A 0 argument callback which can be called multiple times.
Definition Callback.h:129
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::SingleUseCallback2
A 2 argument callback which deletes itself after it's run.
Definition Callback.h:1907
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::plugin::usbpro::GenericUsbProWidget::SetDMXCallback
void SetDMXCallback(ola::Callback0< void > *callback)
Definition GenericUsbProWidget.cpp:56
ola::plugin::usbpro::GenericUsbProWidget::GetParameters
void GetParameters(usb_pro_params_callback *callback)
Definition GenericUsbProWidget.cpp:128
ola::plugin::usbpro::GenericUsbProWidget::GenericStop
void GenericStop()
Definition GenericUsbProWidget.cpp:67
ola::plugin::usbpro::GenericUsbProWidget::FetchDMX
const DmxBuffer & FetchDMX() const
Definition GenericUsbProWidget.cpp:119
ola::plugin::usbpro::GenericUsbProWidget::SetParameters
bool SetParameters(uint8_t break_time, uint8_t mab_time, uint8_t rate)
Definition GenericUsbProWidget.cpp:149
ola::plugin::usbpro
Code for Enttec USB Pro devices and others using the same protocol.
ola::plugin
Code for supported devices and protocols.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::plugin::usbpro::usb_pro_parameters
Definition GenericUsbProWidget.h:36