nidas
v1.2-1520
|
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... | |
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.
TimetagAdjuster::TimetagAdjuster | ( | dsm_sample_id_t | id, |
double | rate | ||
) |
Constructor.
rate | Sample rate in Hz, sec^-1. |
dsm_time_t TimetagAdjuster::adjust | ( | dsm_time_t | tt | ) |
Adjust a time tag.
tt | NIDAS time tag to be adjusted. |
References _dtResultMax, _dtResultMin, _dtUsec, _dtUsecCorr, _dtUsecCorrMax, _dtUsecCorrMin, _dtUsecCorrSum, _id, _maxGap, _nBack, _nBigTdiff, _nCorrSum, _nDt, _nimprove, _nNegTdiff, _npts, _nSamp5Min, _ntotalPts, _nworsen, _tadjMaxUsec, _tadjMinUsec, _tdiffLast, _tdiffminUsec, _tlast, _tt0, _ttAdjLast, _ttnDt0, BIG_GAP_SECONDS, DLOG, GET_DSM_ID, GET_SPS_ID, LOG_VERBOSE, slog(), and USECS_PER_SEC.
Referenced by nidas::core::CharacterSensor::adjustTimeTag(), and nidas::dynld::raf::DSMArincSensor::process().
|
inline |
Return the maximum adjustment to the measured time tags.
References _tadjMaxUsec, and USECS_PER_SEC.
Referenced by log().
|
inline |
Return the minimum adjustment to the measured time tags.
References _tadjMinUsec, and USECS_PER_SEC.
|
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().
|
inline |
Return the maximum calculated delta-T so far.
References _dtUsecCorrMax, and USECS_PER_SEC.
Referenced by log().
|
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().
|
inline |
Maximum data gap in the non-adjusted, raw, time tags, in seconds.
References _maxGap, and USECS_PER_SEC.
Referenced by log().
|
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().
|
inline |
Return the minimum dt in the adjusted time tags.
References _dtResultMin, and USECS_PER_SEC.
Referenced by log().
|
inline |
How many backwards input time tags have been encountered, typically zero.
References _nBack.
|
inline |
|
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 |
||
) |
Log various statistics of the TimetagAdjuster, used by sensors classes on shutdown.
References _id, _nBigTdiff, _nNegTdiff, GET_DSM_ID, GET_SPS_ID, getAdjMax(), getDtAvg(), getDtMax(), getDtMin(), nidas::core::DSMSensor::getId(), nidas::util::Logger::getInstance(), getMaxGap(), getMaxResultDt(), getMinResultDt(), nidas::core::DSMSensor::getName(), getNumPoints(), getRate(), and nidas::util::Logger::log().
Referenced by nidas::core::CharacterSensor::~CharacterSensor(), and nidas::dynld::raf::DSMArincSensor::~DSMArincSensor().
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.
|
private |
Referenced by adjust(), and getMaxResultDt().
|
private |
Referenced by adjust(), and getMinResultDt().
|
private |
|
private |
Corrected delta-T in microseconds.
Referenced by adjust().
|
private |
Maximum averaged dt so far.
Referenced by adjust(), and getDtMax().
|
private |
Minimum averaged dt so far.
Referenced by adjust(), and getDtMin().
|
private |
Sum for average of dt.
Referenced by adjust(), and getDtAvg().
|
private |
|
private |
Referenced by adjust(), and getMaxGap().
|
private |
Referenced by adjust(), and getNumBackwards().
|
private |
Referenced by adjust(), and getDtAvg().
|
private |
Current number of delta-Ts from tt0.
Referenced by adjust().
|
private |
Referenced by adjust().
|
private |
Minimum number of points to compute minimum time difference.
Referenced by adjust().
|
private |
Number of samples in 5 minutes, used for running average.
Referenced by adjust().
|
private |
Referenced by adjust(), and getNumPoints().
|
private |
Referenced by adjust().
|
private |
Referenced by adjust(), and getAdjMax().
|
private |
Referenced by adjust(), and getAdjMin().
|
private |
Referenced by adjust().
|
private |
Minimum diffence between actual time tags and expected, over _npts.
Referenced by adjust().
|
private |
Previous time tag.
Referenced by adjust().
|
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().
|
private |
Referenced by adjust().
|
private |
Referenced by adjust().
|
static |
Referenced by adjust().