Transitions and static reactions rely upon triggers, guards, and actions. These three elements form a logic structure that the statechart uses to determine whether to take a transition or execute a static reaction. The following sections provide more information about these elements.
A trigger is something to which a statechart reacts. For example, a trigger can be a button press or a value change that happens in a caller VI. When you configure a transition or static reaction, you specify which trigger(s) cause the statechart to begin evaluating that transition or static reaction. Statecharts can react only to triggers that are defined for the current active state or superstate.
For example, consider a DVD player. When you press the Play button on a DVD player, the movie begins playing. When you press the Pause button, the movie pauses. The DVD player does not know when you are going to press a particular button, that is, the DVD player only can react to the button you press.
This behavior describes an asynchronous statechart that executes an action only after receiving a trigger. You typically use triggers with asynchronous statecharts, although you can use triggers with synchronous statecharts also.
![]() |
Note You must specify a trigger for every transition and static reaction except in the following situations: entry actions, exit actions, and transitions that leave an Initial pseudostate. |
Statecharts can receive triggers from a VI or from the statechart itself. In either situation, you must define the triggers to which a statechart can react. Asynchronous statecharts store incoming triggers in a trigger queue.
![]() |
Note Statecharts evaluate transitions before static reactions. Therefore, if you configure a static reaction and a transition to react to the same trigger, the statechart evaluates the transition first. |
You can combine triggers into groups. When you configure a transition or static reaction to react to a group, any trigger in that group can initiate the associated transition or static reaction.
After receiving a valid trigger, the statechart then evaluates the guard associated with that reaction or transition. A valid trigger is one that you have created and specified for the transition or static reaction.
Synchronous statecharts execute at defined time intervals and typically react to input data instead of triggers. However, you still must specify a trigger for every transition and static reaction of a synchronous statechart. To address this issue, the LabVIEW Statechart Module provides the NULL trigger.
By default, transitions and static reactions are configured to react to the NULL trigger. By default, synchronous Run Statechart functions send the NULL trigger to the statechart at every iteration of the statechart. This behavior means that, during every iteration of a synchronous statechart, the statechart evaluates NULL transitions and static reactions for the current state.
![]() |
Note You can override this behavior by wiring a trigger value to the Trigger input of the Run Statechart function. |
You can use this behavior to configure transitions and static reactions that rely on guards instead of triggers. If the transition is configured to react to the NULL trigger, and the statechart sends the NULL trigger during every iteration of the statechart, the guard is the primary factor in determining whether the statechart takes a transition. The following section describes a guard.
A guard is LabVIEW block diagram code that the statechart evaluates to determine if the transition or static reaction is valid. After receiving a trigger for a transition or static reaction, the statechart evaluates the guard code. This code, which must return either TRUE or FALSE, determines whether the statechart takes the transition or executes the static reaction. By combining a guard with triggers, you can be more specific about the conditions under which a statechart takes transitions and executes static reactions.
After receiving a specified trigger, the statechart evaluates the guard code. If the guard code returns TRUE, the statechart proceeds with the transition or static reaction. If the guard code returns FALSE, the statechart does not proceed with the transition or static reaction. In this situation, the statechart remains in the state that initiated the transition or static reaction. The statechart then can evaluate other transitions and/or static reactions for that state.
![]() |
Note Statecharts evaluate transitions according to the priority you specify. |
For example, a guard can return TRUE if five or more minutes have elapsed since the statechart began executing. This TRUE value means the statechart takes the transition and enters the next state. Otherwise, the guard returns FALSE. This FALSE value prevents the statechart from taking the transition, and the statechart remains in the same state.
![]() |
Note Specifying a guard is optional. Not specifying a guard is equivalent to specifying that the guard returns TRUE always. |
An action is LabVIEW block diagram code that modifies output or state data data and/or sends a trigger to the internal queue. The statechart executes actions at different times depending on whether that action is associated with a transition or a static reaction. The statechart executes actions in the following situations:
If the guard code returns FALSE in either situation, the statechart does not execute the action. Specifying an action is optional.
![]() |
Note In addition to defining actions for transitions and static reactions, you can define entry and exit actions of a state. |
You configure a transition or static reaction by combining one or more triggers, a guard, and an action into a logical sequence. For example, consider the following statement:
While in State 1: When the user presses the "Transfer" button and if the measured temperature is equal to or above 32 degrees Celsius, transfer the liquid from Container A to Container B.
The following table shows how this statement forms the logic of a transition.
| Phrase | Element of Transition Logic |
|---|---|
| When the user presses the "Transfer" button | Trigger |
| if the measured temperature is equal to or above 32 degrees Celsius | Guard |
| transfer the liquid from Container A to Container B. | Action |
In the LabVIEW Statechart Module, you write LabVIEW block diagram code to express each element of the transition logic.