Use the Event structure, shown as follows, to handle events in a VI.
The Event structure works like a Case structure with a built-in Wait on Notification function. The Event structure can have multiple cases, each of which is a separate event-handling routine. You can configure each case to handle one or more events, but only one of these events can occur at a time. When the Event structure executes, it waits until one of the configured events occur, then executes the corresponding case for that event. The Event structure completes execution after handling exactly one event. It does not implicitly loop to handle multiple events. Like a Wait on Notification function, the Event structure can time out while waiting for notification of an event. When this occurs, a specific Timeout case executes.
The event selector label at the top of the Event structure, shown as follows, indicates which events cause the currently displayed case to execute.
View other event cases by clicking the down arrow next to the case name and selecting another case from the shortcut menu.
(Windows) You also can move the cursor over the selector label and press the <Ctrl> key while moving the mouse wheel. (Mac OS) Press the <Command> key. (Linux) Press the <Meta> key.
The Timeout terminal at the top left corner of the Event structure, shown as follows, specifies the number of milliseconds to wait for an event before timing out.
The default is –1, which specifies to wait indefinitely for an event to occur. If you wire a value to the Timeout terminal, you must provide a Timeout case.
The Event Data Node, shown as follows, behaves similarly to the Unbundle By Name function.
This node is attached to the inside left border of each event case. The node identifies the data LabVIEW provides when an event occurs. You can resize this node vertically to add more data items, and you can set each data item in the node to access any event data element. The node provides different data elements in each case of the Event structure depending on which event(s) you configure that case to handle. If you configure a single case to handle multiple events, the Event Data Node provides only the event data elements that are common to all the events configured for that case.
The Event Filter Node, shown as follows, is similar to the Event Data Node.
This node is attached to the inside right border of filter event cases. The node identifies the subset of data available in the Event Data Node that the event case can modify. The node displays different data depending on which event(s) you configure that case to handle. By default, these items are inplace to the corresponding data items in the Event Data Node. If you do not wire a value to a data item of an Event Filter Node, that data item remains unchanged.
The dynamic event terminals, shown as follows, are available by right-clicking the Event structure and selecting Show Dynamic Event Terminals from the shortcut menu.
These terminals are used only for dynamic event registration.
|Note Like a Case structure, the Event structure supports tunnels. However, by default you do not have to wire Event structure output tunnels in every case. All unwired tunnels use the default value for the tunnel data type. Right-click a tunnel and deselect Use Default If Unwired from the shortcut menu to revert to the default Case structure behavior where tunnels must be wired in all cases. You also can configure the tunnels to wire the input and output tunnels automatically in unwired cases.|