A state is a condition that a statechart can be in. States must be placed within regions and have at least one incoming transition.
Entry and Exit Actions within States
Each state has an associated entry and exit action. An entry action is LabVIEW code that executes when entering a state. An exit action is code that is executed when leaving a state (just before transitioning to the next state). Each state has only one entry and exit action in which both are optional. The entry and/or exit executes the action every time the state is entered or exited when present.
You can access this code through the Configure State dialog box.
Static Reactions within States
You can further configure states to have static reactions. A static reaction is the action a state performs when it is not taking any incoming or outgoing transitions. An individual state can have multiple static reactions that can execute at each iteration of the statechart.
Each static reaction comprises three components – trigger, guard, and action.
A trigger is an event or signal that causes a statechart to react. Asynchronous statecharts execute only after receiving a trigger – for example, a pushbutton or some user-interface interaction can produce a trigger. The trigger value is passed to the statechart that then acts based on the trigger. In synchronous statecharts, triggers are automatically passed to the statechart at periodic intervals. By default, the trigger value is set to NULL.
A guard is a piece of code that is evaluated before performing the action of the state. If the guard evaluates to true, the action code executes. If it evaluates to false, the action is not executed.
If the statechart receives a trigger that is to be handled by a particular static reaction, and the guard code evaluates to true, the reaction performs the action code. The action is LabVIEW code that performs the desired logic of the state. This can be reading inputs or internal state information and modifying outputs accordingly.
You can create static reactions through the Configure State dialog by creating a new reaction. Once you create a new reaction, you can associate it with a trigger and have guard and action code implemented. Only static reactions can be configured to have a trigger and guard.