Session functions, Session functions -3 – National Instruments Image Acquisition Software User Manual

Page 23

Advertising
background image

Chapter 3

Programming with NI-IMAQ

©

National Instruments Corporation

3-3

NI-IMAQ User Manual

Before you can acquire image data successfully, you must open an interface
by using the

imgInterfaceOpen

function.

imgInterfaceOpen

requires

an interface name and returns a handle to this interface. NI-IMAQ then uses
this handle to reference this interface when using other NI-IMAQ
functions.

To establish a connection to the first board in your system, use the
following program example:

INTERFACE_ID

interfaceID;

if (imgInterfaceOpen(“img0”, &interfaceID) == IMG_ERR_GOOD)

{

… user code …

imgClose(interfaceID, FALSE);

}

This example opens an interface to

img0

. When the program is finished

with the interface, it closes the interface using the

imgClose

function.

For a complete list of the available interface functions, refer to the
NI-IMAQ Function Reference Manual.

Session Functions

Use session functions to configure the type of acquisition you want
to perform on a particular interface. After you have established a
connection to an interface, you need to create a session and configure it
to perform the type of acquisition you require.

To create a session, call the

imgSessionOpen

function. This function

requires a valid interface handle and returns a handle to a session.
NI-IMAQ then uses this session handle to reference this session when using
other NI-IMAQ calls.

To create a session, use the following example program:

INTERFACE_ID

interfaceID;

SESSION_ID

sessionID;

if (imgInterfaceOpen(“img0”, &interfaceID) == IMG_ERR_GOOD)

{

if (imgSessionOpen(interfaceID, &sessionID) == IMG_ERR_GOOD)

{

… user code …

imgClose(sessionID, FALSE);

}

imgClose(interfaceID, FALSE);

}

UM.book Page 3 Monday, July 13, 1998 9:49 AM

Advertising