State Machine  0.4.0
This repository contains packages for creating and running general purpose state machines.
state_machine::Rate Class Reference

#include <Rate.hpp>

Public Types

using Time = any_measurements::Time
 Time representation. More...
 

Public Member Functions

 Rate (double frequency, TimeInterfacePtr time)
 
virtual ~Rate ()=default
 
void sleep ()
 Sleep for rest of the rate. More...
 
void reset ()
 Reset the starting time. More...
 
Time getActualCycleDuration ()
 
Time getExpectedCycleDuration ()
 

Private Attributes

const Time expectedCycleDuration_
 Expected duration of a cycle. More...
 
const TimeInterfacePtr time_
 Pointer to the time interface. More...
 
Time start_
 Starting time of the current cycle. More...
 
Time actualCycleDuration_
 Actual duration of the current cycle. More...
 

Detailed Description

Rate implementation for time interface.

Member Typedef Documentation

◆ Time

using state_machine::Rate::Time = any_measurements::Time

Time representation.

Constructor & Destructor Documentation

◆ Rate()

state_machine::Rate::Rate ( double  frequency,
TimeInterfacePtr  time 
)

Constructor.

Parameters
frequencyFrequency at which rate should run.
timeTime interface to query current time and perform sleeps.

◆ ~Rate()

virtual state_machine::Rate::~Rate ( )
virtualdefault

Destructor.

Member Function Documentation

◆ getActualCycleDuration()

Time state_machine::Rate::getActualCycleDuration ( )
inline
Returns
The actual cycle duration.

◆ getExpectedCycleDuration()

Time state_machine::Rate::getExpectedCycleDuration ( )
inline
Returns
The expected cycle duration.

◆ reset()

void state_machine::Rate::reset ( )
inline

Reset the starting time.

◆ sleep()

void state_machine::Rate::sleep ( )

Sleep for rest of the rate.

Member Data Documentation

◆ actualCycleDuration_

Time state_machine::Rate::actualCycleDuration_
private

Actual duration of the current cycle.

◆ expectedCycleDuration_

const Time state_machine::Rate::expectedCycleDuration_
private

Expected duration of a cycle.

Members set during setup.

◆ start_

Time state_machine::Rate::start_
private

Starting time of the current cycle.

Members set during execution.

◆ time_

const TimeInterfacePtr state_machine::Rate::time_
private

Pointer to the time interface.


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