27#ifndef NIDAS_CORE_SYNCRECORDSOURCE_H
28#define NIDAS_CORE_SYNCRECORDSOURCE_H
33#define SYNC_RECORD_ID 3
34#define SYNC_RECORD_HEADER_ID 2
47namespace dynld {
namespace raf {
207 std::list<const Variable*>& variables);
214 std::list<const Variable*>& variables);
273 void flush() throw();
355 nidas::util::LogContext& lc,
int warn_times);
360 void log(
nidas::util::LogContext& lc, const std::
string& msg,
363 void log(
nidas::util::LogContext& lc, const std::
string& msg,
458#define EXPLICIT_SYNCINFO_COPY_ASSIGN
473#ifdef EXPLICIT_SYNCINFO_COPY_ASSIGN
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
Interface for a resampler, simply a SampleClient and a SampleSource.
Definition Resampler.h:39
Pure virtual interface of a client of Samples.
Definition SampleClient.h:38
A source of samples.
Definition SampleSourceSupport.h:47
void removeSampleClient(SampleClient *c)
Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been adde...
Definition SampleSourceSupport.cc:88
void addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:80
SampleTagIterator getSampleTagIterator() const
Definition SampleSourceSupport.cc:75
int getClientCount() const
How many SampleClients are currently in my list.
Definition SampleSourceSupport.cc:136
void removeSampleTag(const SampleTag *tag)
Definition SampleSourceSupport.cc:67
const SampleStats & getSampleStats() const
Definition SampleSourceSupport.h:149
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition SampleSourceSupport.cc:60
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition SampleSourceSupport.cc:54
Pure virtual interface for a source of Samples.
Definition SampleSource.h:48
A source of samples.
Definition SampleStats.h:41
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition NidsIterators.h:218
Class describing a group of variables that are sampled and handled together.
Definition SampleTag.h:88
SampleTracer uses a Logger to log messages about samples as they are encountered in the code.
Definition SampleTracer.h:23
Interface to a data sample.
Definition Sample.h:190
Class describing a sampled variable.
Definition Variable.h:47
Aircraft is a sub-class of a measurement Site.
Definition Aircraft.h:42
Parameters needed for each sample to assemble and write a sync record.
Definition SyncRecordSource.h:465
int dtUsec
Number of microseconds per sample, 1000000/rate, rounded to an integer.
Definition SyncRecordSource.h:509
std::list< const Variable * > variables
Variables in the sample.
Definition SyncRecordSource.h:568
unsigned int discarded
Definition SyncRecordSource.h:576
void decrementRecord()
Definition SyncRecordSource.h:541
bool overWritten
Definition SyncRecordSource.h:578
std::vector< size_t > varLengths
Number of values for each variable in the sample.
Definition SyncRecordSource.h:549
int minDiff
The minimum difference between the sample time tags and their corresponding slot times is computed ov...
Definition SyncRecordSource.h:610
dsm_sample_id_t id
Definition SyncRecordSource.h:491
bool incrementSlot()
Definition SyncRecordSource.cc:183
void incrementRecord()
Definition SyncRecordSource.h:536
int getSlotIndex() const
Definition SyncRecordSource.h:524
int skipMod
skipMod provides a way to insert NaNs in sync records with non-integral rates.
Definition SyncRecordSource.h:632
static unsigned int nassign
Definition SyncRecordSource.h:484
static unsigned int ncopy
Definition SyncRecordSource.h:478
int skipModCount
Sample counter used for non-integral rates.
Definition SyncRecordSource.h:637
static const int TDIFF_CHECK_USEC
If sample time tag differs from the slot time by this much or more then increment nEarlySamp or nLate...
Definition SyncRecordSource.h:643
size_t sampleLength
Number of data values in one second: nSlots times the sum of the varLengths for the variables in the ...
Definition SyncRecordSource.h:556
int nSlots
Smallest integer not less than rate, computed as ceil(rate).
Definition SyncRecordSource.h:503
unsigned int nEarlySamp
How many successive samples have been earlier than their slot time by more than TDIFF_CHECK_USEC.
Definition SyncRecordSource.h:649
void computeSlotIndex(const Sample *samp)
Definition SyncRecordSource.cc:227
SyncRecordSource * _srs
Definition SyncRecordSource.h:664
SyncInfo & operator=(const SyncInfo &)
Assignment.
Definition SyncRecordSource.cc:132
bool decrementSlot()
Definition SyncRecordSource.cc:215
SyncInfo(dsm_sample_id_t i, float r, SyncRecordSource *srs)
Constructor.
Definition SyncRecordSource.cc:73
bool checkNonIntRateIncrement()
Definition SyncRecordSource.cc:197
int islot
Index of next slot for the sample in the current sync record.
Definition SyncRecordSource.h:515
int getRecordIndex() const
Definition SyncRecordSource.h:534
std::vector< size_t > varSRIndex
Indices of the each variable in the sync record array of doubles.
Definition SyncRecordSource.h:574
unsigned int outOfSlotMax
Once nEarlySamp or nLateSamp exceed this value, adjust the slot index.
Definition SyncRecordSource.h:660
int irec
Index of current sync record for this sample.
Definition SyncRecordSource.h:520
unsigned int noverWritten
Definition SyncRecordSource.h:580
size_t sampleSRIndex
Index of this sample in the sync record array of doubles.
Definition SyncRecordSource.h:563
unsigned int skipped
Definition SyncRecordSource.h:584
void addVariable(const Variable *var)
Definition SyncRecordSource.cc:164
unsigned int total
Definition SyncRecordSource.h:586
float rate
Sampling rate of the sample.
Definition SyncRecordSource.h:496
void advanceRecord(int last)
Definition SyncRecordSource.cc:173
unsigned int nskips
Definition SyncRecordSource.h:582
int minDiffInit
See the comment below about minDiff.
Definition SyncRecordSource.h:602
unsigned int nLateSamp
How many successive samples have been later than their slot time by more than TDIFF_CHECK_USEC.
Definition SyncRecordSource.h:655
Definition SyncRecordSource.h:56
SampleSourceSupport _source
Definition SyncRecordSource.h:366
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition SyncRecordSource.h:244
std::map< dsm_sample_id_t, SyncInfo > _syncInfo
Info kept for each sample in order to assemble and write sync records.
Definition SyncRecordSource.h:404
void log(nidas::util::LogContext &lc, const std::string &msg, const Sample *samp, const SyncInfo &sinfo)
static const int NSLOT_LIMIT
Maximum number of delta-Ts allowed between a sample time tag and its slot in the sync record.
Definition SyncRecordSource.h:316
void slog(SampleTracer &stracer, const std::string &msg, const Sample *samp, const SyncInfo &sinfo)
Definition SyncRecordSource.cc:967
SampleT< double > * _syncRecord[2]
Definition SyncRecordSource.h:428
int advanceRecord(dsm_time_t timetag)
Definition SyncRecordSource.cc:682
unsigned int _badLaterSamples
Definition SyncRecordSource.h:442
void removeSampleClientForTag(SampleClient *client, const SampleTag *)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition SyncRecordSource.h:259
const Aircraft * _aircraft
Definition SyncRecordSource.h:436
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition SyncRecordSource.h:239
std::ostringstream _headerStream
Definition SyncRecordSource.h:434
bool checkTime(const Sample *samp, SyncInfo &sinfo, SampleTracer &stracer, nidas::util::LogContext &lc, int warn_times)
Definition SyncRecordSource.cc:813
bool prevRecord(SyncInfo &sinfo)
If the previous sync record is non-null, do sinfo.decrementRecord().
Definition SyncRecordSource.cc:757
void allocateRecord(int irec, dsm_time_t timetag)
Definition SyncRecordSource.cc:656
void addSampleClientForTag(SampleClient *client, const SampleTag *)
Add a Client for a given SampleTag.
Definition SyncRecordSource.h:253
void createHeader(std::ostream &)
Definition SyncRecordSource.cc:469
dsm_time_t _syncTime[2]
Definition SyncRecordSource.h:419
bool nextRecord(SyncInfo &sinfo)
If the next sync record is non-null, do sinfo.incrementRecord().
Definition SyncRecordSource.cc:769
bool _initialized
Definition SyncRecordSource.h:438
void disconnect(SampleSource *source)
Definition SyncRecordSource.cc:454
int computeSlotIndex(const Sample *samp, SyncInfo &sinfo)
Which time slot should a sample be placed.
Definition SyncRecordSource.cc:793
int _unknownSampleType
Definition SyncRecordSource.h:440
SyncRecordSource()
SyncRecordSource builds "sync records" from a sample stream.
Definition SyncRecordSource.cc:233
void removeSampleTag(const SampleTag *tag)
Definition SyncRecordSource.h:376
int getClientCount() const
How many SampleClients are currently in my list.
Definition SyncRecordSource.h:264
static void selectVariablesFromProject(Project *project, std::list< const Variable * > &variables)
This method and selectVariablesFromSensor() are used to select the list of variables from a Project c...
Definition SyncRecordSource.cc:347
size_t _recSize
Definition SyncRecordSource.h:415
static const int NSYNCREC
Definition SyncRecordSource.h:342
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition SyncRecordSource.h:216
void init()
Create the SyncInfo objects for all samples and their variables that will go in the sync record.
Definition SyncRecordSource.cc:368
const SampleStats & getSampleStats() const
Definition SyncRecordSource.h:275
int _current
Index of current sync record.
Definition SyncRecordSource.h:424
void flush()
Implementation of Resampler::flush().
Definition SyncRecordSource.cc:628
static int nextRecordIndex(int i)
Return the index of the next sync record.
Definition SyncRecordSource.cc:746
static void selectVariablesFromSensor(DSMSensor *sensor, std::list< const Variable * > &variables)
See selectVariablesFromProject().
Definition SyncRecordSource.cc:297
SampleTag _syncRecordHeaderSampleTag
Definition SyncRecordSource.h:411
dsm_time_t _syncHeaderTime
Definition SyncRecordSource.h:417
void sendSyncRecord()
Definition SyncRecordSource.cc:638
size_t _unrecognizedSamples
Definition SyncRecordSource.h:432
std::list< const Variable * > _variables
List of all variables in the sync record.
Definition SyncRecordSource.h:409
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition SyncRecordSource.h:218
double * _dataPtr[2]
Definition SyncRecordSource.h:430
std::list< const SampleTag * > getSampleTags() const
Get the output SampleTags.
Definition SyncRecordSource.h:223
SampleTag _syncRecordDataSampleTag
Definition SyncRecordSource.h:413
void preLoadCalibrations(dsm_time_t sampleTime)
Definition SyncRecordSource.cc:565
bool receive(const Sample *)
Method called to pass a sample to this client.
Definition SyncRecordSource.cc:1040
void sendSyncHeader()
Generate and send a sync record header sample.
Definition SyncRecordSource.cc:602
void connect(SampleSource *source)
Connect the resampler to a source.
Definition SyncRecordSource.cc:434
virtual ~SyncRecordSource()
Definition SyncRecordSource.cc:258
SyncRecordSource & operator=(const SyncRecordSource &)
No assignment.
SyncRecordSource(const SyncRecordSource &)
No copying.
static int prevRecordIndex(int i)
Return the index of the previous sync record.
Definition SyncRecordSource.cc:752
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition SyncRecordSource.h:371
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition SyncRecordSource.h:231
int _halfMaxUsecsPerSample
Definition SyncRecordSource.h:426
The essential core classes of nidas.
Definition A2DConverter.h:31
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
#define USECS_PER_MSEC
Definition types.h:115