nidas v1.2.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::dynld::raf::SyncRecordReader Class Reference

SyncRecordReader handles sync samples and provides an interface to access Variables and read sync record data. More...

#include <SyncRecordReader.h>

Inheritance diagram for nidas::dynld::raf::SyncRecordReader:
Inheritance graph
[legend]

Public Member Functions

 SyncRecordReader (IOChannel *iochan)
 Constructor of a SyncRecordReader to a connected IOChannel.
 
 SyncRecordReader (SyncServer *ss)
 Constructor for a SyncRecordReader connected directly as a SampleClient of a SyncServer instance.
 
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.
 
const std::list< const SyncRecordVariable * > getVariables ()
 Get the list of variables in a sync record.
 
const SyncRecordVariablegetVariable (const std::string &name) const
 Get a pointer to a SyncRecordVariable, searching by name.
 
size_t getNumValues () const
 Get number of data values in a sync record.
 
size_t read (dsm_time_t *tt, double *ptr, size_t len)
 Read a sync record.
 
const std::string & textHeader ()
 
virtual bool receive (const Sample *s) throw ()
 Method called to pass a sample to this client.
 
virtual void flush () throw ()
 Ask that this SampleClient send out any buffered Samples that it may be holding.
 
void endOfStream ()
 Signal the end of the sample stream, meaning EOF is reached once the queue is empty.
 
int getSyncRecOffset (const nidas::core::Variable *var)
 
int getLagOffset (const nidas::core::Variable *var)
 
const std::string & getConfigName ()
 After creating a SyncRecordReader on a socket, this method returns the config name from the SampleInputStream header.
 

Private Member Functions

void init ()
 
void scanHeader (const Sample *samp)
 
const SamplenextSample ()
 
std::string getQuotedString (std::istringstream &str)
 
void readKeyedQuotedValues (std::istringstream &header)
 
 SyncRecordReader (const SyncRecordReader &)
 No copying.
 
SyncRecordReaderoperator= (const SyncRecordReader &)
 No assignment.
 

Private Attributes

SampleInputStreaminputStream
 
SyncServersyncServer
 
bool _read_sync_server
 When true, explicitly read from the SyncServer, if given.
 
SyncRecHeaderExceptionheadException
 
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.
 
std::string _sampleStreamConfigName
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SyncRecordReader() [1/3]

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() [2/3]

SyncRecordReader::SyncRecordReader ( SyncServer * ss)

Constructor for a SyncRecordReader connected directly as a SampleClient of a SyncServer instance.

References nidas::core::getSample(), init(), and syncServer.

◆ ~SyncRecordReader()

SyncRecordReader::~SyncRecordReader ( )
virtual

◆ SyncRecordReader() [3/3]

nidas::dynld::raf::SyncRecordReader::SyncRecordReader ( const SyncRecordReader & )
private

No copying.

Member Function Documentation

◆ endOfStream()

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().

Referenced by SyncReaderStop::stop().

◆ flush()

void SyncRecordReader::flush ( )
throw ( )
virtual

Ask that this SampleClient send out any buffered Samples that it may be holding.

Exceptions

)

Implements nidas::core::SampleClient.

◆ getConfigName()

const std::string & nidas::dynld::raf::SyncRecordReader::getConfigName ( )
inline

After creating a SyncRecordReader on a socket, this method returns the config name from the SampleInputStream header.

References _sampleStreamConfigName.

◆ getFlightName()

const std::string & nidas::dynld::raf::SyncRecordReader::getFlightName ( ) const
inline

References flightName.

◆ getLagOffset()

int SyncRecordReader::getLagOffset ( const nidas::core::Variable * var)
Exceptions
SyncRecHeaderException

References getVariable(), and syncServer.

◆ getNumValues()

size_t nidas::dynld::raf::SyncRecordReader::getNumValues ( ) const
inline

Get number of data values in a sync record.

This includes data and dynamic lag values.

References numDataValues.

◆ getProjectName()

const std::string & nidas::dynld::raf::SyncRecordReader::getProjectName ( ) const
inline

References projectName.

◆ getQuotedString()

string SyncRecordReader::getQuotedString ( std::istringstream & str)
private

◆ getSoftwareVersion()

const std::string & nidas::dynld::raf::SyncRecordReader::getSoftwareVersion ( ) const
inline

References softwareVersion.

◆ getStartTime()

time_t nidas::dynld::raf::SyncRecordReader::getStartTime ( ) const
inline

Get UNIX time of the start time of data in the SyncRecords.

References startTime.

◆ getSyncRecOffset()

int SyncRecordReader::getSyncRecOffset ( const nidas::core::Variable * var)
Exceptions
SyncRecHeaderException

References getVariable().

◆ getTailNumber()

const std::string & nidas::dynld::raf::SyncRecordReader::getTailNumber ( ) const
inline

