Designing Your Model: Model-Code Correspondence : Activity Charts : Decomposition of Non-basic Activities : Code for Basic Subactivities

Code for Basic Subactivities

Basic activities can be defined in one of three activation modes:

For reactive controlled and reactive self modes, the code for the basic activity will resemble the following:

void
cgActivity_A111(void)
{

… Body implementation

}

For the procedure-like mode, the code for the basic activity will resemble the following:

void
cgActivity_A112(void)
{

if ((cgActiveActivities1 & BITAC_A112) != 0) {

… Body implementation

stop_activity(A112);

}

}

 

Adding a controller A11_CTRL to A11 will make the code look like:

void
cgActivity_A11acy1(void)
{

cgActivity_A111();

cgActivity_A112();

cgActivity_A11_CTRLcnt1();

}

with the controller function, cgActivity_A11_CTRLcnt1(), looking like:

void
cgActivity_A11_CTRLcnt1(void)
{

cgDo_A11_CTRLcnt1();

}

The implementation of cgDo_A11_CTRLcnt1() depends on whether A11_CTRL is implemented as a statechart or as a flowchart.

For a statechart implementation:

void cgDo_A11_CTRLcnt1(void)
{

StateInfo_A11_CTRLcnt1 nextState_A11_CTRLcnt1 = 0;

if (currentState_A11_CTRLcnt1 == 0) {

nextState_A11_CTRLcnt1 = FS_A11_CTRLst2;

}

else

{

… 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;

}

}

For a flowchart implementation:

void
cgDo_A11_CTRLcnt1(void)
{
… The Flowchart logic
}