RKH
|
Prev: Instantiating the composite states
Next: Declaring the pseudostates
A basic state (also called substate) is defined with the RKH_CREATE_BASIC_STATE() macro and declared with the RKH_DCLR_BASIC_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_BASIC_STATE() macro is used. As will demostrates the use of RKH_CREATE_BASIC_STATE() macro and its arguments is very similar to RKH_CREATE_COMP_STATE() macro.
The Figure 7 highlights the basic states "S2". Also, shows its implementation using the RKH framework.
Defining the basic state "S2"
Declaring the basic state "S2"
Explanation
S2
is the state name. Represents a substate structure. RKH_ROOT
is the parent state of S2
. 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. the
event preprocessor action is unused, therefore it is declared as NULL. Before sending the arrived event to state machine, it can be previously processed using the event preprocessor function. An action function takes the state machine pointer and the event pointer as arguments. The first parameter is optional in compile-time according to RKH_CFG_SMA_PPRO_ARG_SMA_EN macro. Example: This argument is optional, thus it could be declared as NULL.
Example:
The following figures, Figure 8, Figure 9, and Figure 10 highlights the basic states "S111", "S112", "S31", "S32", and "S12" respectively. Also, shows its implementation using the RKH framework.
Prev: Instantiating the composite states
Next: Declaring the pseudostates