Transition code determines which case to execute in the next
While Loop
iteration. You can use the transitions detailed below as a starting point for the transition code in your program.
Table 1.
One State Transition Value
State Transition
|
Example Image
|
Use an
Enum constant
transition when you always want to transition to a specific state after the code in the current state executes.
For example, the Initialize and Exit states in a state machine often use an
Enum constant
transition.
|
|
Table 2.
Two State Transition Values
State Transition
|
Example Image
|
Use a
Select
node and a Boolean value to choose between one of two transition values.
|
|
Table 3.
Three or More State Transition Values
State Transition
|
Example Image
|
Use a
Case Structure
transition when you need to handle a variety of situations. Add a case for each transition you need to program and create transition code in each case to adjust the transition value when the case executes. Each case in the
Case Structure
can include a single transition value or multiple values that the program must choose between.
|
|
Use a transition array when you need to choose between more than two transition values at one time. At run time, an
Index Array
node selects a transition value from an array constant containing each possible state transition value.
|
|
Use an
Event Structure
when you need to change states in response to a user action in your program. The
Event Structure
monitors the program for events and executes a subdiagram of code when a specific event occurs. Each event in the
Event Structure
can include a single transition value or multiple values that the program must choose between.
For example, the Wait for Event state in the simple state machine template uses an
Event Structure.
Note
If you need to perform an action periodically in the Wait for Event state, such as updating a timer, you can include an application timeout event in the
Event Structure.
|
|