In general, functions generated from statecharts will resemble the following (the provided line numbers are used in explanations of the code below):
4 StateInfo_A11_CTRLcnt1 nextState_A11_CTRLcnt1 = 0;5 if (currentState_A11_CTRLcnt1 == 0) {6 nextState_A11_CTRLcnt1 = FS_A11_CTRLst2;7 }9 else10 {11 … The rest of the Statechart logic12 }13 if (nextState_A11_CTRLcnt1 != 0) {14 if (currentState_A11_CTRLcnt1 !=15 cgGlobalFlags |= BITSUPERSTEP_TASK1;16 currentState_A11_CTRLcnt1 =17 }In line 4, the
nextState
variable is reset. This variable will be set only if a transition has been made, and will hold the statechart's new state configuration.Lines 13 and 14 check the
nextState
variable to determine whether a transition was made, and whether to enforce another step in the task holding the statechart.Line 16 advances the statechart configuration a step to hold the configuration of the next step.
In your statechart, lines 5 to 12 will be replaced with specific code resulting from the specified statechart logic. For example, in many cases, two additional functions will be generated here - entry actions and exit actions. If the statechart logic requires entering/exiting reactions, the functions will resemble the following.
When either of these function are needed, the following changes to cgDo_… will also be made:
StateInfo_A11_CTRLcnt1 nextState_A11_CTRLcnt1 = 0;
if (currentState_A11_CTRLcnt1 == 0) {
… The rest of the Statechart logic
if (nextState_A11_CTRLcnt1 != 0) {
cgEnterActions_A11_CTRLcnt1();
if (currentState_A11_CTRLcnt1 !=
cgGlobalFlags |= BITSUPERSTEP_TASK1;