Using daqflex software, Chapter 2 – Measurement Computing DAQFlex User Guide User Manual
Page 9
9
Chapter 2
Using DAQFlex Software
The following procedure describes how to program a DAQFlex-supported device with DAQFlex software.
1.
Add a reference to the DAQFlex assembly to your project.
o In Visual Studio and MonoDevelop, this assembly is listed under the .NET tab of the Add
Reference dialog as DAQFlex API.
If your project is a C# project, add the following statement to your source file:
using MeasurementComputing.DAQFlex
;
2.
Get a list of device names using the static method GetDeviceNames():
C#
string[] deviceNames;
deviceNames = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno);
VB
Dim deviceNames As String()
deviceNames = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno)
GetDeviceNames gets the names of DAQFlex devices detected by the DAQFlex API.
DeviceNameFormat
is an enumeration that specifies the format of the returned values. This enumeration defines four
different formats:
Member Name
Description
NameOnly
The returned values contain only the device name.
NameAndSerno
The return values contain the device name with the device serial number
formatted as "DeviceName::SerialNumber".
NameAndID
The return values contains the device name with the device's user-defined ID
formatted as "DeviceName::DeviceID".
NameSernoAndID
The return values contains the device name, the device serial number and the
device's user-defined ID formatted as "DeviceName::SerialNumber::DeviceID".
Note
: Each DAQFlex API method will throw an exception if an error occurs, and should be enclosed
within a
Try/Catch
block.
3.
Get a device object using the static method CreateDevice():
C
#
int deviceNumber = 0;
DaqDevice device;
string deviceName = deviceNames[deviceNumber];
device = DaqDeviceManager.CreateDevice(deviceName);