beautypg.com

Readscandata() parameters, Internal buffer, Callbacktype – Measurement Computing DAQFlex User Guide User Manual

Page 20

background image

DAQFlex Software User's Guide

Using DAQFlex Software

20

ReadScanData() parameters

The first parameter to the

ReadScanData

method is the number of samples to read.

The second parameter is a time out value in milli-seconds. A value of 0 indicates no timeout

specified.

The ReadScanData method is synchronous, and will return when the number of requested samples are

available for reading. When the number of requested samples are available, the DAQFlex software

copies the requested number of samples from an internal buffer to a new array of data. The DAQFlex
software keeps track of the buffer index so that multiple calls to ReadScanData always return

contiguous data.

Internal buffer

An alternative method for reading scan data is to enable a user-defined callback method. When you

enable a callback method, the DAQFlex software invokes your user-defined method when a specified

number of samples are available for reading, when a scan completes, or if a scan error occurs. This is

done using the EnableCallback method as shown below:

C#

Device.EnableCallback(callbackMethod, callbackType, callbackCount);

VB

Device.EnableCallback(Addressof CallbackMethod, CallbackType, CallbackCount)

The callbackMethod is the name of the method that will be invoked by the DAQFlex software. The

callbackMethod is a class method that must have the following form:

C#

void CallbackMethod(ErrorCodes errorCode, CallbackType callbackType, object callbackData)

VB

Sub CallbackMethod(ByVal errorCode As ErrorCodes, ByVal callbackType As CallbackType,
_ ByVal callbackData As Object)

The callbackType is an enumeration that defines when the callback method will be invoked.

CallbackType

Member Name

Description

OnDataAvailable

Specifies that the callback method will be invoked when a specified

number of samples becomes available for reading.

OnInputScanComplete

Specifies that the callback method will be invoked when a finite scan has

complete or when a continuous scan is stopped.

OnInputScanError

Specifies that the callback method will be invoked when an input scan

error occurs.

Only one callback method can be specified for each callback type. When the callback type is set to

OnDataAvailable, set the callbackData parameter to the number of samples you wish to receive in the

callback method. When the callback type is set to OnInputScanComplete or OnInputScanError, set the

callbackData parameter to null or Nothing.