-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdmxinterface.h
197 lines (152 loc) · 6.17 KB
/
dmxinterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
Q Light Controller Plus
dmxinterface.h
Copyright (C) Heikki Junnila
Massimo Callegari
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef DMXINTERFACE_H
#define DMXINTERFACE_H
#include <QtCore>
#define SETTINGS_TYPE_MAP "qlcftdi/typemap"
#define SETTINGS_FREQ_MAP "qlcftdi/freqmap"
class DMXInterface
{
/************************************************************************
* Construction & Generic Information
************************************************************************/
public:
/**
* Construct a new DMXInterface instance for one DMX adapter.
*
* @param serial The interface USB serial number
* @param name The interface USB name (description)
* @param vendor The interface USB vendor name (description)
* @param VID The interface USB vendor ID
* @param PID The interfce USB product ID
* @param id The ID of the device (used only when FTD2XX is the backend)
*/
DMXInterface(const QString& serial, const QString& name, const QString &vendor,
quint16 VID, quint16 PID, quint32 id = 0);
/** Destructor */
virtual ~DMXInterface();
virtual QString readLabel(uchar label, int *ESTA_code) = 0;
/** Get the widget's USB serial number */
QString serial() const;
/** Get the widget's USB name */
QString name() const;
/** Get the widget's USB vendor name */
QString vendor() const;
/** Get the widget's USB vendor ID */
quint16 vendorID() const;
/** Get the widget's USB product ID */
quint16 productID() const;
/** Get the widget's FTD2XX ID number */
quint32 id() const;
/** Virtual method to retrieve the original USB
* bus location of the device.
* Used only in Linux to perform a sysfs lookup */
virtual quint8 busLocation();
private:
QString m_serial;
QString m_name;
QString m_vendor;
quint16 m_vendorID;
quint16 m_productID;
quint32 m_id;
/************************************************************************
* Widget enumeration
************************************************************************/
public:
static const int FTDIVID = 0x0403; //! FTDI Vendor ID
static const int ATMELVID = 0x03EB; //! Atmel Vendor ID
static const int MICROCHIPVID = 0x04D8; //! Microchip Vendor ID
static const int FTDIPID = 0x6001; //! FTDI Product ID
static const int FTDI2PID = 0x6010; //! FTDI COM485-PLUS2 Product ID
static const int DMX4ALLPID = 0xC850; //! DMX4ALL FTDI Product ID
static const int NANODMXPID = 0x2018; //! DMX4ALL Nano DMX Product ID
static const int EUROLITEPID = 0xFA63; //! Eurolite USB DMX Product ID
static const int ELECTROTASPID = 0x0000;//! ElectroTAS USB DMX Product ID
/** Driver types */
enum Type
{
libFTDI = 0,
FTD2xx,
QtSerial
};
/**
* Check if an interface is supported by QLC+
*
* @return true if supported, false if unsupported
*/
static bool validInterface(quint16 vendor, quint16 product);
bool checkInfo(QString &serial, QString &name, QString &vendor);
/**
* Get a map of [serial = type] bindings that tells which serials should
* be used to force the plugin to use pro/open method on which widget
*/
static QMap <QString,QVariant> typeMap();
static void storeTypeMap(const QMap <QString,QVariant> map);
/**
* Get a map of [serial = frequency] bindings that tells which
* output frequency should be used on a specifi serail number
*/
static QMap <QString,QVariant> frequencyMap();
static void storeFrequencyMap(const QMap <QString,QVariant> map);
/************************************************************************
* DMX/Serial Interface Methods
************************************************************************/
public:
virtual DMXInterface::Type type() = 0;
virtual QString typeString() = 0;
/** Open the widget */
virtual bool open() = 0;
/** Open the widget using a specific Product ID */
virtual bool openByPID(const int FTDIPID) = 0;
/** Close the widget */
virtual bool close() = 0;
/** Check if the widget is open */
virtual bool isOpen() const = 0;
/** Reset the communications line */
virtual bool reset() = 0;
/** Setup communications line for 8N2 traffic */
virtual bool setLineProperties() = 0;
/** Set 250kbps baud rate */
virtual bool setBaudRate() = 0;
/** Disable flow control */
virtual bool setFlowControl() = 0;
/**
* Set the widget in "low latency mode". Some DMX controllers send DMX
* frames at a much higher rate than the specified value. USB widget may
* have difficulties to read independant frames in this case and need
* some configuration.
*
* @param lowLatency true for low latency, false otherwise
* @return true if the interface was set in low latency state
*/
virtual bool setLowLatency(bool lowLatency) = 0;
/** Clear the RTS bit */
virtual bool clearRts() = 0;
/** Purge TX & RX buffers */
virtual bool purgeBuffers() = 0;
/** Toggle communications line BREAK condition on/off */
virtual bool setBreak(bool on) = 0;
/** Write data to a previously-opened line */
virtual bool write(const QByteArray& data) = 0;
/** Read data from a previously-opened line. Optionally provide own data buffer. */
virtual QByteArray read(int size, uchar* buffer = NULL) = 0;
/** Read exactly one byte. $ok tells if a byte was read or not. */
virtual uchar readByte(bool* ok = NULL) = 0;
protected:
/** Latency amount in ms for FTDI devices */
unsigned char m_defaultLatency;
};
#endif