chai3d::cFrequencyCounter Class Reference

This class implements a frequency counter. More...

#include <CFrequencyCounter.h>

Public Member Functions

 cFrequencyCounter (const double a_timePeriod=1.0)
 Constructor of cFrequencyCounter. More...
 
virtual ~cFrequencyCounter ()
 Destructor of cFrequencyCounter. More...
 
void reset ()
 This method resets the frequency counter to zero. More...
 
void setTimePeriod (const double &a_timePeriod)
 This method sets the time period in seconds. More...
 
double getTimePeriod () const
 This method returns the time period in seconds. More...
 
double getFrequency ()
 This method returns the most recent estimated frequency value in Hertz. More...
 
double signal (const unsigned int a_numEvents=1)
 This method signals the frequency counter of a one or more events. More...
 

Protected Attributes

cPrecisionClock m_clock
 High precision clock. More...
 
double m_frequency
 Estimated frequency value in Hertz. More...
 
unsigned int m_counter
 Event counter. More...
 

Detailed Description

cFrequencyCounter is a basic frequency counter. Frequency is defined as the number of events of a particular sort occurring in a set period of time. The sampling time period is adjustable but is set at 1 second as a default value.
By calling the method signal() a counter is incremented. When the internal clock reaches the programmed timeout period (1 second for instance), the frequency value is computed and updated.

Constructor & Destructor Documentation

chai3d::cFrequencyCounter::cFrequencyCounter ( const double  a_timePeriod = 1.0)

Constructor of cFrequencyCounter.

Parameters
a_timePeriodTime period in seconds.
virtual chai3d::cFrequencyCounter::~cFrequencyCounter ( )
inlinevirtual

Member Function Documentation

void chai3d::cFrequencyCounter::reset ( )

This method resets the frequency counter to zero.

void chai3d::cFrequencyCounter::setTimePeriod ( const double &  a_timePeriod)

This method sets the time period of the frequency counter.

Parameters
a_timePeriodTime period in seconds.
double chai3d::cFrequencyCounter::getTimePeriod ( ) const
inline
double chai3d::cFrequencyCounter::getFrequency ( )
inline
double chai3d::cFrequencyCounter::signal ( const unsigned int  a_numEvents = 1)

This method signals one of more events (The default value is 1). The reported events are added to the event counter and the frequency is estimated from the time reported by the high precision clock.

Parameters
a_numEventsNumber of new events.
Returns
Most recent estimated frequency value in Hertz.

Member Data Documentation

cPrecisionClock chai3d::cFrequencyCounter::m_clock
protected
double chai3d::cFrequencyCounter::m_frequency
protected
unsigned int chai3d::cFrequencyCounter::m_counter
protected

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