Measurement Computing ADLIB WIN User Manual

Page 18

Advertising
background image

Chapter 4 Application Development

4-2

Notification Methods:

See function AL_SetBufferDoneHandler(…)

AL_CHECK_BUFFER

This is a “synchronous” method where the application calls a
GetDoneBuffPtr() function to determine whether or not the buffer
transfer is complete. If any buffers have been completed, a pointer to the
first buffer completed is returned. The retrieval of buffers is always
done in a first completed, first returned order. Once the application has
processed the data in an input buffer, it must call a function to clear the
Buffer Done flag -- this tells the Library functions that it is OK to reuse
the buffer. If the Library gets to the point where it needs to use the
buffer again, and the Buffer Done flag hasn’t cleared, the Library will
flag an error condition.

AL_POSTMESSAGE

This is an “asynchronous” method where the library sends a message to
the application when the buffer is done. The application sets up this
message handler function through the use of standard library routines.
That function would then process the data in the buffers. Again, the
application is responsible for clearing the Buffer Done flag as described
above. See below for Postmessage handler examples.

AL_POSTMESSAGE_PARAMS

This method is similar to the AL_POSTMESSAGE descrived above,
except that ADLIB calls the users message handler with the specified
lparam and wparam set by the AL_SetBufferDoneHandlerParams
function.

AL_CALLBACK

ADLIB calls a user defined “MSC CALLBACK” function per the
specified addrees per the AL_SetBufferDoneHandlerFunc. (MSC
Support Only)


C/C++ POSTMESSAGE HANDLER EXAMPLE
long OnBufferHandler(WPARAM wParam, LPARAM lParam)
{
float EngUnits[NUM_CHANNELS];
long lBuffNum;

/* Get the pointer to the buffer structure */
lpbuff = (LPBUFFSTRUCT)lParam;
/* the buffer number is wParam */
lBuffNum = wParam;

/* Check buffer errors flags */
if (lpbuff->lErrorFlags != 0)
OnBufferError(lpbuff);

/* Check buffer status flags */
if (lpbuff->dwStatusFlags != BUFFER_FULL)
OnBufferError(lpbuff);

/* Convert to Eng. units */
AL_DemuxData(lhldAdc0, lpbuff, EngUnits, Buffersize);

/* Clear the buffer done flags */
AL_ClearBufferDoneFlag(lhldAdc0, lpbuff->dwBuffNum);

return(0);

}

Advertising