nidas
v1.2-1520
|
SyncRecordReader handles sync samples and provides an interface to access Variables and read sync record data. More...
#include <SyncRecordReader.h>
Public Member Functions | |
SyncRecordReader (IOChannel *iochan) | |
Constructor of a SyncRecordReader to a connected IOChannel. More... | |
SyncRecordReader (SyncServer *ss) | |
Constructor for a SyncRecordReader connected directly as a SampleClient of a SyncServer instance. More... | |
virtual | ~SyncRecordReader () |
const std::string & | getProjectName () const |
const std::string & | getTailNumber () const |
const std::string & | getFlightName () const |
const std::string & | getSoftwareVersion () const |
time_t | getStartTime () const |
Get UNIX time of the start time of data in the SyncRecords. More... | |
const std::list< const SyncRecordVariable * > | getVariables () throw (nidas::util::Exception) |
Get the list of variables in a sync record. More... | |
const SyncRecordVariable * | getVariable (const std::string &name) const |
Get a pointer to a SyncRecordVariable, searching by name. More... | |
size_t | getNumValues () const |
Get number of data values in a sync record. More... | |
size_t | read (dsm_time_t *tt, double *ptr, size_t len) throw (nidas::util::IOException) |
Read a sync record. More... | |
const std::string & | textHeader () |
virtual bool | receive (const Sample *s) throw () |
Method called to pass a sample to this client. More... | |
virtual void | flush () throw () |
Ask that this SampleClient send out any buffered Samples that it may be holding. More... | |
void | endOfStream () |
Signal the end of the sample stream, meaning EOF is reached once the queue is empty. More... | |
int | throw (SyncRecHeaderException) |
int | throw (SyncRecHeaderException) |
const std::string & | getConfigName () |
After creating a SyncRecordReader on a socket, this method returns the config name from the SampleInputStream header. More... | |
Private Member Functions | |
void | init () |
void | scanHeader (const Sample *samp) |
const Sample * | nextSample () |
std::string | getQuotedString (std::istringstream &str) |
void | readKeyedQuotedValues (std::istringstream &header) throw (SyncRecHeaderException) |
SyncRecordReader (const SyncRecordReader &) | |
No copying. More... | |
SyncRecordReader & | operator= (const SyncRecordReader &) |
No assignment. More... | |
Private Attributes | |
SampleInputStream * | inputStream |
SyncServer * | syncServer |
bool | _read_sync_server |
When true, explicitly read from the SyncServer, if given. More... | |
SyncRecHeaderException * | headException |
std::list< SampleTag * > | sampleTags |
std::list< const SyncRecordVariable * > | variables |
std::map< std::string, const SyncRecordVariable * > | variableMap |
size_t | numDataValues |
std::string | projectName |
std::string | aircraftName |
std::string | flightName |
std::string | softwareVersion |
time_t | startTime |
bool | _debug |
std::string | _header |
nidas::util::Cond | _qcond |
bool | _eoq |
std::deque< const Sample * > | _syncRecords |
Place to stash sample records received as a SampleClient. More... | |
std::string | _sampleStreamConfigName |
SyncRecordReader handles sync samples and provides an interface to access Variables and read sync record data.
It gets the Variables and other information from the sync header, and then data in the special sync record layout are copied directly from sync samples.
The sync samples can be received in one of two ways. It can read from an IOChannel on which it blocks waiting for new sync samples, or it can read samples through a SyncServer instance until a new sync sample is distributed to this reader. For now these methods correspond to real-time or post-processing. In real-time a DSM server generates the sync records and provides a sample output to which an IOChannel connect. In post-processing, a SyncServer is setup with input files and the output of it's processing chain is connected to this reader. In the latter case the SyncRecordReader behaves like an instance of a SampleClient.
SyncRecordReader::SyncRecordReader | ( | IOChannel * | iochan | ) |
Constructor of a SyncRecordReader to a connected IOChannel.
SyncRecordReader will own the IOChannel pointer and will delete it when done.
References init().
SyncRecordReader::SyncRecordReader | ( | SyncServer * | ss | ) |
Constructor for a SyncRecordReader connected directly as a SampleClient of a SyncServer instance.
References nidas::dynld::raf::SyncServer::addSampleClient(), nidas::dynld::raf::SyncServer::init(), init(), nidas::dynld::raf::SyncServer::setStopSignal(), and syncServer.
|
virtual |
|
private |
No copying.
void SyncRecordReader::endOfStream | ( | ) |
Signal the end of the sample stream, meaning EOF is reached once the queue is empty.
References _eoq, _qcond, DLOG, nidas::util::Cond::lock(), nidas::util::Cond::signal(), and nidas::util::Cond::unlock().
|
virtual |
Ask that this SampleClient send out any buffered Samples that it may be holding.
Implements nidas::core::SampleClient.
|
inline |
After creating a SyncRecordReader on a socket, this method returns the config name from the SampleInputStream header.
References _sampleStreamConfigName.
|
inline |
References flightName.
Referenced by SyncDumper::run().
|
inline |
Get number of data values in a sync record.
This includes data and dynamic lag values.
References numDataValues.
Referenced by SyncDumper::run().
|
inline |
References projectName.
Referenced by SyncDumper::run().
|
private |
Referenced by scanHeader().
|
inline |
References softwareVersion.
Referenced by SyncDumper::run().
|
inline |
Get UNIX time of the start time of data in the SyncRecords.
References startTime.
|
inline |
References aircraftName.
Referenced by SyncDumper::run().
const SyncRecordVariable * SyncRecordReader::getVariable | ( | const std::string & | name | ) | const |
Get a pointer to a SyncRecordVariable, searching by name.
Returns NULL if not found.
References variableMap.
const list< const SyncRecordVariable * > SyncRecordReader::getVariables | ( | ) | ||
throw | ( | nidas::util::Exception | ||
) |
Get the list of variables in a sync record.
References headException, and variables.
Referenced by SyncDumper::run().
|
private |
References _debug, _sampleStreamConfigName, DLOG, nidas::core::Sample::freeReference(), nidas::core::SampleInputHeader::getConfigName(), nidas::core::Sample::getId(), nidas::dynld::SampleInputStream::getInputHeader(), headException, inputStream, nextSample(), nidas::dynld::SampleInputStream::readInputHeader(), nidas::dynld::SampleInputStream::readSample(), scanHeader(), SYNC_RECORD_HEADER_ID, and nidas::util::Exception::what().
Referenced by SyncRecordReader().
|
private |
References _eoq, _qcond, _read_sync_server, _syncRecords, nidas::util::Cond::lock(), nidas::util::Cond::signal(), nidas::util::Cond::unlock(), and nidas::util::Cond::wait().
Referenced by init().
|
private |
No assignment.
size_t SyncRecordReader::read | ( | dsm_time_t * | tt, |
double * | ptr, | ||
size_t | len | ||
) | |||
throw | ( | nidas::util::IOException | |
) |
Read a sync record.
tt | Pointer to a dsm_time_t variable to store the sync record time tag (microseconds since 1970 Jan 1 00:: GMT). |
ptr | Pointer to the array which the caller has allocated. |
len | Number of values to read. Use getNumValues() to find out the number of values in a sync record. |
len
on success or 0 on eof or failure. References nidas::core::DOUBLE_ST, nidas::core::Sample::freeReference(), nidas::core::Sample::getConstVoidDataPtr(), nidas::core::Sample::getDataLength(), nidas::core::Sample::getId(), nidas::core::Sample::getTimeTag(), nidas::core::Sample::getType(), len, and SYNC_RECORD_ID.
Referenced by SyncDumper::run().
|
private |
Referenced by scanHeader().
|
virtual |
Method called to pass a sample to this client.
This method is typically called by a SampleSource for each of its SampleClients when it has a sample ready. Returns true: success false: sample rejected. This is meant to signal a warning-type situation - like a socket not being available temporarily. True errors will be thrown as an IOException.
Implements nidas::core::SampleClient.
|
private |
References _debug, _header, nidas::core::SampleTag::addVariable(), nidas::core::Variable::CLOCK, nidas::core::Variable::CONTINUOUS, nidas::core::Variable::COUNTER, nidas::core::Sample::getConstVoidDataPtr(), nidas::core::Sample::getDataLength(), nidas::core::Variable::getLength(), nidas::core::Variable::getName(), getQuotedString(), nidas::core::Sample::getTimeTag(), headException, numDataValues, nidas::core::Variable::OTHER, rate, readKeyedQuotedValues(), sampleTags, nidas::core::VariableConverter::setCalFile(), nidas::core::Polynomial::setCoefficients(), nidas::core::Variable::setConverter(), nidas::core::CalFile::setFile(), nidas::dynld::raf::SyncRecordVariable::setLagOffset(), nidas::core::Variable::setLength(), nidas::core::Variable::setLongName(), nidas::core::Variable::setName(), nidas::core::CalFile::setPath(), nidas::core::SampleTag::setRate(), nidas::dynld::raf::SyncRecordVariable::setSyncRecOffset(), nidas::core::Variable::setType(), nidas::core::VariableConverter::setUnits(), nidas::core::Variable::setUnits(), startTime, USECS_PER_SEC, variableMap, variables, and nidas::util::Exception::what().
Referenced by init().
|
inline |
References _header.
Referenced by SyncDumper::run().
int SyncRecordReader::throw | ( | SyncRecHeaderException | ) |
int nidas::dynld::raf::SyncRecordReader::throw | ( | SyncRecHeaderException | ) |
|
private |
Referenced by init(), and scanHeader().
|
private |
Referenced by endOfStream(), and nextSample().
|
private |
Referenced by scanHeader(), and textHeader().
|
private |
Referenced by endOfStream(), nextSample(), and ~SyncRecordReader().
|
private |
When true, explicitly read from the SyncServer, if given.
Otherwise run the SyncServer thread to push samples through it's pipeline to the SyncRecordReader.
Referenced by nextSample().
|
private |
Referenced by getConfigName(), and init().
|
private |
Place to stash sample records received as a SampleClient.
Referenced by nextSample(), and ~SyncRecordReader().
|
private |
Referenced by getTailNumber().
|
private |
Referenced by getFlightName().
|
private |
Referenced by getVariables(), init(), scanHeader(), and ~SyncRecordReader().
|
private |
Referenced by init(), and ~SyncRecordReader().
|
private |
Referenced by getNumValues(), and scanHeader().
|
private |
Referenced by getProjectName().
|
private |
Referenced by scanHeader(), and ~SyncRecordReader().
|
private |
Referenced by getSoftwareVersion().
|
private |
Referenced by getStartTime(), and scanHeader().
|
private |
Referenced by SyncRecordReader().
|
private |
Referenced by getVariable(), and scanHeader().
|
private |
Referenced by getVariables(), and scanHeader().