Creating a caller VI to communicate with a statechart a is different depending on whether the statechart is asynchronous or synchronous. In either case, you complete the following steps to prepare the statechart.
- Generate LabVIEW code for the statechart.
- Display the Project Explorer window that contains the .lvsc file for which you generated code.
- Create a new, blank VI to serve as the caller VI.
- Display the block diagram of this VI.
- Drag the .lvsc project item onto the block diagram. This action creates a Run Statechart function that links to the appropriate statechart.
- (Optional) Provide input data to the statechart by wiring a value to the Inputs input of the Run Statechart function.
- (Optional) Right-click the Outputs output and select Create»Indicator. This action creates a cluster indicator for data that the statechart returns. You can unbundle this cluster to access specific elements.
Asynchronous Statecharts
The following example shows how to create a caller VI that both executes and sends triggers to an asynchronous statechart. In this situation, the caller VI has two While Loops that execute in parallel. The first While Loop contains an Event structure that uses the Send External Trigger function to send triggers to the external queue of the statechart. The second While Loop contains the Run Statechart function that executes the statechart. You also can place these loops in two separate VIs to achieve greater modularization.
Complete the following steps to configure a caller VI to execute and send triggers to an asynchronous statechart.
- Place an Event structure in first loop and the Run Statechart function in the second loop.
- Add event cases to the Event structure. Each case should correspond to one or more triggers that you want to send to the statechart.
- Wire a value to the Instance Name input of the Run Statechart function. This action creates a name for the external queue of the statechart instance this function runs.
 |
Note If you do not see this input, the Run Statechart function is linked to a synchronous statechart. You must link the Run Statechart function to an asynchronous statechart. |
- Right-click the Run Statechart function and select Create Send External Trigger Function. This action creates a Send External Trigger function that links to the appropriate statechart.
- Place the Send External Trigger function in the loop that contains the Event structure.
- Specify the queue to which this function sends the trigger by wiring a value to the Instance Name terminal of the Send External Trigger function. Ensure this name is identical to the value you wired to the Instance Name input of the Run Statechart function.
- Specify the trigger to send by wiring a value to the Trigger input of the Send External Trigger function.
 |
Tip You can obtain a list of valid triggers by right-clicking the Trigger input and selecting either Create»Control or Create»Constant. |
- Move the trigger constant or control inside the corresponding case of the Event structure.
- Wire the trigger constant or control to the Trigger input of the Send External Trigger function. This wire exits the Event structure through an output tunnel.
- For each case of the Event structure, right-click the output tunnel and select either Create Control or Create Constant. Change the control or constant to represent the trigger you want to send.
The caller VI now resembles the following figure:

The caller VI now is configured to execute and send triggers to the statechart.
Synchronous Statecharts
You use only one loop in a caller VI. This loop contains only the Run Statechart function. You also can use this loop to send triggers to the statechart by wiring a trigger to the Trigger input of this function.
This loop can be a While Loop. However, if you need to execute the statechart at specific intervals, National Instruments recommends placing the Run Statechart function in a Timed Loop instead.
Complete the following steps to configure a caller VI to execute a synchronous statechart.
- Place the Run Statechart function in the loop.
- (Optional) Specify the trigger to send by wiring a value to the Trigger input of the Run Statechart function.
 |
Tip You can obtain a list of valid triggers by right-clicking the Trigger input input and selecting either Create»Control or Create»Constant. |
The caller VI now is configured to execute the statechart.