User`s guide
62
•
PCIS-DASK Application Hints
5.5 Interrupt Event Message Programming Hints
PCIS-DASK provides two methods to perform interrupt occurrence notification
for NuDAQ DIO cards that have dual interrupt system.
The Event Message method handles event notification through user-defined
callbacks and/or the Windows Message queue (for VB5, through user-defined
callbacks only). When a user-specified interrupt event occurs, PCIS-DASK
calls the user-defined callback (if defined) and/or puts a message into the
Windows Message queue, if you specified a window handle. After receiving the
message, the user’s 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 interrupt events is smaller
than the time taken for callback function processing, the succeeding interrupt
events will not be handled. Therefore this mechanism is not suitable for the
frequent interrupt occurrence condition.
The Event Status checking and waiting method handles interrupt event
status checking through Win32 wait functions, such as WaitForSingleObject or
WaitForMultipleObjects. This method is useful for the situation that the
interrupt event occurs very often, and the applications written in the language
that doesn’t support function pointers (e.g. VB4).
1. Through user-defined callbacks and the Windows Message queue
[Example Code Fragment]
card = Register_Card(PCI_7230, card_number);
//INT1 event notification is through window message
DIO_INT1_EventMessage (card, INT1_EXT_SIGNAL, hWnd,
WM_INT, NULL);
//INT2 event notification is through a callback function
DIO_INT2_EventMessage (card, INT2_EXT_SIGNAL, hWnd, NULL,
(void *) cbfn);
… .
//window message handling function
long PASCAL MainWndProc(hWnd, message, wParam,
lParam)
{
switch(message) {
… .