artdaq_core  v3_06_01
artdaq::MonitoredQuantity Class Reference

This class keeps track of statistics for a set of sample values and provides timing information on the samples. More...

#include <artdaq-core/Core/MonitoredQuantity.hh>

Inheritance diagram for artdaq::MonitoredQuantity:
artdaq::MonitoredQuantityStats

Public Member Functions

 MonitoredQuantity (DURATION_T expectedCalculationInterval, DURATION_T timeWindowForRecentResults)
 Instantiates a MonitoredQuantity object. More...
 
void addSample (const double value=1.0)
 Adds the specified doubled valued sample value to the monitor instance. More...
 
void addSample (const int value=1)
 Adds the specified integer valued sample value to the monitor instance. More...
 
void addSample (const uint32_t value=1)
 Adds the specified uint32_t valued sample value to the monitor instance. More...
 
void addSample (const uint64_t value=1)
 Adds the specified uint64_t valued sample value to the monitor instance. More...
 
bool calculateStatistics (TIME_POINT_T currentTime=getCurrentTime())
 Forces a calculation of the statistics for the monitored quantity. More...
 
void reset ()
 
void enable ()
 
void disable ()
 
bool isEnabled () const
 Tests whether the monitor is currently enabled. More...
 
void setNewTimeWindowForRecentResults (DURATION_T interval)
 Specifies a new time interval to be used when calculating "recent" statistics. More...
 
DURATION_T getTimeWindowForRecentResults () const
 Returns the length of the time window that has been specified for recent results. More...
 
DURATION_T ExpectedCalculationInterval () const
 Returns the expected interval between calculateStatistics calls. More...
 
bool waitUntilAccumulatorsHaveBeenFlushed (DURATION_T timeout) const
 Blocks while the MonitoredQuantity is flushed, up to timeout duration. More...
 
void getStats (MonitoredQuantityStats &stats) const
 Write all our collected statistics into the given Stats struct. More...
 
TIME_POINT_T getLastCalculationTime () const
 Access the last calculation time.
 
DURATION_T getFullDuration () const
 Access the full duration of the statistics.
 
double getRecentValueSum () const
 Access the sum of the value samples in the "recent" time span.
 
double getRecentValueAverage () const
 Access the average of the value samples in the "recent" time span.
 
size_t getFullSampleCount () const
 Access the count of samples for the entire history of the MonitoredQuantity.
 

Static Public Member Functions

static TIME_POINT_T getCurrentTime ()
 Returns the current point in time. More...
 

Detailed Description

This class keeps track of statistics for a set of sample values and provides timing information on the samples.

Definition at line 157 of file MonitoredQuantity.hh.

Constructor & Destructor Documentation

MonitoredQuantity::MonitoredQuantity ( DURATION_T  expectedCalculationInterval,
DURATION_T  timeWindowForRecentResults 
)
explicit

Instantiates a MonitoredQuantity object.

Parameters
expectedCalculationIntervalHow often calculateStatistics is expected to be called
timeWindowForRecentResultsDefines the meaning of DataSetType::RECENT

Definition at line 8 of file MonitoredQuantity.cc.

Member Function Documentation

void MonitoredQuantity::addSample ( const double  value = 1.0)

Adds the specified doubled valued sample value to the monitor instance.

Parameters
valueThe sample value to add

Definition at line 17 of file MonitoredQuantity.cc.

void MonitoredQuantity::addSample ( const int  value = 1)

Adds the specified integer valued sample value to the monitor instance.

Parameters
valueThe sample value to add

Definition at line 33 of file MonitoredQuantity.cc.

void MonitoredQuantity::addSample ( const uint32_t  value = 1)

Adds the specified uint32_t valued sample value to the monitor instance.

Parameters
valueThe sample value to add

Definition at line 38 of file MonitoredQuantity.cc.

void MonitoredQuantity::addSample ( const uint64_t  value = 1)

Adds the specified uint64_t valued sample value to the monitor instance.

Parameters
valueThe sample value to add

Definition at line 43 of file MonitoredQuantity.cc.

bool MonitoredQuantity::calculateStatistics ( TIME_POINT_T  currentTime = getCurrentTime())

Forces a calculation of the statistics for the monitored quantity.

Parameters
currentTimeTime point to use for calculating statistics (if synchronized at a higher level)
Returns
Whether the statisics were calculated

Forces a calculation of the statistics for the monitored quantity. The frequency of the updates to the statistics is driven by how often this method is called. It is expected that this method will be called once per interval specified by expectedCalculationInterval

Definition at line 48 of file MonitoredQuantity.cc.

void MonitoredQuantity::disable ( )

Disables the monitor.

Definition at line 272 of file MonitoredQuantity.cc.

void MonitoredQuantity::enable ( )

Enables the monitor (and resets the statistics to provide a fresh start).

Definition at line 263 of file MonitoredQuantity.cc.

DURATION_T artdaq::MonitoredQuantity::ExpectedCalculationInterval ( ) const
inline

Returns the expected interval between calculateStatistics calls.

Returns
The expected interval between calculateStatistics calls

Definition at line 255 of file MonitoredQuantity.hh.

MonitoredQuantity::TIME_POINT_T MonitoredQuantity::getCurrentTime ( )
static

Returns the current point in time.

Returns
The current point in time.

Returns the current point in time. A negative value indicates that an error occurred when fetching the time from the operating system.

Definition at line 374 of file MonitoredQuantity.cc.

void MonitoredQuantity::getStats ( MonitoredQuantityStats stats) const

Write all our collected statistics into the given Stats struct.

Parameters
statsDestination for copy of collected statistics

Definition at line 331 of file MonitoredQuantity.cc.

DURATION_T artdaq::MonitoredQuantity::getTimeWindowForRecentResults ( ) const
inline

Returns the length of the time window that has been specified for recent results.

Returns
The length of the time windows for recent results

Returns the length of the time window that has been specified for recent results. (This may be different than the actual length of the recent time window which is affected by the interval of calls to the calculateStatistics() method. Use a getDuration(RECENT) call to determine the actual recent time window.)

Definition at line 246 of file MonitoredQuantity.hh.

bool artdaq::MonitoredQuantity::isEnabled ( ) const
inline

Tests whether the monitor is currently enabled.

Returns
Whether the monitor is currently enabled.

Definition at line 226 of file MonitoredQuantity.hh.

void MonitoredQuantity::reset ( )

Resets the monitor (zeroes out all counters and restarts the time interval).

Definition at line 251 of file MonitoredQuantity.cc.

void MonitoredQuantity::setNewTimeWindowForRecentResults ( DURATION_T  interval)

Specifies a new time interval to be used when calculating "recent" statistics.

Parameters
intervalThe new time interval for calculating "recent" statistics.

Definition at line 279 of file MonitoredQuantity.cc.

bool MonitoredQuantity::waitUntilAccumulatorsHaveBeenFlushed ( DURATION_T  timeout) const

Blocks while the MonitoredQuantity is flushed, up to timeout duration.

Parameters
timeoutHow long to wait for the MonitoredQuantity to be emptied, in seconds
Returns
Whether the MonitoredQuantity was emptied within the specified timeout

Definition at line 312 of file MonitoredQuantity.cc.


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