CFEL - ASG Software Suite  2.5.0
CASS
Public Member Functions | Private Attributes | List of all members
cass::Ratemeter Class Reference

class calculating a rate in Hz. More...

#include <ratemeter.h>

+ Collaboration diagram for cass::Ratemeter:

Public Member Functions

 Ratemeter (const double averagetime=1)
 constuctor More...
 
double calculateRate ()
 retrieve the rate More...
 
void count (double increase=1.)
 increase the counts More...
 

Private Attributes

QMutex _mutex
 mutex to make function counting reentrant More...
 
QTime _time
 the time to stop the timeinterval More...
 
double _counts
 a counter that will increase with each call to count More...
 
double _rate
 the current rate More...
 
const double _averagetime
 time constant with which the rate will decrease More...
 

Detailed Description

class calculating a rate in Hz.

slot count has to be called to increase the count the current rate will be updated once the rate is retrieved

Author
Lutz Foucar

Definition at line 28 of file ratemeter.h.

Constructor & Destructor Documentation

Ratemeter::Ratemeter ( const double  averagetime = 1)

constuctor

Parameters
averagetimetime in seconds over which you want to average the rate. Default is 1 s.

Definition at line 17 of file ratemeter.cpp.

References _time, and QTime::start().

Member Function Documentation

double Ratemeter::calculateRate ( )

retrieve the rate

the rate is calculated using the formular found in wiki at

See also
http://en.wikipedia.org/wiki/Moving_average It uses the elapsed time since the last time we called calculateRate() and the current value is the number of counts that we acquired since the last time.

Definition at line 26 of file ratemeter.cpp.

References _averagetime, _counts, _rate, _time, QTime::elapsed(), and QTime::restart().

Referenced by cass::RatePlotter::run().

void Ratemeter::count ( double  increase = 1.)

increase the counts

this function is locked by a mutex to make it reentrant

Parameters
increasethe value to increase by. Default is 1.

Definition at line 42 of file ratemeter.cpp.

References _counts, and _mutex.

Referenced by cass::Worker::runthis().

Member Data Documentation

const double cass::Ratemeter::_averagetime
private

time constant with which the rate will decrease

Definition at line 70 of file ratemeter.h.

Referenced by calculateRate().

double cass::Ratemeter::_counts
private

a counter that will increase with each call to count

Definition at line 64 of file ratemeter.h.

Referenced by calculateRate(), and count().

QMutex cass::Ratemeter::_mutex
private

mutex to make function counting reentrant

Definition at line 58 of file ratemeter.h.

Referenced by count().

double cass::Ratemeter::_rate
private

the current rate

Definition at line 67 of file ratemeter.h.

Referenced by calculateRate().

QTime cass::Ratemeter::_time
private

the time to stop the timeinterval

Definition at line 61 of file ratemeter.h.

Referenced by calculateRate(), and Ratemeter().


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