
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;
Содержание E2094S
Страница 6: ...6 Agilent VISA User s Guide ...
Страница 116: ...116 Agilent VISA User s Guide 4 Programming via GPIB and VXI ...
Страница 126: ...126 Agilent VISA User s Guide 5 Programming via LAN ...
Страница 143: ...Glossary Agilent VISA User s Guide 143 Windows notification area See notification area ...
Страница 144: ...144 Agilent VISA User s Guide Glossary ...