User events are defined on the diagram and triggered by the execution of diagram code.
Unlike user interface events, which require direct user interaction with front panel objects, user events allow you to create an application that responds to programmatic changes on objects.
Additionally, you can handle data associated with the event in its case of the
Event Structure.
What to Use
What to Do
Create the following diagram to build a user event that notifies the
Event Structure
to handle the event and any associated data.
Customize the gray sections for your unique programming goals.
|
To define a user event, wire a constant of the same data type as the event to
Create User Event.
The input for
Create User Event
is an individual element or a cluster whose data type defines the data type for the event.
|
|
Create User Event
returns a reference to the user event that you create. Use this reference to register for events and generate a user event.
To give a unique name to the user event you create, select
Create User Event
and edit the
Event name
field on the
Item
tab. In this diagram, the name of the user event is My User Event.
|
|
Use
Register For Events
to dynamically register the user event. You must dynamically register the user event so that the
Event Structure
can handle it when it occurs.
|
|
To display the
Dynamic Event Terminal, click the
Event Structure
and select
Use dynamic events
on the
Item
tab. Wire the
event registration refnum
output of
Register For Events
to the
Dynamic Event Terminal
on the left side of the
Event Structure.
After you select an event, the user event data items appear in the
Event Data Node
on the left border of the
Event Structure.
|
|
Click the event selector label at the top of the
Event Structure
to select one or more event sources for which you want to respond. Then select an event type for each event source.
The name of the user event appears under the
Event type
drop-down list when you select
Dynamic
as the event source.
|
|
Use the
Event Data Node
to access data elements associated with a particular event.
To add more data items to the
Event Data Node, vertically resize the node.
|
|
Use
Generate User Event
to broadcast the user event you wire to this node and the associated event data to each
Event Structure
registered to handle the event.
The data value that you wire to this node must match the data type of the user event.
Note
If the user event is not registered,
Generate User Event
has no effect. If the user event is registered but no
Event Structure
is waiting on it, the VI queues the user event and data until an
Event Structure
executes to handle the event.
|
|
To conserve memory resources, use
Unregister For Events
and
Destroy User Event
to release the associated events and the user event reference.
|
|
Create code that executes whenever this user event occurs.
|