nidas  v1.2-1520
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. 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 SyncRecordVariablegetVariable (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 SamplenextSample ()
 
std::string getQuotedString (std::istringstream &str)
 
void readKeyedQuotedValues (std::istringstream &header) throw (SyncRecHeaderException)
 
 SyncRecordReader (const SyncRecordReader &)
 No copying. More...
 
SyncRecordReaderoperator= (const SyncRecordReader &)
 No assignment. More...
 

Private Attributes

SampleInputStreaminputStream
 
SyncServersyncServer
 
bool _read_sync_server
 When true, explicitly read from the SyncServer, if given. More...
 
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. More...
 
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::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)
SyncRecordReader::~SyncRecordReader ( )
virtual
nidas::dynld::raf::SyncRecordReader::SyncRecordReader ( const SyncRecordReader )
private

No copying.

Member Function Documentation

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

void SyncRecordReader::flush ( )
throw (
)
virtual

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

Implements nidas::core::SampleClient.

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.

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

References flightName.

Referenced by SyncDumper::run().

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.

Referenced by SyncDumper::run().

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

References projectName.

Referenced by SyncDumper::run().

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

Referenced by scanHeader().

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

References softwareVersion.

Referenced by SyncDumper::run().

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

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

References startTime.

const std::string& nidas::dynld::raf::SyncRecordReader::getTailNumber ( ) const
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().

void SyncRecordReader::init ( )
private
const Sample * SyncRecordReader::nextSample ( )
private
SyncRecordReader& nidas::dynld::raf::SyncRecordReader::operator= ( const SyncRecordReader )
private

No assignment.

size_t SyncRecordReader::read ( dsm_time_t tt,
double *  ptr,
size_t  len 
)
throw (nidas::util::IOException
)

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.

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

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

Referenced by scanHeader().

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.

Implements nidas::core::SampleClient.

void SyncRecordReader::scanHeader ( const Sample samp)
private
const std::string& nidas::dynld::raf::SyncRecordReader::textHeader ( )
inline

References _header.

Referenced by SyncDumper::run().

int SyncRecordReader::throw ( SyncRecHeaderException  )
int nidas::dynld::raf::SyncRecordReader::throw ( SyncRecHeaderException  )

Member Data Documentation

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

Referenced by init(), and scanHeader().

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

Referenced by endOfStream(), and nextSample().

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

Referenced by scanHeader(), and textHeader().

nidas::util::Cond nidas::dynld::raf::SyncRecordReader::_qcond
private
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().

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

Referenced by getConfigName(), and init().

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

Place to stash sample records received as a SampleClient.

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

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

Referenced by getTailNumber().

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

Referenced by getFlightName().

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

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

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

Referenced by getNumValues(), and scanHeader().

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

Referenced by getProjectName().

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

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

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

Referenced by getSoftwareVersion().

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

Referenced by getStartTime(), and scanHeader().

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

Referenced by SyncRecordReader().

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

Referenced by getVariable(), and scanHeader().

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: