User`s guide

36 ? PCIS-DASK Application Hints
4.5 DAQ Event Message Programming Hints
DAQ Event Message functions are an efficient way to monitor your background data acquisition processes, without
dedicating your foreground process for status checking. There are two kinds of events, which are AI/DI/DO operation
completeness notification event and half buffer ready notification event.
To receive notification from the PCIS-DASK data acquisition process in case of special events, you can call
AI_EventCallBack, DI_EventCallBack, or DO_EventCallBack to specify an event in which you are interested.
Event notification is done through user-defined callbacks. When a user-specified DAQ event occurs, PCIS-DASK calls
the user-defined callback. After receiving the message, the users application can carry out the appropriate task.
The event message mechanism is easy and safe in Windows 98 and NT systems; however, the time delay between the
event and notification is highly variable and depends largely on how loaded your system is. In addition, if a callback
function is called, succeeding events will not be handled until your callback has returned. If the time interval between
events is smaller than the time taken for callback function processing, the succeeding events will not be handled.
Therefore this mechanism is not suitable for the frequent events occurrence condition.
[Example Code Fragment]
card = Register_Card(PCI_9118DG, card_number);
AI_9118_Config(card,P9118_AI_BiPolar|P9118_AI_SingEnded,
P9118_AI_DtrgPositive|P9118_AI_EtrgPositive|P9118_AI_AboutTrgEn,0,postCount);
AI_AsyncDblBufferMode(card, 1); //double-buffer mode;
// Enable half buffer ready event notification
AI_EventCallBack (card, 1, DBEvent, (U32) DB_cbfn );
//Enable AI completeness event notification
AI_EventCallBack (card, 1, AIEnd, (U32) AI_cbfn );
AI_ContScanChannels (card, channel, range, NULL, data_size, (F64)sample_rate, ASYNCH_OP); or
AI_ContReadChannel(card, channel, range, NULL, data_size, (F64)sample_rate, ASYNCH_OP)
....
Release_Card(card);
//Half buffer ready call back function
void DB_cbfn()
{
//half buffer is ready
AI_AsyncDblBufferTransfer(card, ai_buf); //transfer to user buffer
.
}
//AI completeness call back function
void AI_cbfn()
{
//AI is completed ]
AI_AsyncClear(card, &count);
//Transfer the remainling data into the user buffer
AI_AsyncDblBufferTransfer(card, ai_buf);
.
}