References aircraftName.

◆ getVariable()

const SyncRecordVariable * SyncRecordReader::getVariable ( const std::string & name) const

Get a pointer to a SyncRecordVariable, searching by name.

Returns NULL if not found.

References nidas::core::getSample(), and variableMap.

Referenced by getLagOffset(), and getSyncRecOffset().

◆ getVariables()

const list< const SyncRecordVariable * > SyncRecordReader::getVariables ( )

Get the list of variables in a sync record.

Exceptions
nidas::util::Exception

References headException, and variables.

◆ init()

void SyncRecordReader::init ( )
private

◆ nextSample()

const Sample * SyncRecordReader::nextSample ( )
private

◆ operator=()

SyncRecordReader & nidas::dynld::raf::SyncRecordReader::operator= ( const SyncRecordReader & )
private

No assignment.

◆ read()

size_t SyncRecordReader::read ( dsm_time_t * tt,
double * ptr,
size_t len )

Read a sync record.

Parameters
ttPointer to a dsm_time_t variable to store the sync record time tag (microseconds since 1970 Jan 1 00:: GMT).
ptrPointer to the array which the caller has allocated.
lenNumber of values to read. Use getNumValues() to find out the number of values in a sync record.
Returns
len on success or 0 on eof or failure.
Exceptions
nidas::util::IOException

References _read_sync_server, nidas::core::DOUBLE_ST, nidas::core::getSample(), inputStream, len, nextSample(), nidas::dynld::raf::SyncServer::read(), nidas::dynld::SampleInputStream::readSample(), SYNC_RECORD_ID, and syncServer.

◆ readKeyedQuotedValues()

void SyncRecordReader::readKeyedQuotedValues ( std::istringstream & header)
private

◆ receive()

bool SyncRecordReader::receive ( const Sample * s)
throw ( )
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.

Exceptions

)

Implements nidas::core::SampleClient.

◆ scanHeader()

void SyncRecordReader::scanHeader ( const Sample * samp)
private

◆ textHeader()

const std::string & nidas::dynld::raf::SyncRecordReader::textHeader ( )
inline

References _header.

Member Data Documentation

◆ _debug

bool nidas::dynld::raf::SyncRecordReader::_debug
private

Referenced by init(), and scanHeader().

◆ _eoq

bool nidas::dynld::raf::SyncRecordReader::_eoq
private

Referenced by endOfStream(), and nextSample().

◆ _header

std::string nidas::dynld::raf::SyncRecordReader::_header
private

Referenced by scanHeader(), and textHeader().

◆ _qcond

nidas::util::Cond nidas::dynld::raf::SyncRecordReader::_qcond
private

◆ _read_sync_server

bool nidas::dynld::raf::SyncRecordReader::_read_sync_server
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(), and read().

◆ _sampleStreamConfigName

std::string nidas::dynld::raf::SyncRecordReader::_sampleStreamConfigName
private

Referenced by getConfigName(), and init().

◆ _syncRecords

std::deque<const Sample*> nidas::dynld::raf::SyncRecordReader::_syncRecords
private

Place to stash sample records received as a SampleClient.

Referenced by nextSample(), and ~SyncRecordReader().

◆ aircraftName

std::string nidas::dynld::raf::SyncRecordReader::aircraftName
private

◆ flightName

std::string nidas::dynld::raf::SyncRecordReader::flightName
private

◆ headException

SyncRecHeaderException* nidas::dynld::raf::SyncRecordReader::headException
private

◆ inputStream

SampleInputStream* nidas::dynld::raf::SyncRecordReader::inputStream
private

Referenced by init(), read(), and ~SyncRecordReader().

◆ numDataValues

size_t nidas::dynld::raf::SyncRecordReader::numDataValues
private

Referenced by getNumValues(), and scanHeader().

◆ projectName

std::string nidas::dynld::raf::SyncRecordReader::projectName
private

◆ sampleTags

std::list<SampleTag*> nidas::dynld::raf::SyncRecordReader::sampleTags
private

Referenced by scanHeader(), and ~SyncRecordReader().

◆ softwareVersion

std::string nidas::dynld::raf::SyncRecordReader::softwareVersion
private

◆ startTime

time_t nidas::dynld::raf::SyncRecordReader::startTime
private

Referenced by getStartTime(), and scanHeader().

◆ syncServer

SyncServer* nidas::dynld::raf::SyncRecordReader::syncServer
private

◆ variableMap

std::map<std::string,const SyncRecordVariable*> nidas::dynld::raf::SyncRecordReader::variableMap
private

Referenced by getVariable(), and scanHeader().

◆ variables

std::list<const SyncRecordVariable*> nidas::dynld::raf::SyncRecordReader::variables
private

Referenced by getVariables(), and scanHeader().


The documentation for this class was generated from the following files: