Structuring Language: Activity Chart Implementation : TASK Activities : BASIC TASK

BASIC TASK

A BASIC TASK runs once, upon activation, and then terminates.

The code frame for a BASIC TASK (for example: TASK1 containing Activities A11 and A12), without controller, will resemble the following:

TASK (TASK1)
{
cgActivity_A11();
cgActivity_A12();
TerminateTask();
}.
 
 

If the TASK is periodic, with a period of 10 ticks, the code will change to look like this:

TASK (TASK1)
{
if ((cgGlobalFlags & ALARM_SET_TASK1) == 0){
cgGlobalFlags |= ALARM_SET_TASK1;
SetRelAlarm(TASK1_ALARM, 10, 10);
};
cgActivity_A11();
cgActivity_A12();
TerminateTask();
}
 
 
Note: Use the Data Dictionary->Design Attributes->Schedule Periodic flag to define a periodic Task.

If the TASK is periodic, containing Activities A11 and A12 with CTRL1 as controller, the code will change to look like this:

TASK (TASK1)
{
if ((cgGlobalFlags & ALARM_SET_TASK1) == 0){
cgGlobalFlags |= ALARM_SET_TASK1;
SetAbsAlarm(TASK1_ALARM, 10, 10);
};
do {
cgGlobalFlags &= ~BITSUPERSTEP_TASK3;
cgActivity_A11();
cgActivity_A12();
cgActivity_CTRL1cnt1();
} while ( (cgGlobalFlags & BITSUPERSTEP_TASK1) != 0);
TerminateTask();
}.