nidas
v1.2-1520
|
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. More... | |
SyncInfo (const SyncInfo &) | |
Copy constructor. More... | |
SyncInfo & | operator= (const SyncInfo &) |
Assignment. More... | |
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. More... | |
int | nSlots |
Smallest integer not less than rate, computed as ceil(rate). More... | |
int | dtUsec |
Number of microseconds per sample, 1000000/rate, rounded to an integer. More... | |
std::vector< size_t > | varLengths |
Number of values for each variable in the sample. More... | |
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. More... | |
size_t | sampleSRIndex |
Index of this sample in the sync record array of doubles. More... | |
std::list< const Variable * > | variables |
Variables in the sample. More... | |
std::vector< size_t > | varSRIndex |
Indices of the each variable in the sync record array of doubles. More... | |
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. More... | |
int | minDiff |
The minimum difference between the sample time tags and their corresponding slot times is computed over the second. More... | |
int | skipMod |
skipMod provides a way to insert NaNs in sync records with non-integral rates. More... | |
int | skipModCount |
Sample counter used for non-integral rates. More... | |
unsigned int | nEarlySamp |
How many successive samples have been earlier than their slot time by more than TDIFF_CHECK_USEC. More... | |
unsigned int | nLateSamp |
How many successive samples have been later than their slot time by more than TDIFF_CHECK_USEC. More... | |
unsigned int | outOfSlotMax |
Once nEarlySamp or nLateSamp exceed this value, adjust the slot index. More... | |
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. More... | |
Private Attributes | |
int | islot |
Index of next slot for the sample in the current sync record. More... | |
int | irec |
Index of current sync record for this sample. More... | |
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.
void SyncInfo::addVariable | ( | const Variable * | var | ) |
References nidas::core::Variable::getLength(), nSlots, sampleLength, variables, varLengths, and varSRIndex.
Referenced by nidas::dynld::raf::SyncRecordSource::init().
void SyncInfo::advanceRecord | ( | int | last | ) |
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().
void SyncInfo::computeSlotIndex | ( | const Sample * | samp | ) |
References _srs, nidas::dynld::raf::SyncRecordSource::computeSlotIndex(), islot, nEarlySamp, and nLateSamp.
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime(), and nidas::dynld::raf::SyncRecordSource::receive().
|
inline |
Referenced by nidas::dynld::raf::SyncRecordSource::prevRecord().
bool SyncInfo::decrementSlot | ( | ) |
References _srs, islot, nLateSamp, nSlots, nidas::dynld::raf::SyncRecordSource::prevRecord(), and skipModCount.
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime().
|
inline |
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime(), nidas::dynld::raf::SyncRecordSource::computeSlotIndex(), nidas::dynld::raf::SyncRecordSource::nextRecord(), nidas::dynld::raf::SyncRecordSource::prevRecord(), nidas::dynld::raf::SyncRecordSource::receive(), and nidas::dynld::raf::SyncRecordSource::slog().
|
inline |
|
inline |
Referenced by nidas::dynld::raf::SyncRecordSource::nextRecord().
bool SyncInfo::incrementSlot | ( | ) |
Assignment.
References _srs, discarded, dtUsec, 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(), incrementSlot(), and operator=().
unsigned int nidas::dynld::raf::SyncInfo::discarded |
int nidas::dynld::raf::SyncInfo::dtUsec |
Number of microseconds per sample, 1000000/rate, rounded to an integer.
Referenced by checkNonIntRateIncrement(), nidas::dynld::raf::SyncRecordSource::checkTime(), nidas::dynld::raf::SyncRecordSource::computeSlotIndex(), 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(), and operator=().
|
private |
Index of next slot for the sample in the current sync record.
Referenced by advanceRecord(), checkNonIntRateIncrement(), computeSlotIndex(), decrementSlot(), 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(), nidas::dynld::raf::SyncRecordSource::checkTime(), operator=(), nidas::dynld::raf::SyncRecordSource::receive(), and nidas::dynld::raf::SyncRecordSource::slog().
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 nidas::dynld::raf::SyncRecordSource::checkTime(), and operator=().
|
static |
Referenced by operator=().
|
static |
Referenced by SyncInfo().
unsigned int nidas::dynld::raf::SyncInfo::nEarlySamp |
How many successive samples have been earlier than their slot time by more than TDIFF_CHECK_USEC.
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime(), computeSlotIndex(), and operator=().
unsigned int nidas::dynld::raf::SyncInfo::nLateSamp |
How many successive samples have been later than their slot time by more than TDIFF_CHECK_USEC.
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime(), computeSlotIndex(), decrementSlot(), and operator=().
unsigned int nidas::dynld::raf::SyncInfo::noverWritten |
unsigned int nidas::dynld::raf::SyncInfo::nskips |
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime(), and 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(), nidas::dynld::raf::SyncRecordSource::checkTime(), decrementSlot(), incrementSlot(), operator=(), nidas::dynld::raf::SyncRecordSource::receive(), and nidas::dynld::raf::SyncRecordSource::slog().
unsigned int nidas::dynld::raf::SyncInfo::outOfSlotMax |
Once nEarlySamp or nLateSamp exceed this value, adjust the slot index.
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime(), and operator=().
bool nidas::dynld::raf::SyncInfo::overWritten |
float nidas::dynld::raf::SyncInfo::rate |
Sampling rate of the sample.
Referenced by checkNonIntRateIncrement(), nidas::dynld::raf::SyncRecordSource::createHeader(), operator=(), nidas::dynld::raf::SyncRecordSource::slog(), and nidas::dynld::raf::SyncRecordSource::~SyncRecordSource().
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(), nidas::dynld::raf::SyncRecordSource::init(), 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(), operator=(), and nidas::dynld::raf::SyncRecordSource::receive().
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(), operator=(), and nidas::dynld::raf::SyncRecordSource::slog().
int nidas::dynld::raf::SyncInfo::skipModCount |
Sample counter used for non-integral rates.
Referenced by checkNonIntRateIncrement(), decrementSlot(), incrementSlot(), operator=(), and nidas::dynld::raf::SyncRecordSource::slog().
unsigned int nidas::dynld::raf::SyncInfo::skipped |
|
static |
If sample time tag differs from the slot time by this much or more then increment nEarlySamp or nLateSamp.
Referenced by nidas::dynld::raf::SyncRecordSource::checkTime().
unsigned int nidas::dynld::raf::SyncInfo::total |
std::list<const Variable*> nidas::dynld::raf::SyncInfo::variables |
Variables in the sample.
Referenced by addVariable(), nidas::dynld::raf::SyncRecordSource::createHeader(), nidas::dynld::raf::SyncRecordSource::init(), and operator=().
std::vector<size_t> nidas::dynld::raf::SyncInfo::varLengths |
Number of values for each variable in the sample.
Referenced by addVariable(), operator=(), and nidas::dynld::raf::SyncRecordSource::receive().
std::vector<size_t> nidas::dynld::raf::SyncInfo::varSRIndex |
Indices of the each variable in the sync record array of doubles.
Referenced by addVariable(), nidas::dynld::raf::SyncRecordSource::init(), operator=(), and nidas::dynld::raf::SyncRecordSource::receive().