viEnableEvent

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

Purpose

Enables notification of a specified event.

C Syntax

ViStatus viEnableEvent(ViSession vi, ViEventType eventType, ViUInt16 mechanism, ViEventFilter context)

Visual Basic Syntax

viEnableEvent&(ByVal vi&, ByVal eventType&, ByVal mechanism%, ByVal context&)

Resource Classes

All I/O session types

Parameters

Name Direction Description

vi

IN

Unique logical identifier to a session.

eventType

IN

Logical event identifier.

mechanism

IN

Specifies event handling mechanisms to be enabled. The queuing mechanism is enabled by specifying VI_QUEUE (1), and the callback mechanism is enabled by specifying VI_HNDLR (2) or VI_SUSPEND_HNDLR (4).

context

IN

VI_NULL (0).

Return Values

Completion Codes Description

VI_SUCCESS

Event enabled successfully.

VI_SUCCESS_EVENT_EN

Specified event is already enabled for at least one of the specified mechanisms.

Error Codes

Description

VI_ERROR_INV_OBJECT

The given session reference is invalid.

VI_ERROR_INV_EVENT

Specified eventType is not supported by the resource.

VI_ERROR_INV_MECH

Invalid mechanism specified for the event.

VI_ERROR_INV_CONTEXT

Specified event context is invalid.

VI_ERROR_INV_SETUP

Unable to start write operation because setup is invalid (due to attributes being set to an inconsistent state).

VI_ERROR_HNDLR_NINSTALLED

A handler is not currently installed for the specified event. The session cannot be enabled for the VI_HNDLR mode of the callback mechanism.

VI_ERROR_NSUP_MECH

The specified mechanism is not supported for the given eventType.

Description

The viEnableEvent() operation enables notification of an event identified by the eventType parameter for mechanisms specified in the mechanism parameter. The specified session can be enabled to queue events by specifying VI_QUEUE. Applications can enable the session to invoke a callback function to execute the handler by specifying VI_HNDLR. The applications are required to install at least one handler to be enabled for this mode. Specifying VI_SUSPEND_HNDLR enables the session to receive callbacks, but the invocation of the handler is deferred to a later time. Successive calls to this operation replace the old callback mechanism with the new callback mechanism.

Specifying VI_ALL_ENABLED_EVENTS for the eventType parameter refers to all events which have previously been enabled on this session, making it easier to switch between the two callback mechanisms for multiple events.

NI-VISA does not support enabling both the queue and the handler for the same event type on the same session. If you need to use both mechanisms for the same event type, you should open multiple sessions to the resource.


Related Topics

Events

viDisableEvent

viEventHandler

viInstallHandler

VISA Resource Template

viUninstallHandler

viWaitOnEvent

WAS THIS ARTICLE HELPFUL?

Not Helpful