Dieser Inhalt liegt nicht in Ihrer bevorzugten Sprache vor.

Der Inhalt wird Ihnen in einer anderen verfügbaren Sprache angezeigt. Ihr Browser bietet ggf. Funktionen, die Sie bei der Übersetzung des Textes unterstützen.

Trigger Events for All of the Items in a Cluster Using LabVIEW

Updated Oct 23, 2023

Environment

Software

  • LabVIEW

This article goes through the steps on how to generate an event for all of the items in a cluster instead of having to add each of the items into the event structure manually. In order to understand this article, you need to have basic knowledge about event-driven programming in LabVIEW.

You can register for events the items contained within a cluster by doing this dynamically instead of adding all of the items manually. Follow these steps to dynamically register the items contained within a cluster:

1. Create a reference to the cluster by right-clicking on it and selecting Create >> Reference.
2. Wire a property node to the reference and select the Controls[] property to get an array with the reference to all of the items contained within the cluster.
3. Place the Register For Events Function in the block diagram and wire the output of the previously created property node to the input of this function.
4. Select the event that you want to register for the items in the cluster.
5. Create an event structure within a while loop and wire the stop condition.
6. Right-click on the event structure and click on Show Dynamic Event Terminals.
7. Wire the event reg refnum out from the Register For Events Function to the Event Dynamic Registration terminal.
8. Place an Unregister For Events Function outside the while loop and wire the Event Dynamic Registration output terminal of the event structure to it.
9. Right-click on the event structure and click on Add Event Case...
10. In the Edit Events Window go to the Event Sources panel and you should be able to find the dynamically registered event under the Dynamic section. Click on the registered action and then click on Add Event.
11. Configure the event case with the additional code required by your application.
 

In this example, a cluster with several string indicators is used. Each one of the string indicators has a shortcut menu, when one of the options in the shortcut menu (accessible by right-clicking on the string indicator) is clicked, an event is triggered that will show the text label of the specific item for which the menu was accessed.
 
Dynamically register items in cluster.png

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.