nidas v1.2.3
TimetagAdjuster.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2005, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26
27#ifndef NIDAS_CORE_TIMETADJUSTER_H
28#define NIDAS_CORE_TIMETADJUSTER_H
29
30#include "SampleTag.h"
31#include "DSMSensor.h"
32
33namespace nidas { namespace core {
34
35class SampleTracer;
36
46public:
47
53
60
65 void log(int level, const DSMSensor* sensor, bool octalLable=false);
66
71 void slog(SampleTracer& stracer, const std::string& msg, dsm_time_t tt,
72 long long toff, int tdiff, int tdiffUncorr);
73
78 void slog(SampleTracer& stracer, const std::string& msg, dsm_time_t tt);
79
83 float getRate() const { return USECS_PER_SEC / (float) _dtUsec; }
84
89 float getMaxResultDt() const { return (float)_dtResultMax / USECS_PER_SEC; }
90
94 float getMinResultDt() const { return (float)_dtResultMin / USECS_PER_SEC; }
95
100 double getDtAvg() const { return _dtUsecCorrSum / _nCorrSum / USECS_PER_SEC; }
101
108 float getDtMin() const { return (float)_dtUsecCorrMin / USECS_PER_SEC; }
109
113 float getDtMax() const { return (float)_dtUsecCorrMax / USECS_PER_SEC; }
114
118 float getAdjMax() const { return (float)_tadjMaxUsec / USECS_PER_SEC; }
119
123 float getAdjMin() const { return (float)_tadjMinUsec / USECS_PER_SEC; }
124
128 float getMaxGap() const { return (float) _maxGap / USECS_PER_SEC; }
129
133 unsigned int getNumPoints() const { return _ntotalPts; }
134
138 unsigned int getNumBackwards() const { return _nBack; }
139
140 static const int BIG_GAP_SECONDS = 10;
141
142private:
143
151
156
161
163
164 long long _maxGap;
165
170
175
179 unsigned int _dtUsec;
180
184 unsigned int _dtUsecCorr;
185
189 unsigned int _nDt;
190
194 unsigned int _npts;
195
200
205
209 unsigned int _dtUsecCorrMax;
210
211 unsigned int _nCorrSum;
212
213 unsigned int _nBack;
214
216 unsigned int _tadjMaxUsec;
217
218 unsigned int _ntotalPts;
219
220
223
225
226 unsigned int _nNegTdiff;
227
228 unsigned int _nBigTdiff;
229
232
236 unsigned int _nSamp5Min;
237};
238
239}} // namespace nidas namespace core
240
241#endif
242
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
SampleTracer uses a Logger to log messages about samples as they are encountered in the code.
Definition SampleTracer.h:23
Adjust time tags of fixed delta-T time series to correct for irregular latency in the assignments of ...
Definition TimetagAdjuster.h:45
unsigned int _nBigTdiff
Definition TimetagAdjuster.h:228
unsigned int _nDt
Current number of delta-Ts from tt0.
Definition TimetagAdjuster.h:189
dsm_time_t adjust(dsm_time_t tt)
Adjust a time tag.
Definition TimetagAdjuster.cc:74
int _dtResultMax
Definition TimetagAdjuster.h:222
static const int BIG_GAP_SECONDS
Definition TimetagAdjuster.h:140
unsigned int _nBack
Definition TimetagAdjuster.h:213
unsigned int _npts
Minimum number of points to compute minimum time difference.
Definition TimetagAdjuster.h:194
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.
int _nworsen
Definition TimetagAdjuster.h:230
unsigned int _dtUsecCorr
Corrected delta-T in microseconds.
Definition TimetagAdjuster.h:184
int _tdiffminUsec
Minimum diffence between actual time tags and expected, over _npts.
Definition TimetagAdjuster.h:199
double _dtUsecCorrSum
Sum for average of dt.
Definition TimetagAdjuster.h:169
void slog(SampleTracer &stracer, const std::string &msg, dsm_time_t tt)
Log message for a traced sample.
dsm_time_t _ttnDt0
Definition TimetagAdjuster.h:160
int _dtResultMin
Definition TimetagAdjuster.h:221
void log(int level, const DSMSensor *sensor, bool octalLable=false)
Log various statistics of the TimetagAdjuster, used by sensors classes on shutdown.
Definition TimetagAdjuster.cc:275
dsm_time_t _ttAdjLast
Definition TimetagAdjuster.h:162
unsigned int getNumPoints() const
Total number of time tags processed.
Definition TimetagAdjuster.h:133
int _nimprove
Definition TimetagAdjuster.h:231
float getMaxResultDt() const
Return the maximum dt in the adjusted time tags.
Definition TimetagAdjuster.h:89
int _tdiffLast
Definition TimetagAdjuster.h:224
TimetagAdjuster(dsm_sample_id_t id, double rate)
Constructor.
Definition TimetagAdjuster.cc:38
float getAdjMax() const
Return the maximum adjustment to the measured time tags.
Definition TimetagAdjuster.h:118
float getRate() const
Return the configured sample rate, as passed to constructor.
Definition TimetagAdjuster.h:83
float getMinResultDt() const
Return the minimum dt in the adjusted time tags.
Definition TimetagAdjuster.h:94
long long _maxGap
Definition TimetagAdjuster.h:164
int _dtUsecCorrMin
Minimum averaged dt so far.
Definition TimetagAdjuster.h:204
unsigned int _nCorrSum
Definition TimetagAdjuster.h:211
unsigned int _ntotalPts
Definition TimetagAdjuster.h:218
double getDtAvg() const
Return the current average input delta-T so far.
Definition TimetagAdjuster.h:100
unsigned int _tadjMaxUsec
Definition TimetagAdjuster.h:216
float getDtMin() const
Return the minimum calculated delta-T so far.
Definition TimetagAdjuster.h:108
unsigned int _dtUsec
Expected delta-T in microseconds, 1/rate.
Definition TimetagAdjuster.h:179
float getAdjMin() const
Return the minimum adjustment to the measured time tags.
Definition TimetagAdjuster.h:123
unsigned int _nNegTdiff
Definition TimetagAdjuster.h:226
dsm_sample_id_t _id
ID of samples that are adjusted, used in log messages.
Definition TimetagAdjuster.h:174
float getDtMax() const
Return the maximum calculated delta-T so far.
Definition TimetagAdjuster.h:113
unsigned int getNumBackwards() const
How many backwards input time tags have been encountered, typically zero.
Definition TimetagAdjuster.h:138
dsm_time_t _tlast
Previous time tag.
Definition TimetagAdjuster.h:155
unsigned int _nSamp5Min
Number of samples in 5 minutes, used for running average.
Definition TimetagAdjuster.h:236
dsm_time_t _tt0
Result time tags will have a integral number of delta-Ts from this base time.
Definition TimetagAdjuster.h:150
float getMaxGap() const
Maximum data gap in the non-adjusted, raw, time tags, in seconds.
Definition TimetagAdjuster.h:128
unsigned int _dtUsecCorrMax
Maximum averaged dt so far.
Definition TimetagAdjuster.h:209
int _tadjMinUsec
Definition TimetagAdjuster.h:215
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
long long dsm_time_t
Posix time in microseconds, the number of non-leap microseconds since 1970 Jan 1 00:00 UTC.
Definition Sample.h:62
unsigned int dsm_sample_id_t
Definition Sample.h:64
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
static float rate
Definition sing.cc:53
#define USECS_PER_SEC
Definition ublox.cc:59