nidas  v1.2-1520
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
nidas::core::TimetagAdjuster Class Reference

Adjust time tags of fixed delta-T time series to correct for irregular latency in the assignments of the time tags at acquisition time. More...

#include <TimetagAdjuster.h>

Public Member Functions

 TimetagAdjuster (dsm_sample_id_t id, double rate)
 Constructor. More...
 
dsm_time_t adjust (dsm_time_t tt)
 Adjust a time tag. More...
 
void log (int level, const DSMSensor *sensor, bool octalLable=false)
 Log various statistics of the TimetagAdjuster, used by sensors classes on shutdown. More...
 
void slog (SampleTracer &stracer, const std::string &msg, dsm_time_t tt, long long toff, int tdiff, int tdiffUncorr)
 Log message for a traced sample. More...
 
void slog (SampleTracer &stracer, const std::string &msg, dsm_time_t tt)
 Log message for a traced sample. More...
 
float getRate () const
 Return the configured sample rate, as passed to constructor. More...
 
float getMaxResultDt () const
 Return the maximum dt in the adjusted time tags. More...
 
float getMinResultDt () const
 Return the minimum dt in the adjusted time tags. More...
 
double getDtAvg () const
 Return the current average input delta-T so far. More...
 
float getDtMin () const
 Return the minimum calculated delta-T so far. More...
 
float getDtMax () const
 Return the maximum calculated delta-T so far. More...
 
float getAdjMax () const
 Return the maximum adjustment to the measured time tags. More...
 
float getAdjMin () const
 Return the minimum adjustment to the measured time tags. More...
 
float getMaxGap () const
 Maximum data gap in the non-adjusted, raw, time tags, in seconds. More...
 
unsigned int getNumPoints () const
 Total number of time tags processed. More...
 
unsigned int getNumBackwards () const
 How many backwards input time tags have been encountered, typically zero. More...
 

Static Public Attributes

static const int BIG_GAP_SECONDS = 10
 

Private Attributes

dsm_time_t _tt0
 Result time tags will have a integral number of delta-Ts from this base time. More...
 
dsm_time_t _tlast
 Previous time tag. More...
 
dsm_time_t _ttnDt0
 
dsm_time_t _ttAdjLast
 
long long _maxGap
 
double _dtUsecCorrSum
 Sum for average of dt. More...
 
dsm_sample_id_t _id
 ID of samples that are adjusted, used in log messages. More...
 
unsigned int _dtUsec
 Expected delta-T in microseconds, 1/rate. More...
 
unsigned int _dtUsecCorr
 Corrected delta-T in microseconds. More...
 
unsigned int _nDt
 Current number of delta-Ts from tt0. More...
 
unsigned int _npts
 Minimum number of points to compute minimum time difference. More...
 
int _tdiffminUsec
 Minimum diffence between actual time tags and expected, over _npts. More...
 
int _dtUsecCorrMin
 Minimum averaged dt so far. More...
 
unsigned int _dtUsecCorrMax
 Maximum averaged dt so far. More...
 
unsigned int _nCorrSum
 
unsigned int _nBack
 
int _tadjMinUsec
 
unsigned int _tadjMaxUsec
 
unsigned int _ntotalPts
 
int _dtResultMin
 
int _dtResultMax
 
int _tdiffLast
 
unsigned int _nNegTdiff
 
unsigned int _nBigTdiff
 
int _nworsen
 
int _nimprove
 
unsigned int _nSamp5Min
 Number of samples in 5 minutes, used for running average. More...
 

Detailed Description

Adjust time tags of fixed delta-T time series to correct for irregular latency in the assignments of the time tags at acquisition time.

See nidas/doc/timetags.md for a discussion of the algorithm.

Constructor & Destructor Documentation

TimetagAdjuster::TimetagAdjuster ( dsm_sample_id_t  id,
double  rate 
)

Constructor.

Parameters
rateSample rate in Hz, sec^-1.

Member Function Documentation

dsm_time_t TimetagAdjuster::adjust ( dsm_time_t  tt)
float nidas::core::TimetagAdjuster::getAdjMax ( ) const
inline

Return the maximum adjustment to the measured time tags.

References _tadjMaxUsec, and USECS_PER_SEC.

Referenced by log().

float nidas::core::TimetagAdjuster::getAdjMin ( ) const
inline

Return the minimum adjustment to the measured time tags.

References _tadjMinUsec, and USECS_PER_SEC.

double nidas::core::TimetagAdjuster::getDtAvg ( ) const
inline

Return the current average input delta-T so far.

1.0 / getDtAvg() is the observed sample rate.

References _dtUsecCorrSum, _nCorrSum, and USECS_PER_SEC.

Referenced by log().

float nidas::core::TimetagAdjuster::getDtMax ( ) const
inline

Return the maximum calculated delta-T so far.

References _dtUsecCorrMax, and USECS_PER_SEC.

Referenced by log().

float nidas::core::TimetagAdjuster::getDtMin ( ) const
inline

Return the minimum calculated delta-T so far.

The observed delta-T of the input raw time tags is averaged to get a better estimate of the actual dt , because it will not typically be exactly the inverse of the configured rate.

References _dtUsecCorrMin, and USECS_PER_SEC.

Referenced by log().

float nidas::core::TimetagAdjuster::getMaxGap ( ) const
inline

Maximum data gap in the non-adjusted, raw, time tags, in seconds.

