Method ITcRTimeTask::GetCpuAccount()

Query of the CPU account of a TwinCAT Task.

Syntax

virtual HRESULT TCOMAPI GetCpuAccount(PULONG pAccount)=0; 

Parameter

pAccount: (type: PULONG) [out] TwinCAT Task CPU account is stored in this parameter.

Return value

If successful, S_OK ("0") or another positive value will be returned, cf. Return values. Extended messages refer in particular to the column HRESULT in ADS Return Codes.

E_POINTER if the parameter pAccount = NULL.

Description

The GetCpuAccount() method can be used to query the current computing time used for the task.

Code snippet showing the use of GetCpuAccount(), e.g. within an ITcCyclic::CycleUpdate() method:


// CPU account in 100 ns interval
ITcRTimeTaskPtr spRTimeTask = ipTask;
ULONG nCpuAccountForComputeSomething = 0;
if (spRTimeTask != NULL)
{
ULONG nStart = 0;
hr = FAILED(hr) ? hr : spRTimeTask->GetCpuAccount(&nStart);

ComputeSomething();

ULONG nStop = 0;
hr = FAILED(hr) ? hr : spRTimeTask->GetCpuAccount(&nStop);

nCpuAccountForComputeSomething = nStop - nStart;
}