RKH
  1. Declaring the pseudostates
rkh_bunner.jpg


Prev: Declaring the basic states
Next: Defining the state machine's objects

The conditional, choice, shallow history, and deep history pseudostates are created using RKH_CREATE_COND_STATE(), RKH_CREATE_CHOICE_STATE(), RKH_CREATE_SHALLOW_HISTORY_STATE(), and RKH_CREATE_DEEP_HISTORY_STATE() macros respectively, which are defined in rkh.h file. Also, these macros are broadly explained in the Quick reference section.

The following figures, Figure 11, Figure 12, Figure 13, and Figure 14 highlights the pseudostates "C1", "C2", "CH", "H", and "DH" respectively. Also, shows its implementation using the RKH framework.


ic1.png
Figure 11 - conditional pseudostate "C1"


ic2.png
Figure 12 - conditional pseudostate "C2"

A condition connector has one incoming transition and can have several outgoing transition segments called branches. Branches are labeled with guards that determine which one is to be actually taken. Since the condition connector is an OR connector, only one of the branches can be taken. Each condition connector can have one special branch with a guard labeled rkh_sm_else, which is taken if all the guards on the other branches are false. Branches cannot contain triggers, but in addition to a guard they may contain actions. A branch can enter another condition connector, thus providing for the nesting of branches. In RKH branches are defined by the macro RKH_BRANCH(). The general syntax of an expression labelling a branch in a statechart is "[c]/a" where c is a condition that guards the transition from being taken unless it is true, and a is an action that is carried out if and when the transition is taken. All of these parts are optional. The following listing shows the C2's branch table:

(2) RKH_BRANCH( x1, dummy_act, &S3 ),
RKH_BRANCH( x2_or_x3, NULL, &S32 ),
(3) RKH_BRANCH( ELSE, NULL, &S2 ),

Explanation

  • (2) The RKH_BRANCH() macro defines a branch segment, where x1() is the guard function, dummy_act() is the action function to be taken, and "S3" is the target state.
  • (3) If all the guards on the other branches are false abort function will be invoked, and "S2" will be the next state.

As said above, the actions and guards in RKH framework are represented by functions.


ich.png
Figure 13 - choice pseudostate "CH"


ih.png
Figure 14 - history pseudostates "H" and "DH"


Prev: Declaring the basic states
Next: Defining the state machine's objects