References _maxGap, and USECS_PER_SEC.

Referenced by log().

float nidas::core::TimetagAdjuster::getMaxResultDt ( ) const
inline

Return the maximum dt in the adjusted time tags.

This is the maximum difference between successive, adjusted time tags.

References _dtResultMax, and USECS_PER_SEC.

Referenced by log().

float nidas::core::TimetagAdjuster::getMinResultDt ( ) const
inline

Return the minimum dt in the adjusted time tags.

References _dtResultMin, and USECS_PER_SEC.

Referenced by log().

unsigned int nidas::core::TimetagAdjuster::getNumBackwards ( ) const
inline

How many backwards input time tags have been encountered, typically zero.

References _nBack.

unsigned int nidas::core::TimetagAdjuster::getNumPoints ( ) const
inline

Total number of time tags processed.

References _ntotalPts.

Referenced by log().

float nidas::core::TimetagAdjuster::getRate ( ) const
inline

Return the configured sample rate, as passed to constructor.

References _dtUsec, and USECS_PER_SEC.

Referenced by log().

void TimetagAdjuster::log ( int  level,
const DSMSensor sensor,
bool  octalLable = false 
)
void nidas::core::TimetagAdjuster::slog ( SampleTracer stracer,
const std::string &  msg,
dsm_time_t  tt,
long long  toff,
int  tdiff,
int  tdiffUncorr 
)

Log message for a traced sample.

Used for high-rate messages containing each time tag and tdiff.

Referenced by adjust().

void nidas::core::TimetagAdjuster::slog ( SampleTracer stracer,
const std::string &  msg,
dsm_time_t  tt 
)

Log message for a traced sample.

Used for lower-rate messages every _npts.

Member Data Documentation

int nidas::core::TimetagAdjuster::_dtResultMax
private

Referenced by adjust(), and getMaxResultDt().

int nidas::core::TimetagAdjuster::_dtResultMin
private

Referenced by adjust(), and getMinResultDt().

unsigned int nidas::core::TimetagAdjuster::_dtUsec
private

Expected delta-T in microseconds, 1/rate.

Referenced by adjust(), and getRate().

unsigned int nidas::core::TimetagAdjuster::_dtUsecCorr
private

Corrected delta-T in microseconds.

Referenced by adjust().

unsigned int nidas::core::TimetagAdjuster::_dtUsecCorrMax
private

Maximum averaged dt so far.

Referenced by adjust(), and getDtMax().

int nidas::core::TimetagAdjuster::_dtUsecCorrMin
private

Minimum averaged dt so far.

Referenced by adjust(), and getDtMin().

double nidas::core::TimetagAdjuster::_dtUsecCorrSum
private

Sum for average of dt.

Referenced by adjust(), and getDtAvg().

dsm_sample_id_t nidas::core::TimetagAdjuster::_id
private

ID of samples that are adjusted, used in log messages.

Referenced by adjust(), and log().

long long nidas::core::TimetagAdjuster::_maxGap
private

Referenced by adjust(), and getMaxGap().

unsigned int nidas::core::TimetagAdjuster::_nBack
private

Referenced by adjust(), and getNumBackwards().

unsigned int nidas::core::TimetagAdjuster::_nBigTdiff
private

Referenced by adjust(), and log().

unsigned int nidas::core::TimetagAdjuster::_nCorrSum
private

Referenced by adjust(), and getDtAvg().

unsigned int nidas::core::TimetagAdjuster::_nDt
private

Current number of delta-Ts from tt0.

Referenced by adjust().

int nidas::core::TimetagAdjuster::_nimprove
private

Referenced by adjust().

unsigned int nidas::core::TimetagAdjuster::_nNegTdiff
private

Referenced by adjust(), and log().

unsigned int nidas::core::TimetagAdjuster::_npts
private

Minimum number of points to compute minimum time difference.

Referenced by adjust().

unsigned int nidas::core::TimetagAdjuster::_nSamp5Min
private

Number of samples in 5 minutes, used for running average.

Referenced by adjust().

unsigned int nidas::core::TimetagAdjuster::_ntotalPts
private

Referenced by adjust(), and getNumPoints().

int nidas::core::TimetagAdjuster::_nworsen
private

Referenced by adjust().

unsigned int nidas::core::TimetagAdjuster::_tadjMaxUsec
private

Referenced by adjust(), and getAdjMax().

int nidas::core::TimetagAdjuster::_tadjMinUsec
private

Referenced by adjust(), and getAdjMin().

int nidas::core::TimetagAdjuster::_tdiffLast
private

Referenced by adjust().

int nidas::core::TimetagAdjuster::_tdiffminUsec
private

Minimum diffence between actual time tags and expected, over _npts.

Referenced by adjust().

dsm_time_t nidas::core::TimetagAdjuster::_tlast
private

Previous time tag.

Referenced by adjust().

dsm_time_t nidas::core::TimetagAdjuster::_tt0
private

Result time tags will have a integral number of delta-Ts from this base time.

This base time is slowly adjusted by computing the minimum difference between the result time tags and the input time tags.

Referenced by adjust().

dsm_time_t nidas::core::TimetagAdjuster::_ttAdjLast
private

Referenced by adjust().

dsm_time_t nidas::core::TimetagAdjuster::_ttnDt0
private

Referenced by adjust().

const int nidas::core::TimetagAdjuster::BIG_GAP_SECONDS = 10
static

Referenced by adjust().


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