EnableEvent()

Binds one or more event conditions to a user-defined callback function. Upon detection of an event condition, the user-defined function is invoked with board- and event-specific data. Detection of event conditions occurs in response to interrupts. Typically, this method is used in conjunction with interrupt driven processes such as AInScan(), APretrig(), or AOut().

Member of the MccBoard class.

Function Prototype

VB .NET

Public Function EnableEvent(ByVal eventType As MccDaq.EventType, ByVal eventParameter As Integer, ByVal callbackFunc As MccDaq.EventCallback, ByVal userData As IntPtr) As MccDaq.ErrorInfo



Public Function EnableEvent(ByVal eventType As MccDaq.EventType, ByVal eventParameter As System.UInt32, ByVal callbackFunc As MccDaq.EventCallback, ByVal userData As IntPtr) As MccDaq.ErrorInfo



Public Function EnableEvent(ByVal eventType As MccDaq.EventType, ByVal eventParameter As MccDaq.EventParameter, ByVal callbackFunc As MccDaq.CallbackFunction, ByVal userData As IntPtr) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo EnableEvent(MccDaq.EventType eventType, uint eventParameter, MccDaq.EventCallback callbackFunc, System.IntPtr userData)



public MccDaq.ErrorInfo EnableEvent(MccDaq.EventType eventType, int eventParameter, MccDaq.EventCallback callbackFunc, System.IntPtr userData)



public MccDaq.ErrorInfo EnableEvent(MccDaq.EventType eventType, MccDaq.EventParameter eventParameter, MccDaq.CallbackFunction callbackFunc, System.IntPtr userData)

Parameters

eventType

Specifies one or more event conditions that will be bound to the user-defined callback function. More than one event type can be specified by bitwise OR'ing the event types. Set it to one of the constants in the eventType Parameter Values section below.

eventParameter

Additional data required to specify some event conditions, such as an OnDataAvailable event or OnExternalInterrupt event.

For OnDataAvailable events, eventParameter is used to determine the minimum number of samples to acquire during an analog input scan before generating the event. For OnExternalInterrupt events, eventParameter is used to latch digital bits on supported hardware by setting it to one of the constants in the eventParameter parameter Values section below.

Most event conditions ignore this value.

callbackFunc

A delegate type that is the user-defined callback function to handle the above event type(s). A delegate is a data structure that refers either to a static method, or to a class instance and an instance method of that class.

The callbackFunc needs the same parameters as the EventCallback delegate declaration. Refer to the "EventCallback delegate" section for proper syntax and return values.

userData

Reference to user-defined data that is passed to the EventCallback delegate. This parameter is NOT de-referenced by the library or its drivers; as a consequence, a NULL pointer can be supplied.

Returns

eventType Parameter Values

OnDataAvailableGenerates an event whenever the number of samples acquired during an analog input scan increases by eventParameter samples or more. Note that for BlockIo scans, events will be generated on packet transfers; for example, even if EventParameter is set to 1, events will only be generated every packet-size worth of data (256 samples for the PCI-DAS1602) for aggregate rates greater than 1 kHz for the default AInScan() mode.

For APretrig(), the first event is not generated until a minimum of EventParameter samples after the pretrigger.
OnEndOfInputScanGenerates an event upon completion or fatal error of AInScan() or APretrig().

Some devices, such as the USB-1208FS and USB-1408FS, will generate an end of scan event after StopBackground() is called, but most devices do not. Handle post-scan tasks directly after calling StopBackground.
OnEndOfOutputScanGenerates an event upon completion or fatal error of AOutScan().

Some devices, such as the USB-1208FS and USB-1408FS, will generate an end of scan event after StopBackground() is called, but most devices do not. Handle post-scan tasks directly after calling StopBackground.
OnExternalInterruptFor some digital and counter boards, generates an event, latches digital input data, or latches digital output data upon detection of a pulse at the External Interrupt pin.
OnPretriggerFor APretrig(), generates an event upon detection of the first trigger.
OnScanErrorGenerates an event upon detection of a driver error during Background input and output scans. This includes OverRun, UnderRun, and TooFew errors.

eventParameter Parameter Values

LatchDIReturns the data that was latched in at the most recent interrupt edge.
LatchDOLatches out the data most recently written to the hardware.

Callback Function Prototypes

C# .NET

public delegate void EventCallback( int BoardNum, MccDaq.EventType EventType, uint EventData, IntPtr pUserData);

VB .NET

Public Sub MyCallback(ByVal BoardNum As Integer, ByVal EventType As MccDaq.EventType, ByVal EventData As UInt32, ByVal pUserData As System.IntPtr)

Notes

Important!

In order to understand the methods, you must read the board-specific information contained in the Universal Library User's Guide. Review and run the example programs before attempting any programming of your own. Following this advice will save you hours of frustration, and possibly time wasted holding for technical support.

This note, which appears elsewhere, is especially applicable to this method. Now is the time to read the board-specific information for your board (see the Universal Library User's Guide). We suggest that you make a copy of that page to refer to as you read this manual and examine the example programs.