此示例介绍三个一起使用的功能 IsFirstMastCycle、IsFirstMastColdCycle 和 IsFirstMastWarmCycle。
请在 MAST 任务中使用此示例。否则,可能会运行多次或一次也不运行(在第一个 MAST 任务循环期间可能会多次调用或不调用某个附加任务):
VAR
MyIsFirstMastCycle : BOOL;
MyIsFirstMastWarmCycle : BOOL;
MyIsFirstMastColdCycle : BOOL;
END_VAR
MyIsFirstMastWarmCycle := IsFirstMastWarmCycle();
MyIsFirstMastColdCycle := IsFirstMastColdCycle();
MyIsFirstMastCycle := IsFirstMastCycle();
IF (MyIsFirstMastWarmCycle) THEN
(*This is the first Mast Cycle after a Warm Start: all variables are set to their initialization values except the Retain variables*)
(*=> initialize the needed variables so that your application runs as expected in this case*)
END_IF;
IF (MyIsFirstMastColdCycle) THEN
(*This is the first Mast Cycle after a Cold Start: all variables are set to their initialization values including the Retain Variables*)
(*=> initialize the needed variables so that your application runs as expected in this case*)
END_IF;
IF (MyIsFirstMastCycle) THEN
(*This is the first Mast Cycle after a Start, i.e. after a Warm or Cold Start as well as STOP/RUN commands*)
(*=> initialize the needed variables so that your application runs as expected in this case*)
END_IF;