User`s guide

54 Agilent VISA User’s Guide
3 Programming with VISA
Example: Reading Event Attributes Once you have decided
which attribute to check, you can read the attribute using the
viGetAttribute function. The following example shows one way you
could check which trigger line fired when the VI_EVENT_TRIG event
was delivered.
Note that the context parameter is either the event context passed to your
event handler, or the outcontext specified when doing a wait on event.
See “VISA Attributes” in this chapter for more information on reading
attribute states.
ViInt16 state;
.
.
viGetAttribute(context, VI_ATTR_RECV_TRIG_ID,
&state)
Using the Callback Method
The callback method of event notification is used when an immediate
response to an event is required. To use the callback method for
receiving notification that an event has occurred, you must do the
following.
Install an event handler with the viInstallHandler function
Enable one or several events with the viEnableEvent function
When the enabled event occurs, the installed event handler is called.
Example: Using the Callback Method This example shows one
way you can use the callback method.
ViStatus _VI_FUNCH my_handler (ViSession vi,
ViEventType eventType, ViEvent context, ViAddr
usrHandle) {
/* your event handling code here */
return VI_SUCCESS;
}
main(){
ViSession vi;
ViAddr addr=0;