-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUSAGE.txt
More file actions
executable file
·273 lines (233 loc) · 12.7 KB
/
USAGE.txt
File metadata and controls
executable file
·273 lines (233 loc) · 12.7 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
LJUDDotNet .NET Assembly Usage
04/11/2019
This file provides more information on the LJUDDotNet.dll .NET assembly and its
interface.
The driver implements a namespace called LabJack.LabJackUD under which
everything exists. The main object inside that namespace is the LJUD object.
That object basically copies the functionality of the LabJackUD.dll driver.
It contains the following enumerated types to act as constants:
CHANNEL
CONNECTION
DEVICE
EVENTCODE
IO
LJUDERROR
RANGES
STREAMWAITMODES
THERMOCOUPLETYPE
TIMERCLOCKS
TIMERMODE
Each of these work similarly to that which is found in the header file for the
LabJackUD.dll file.
Where you would use LJ_dtUE9 for the LabJackUD.dll, you would now use
LabJackUD.DEVICE.UE9. LJ_ioANALOG_INPUT would be LabJackUD.IO.ANALOG_INPUT, and
so on.
The LJUD object provides static method wrappers to the LabJackUD.dll functions
with the following definitions:
public static LJUDERROR AddRequest(int handle, IO IOType, CHANNEL channel, double val, int x1, double userData)
public static LJUDERROR AddRequest(int handle, IO IOType, CHANNEL channel, double val, byte[] x1, double userData)
public static LJUDERROR AddRequest(int handle, IO IOType, CHANNEL channel, double val, double[] x1, double userData)
public static LJUDERROR AddRequest(int handle, IO IOType, int channel, double val, int x1, double userData)
public static LJUDERROR AddRequestPtr(int handle, IO IOType, CHANNEL channel, double val, byte[] x1, double userData)
public static LJUDERROR AddRequestPtr(int handle, IO IOType, CHANNEL channel, double val, double[] x1, double userData)
public static LJUDERROR AddRequestPtr(int handle, IO IOType, int channel, double val, byte[] x1, double userData)
public static LJUDERROR AddRequestPtr(int handle, IO IOType, int channel, double val, double[] x1, double userData)
public static LJUDERROR AddRequestS(int handle, string IOType, CHANNEL channel, double val, int x1, double userData)
public static LJUDERROR AddRequestS(int handle, string IOType, int channel, double val, int x1, double userData)
public static LJUDERROR AddRequestSS(int handle, string IOType, string channel, double val, int x1, double userData)
public static LJUDERROR Close()
public static LJUDERROR DoubleToStringAddress(double number, char[] str, int hexDot)
public static LJUDERROR eAddGoGet(int handle, int numRequests, int[] aIOTypes, int[] aChannels, double[] aValues, int[] aX1s, int[] aRequestErrors, ref int goError, int[] aResultErrors)
public static LJUDERROR eAIN(int handle, int channelP, int channelN, ref double voltage, int range, int resolution, int settling, int binary)
public static LJUDERROR eDAC(int handle, int channel, double voltage, int binary, int reserved1, int reserved2)
public static LJUDERROR eDI(int handle, int channel, ref int state)
public static LJUDERROR eDO(int handle, int channel, int state)
public static LJUDERROR eGet(int handle, IO IOType, CHANNEL channel, ref double val, int x1)
public static LJUDERROR eGet(int handle, IO IOType, CHANNEL channel, ref double val, byte[] x1)
public static LJUDERROR eGet(int handle, IO IOType, CHANNEL channel, ref double val, double[] x1)
public static LJUDERROR eGet(int handle, IO IOType, int channel, ref double val, int x1)
public static LJUDERROR eGet(int handle, IO IOType, int channel, ref double val, byte[] x1)
public static LJUDERROR eGet(int handle, IO IOType, int channel, ref double val, double[] x1)
public static LJUDERROR eGetPtr(int handle, IO IOType, CHANNEL channel, ref double val, byte[] x1)
public static LJUDERROR eGetPtr(int handle, IO IOType, CHANNEL channel, ref double val, double[] x1)
public static LJUDERROR eGetPtr(int handle, IO IOType, int channel, ref double val, byte[] x1)
public static LJUDERROR eGetPtr(int handle, IO IOType, int channel, ref double val, double[] x1)
public static LJUDERROR eGetS(int handle, string IOType, CHANNEL channel, ref double val, int x1)
public static LJUDERROR eGetS(int handle, string IOType, int channel, ref double val, int x1)
public static LJUDERROR eGetSS(int handle, string IOType, string channel, ref double val, int x1)
public static LJUDERROR ePut(int handle, IO IOType, CHANNEL channel, double val, int x1)
public static LJUDERROR ePut(int handle, IO IOType, CHANNEL channel, double val, byte[] x1)
public static LJUDERROR ePut(int handle, IO IOType, CHANNEL channel, double val, double[] x1)
public static LJUDERROR ePut(int handle, IO IOType, int channel, double val, int x1)
public static LJUDERROR ePut(int handle, IO IOType, int channel, double val, byte[] x1)
public static LJUDERROR ePut(int handle, IO IOType, int channel, double val, double[] x1)
public static LJUDERROR ePutS(int handle, string IOType, CHANNEL channel, double val, int x1)
public static LJUDERROR ePutS(int handle, string IOType, int channel, double val, int x1)
public static LJUDERROR ePutSS(int handle, string IOType, string channel, double val, int x1)
public static void ErrorToString(ERROR errorCode, char[] str)
public static LJUDERROR eTCConfig(int handle, int[] aEnableTimers, int[] aEnableCounters, int TCPinOffset, int TimerClockBaseIndex, int TimerClockDivisor, int[] aTimerModes, double[] aTimerValues, int reserved1, int reserved2)
public static LJUDERROR eTCValues(int handle, int[] aReadTimers, int[] aUpdateResetTimers, int[] aReadCounters, int[] aResetCounters, double[] aTimerValues, double[] aCounterValues, int reserved1, int reserved2)
public static double GetDriverVersion()
public static LJUDERROR GetFirstResult(int handle, ref IO IOType, ref CHANNEL channel, ref double val, ref int px1, ref double userData)
public static LJUDERROR GetFirstResult(int handle, ref IO IOType, ref int channel, ref double val, ref int px1, ref double userData)
public static LJUDERROR GetFirstResult(int handle, ref int IOType, ref int channel, ref double val, ref int px1, ref double userData)
public static LJUDERROR GetNextResult(int handle, ref IO IOType, ref CHANNEL channel, ref double val, ref int px1, ref double userData)
public static LJUDERROR GetNextResult(int handle, ref IO IOType, ref int channel, ref double val, ref int px1, ref double userData)
public static LJUDERROR GetNextResult(int handle, ref int IOType, ref CHANNEL channel, ref double val, ref int px1, ref double userData)
public static LJUDERROR GetNextResult(int handle, ref int IOType, ref int channel, ref double val, ref int px1, ref double userData)
public static LJUDERROR GetResult(int handle, IO IOType, CHANNEL channel, ref double val)
public static LJUDERROR GetResult(int handle, IO IOType, int channel, ref double val)
public static LJUDERROR GetResult(int handle, int IOType, int channel, ref double val)
public static LJUDERROR GetResultS(int handle, string IOType, CHANNEL channel, ref double val)
public static LJUDERROR GetResultS(int handle, string IOType, int channel, ref double val)
public static LJUDERROR GetResultSS(int handle, string IOType, string channel, ref double val)
public static LJUDERROR Go()
public static LJUDERROR GoOne(int handle)
public static LJUDERROR ListAll(DEVICE deviceType, CONNECTION connectionType, ref int numFound, int[] serialNumbers, int[] IDs, double[] addresses)
public static LJUDERROR ListAllS(string deviceType, string connectionType, ref int numFound, int[] serialNumbers, int[]
public static LJUDERROR OpenLabJack(DEVICE deviceType, CONNECTION connectionType, string address, bool firstFound, ref int handle)
public static LJUDERROR OpenLabJackS(string deviceType, string connectionType, string address, bool firstFound, ref int handle)
public static LJUDERROR ResetLabJack(int handle)
public static int StringToConstant(string str)
public static LJUDERROR StringToDoubleAddress(string str, ref double number, int hexDot)
public static LJUDERROR TCVoltsToTemp(THERMOCOUPLETYPE TCType, double TCVolts, double CJTempK, ref double TCTempK)
The parameters to these methods all work the same as outlined in the LabJackUD
documentation of functions. Some methods have more than one definition to
provide support for more than one calling type. If you pass the data type you
are expecting, the compiler should be able to identify which method you are
calling and handle it appropriately.
There is also an object in the LabJack.LabJackUD namespace called
LabJackUDException. This object is an Exception object which provides an easier
way of doing error handling. The object has a public LJUD.LJUDERROR error field
which can be used to retrieve the error, and a ToString() method that calls
LJUD.ErrorToString(error, s) to resolve the value. Thus, you can do the
following to detect errors:
try
{
// Add requests
LJUD.AddRequest(handle, LJUD.IO.ANALOG_INPUT, (LJUD.CHANNEL) 0,0,0,0);
// Execute
LJUD.GoOne(handle);
// Get result
LJUD.GetResult(handle, LJUD.IO.ANALOG_INPUT, (LJUD.CHANNEL) 0, ref AI0);
}
catch (LabJackUDException e)
{
// Display error in a message box
MessageBox.Show(this, e.ToString(), "LabjackUD Error #" + (int)e.error);
}
There are also the UE9, U3 and U6 objects in the LabJack.LabJackUD namespace that
provides a few extra features to make working with the devices easier. The UE9,
U3 and U6 objects inherits from the LJUD object, thus containing the same static
methods.
The UE9 object supports the additional methods:
public void commConfig()
public void controlConfig()
public bool Equals(Object o)
public int GetHashCode()
public void locID()
The U3 object supports the additional methods:
public bool Equals(Object o)
public int GetHashCode()
public void locID()
public void u3Config()
The U6 object supports the additional methods:
public bool Equals(Object o)
public int GetHashCode()
public void locID()
public void U6Config()
These methods allow you to use the object as a representation as a UE9, U3 or
U6. Thus you can use it as an Object in a collection data type or for other
purposes.
The UE9 object has the following public fields defined:
public double blver
public double cmfwver
public double cntfwver
public double cntpow
public double dhcp
public double eth
public double gateway
public double hwver
public double ip
public int ljhandle
public double localid;
public double mac
public double pid
public double porta
public double portb
public double powlev
public double productid
public double rstsrc
public double sernum
public double subnet
public bool UE9Pro
public double usb
The U3 object has the following public fields defined:
public double bootloaderversion
public double firmwareversion
public double hardwareversion
public int ljhandle
public double localid
public double serialnumber
The U6 object has the following public fields defined:
public double bootloaderversion
public double firmwareversion
public double hardwareversion
public int ljhandle
public double localid
public double serialnumber
public bool U6Pro
These variables are populated with the correct values from a UE9 by calling the
commConfig and controlConfig methods, from a U3 by calling the u3Config
method and from a U6 by calling the u6Config method. The ljhandle field
is used to store the handle to communicate with the device.
You can communicate with a UE9 by doing:
UE9 ue9;
try
{
// Open first found UE9 over USB
ue9 = new UE9(LabJackUD.CONNECTION.USB, "0", true);
ue9.commConfig();
ue9.controlConfig()
}
catch (LabJackUDException e)
{
// Display error in a message box
MessageBox.Show(this, e.ToString(), "LabjackUD Error #" + (int)e.error);
}
MessageBox.Show("Handle: " + ue9.ljhandle + " Local ID:" + ue9.localid);
You can communicate with a U3 by doing:
U3 u3;
try
{
// Open first found U3 over USB
u3 = new U3(LabJackUD.CONNECTION.USB, "0", true);
u3.u3Config();
}
catch (LabJackUDException e)
{
// Display error in a message box
MessageBox.Show(this, e.ToString(), "LabjackUD Error #" + (int)e.error);
}
MessageBox.Show("Handle: " + u3.ljhandle + " Local ID:" + u3.localid);
You can communicate with a U6 by doing
U6 u6;
try
{
// Open first found U6 over USB
u6 = new U6(LabJackUD.CONNECTION.USB, "0", true);
u6.U6Config();
}
catch (LabJackUDException e)
{
// Display error in a message box
MessageBox.Show(this, e.ToString(), "LabjackUD Error #" + (int)e.error);
}
MessageBox.Show("Handle: " + u3.ljhandle + " Local ID:" + u3.localid);
For more examples please refer to the code/projects in the Examples folder.
Device documentation can be found here:
UE9 Datasheet - https://labjack.com/support/datasheets/ue9
U3 Datasheet - https://labjack.com/support/datasheets/u3
U6 Datasheet - https://labjack.com/support/datasheets/u6
Section 4 of the datasheets have general LabJackUD driver documentation,
including function references and helpful pseudocode.