Designing Your Model: Model-Code Correspondence : Statecharts : Functions Generated for Statecharts

Functions Generated for Statecharts

For a control activity All_CTRL, the following two functions will be generated:

void cgActivity_A11_CTRLcnt1(void)
void cgDo_A11_CTRLcnt1(void)

 

The code generated for these functions will be as follows:

void cgDo_A11_CTRLcnt1(void)
{

StateInfo_A11_CTRLcnt1 nextState_A11_CTRLcnt1 = 0;

if (currentState_A11_CTRLcnt1 == 0) {

nextState_A11_CTRLcnt1 = FS_A11_CTRLst2;

}

else

{

… The rest of the Statechart logic

}

if (nextState_A11_CTRLcnt1 != 0) {

if (currentState_A11_CTRLcnt1 !=

nextState_A11_CTRLcnt1)

cgGlobalFlags |= BITSUPERSTEP_TASK1;

currentState_A11_CTRLcnt1 = nextState_A11_CTRLcnt1;

}

}

 

void cgActivity_A11_CTRLcnt1(void)
{

cgDo_A11_CTRLcnt1();

}