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
47 namespace dynld {
namespace raf {
49 using namespace nidas::core;
206 selectVariablesFromProject(
Project* project,
207 std::list<const Variable*>& variables);
213 selectVariablesFromSensor(
DSMSensor* sensor,
214 std::list<const Variable*>& variables);
225 return _source.getSampleTags();
233 return _source.getSampleTagIterator();
241 _source.addSampleClient(client);
246 _source.removeSampleClient(client);
256 _source.addSampleClient(client);
261 _source.removeSampleClient(client);
266 return _source.getClientCount();
273 void flush() throw();
277 return _source.getSampleStats();
303 void sendSyncHeader() throw();
305 bool receive(const
Sample*) throw();
310 preLoadCalibrations(
dsm_time_t sampleTime) throw();
316 static const
int NSLOT_LIMIT = 2;
321 static
int nextRecordIndex(
int i);
328 static
int prevRecordIndex(
int i);
342 static const
int NSYNCREC = 2;
355 nidas::util::LogContext& lc,
int warn_times);
357 void slog(
SampleTracer& stracer, const std::
string& msg,
360 void log(nidas::util::LogContext& lc, const std::
string& msg,
363 void log(nidas::util::LogContext& lc, const std::
string& msg,
378 _source.removeSampleTag(tag);
381 void createHeader(std::ostream&) throw();
426 int _halfMaxUsecsPerSample;
432 size_t _unrecognizedSamples;
434 std::ostringstream _headerStream;
440 int _unknownSampleType;
442 unsigned int _badLaterSamples;
448 SyncRecordSource& operator=(const SyncRecordSource&);
458 #define EXPLICIT_SYNCINFO_COPY_ASSIGN
471 SyncInfo(dsm_sample_id_t i,
float r, SyncRecordSource* srs);
473 #ifdef EXPLICIT_SYNCINFO_COPY_ASSIGN
487 void addVariable(
const Variable* var);
489 void advanceRecord(
int last);
526 bool incrementSlot();
528 bool decrementSlot();
530 bool checkNonIntRateIncrement();
532 void computeSlotIndex(
const Sample* samp);
538 irec = _srs->nextRecordIndex(irec);
Interface for a resampler, simply a SampleClient and a SampleSource.
Definition: Resampler.h:39
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SyncRecordSource.h:218
void decrementRecord()
Definition: SyncRecordSource.h:541
unsigned int nLateSamp
How many successive samples have been later than their slot time by more than TDIFF_CHECK_USEC.
Definition: SyncRecordSource.h:655
std::list< const SampleTag * > getSampleTags() const
Get the output SampleTags.
Definition: SyncRecordSource.h:223
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition: SyncRecordSource.h:231
unsigned int dsm_sample_id_t
Definition: Sample.h:63
dsm_sample_id_t id
Definition: SyncRecordSource.h:491
unsigned int total
Definition: SyncRecordSource.h:586
unsigned int discarded
Definition: SyncRecordSource.h:576
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:61
Class describing a sampled variable.
Definition: Variable.h:46
Pure virtual interface for a source of Samples.
Definition: SampleSource.h:48
unsigned int outOfSlotMax
Once nEarlySamp or nLateSamp exceed this value, adjust the slot index.
Definition: SyncRecordSource.h:660
unsigned int nskips
Definition: SyncRecordSource.h:582
Parameters needed for each sample to assemble and write a sync record.
Definition: SyncRecordSource.h:464
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SyncRecordSource.h:264
void incrementRecord()
Definition: SyncRecordSource.h:536
A source of samples.
Definition: SampleSourceSupport.h:47
void addSampleClientForTag(SampleClient *client, const SampleTag *)
Add a Client for a given SampleTag.
Definition: SyncRecordSource.h:253
int minDiff
The minimum difference between the sample time tags and their corresponding slot times is computed ov...
Definition: SyncRecordSource.h:610
float rate
Sampling rate of the sample.
Definition: SyncRecordSource.h:496
int getRecordIndex() const
Definition: SyncRecordSource.h:534
Pure virtual interface of a client of Samples.
Definition: SampleClient.h:38
Definition: SyncRecordSource.h:55
int getSlotIndex() const
Definition: SyncRecordSource.h:524
std::vector< size_t > varLengths
Number of values for each variable in the sample.
Definition: SyncRecordSource.h:549
int irec
Index of current sync record for this sample.
Definition: SyncRecordSource.h:520
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
int dtUsec
Number of microseconds per sample, 1000000/rate, rounded to an integer.
Definition: SyncRecordSource.h:509
int skipModCount
Sample counter used for non-integral rates.
Definition: SyncRecordSource.h:637
std::vector< size_t > varSRIndex
Indices of the each variable in the sync record array of doubles.
Definition: SyncRecordSource.h:574
A typed Sample, with data of type DataT.
Definition: Sample.h:393
SyncRecordSource * _srs
Definition: SyncRecordSource.h:664
void removeSampleTag(const SampleTag *tag)
Definition: SyncRecordSource.h:376
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
static unsigned int ncopy
Definition: SyncRecordSource.h:478
Interface to a data sample.
Definition: Sample.h:189
bool overWritten
Definition: SyncRecordSource.h:578
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition: DSMSensor.h:87
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SyncRecordSource.h:216
int skipMod
skipMod provides a way to insert NaNs in sync records with non-integral rates.
Definition: SyncRecordSource.h:632
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition: NidsIterators.h:217
#define USECS_PER_MSEC
Definition: types.h:115
unsigned int noverWritten
Definition: SyncRecordSource.h:580
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
Aircraft is a sub-class of a measurement Site.
Definition: Aircraft.h:42
int islot
Index of next slot for the sample in the current sync record.
Definition: SyncRecordSource.h:515
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 removeSampleClientForTag(SampleClient *client, const SampleTag *)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition: SyncRecordSource.h:259
A source of samples.
Definition: SampleStats.h:41
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition: SyncRecordSource.h:239
SampleTracer uses a Logger to log messages about samples as they are encountered in the code...
Definition: SampleTracer.h:22
int minDiffInit
See the comment below about minDiff.
Definition: SyncRecordSource.h:602
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition: SyncRecordSource.h:244
std::list< const Variable * > variables
Variables in the sample.
Definition: SyncRecordSource.h:568
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition: SampleSourceSupport.cc:60
static unsigned int nassign
Definition: SyncRecordSource.h:484