PlcTaskSystemInfo

Each PLC contains an array of instances of this type. The name of the arrays is '_TaskInfo[]'.
The individual instances of this type can be accessed by using the index of the corresponding task as array index. The task index can be read out using the GETCURTASKINDEXEX function, which is provided by the Tc2_System library.

The corresponding namespace is 'TwinCAT_SystemInfoVarList'. This must be specified for use in a library, for example.

{attribute 'Namespace' := 'PLC'}
TYPE PlcTaskSystemInfo
STRUCT
     ObjId                   : OTCID;
     CycleTime               : UDINT;
     Priority                : UINT;
     AdsPort                 : UINT;
     CycleCount              : UDINT;
     DcTaskTime              : LINT;
     LastExecTime            : UDINT;
     FirstCycle              : BOOL;
     CycleTimeExceeded       : BOOL;
     InCallAfterOutputUpdate : BOOL;
     RTViolation             : BOOL;

     TaskName                : STRING(63);
END_STRUCT
END_TYPE

ObjId

Object ID of the task reference, from which the PLC program is called.

CycleTime

Set task cycle time in multiples of 100 ns

Priority

Set task priority

AdsPort

ADS port of the task

CycleCount

Cycle counter

Please note that the cycle counter refers to the actual system task and not to the task reference of the PLC project. The background to this is that several PLC projects or other TcCOM modules can share a task and these modules can thus access the same cycle counter. As a result, the cycle counter is reset during a TwinCAT restart in RUN mode (and not when resetting the PLC project).

DcTaskTime

Distributed Clock System Time. It remains constant for a task runtime.

LastExecTime

Cycle time required for the last cycle in multiples of 100 ns

FirstCycle

During the first PLC task cycle, this variable has the value TRUE.

CycleTimeExceeded

This variable indicates whether the set task cycle time was exceeded.

The value of the CycleTimeExceeded variable is updated in each cycle. The variable is set to 0 if the previous cycle has been completed within its intended timeframe, otherwise to 1.

InCallAfterOutputUpdate

This variable has the value TRUE if the origin of the current call is declared with the attribute 'TcCallAfterOutputUpdate'.

RTViolation

This variable has the value TRUE if the real-time limit is exceeded on a mixed core (Windows + real-time on one core). In this case the value TRUE refers to the core on which the corresponding task is running.

TaskName

Name of the task reference object in the PLC project (e.g. 'MyPlcProject_PlcTaskRef')

Sample:

VAR
    nTaskIdx     : DINT;
    nCycleTime   : UDINT;
END_VAR
nTaskIdx := GETCURTASKINDEXEX();
IF nTaskIdx > 0 THEN
    nCycleTime := _TaskInfo[nTaskIdx].CycleTime;
END_IF