RKH
|
Prev: Instantiating the state machine
Next: Declaring the basic states
A superstate or composite state is defined with the RKH_CREATE_COMP_STATE() macro and declared with the RKH_DCLR_COMP_STATE() macro. Frequently, each state machine and its states (superstates and substates) are encapsulated inside a dedicated source file (.c file), from which the RKH_CREATE_COMP_STATE() macro is used.
The Figure 3 highlights the state "S1" and its relevant aspects. Also, shows its implementation using the RKH framework.
Defining the composite state "S1"
Declaring the composite state "S1"
Explanation
S1
is the state name. Represents a composite state structure. set_y_0()
defines the entry action to be executed unconditionally upon the entry to the S1
state. This argument is optional, thus it could be declared as NULL. The RKH_ENT_ACT_T defines the function prototype. dummy_exit()
defines the exit action, which is executed upon exit from the S1
state. This argument is optional, thus it could be declared as NULL. The RKH_EXT_ACT_T defines the function prototype. RKH_ROOT
is the parent state of S1
. If a state has no explicit superstate means that it is implicitly nested in the "top" state, and the parent state is defined by means of RKH_ROOT macro. The "top" state is a UML concept that denotes the ultimate root of the state hierarchy in a hierarchical state machine. S11
is the default state of S1
state machine. At each level of nesting, a superstate can have a private initial transition that designates the active substate after the superstate is entered directly. Here the initial transition of state S1
designates the state S11
as the initial active substate. DH
is the deep history pseudostate. This argument is optional, thus it could be declared as NULL. See RKH_CREATE_SHALLOW_HISTORY_STATE() macro and RKH_CREATE_DEEP_HISTORY_STATE().In RKH every state is associated with a transition table, which is composed of a well-defined set of transitions. The general syntax of an expression labelling a transition in a statechart is "i[c]/a" where i is the input that triggers the transition, c is a condition that guards the transition from being taken unless it is true when i occurs, and a is an action that is carried out if and when the transition is taken. All of these parts are optional. Thus, in RKH each row in a table represents a transition, which is well-defined by an event, a guard, an action, and target state (or pseudostate). The Figure 3 shows the transition table of "S1".
The following figures, Figure 5, and Figure 6 highlights the composite states "S3", and "S11". Also, shows its implementation using the RKH framework.
Prev: Instantiating the state machine
Next: Declaring the basic states