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 long &cycleDurationMs, bool forceSystemTime=false)
 
IceUtil::Time getAverageDuration () const
 
float getBusyWaitShare () const
 
long 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...
 

Protected Member Functions

IceUtil::Time now ()
 

Protected Attributes

float busyWaitShare
 
long 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 38 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 long &  cycleDurationMs,
bool  forceSystemTime = false 
)

Definition at line 38 of file CycleUtil.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ getAverageDuration()

IceUtil::Time getAverageDuration ( ) const

Definition at line 97 of file CycleUtil.cpp.

◆ getBusyWaitShare()

float getBusyWaitShare ( ) const

Definition at line 119 of file CycleUtil.cpp.

◆ getCycleCount()

long getCycleCount ( ) const

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

how often waitForCycleDuration() was called.

Definition at line 92 of file CycleUtil.cpp.

◆ getLastCycleTime()

IceUtil::Time getLastCycleTime ( ) const

Time when the last cycle finished or start time.

Definition at line 134 of file CycleUtil.cpp.

◆ getMaximumDuration()

IceUtil::Time getMaximumDuration ( ) const

Definition at line 114 of file CycleUtil.cpp.

◆ getMinimumDuration()

IceUtil::Time getMinimumDuration ( ) const

Definition at line 109 of file CycleUtil.cpp.

◆ getStartTime()

IceUtil::Time getStartTime ( ) const

Time when object was constructed or reset was last called.

Definition at line 87 of file CycleUtil.cpp.

◆ now()

IceUtil::Time now ( )
protected

Definition at line 129 of file CycleUtil.cpp.

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

◆ reset()

void reset ( )

resets startTime, lastCycleTime and cycleCount.

Definition at line 45 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 124 of file CycleUtil.cpp.

+ Here is the call graph for this function:

◆ update()

IceUtil::Time update ( )

Definition at line 70 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:

Field Documentation

◆ busyWaitShare

float busyWaitShare
protected

Definition at line 86 of file CycleUtil.h.

◆ cycleCount

long cycleCount
protected

Definition at line 84 of file CycleUtil.h.

◆ cycleDuration

IceUtil::Time cycleDuration
protected

Definition at line 81 of file CycleUtil.h.

◆ cycleMaxDuration

IceUtil::Time cycleMaxDuration
protected

Definition at line 83 of file CycleUtil.h.

◆ cycleMinDuration

IceUtil::Time cycleMinDuration
protected

Definition at line 82 of file CycleUtil.h.

◆ forceSystemTime

bool forceSystemTime
protected

Definition at line 85 of file CycleUtil.h.

◆ lastCycleTime

IceUtil::Time lastCycleTime
protected

Definition at line 80 of file CycleUtil.h.

◆ startTime

IceUtil::Time startTime
protected

Definition at line 79 of file CycleUtil.h.


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