CycleUtil Class Reference

This util class helps with keeping a cycle time during a control cycle. More...

#include <ArmarXCore/core/time/CycleUtil.h>

Public Member Functions

 CycleUtil (const IceUtil::Time &cycleDuration, bool forceSystemTime=false)
 
 CycleUtil (const std::int64_t &cycleDurationMs, bool forceSystemTime=false)
 
IceUtil::Time getAverageDuration () const
 
float getBusyWaitShare () const
 
std::int64_t getCycleCount () const
 Count of how many cycles were executed, i.e. More...
 
IceUtil::Time getLastCycleTime () const
 Time when the last cycle finished or start time. More...
 
IceUtil::Time getMaximumDuration () const
 
IceUtil::Time getMinimumDuration () const
 
IceUtil::Time getStartTime () const
 Time when object was constructed or reset was last called. More...
 
void reset ()
 resets startTime, lastCycleTime and cycleCount. More...
 
void setBusyWaitShare (float value)
 
IceUtil::Time update ()
 
IceUtil::Time waitForCycleDuration ()
 This function will wait (virtual or system time) until the cycle time is reached. More...
 

Static Protected Member Functions

static IceUtil::Time now ()
 

Protected Attributes

float busyWaitShare
 
std::int64_t cycleCount
 
IceUtil::Time cycleDuration
 
IceUtil::Time cycleMaxDuration
 
IceUtil::Time cycleMinDuration
 
bool forceSystemTime
 
IceUtil::Time lastCycleTime
 
IceUtil::Time startTime
 

Detailed Description

This util class helps with keeping a cycle time during a control cycle.

The main function is waitForCycleDuration(), which should be called in every cycle. The function will wait (virtual or system time) until the cycle time is reached. If the last cycle took already too long, it will return immediately. The last cycle time is updated, when waitForCycleDuration() is called.

Note
If system time is used (i.e. not the timeserver) the monotonic clock is used.

Definition at line 40 of file CycleUtil.h.

Constructor & Destructor Documentation

◆ CycleUtil() [1/2]

CycleUtil ( const IceUtil::Time &  cycleDuration,
bool  forceSystemTime = false 
)

Definition at line 30 of file CycleUtil.cpp.

+ Here is the call graph for this function:

◆ CycleUtil() [2/2]

CycleUtil ( const std::int64_t &  cycleDurationMs,
bool  forceSystemTime = false 
)

Definition at line 36 of file CycleUtil.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ getAverageDuration()

IceUtil::Time getAverageDuration ( ) const

Definition at line 103 of file CycleUtil.cpp.

+ Here is the call graph for this function:

◆ getBusyWaitShare()

float getBusyWaitShare ( ) const

Definition at line 126 of file CycleUtil.cpp.

◆ getCycleCount()

std::int64_t getCycleCount ( ) const

Count of how many cycles were executed, i.e.

how often waitForCycleDuration() was called.

Definition at line 97 of file CycleUtil.cpp.

◆ getLastCycleTime()

IceUtil::Time getLastCycleTime ( ) const

Time when the last cycle finished or start time.

Definition at line 146 of file CycleUtil.cpp.

◆ getMaximumDuration()

IceUtil::Time getMaximumDuration ( ) const

Definition at line 120 of file CycleUtil.cpp.

◆ getMinimumDuration()

IceUtil::Time getMinimumDuration ( ) const

Definition at line 114 of file CycleUtil.cpp.

◆ getStartTime()

IceUtil::Time getStartTime ( ) const

Time when object was constructed or reset was last called.

Definition at line 91 of file CycleUtil.cpp.

◆ now()

IceUtil::Time now ( )
staticprotected

Definition at line 138 of file CycleUtil.cpp.

+ Here is the caller graph for this function:

◆ reset()

void reset ( )

resets startTime, lastCycleTime and cycleCount.

Definition at line 44 of file CycleUtil.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBusyWaitShare()

void setBusyWaitShare ( float  value)

Definition at line 132 of file CycleUtil.cpp.

+ Here is the call graph for this function:

◆ update()

IceUtil::Time update ( )

Definition at line 73 of file CycleUtil.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ waitForCycleDuration()

IceUtil::Time waitForCycleDuration ( )

This function will wait (virtual or system time) until the cycle time is reached.

If the last cycle took already too long, it will return immediately. The last cycle time is updated, when this function is called.

Returns
returns the time the function waited

Definition at line 53 of file CycleUtil.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ busyWaitShare

float busyWaitShare
protected

Definition at line 88 of file CycleUtil.h.

◆ cycleCount

std::int64_t cycleCount
protected

Definition at line 86 of file CycleUtil.h.

◆ cycleDuration

IceUtil::Time cycleDuration
protected

Definition at line 83 of file CycleUtil.h.

◆ cycleMaxDuration

IceUtil::Time cycleMaxDuration
protected

Definition at line 85 of file CycleUtil.h.

◆ cycleMinDuration

IceUtil::Time cycleMinDuration
protected

Definition at line 84 of file CycleUtil.h.

◆ forceSystemTime

bool forceSystemTime
protected

Definition at line 87 of file CycleUtil.h.

◆ lastCycleTime

IceUtil::Time lastCycleTime
protected

Definition at line 82 of file CycleUtil.h.

◆ startTime

IceUtil::Time startTime
protected

Definition at line 81 of file CycleUtil.h.


The documentation for this class was generated from the following files: