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.
 
IceUtil::Time getLastCycleTime () const
 Time when the last cycle finished or start time.
 
IceUtil::Time getMaximumDuration () const
 
IceUtil::Time getMinimumDuration () const
 
IceUtil::Time getStartTime () const
 Time when object was constructed or reset was last called.
 
void reset ()
 resets startTime, lastCycleTime and cycleCount.
 
void setBusyWaitShare (float value)
 
IceUtil::Time update ()
 
IceUtil::Time waitForCycleDuration ()
 This function will wait (virtual or system time) until the cycle time is reached.
 

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.

Constructor & Destructor Documentation

◆ CycleUtil() [1/2]

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

◆ CycleUtil() [2/2]

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

Member Function Documentation

◆ getAverageDuration()

IceUtil::Time getAverageDuration ( ) const

◆ getBusyWaitShare()

float getBusyWaitShare ( ) const

◆ getCycleCount()

std::int64_t getCycleCount ( ) const

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

how often waitForCycleDuration() was called.

◆ getLastCycleTime()

IceUtil::Time getLastCycleTime ( ) const

Time when the last cycle finished or start time.

◆ getMaximumDuration()

IceUtil::Time getMaximumDuration ( ) const

◆ getMinimumDuration()

IceUtil::Time getMinimumDuration ( ) const

◆ getStartTime()

IceUtil::Time getStartTime ( ) const

Time when object was constructed or reset was last called.

◆ now()

IceUtil::Time now ( )
staticprotected

◆ reset()

void reset ( )

resets startTime, lastCycleTime and cycleCount.

◆ setBusyWaitShare()

void setBusyWaitShare ( float value)

◆ update()

IceUtil::Time update ( )

◆ 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

Member Data Documentation

◆ busyWaitShare

float busyWaitShare
protected

◆ cycleCount

std::int64_t cycleCount
protected

◆ cycleDuration

IceUtil::Time cycleDuration
protected

◆ cycleMaxDuration

IceUtil::Time cycleMaxDuration
protected

◆ cycleMinDuration

IceUtil::Time cycleMinDuration
protected

◆ forceSystemTime

bool forceSystemTime
protected

◆ lastCycleTime

IceUtil::Time lastCycleTime
protected

◆ startTime

IceUtil::Time startTime
protected

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