ddc
Public Types | Public Member Functions | Public Attributes | List of all members
DDCTimeAvg Struct Reference

#include <ddcTime.h>

Collaboration diagram for DDCTimeAvg:
Collaboration graph
[legend]

Public Types

typedef size_t DelayT
 
typedef double ValueT
 
typedef DDCTimeHiRes TimeT
 
typedef std::map< DelayT, ValueTMapT
 

Public Member Functions

 DDCTimeAvg (DelayT delay1=60, DelayT delay2=300, DelayT delay3=900, ValueT val=0)
 
 DDCTimeAvg (const std::vector< DelayT > &delays, ValueT val=0)
 
 DDCTimeAvg (const DDCTimeAvg &X)
 
void reset (ValueT val=0)
 
void clear ()
 
void SetDelays (const std::vector< DelayT > &delays, ValueT val=0)
 
void SetDelays (DelayT delay1=60, DelayT delay2=300, DelayT delay3=900, ValueT val=0)
 
void SetDelays (const MapT &delayMap)
 
MapTAppend (ValueT sample, const TimeT &when, size_t n=1)
 
MapTAppend (ValueT sample=0)
 
void AppendTotal (ValueT sample)
 
DDCTimeAvgoperator+= (const DDCTimeAvg &x)
 
void Scrub ()
 
const MapTValues () const
 
const TimeTTime () const
 
ValueT Total () const
 
ValueT Average () const
 
ValueT tAverage () const
 
std::string toJsonArray () const
 
std::string toJsonMap () const
 

Public Attributes

MapT m_map
 
TimeT m_t
 
ValueT m_total
 
size_t m_n
 

Member Typedef Documentation

◆ DelayT

typedef size_t DDCTimeAvg::DelayT

typedef for delay keys (in seconds)

◆ ValueT

typedef double DDCTimeAvg::ValueT

typedef for moving-average samples and values

◆ TimeT

typedef for timestamps

◆ MapT

typedef std::map<DelayT,ValueT> DDCTimeAvg::MapT

typedef for delay-to-value map

Constructor & Destructor Documentation

◆ DDCTimeAvg() [1/3]

DDCTimeAvg::DDCTimeAvg ( DelayT  delay1 = 60,
DelayT  delay2 = 300,
DelayT  delay3 = 900,
ValueT  val = 0 
)
inline

constructor given up to three delays and optional initial value

References DDCTimeHiRes::Set().

Here is the call graph for this function:

◆ DDCTimeAvg() [2/3]

DDCTimeAvg::DDCTimeAvg ( const std::vector< DelayT > &  delays,
ValueT  val = 0 
)
inline

constructor given delays as vector and optional initial value

References DDCTimeHiRes::Set().

Here is the call graph for this function:

◆ DDCTimeAvg() [3/3]

DDCTimeAvg::DDCTimeAvg ( const DDCTimeAvg X)
inline

copy constructor

Member Function Documentation

◆ reset()

void DDCTimeAvg::reset ( ValueT  val = 0)

reset sample values to zero

Referenced by CDDCServerStats::clear().

Here is the caller graph for this function:

◆ clear()

void DDCTimeAvg::clear ( )
inline

clear all data

◆ SetDelays() [1/3]

void DDCTimeAvg::SetDelays ( const std::vector< DelayT > &  delays,
ValueT  val = 0 
)

set delays, given vector of delay keys

◆ SetDelays() [2/3]

void DDCTimeAvg::SetDelays ( DelayT  delay1 = 60,
DelayT  delay2 = 300,
DelayT  delay3 = 900,
ValueT  val = 0 
)

convenience method for setting up to 3 delays (zero delay-values are ignored)

◆ SetDelays() [3/3]

void DDCTimeAvg::SetDelays ( const MapT delayMap)
inline

set delays, given a map of delay-keys to moving-average values

◆ Append() [1/2]

DDCTimeAvg::MapT & DDCTimeAvg::Append ( ValueT  sample,
const TimeT when,
size_t  n = 1 
)

append a new sample value with timestamp when

Returns
new moving-average value map

References DDCTimeHiRes::Elapsed(), and SIZE_MAX.

Referenced by CDDCServer::ProcessSocketString().

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

◆ Append() [2/2]

MapT& DDCTimeAvg::Append ( ValueT  sample = 0)
inline

append a new sample value with current timestamp

Returns
new moving-average

◆ AppendTotal()

void DDCTimeAvg::AppendTotal ( ValueT  sample)
inline

append a new sample to the total only

Referenced by CDDCServer::ProcessSocketString().

Here is the caller graph for this function:

◆ operator+=()

DDCTimeAvg& DDCTimeAvg::operator+= ( const DDCTimeAvg x)
inline

hack: add EMA data from another object

  • used by CDDCServerStats to add session-local averages to server-global stats
  • does nothing if x.m_n==0; otherwise actually calls Append(x.Total())

References m_n, and Total().

Here is the call graph for this function:

◆ Scrub()

void DDCTimeAvg::Scrub ( )
inline

alias used by CDDCLeafServer::handle__status() to synchronize times: causes moving-averages to decay

Referenced by CDDCLeafServer::handle__status().

Here is the caller graph for this function:

◆ Values()

const MapT& DDCTimeAvg::Values ( ) const
inline

get most recent sample-values (undecayed)

◆ Time()

const TimeT& DDCTimeAvg::Time ( ) const
inline

get most recent sample timestamp

References DDCTimeUnix::m_t.

◆ Total()

ValueT DDCTimeAvg::Total ( ) const
inline

get sample total

Referenced by operator+=().

Here is the caller graph for this function:

◆ Average()

ValueT DDCTimeAvg::Average ( ) const
inline

get global average value

Referenced by CDDCLeafServer::handle__status().

Here is the caller graph for this function:

◆ tAverage()

ValueT DDCTimeAvg::tAverage ( ) const
inline

get highest-resolution average value; used by CDDCLeafServer::handle__status() for compatiblity reports

◆ toJsonArray()

string DDCTimeAvg::toJsonArray ( ) const

get JSON-array string of averages in ascending order of delay key

References Format().

Referenced by CDDCLeafServer::handle__status().

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

◆ toJsonMap()

string DDCTimeAvg::toJsonMap ( ) const

get JSON-map string of averages in ascending order of delay key

References Format().

Here is the call graph for this function:

Member Data Documentation

◆ m_map

MapT DDCTimeAvg::m_map

maps decay delays to current moving average values

  • keys ~ delays: number(s) of seconds until the contribution of a sample falls below 1/e (default=[60 300 900] ~ 1,5,15 minutes)
  • values ~ currentmoving average values

◆ m_t

TimeT DDCTimeAvg::m_t

timestamp of the current sample as returned by DDCTime::Now()

◆ m_total

ValueT DDCTimeAvg::m_total

global sample total

◆ m_n

size_t DDCTimeAvg::m_n

global number of samples

Referenced by operator+=().


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