Program development, Including adlib win in c\c, Steps to programming in c\c – Measurement Computing ADLIB WIN User Manual

Page 21

Advertising
background image

Chapter 5 Program Development

5-1

5. PROGRAM DEVELOPMENT

5.1 INCLUDING ADLIB WIN IN C\C++

The sections presented below describe the mechanics of incorporating the ADLIB WIN library in a
Windows based application program. To add the ADLIB library into the Windows Application
Programming Interface (API) requires the inclusion of the following header files in your program.

1. “adlib.h”

ADLIB

API

2. “adlerr.h”

ADLIB error codes

3. “drverr.h”

ADLIB

hardware generic error codes

5.1.1 Steps To Programming In C\C++

LHLD lhldAdc0;

/* Define a handle variable for the ADC device. */

LPBUFFSTRUCT lpbuff;

/* Define a pointer to an ADLIB data buffer structure */

ERRNUM errnum;

/* Define an error number variable. */


/* Load and initialize the environment. */
errnum = AL_LoadEnvironment(“c:\adlib\alwdm\Pci55mfhr\examples\pci55xx\msc\adlai01\adlib.con”);

/* Allocate the ADC0 subsystem on board number 0. Reads in the current */
/* Loads the initialization file (.INI) and sets the LDSD as defined. */
lhldAdc0 = AL_AllocateDevice(“ADC0”, BoardNum);

/* Make any changes to the LDSD before initializing the device. All LDSD parameters are either set to
their initialization file (.INI) defaults when specified, otherwise each undefined parameter defaults to the
first or lowest option available in the DAQ board's capability file (.CAP). If the parameter can’t be found in
capabilities file the option is defined as unsupported. */

errnum = AL_SetCycleMode(lhldAdc0, AL_SINGLE_CYCLE);
errnum = AL_SetTriggerMode(lhldAdc0, “POST_TRIG”);
errmum = AL_SetNumOfBuffers(lhldAdc0, 1);
errmum = AL_SetBufferSize(lhldAdc0, 1000);
.
.
/* Initializes the hardware device to the current LDSD settings. */
errnum = AL_InitDevice(lhldAdc0);

/* Start the logical device. */
errnum = AL_StartDevice(lhldAdc0);


lpbuff = AL_GetDoneBuffPtr(lhldAdc0);
if (NULL != lpbuff)
{
if (lpbuff->lErrorFlag == 0)
DoSomethingWithBuffer(lpbuff);
else
HandleERROR();
}
AL_StopDevice(lhldAdc0);
AL_ReleaseDevice(lhldAdc0);
AL_ReleaseEnvironment();

Advertising