GETCURTASKINDEX

GETCURTASKINDEX 1:

The function block GETCURTASKINDEX determines the task index of the task in which it is currently called.

To differentiate whether the current call occurs in the real-time context or from a cyclic PLC task, see the documentation for the GETCURTASKINDEXEX function. For example, the automatic call of FB_init methods during initialization does not occur from a cyclic PLC task.

VAR_INPUT

VAR_INPUT
(*none*)
END_VAR

VAR_OUTPUT

VAR_OUTPUT
    index : BYTE;
END_VAR

index: Returns the current task index of the calling task (1..4).

Example of calling the block in FBD:

GETCURTASKINDEX 2:

Requirements

Development environment

Target system type

PLC libraries to include (Category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_System (System)