Task Execution Time

Is it possible to programmatically read the task execution time?

I guess you can use the CmpIECTask library.
I’ve found some information here

1 Like

PROGRAM Task_Control2
VAR
Result: CmpIecTask.RTS_IEC_RESULT;
hTask : CmpIecTask.RTS_IEC_HANDLE;
pCurrentTaskInfo: POINTER TO Task_Info2;
CurrentTaskInfo: Task_Info2;
xReset: BOOL;
END_VAR

hTask := IecTaskGetCurrent(ADR(Result));
pCurrentTaskInfo := IecTaskGetInfo3(hIecTask := hTask, pResult := ADR(Result));
CurrentTaskInfo := pCurrentTaskInfo^;

IF xReset THEN
xReset := FALSE;
IF hTask <> 0 THEN
Result := IecTaskResetStatistics(hIecTask := hTask);
END_IF
END_IF

CurrentTaskInfo.dwCycleTime; // This contains the task cycle time in micro seconds.

2 Likes