Statechart Module Tutorial Part 6: Splitting and Merging Transition Segments
- Updated2023-02-21
- 7 minute(s) read
In Part 5 of this tutorial, you added orthogonal regions and used state history. In Part 6 of this tutorial, you create one transition to multiple substates. You also create one transition from multiple substates to a single state. You also use a subdiagram to improve the appearance of the statechart diagram.
![]() |
You can complete these exercises in approximately 45 minutes. |
![]() |
Note Refer to the labview\examples\Statechart\Tutorial\Asynchronous\Getting Started 6.lvsc for a completed version of the statechart you create in this part of the tutorial. |
Creating One Transition to Multiple Substates
Examine the Statechart Editor window for the My Getting Started Statechart.lvsc statechart that you constructed in Part 5 of this tutorial. You also can navigate to the labview\examples\Statechart\Tutorial\Asynchronous directory and open Getting Started 5.lvsc for the completed statechart from Part 5 of this tutorial. In the current configuration, when the statechart takes the transition from the Pause state to the Play superstate, the statechart enters the Deep History pseudostate and the Red substate. The statechart enters the Red substate because this substate is connected to the Initial pseudostate in the region.
In some cases, you might want to bypass this initial transition by creating a transition to a specific substate. The Play superstate has a specific transition already that goes from the Pause state to the Deep History pseudostate. Instead of creating an additional transition, you can specify that this transition goes to not only the Deep History pseudostate, but also the Green substate.
Complete the following steps to define this behavior.
- Locate the transition that goes from the Pause state to the Deep History pseudostate.
- Double-click the segment of this transition that lies inside the Play superstate.
- Press the <Delete> key to delete this transition segment.
- Place a Fork connector, located on the Statechart Development palette, in the location of the segment you deleted.

Note You might have to resize the Play superstate. You also can resize the Fork connector.
Notice the triangular port on the top half of the Fork connector. This port is where you connect the incoming transition segment. The gray area on the bottom half of this connector is where you click to create outgoing transition segments.
The Play superstate now resembles the following figure:

Creating Transition Segments to and from the Fork Connector
Complete the following steps to define the transition that the Fork connector takes.
- Locate the triangular port of the transition from the Pause state to the Play superstate. This port is in the Play superstate.
- Move the cursor over this port until the cursor changes to the Wiring tool.
- Click to initiate a transition segment.
- Move the cursor over the incoming port to the Fork connector.
- Click to complete the transition segment. The Play superstate now resembles the following figure:

- Click the gray area on the bottom half of the Fork connector to initiate an outgoing transition segment from the Fork connector.
- Click the rectangular port that connects to the Deep History pseudostate to complete the outgoing transition segment from the Fork connector to the Deep History pseudostate.
- Create a transition segment from the Fork connector to the Green substate.
- Save the statechart.
The Play superstate now resembles the following figure:

![]() |
Note You can click and drag the transition segments to rearrange the position of these segments on the statechart diagram. You also can right-click a segment and select Clean Up Wire to have LabVIEW route the segment automatically. |
Before you placed the Fork connector, upon moving from the Pause state to the Play superstate, the statechart entered the Deep History pseudostate and the Red substate. In the current configuration, the Fork connector specifies that, upon moving from the Pause state to the Play superstate, the statechart enters the Deep History pseudostate and the Green substate. For the purposes of the statechart execution, this split segment is considered a single transition, even though the outgoing segments move to different substates.
![]() |
Note Notice the transition segments that are in the Play superstate have no transition nodes. You can configure this transition only at the point where the transition is in a region. In this situation, the top-level statechart diagram is the region. |
Specifying the Substates in which the Statechart Must Be Before It can Leave the Play Superstate
Recall the guarded transition that exits the Play superstate and enters the Menu state. The statechart takes this transition only if the value of the Counter indicator is greater than 25. In some situations, you might want to specify that the statechart must be in particular substates before taking this transition. This specification adds another condition to the transition. However, this condition is based on which states are active rather than the value of statechart data.
Complete the following steps to define this behavior.
- Place a Join connector, located on the Statechart Development palette, in the Play superstate below the two regions.

Note You might have to resize the Play superstate. You also can resize the Join connector. - Create a transition segment from the Tock substate to the gray area of the Join connector.
- Create a transition segment from the Green substate to the gray area of the Join connector.
- Create a transition segment from the Join connector to the rectangular port of the guarded transition from the Play superstate to the Menu state.
The Play superstate resembles the following figure:
The Join connector specifies that the statechart must be in both the Tock and Green substates before the statechart can evaluate the transition guard. Again, for the purposes of statechart execution, these merged segments are considered a single transition. - Save the statechart.
- Generate code for the statechart.
Running the Caller VI Again
- Run the caller VI and watch the state data.
- Click the Play front panel button.
- When the Counter indicator reaches 10, click the Pause front panel button.
- Highlight the execution of the statechart.
- Click the Play front panel button. Watch the execution of the statechart as the statechart takes the transition segment into the Fork connector and then into the Deep History pseudostate and Green substate.
- Turn off execution highlighting.
- Stop the caller VI.
- Close all debugging windows.
Viewing the Play Superstate as a Subdiagram
During this tutorial, you have added a significant amount of content to the Play superstate. A state of this size and complexity can make visual navigation of the statechart difficult. To address this issue, you can use subdiagrams to separate parts of the statechart diagram visually. This separation hides states you do not need to see, which makes the statechart diagram easier to navigate.
Complete the following steps to view the Play superstate as a subdiagram.
- Display the statechart diagram.
- Right-click the border of the Play superstate and select View as Subdiagram. LabVIEW displays a new window that shows the contents of the Play superstate on a blue diagram. For now, minimize this window.
- Return to the statechart diagram and look at the Play superstate. Notice how this state has a darker color and no longer has a border.
- Resize the Play superstate to be smaller. Notice how viewing the state as a subdiagram can save a lot of room on the statechart diagram.
- Right-click the Play superstate and select Open Subdiagram. The contents of the state appear in a separate window. Notice how this window has a blue diagram that distinguishes this window from the statechart diagram. You can place statechart objects in this window the same way as if you were viewing the state in the Statechart Editor window.

Note You can view the state normally again by repeating step 3. However, if you resized the state to be smaller, the state contents might not fit in the smaller state. You might have to resize the state again. - Save the statechart.
- Close LabVIEW.
Summary
In this tutorial, you learned about the following tasks:
- Creating one transition that goes to multiple substates.
- Specifying that the statechart must be in certain substates before taking a transition.
- Viewing states as subdiagrams.
Where to Go from Here
- You can view the statechart diagram that you completed in this tutorial with links to each of the objects in the diagram.
- Documentation related to the LabVIEW Statechart Module.
- The Getting Started with LabVIEW manual contains an in-depth introduction to LabVIEW, including several tutorials that showcase LabVIEW features.
- The LabVIEW Fundamentals book provides information about LabVIEW programming concepts, techniques, features, VIs, and functions you can use to create many types of applications.
- Refer to the National Instruments Web site for additional developer resources, training, technical support, and so on.
|
|
(Windows) To view topics related to the Statechart Module, click the Locate button, shown at left, in the toolbar at the top of this window. The LabVIEW Help highlights this topic in the Contents tab so you can navigate the related topics. |

