nidas v1.2.3
|
Parameters needed for each sample to assemble and write a sync record. More...
#include <SyncRecordSource.h>
Public Member Functions | |
SyncInfo (dsm_sample_id_t i, float r, SyncRecordSource *srs) | |
Constructor. | |
SyncInfo (const SyncInfo &) | |
Copy constructor. | |
SyncInfo & | operator= (const SyncInfo &) |
Assignment. | |
void | addVariable (const Variable *var) |
void | advanceRecord (int last) |
int | getSlotIndex () const |
bool | incrementSlot () |
bool | decrementSlot () |
bool | checkNonIntRateIncrement () |
void | computeSlotIndex (const Sample *samp) |
int | getRecordIndex () const |
void | incrementRecord () |
void | decrementRecord () |
Public Attributes | |
dsm_sample_id_t | id |
float | rate |
Sampling rate of the sample. | |
int | nSlots |
Smallest integer not less than rate, computed as ceil(rate). | |
int | dtUsec |
Number of microseconds per sample, 1000000/rate, rounded to an integer. | |
std::vector< size_t > | varLengths |
Number of values for each variable in the sample. | |
size_t | sampleLength |
Number of data values in one second: nSlots times the sum of the varLengths for the variables in the sample plus one for the time offset. | |
size_t | sampleSRIndex |
Index of this sample in the sync record array of doubles. | |
std::list< const Variable * > | variables |
Variables in the sample. | |
std::vector< size_t > | varSRIndex |
Indices of the each variable in the sync record array of doubles. | |
unsigned int | discarded |
bool | overWritten |
unsigned int | noverWritten |
unsigned int | nskips |
unsigned int | skipped |
unsigned int | total |
int | minDiffInit |
See the comment below about minDiff. | |
int | minDiff |
The minimum difference between the sample time tags and their corresponding slot times is computed over the second. | |
int | skipMod |
skipMod provides a way to insert NaNs in sync records with non-integral rates. | |
int | skipModCount |
Sample counter used for non-integral rates. | |
unsigned int | nEarlySamp |
How many successive samples have been earlier than their slot time by more than TDIFF_CHECK_USEC. | |
unsigned int | nLateSamp |
How many successive samples have been later than their slot time by more than TDIFF_CHECK_USEC. | |
unsigned int | outOfSlotMax |
Once nEarlySamp or nLateSamp exceed this value, adjust the slot index. | |
Static Public Attributes | |
static unsigned int | ncopy |
static unsigned int | nassign |
static const int | TDIFF_CHECK_USEC = 2 * USECS_PER_MSEC |
If sample time tag differs from the slot time by this much or more then increment nEarlySamp or nLateSamp. | |
Private Attributes | |
int | islot |
Index of next slot for the sample in the current sync record. | |
int | irec |
Index of current sync record for this sample. | |
SyncRecordSource * | _srs |
Parameters needed for each sample to assemble and write a sync record.
SyncInfo::SyncInfo | ( | dsm_sample_id_t | i, |
float | r, | ||
SyncRecordSource * | srs ) |
Constructor.
Note there is not a default, no-arg constuctor.
Copy constructor.
References nidas::core::getSample(), and ncopy.
References nSlots, sampleLength, variables, varLengths, and varSRIndex.
Referenced by nidas::dynld::raf::SyncRecordSource::init().
References irec, islot, and nidas::dynld::raf::SyncRecordSource::nextRecordIndex().
bool SyncInfo::checkNonIntRateIncrement | ( | ) |
References dtUsec, incrementSlot(), islot, minDiff, nSlots, rate, skipMod, skipModCount, and USECS_PER_SEC.
Referenced by incrementSlot().
References _srs, nidas::dynld::raf::SyncRecordSource::computeSlotIndex(), islot, nEarlySamp, and nLateSamp.
|
inline |
References incrementRecord().
bool SyncInfo::decrementSlot | ( | ) |
References _srs, islot, nLateSamp, nSlots, nidas::dynld::raf::SyncRecordSource::prevRecord(), and skipModCount.
|
inline |
References _srs, irec, and nidas::dynld::raf::SyncRecordSource::nextRecordIndex().
Referenced by decrementRecord().
bool SyncInfo::incrementSlot | ( | ) |
References _srs, checkNonIntRateIncrement(), islot, nidas::dynld::raf::SyncRecordSource::nextRecord(), nSlots, and skipModCount.
Referenced by checkNonIntRateIncrement().
Assignment.
References _srs, discarded, dtUsec, nidas::core::getSample(), id, irec, islot, minDiff, minDiffInit, nassign, nEarlySamp, nLateSamp, noverWritten, nskips, nSlots, outOfSlotMax, overWritten, rate, sampleLength, sampleSRIndex, skipMod, skipModCount, skipped, total, variables, varLengths, and varSRIndex.
|
private |
Referenced by computeSlotIndex(), decrementSlot(), incrementRecord(), incrementSlot(), and operator=().
Referenced by operator=().
int nidas::dynld::raf::SyncInfo::dtUsec |
Number of microseconds per sample, 1000000/rate, rounded to an integer.
Referenced by checkNonIntRateIncrement(), and operator=().
dsm_sample_id_t nidas::dynld::raf::SyncInfo::id |
Referenced by operator=().
|
private |
Index of current sync record for this sample.
Referenced by advanceRecord(), getRecordIndex(), incrementRecord(), and operator=().
|
private |
Index of next slot for the sample in the current sync record.
Referenced by advanceRecord(), checkNonIntRateIncrement(), computeSlotIndex(), decrementSlot(), getSlotIndex(), incrementSlot(), and operator=().
int nidas::dynld::raf::SyncInfo::minDiff |
The minimum difference between the sample time tags and their corresponding slot times is computed over the second.
This value is written into the sync record as the time offset for the samples within that second.
Referenced by checkNonIntRateIncrement(), and operator=().
int nidas::dynld::raf::SyncInfo::minDiffInit |
See the comment below about minDiff.
The minimum difference will never be more than minDiffInit. For integral sample rates it is simply minDiffInit = dtUsec For non-integral rates it can be either minDiffInit = dtUsec or minDiffInit = (nSlots * dtUsec) % USECS_PER_SEC The first value results in output sample tags that are closer to the original samples with cleaner delta-Ts between non-nan values, but last slot time in a sync record may be in the next second. We now believe this isn't an issue with nimbus, so we'll go with minDiffInit = dtUsec.
Referenced by operator=().
Referenced by operator=().
Referenced by SyncInfo().
How many successive samples have been earlier than their slot time by more than TDIFF_CHECK_USEC.
Referenced by computeSlotIndex(), and operator=().
How many successive samples have been later than their slot time by more than TDIFF_CHECK_USEC.
Referenced by computeSlotIndex(), decrementSlot(), and operator=().
Referenced by operator=().
Referenced by operator=().
int nidas::dynld::raf::SyncInfo::nSlots |
Smallest integer not less than rate, computed as ceil(rate).
The number of slots for the sample in the sync record. For example, 13 for a sample rate of 12.5.
Referenced by addVariable(), checkNonIntRateIncrement(), decrementSlot(), incrementSlot(), and operator=().
Once nEarlySamp or nLateSamp exceed this value, adjust the slot index.
Referenced by operator=().
bool nidas::dynld::raf::SyncInfo::overWritten |
Referenced by operator=().
float nidas::dynld::raf::SyncInfo::rate |
Sampling rate of the sample.
Referenced by checkNonIntRateIncrement(), and operator=().
size_t nidas::dynld::raf::SyncInfo::sampleLength |
Number of data values in one second: nSlots times the sum of the varLengths for the variables in the sample plus one for the time offset.
Referenced by addVariable(), and operator=().
size_t nidas::dynld::raf::SyncInfo::sampleSRIndex |
Index of this sample in the sync record array of doubles.
The first value for the sample is the time offset within the second, followed by the data values for each variable.
Referenced by nidas::dynld::raf::SyncRecordSource::init(), and operator=().
int nidas::dynld::raf::SyncInfo::skipMod |
skipMod provides a way to insert NaNs in sync records with non-integral rates.
In incrementCount(), if the next slot to be written is the last in the record and the modulus (sampCount % skipMod) is non-zero, then the last slot in the record is skipped, leaving a NaN.
skipMod is initialized to (int)(1.0 / (1 - (nSlots-rate))) Here are the values for some expected rates, including non-integral ARINC rates.
rate skipMod (skipModCount % skipMod) ! = 0 integral 1 never true, no skips 12.5 2 skip slot every other second 6.25 4 skip slot in 3 out of 4 seconds 3.125 8 skip slot in 7 out of 8 1.5625 1 never true (algorithm breaks down)
Referenced by checkNonIntRateIncrement(), and operator=().
int nidas::dynld::raf::SyncInfo::skipModCount |
Sample counter used for non-integral rates.
Referenced by checkNonIntRateIncrement(), decrementSlot(), incrementSlot(), and operator=().
Referenced by operator=().
|
static |
If sample time tag differs from the slot time by this much or more then increment nEarlySamp or nLateSamp.
Referenced by operator=(), and nidas::dynld::raf::SyncRecordSource::receive().
Variables in the sample.
Referenced by addVariable(), and operator=().
std::vector<size_t> nidas::dynld::raf::SyncInfo::varLengths |
Number of values for each variable in the sample.
Referenced by addVariable(), and operator=().
std::vector<size_t> nidas::dynld::raf::SyncInfo::varSRIndex |
Indices of the each variable in the sync record array of doubles.
Referenced by addVariable(), and operator=().