nidas
v1.2-1520
|
#include <SampleScanner.h>
Public Member Functions | |
DatagramSampleScanner (int bufsize=16384) | |
void | setMessageParameters (unsigned int, const std::string &, bool) throw (nidas::util::InvalidParameterException) |
setMessageSeparator is not implemented in DatagramSampleScanner. More... | |
size_t | readBuffer (DSMSensor *sensor, bool &exhausted) throw (nidas::util::IOException) |
Read from the sensor into the internal buffer of this SampleScanner. More... | |
Sample * | nextSample (DSMSensor *sensor) |
Extract the next sample from the buffer. More... | |
void | setNullTerminate (bool val) |
User of DatagramSampleScanner should specify if they want the samples to be null terminated. More... | |
bool | getNullTerminate () const |
Should the SampleScanner append a null character, '\0', to the messages. More... | |
virtual void | init () |
Initialize the scanner. More... | |
virtual const std::string & | getMessageSeparator () const |
Returns an empty string. More... | |
virtual const std::string | getBackslashedMessageSeparator () const |
Returns an empty string. More... | |
virtual bool | getMessageSeparatorAtEOM () const |
virtual unsigned int | getMessageLength () const |
Returns 0. More... | |
void | setUsecsPerByte (int val) |
int | getUsecsPerByte () const |
virtual size_t | readBuffer (DSMSensor *sensor, bool &exhausted, int msecTimeout) throw (nidas::util::IOException) |
Read from the sensor into the internal buffer of this SampleScanner, providing a timeout in milliseconds. More... | |
virtual void | clearBuffer () |
unsigned int | getBytesInBuffer () const |
virtual void | resetStatistics () |
virtual void | calcStatistics (unsigned int periodUsec) |
Update the sensor sampling statistics: samples/sec, bytes/sec, min/max sample size, that can be accessed via getObservedSamplingRate(), getObservedDataRate() etc. More... | |
unsigned int | getMaxSampleLength () const |
unsigned int | getMinSampleLength () const |
unsigned int | getBadTimeTagCount () const |
float | getObservedSamplingRate () const |
float | getObservedDataRate () const |
void | addNumBytesToStats (size_t val) |
void | addSampleToStats (unsigned int val) |
void | incrementBadTimeTags () |
Protected Attributes | |
const unsigned int | BUFSIZE |
Buffer size for reading from sensor. More... | |
char * | _buffer |
unsigned int | _bufhead |
unsigned int | _buftail |
Sample * | _osamp |
struct dsm_sample | _header |
unsigned int | _outSampRead |
unsigned int | _outSampToRead |
char * | _outSampDataPtr |
std::string | _messageSeparator |
int | _messageLength |
bool | _separatorAtEOM |
char * | _separator |
messageSeparator in a C string. More... | |
int | _separatorLen |
Length of messageSeparator. More... | |
Private Attributes | |
std::list< int > | _packetLengths |
std::list< dsm_time_t > | _packetTimes |
bool | _nullTerminate |
DatagramSampleScanner::DatagramSampleScanner | ( | int | bufsize = 16384 | ) |
|
inlineinherited |
References nidas::core::SampleScanner::_nbytes.
|
inlineinherited |
References nidas::core::SampleScanner::_currentIndex, nidas::core::SampleScanner::_maxSampleLength, nidas::core::SampleScanner::_minSampleLength, and nidas::core::SampleScanner::_nsamples.
Referenced by nidas::core::DriverSampleScanner::nextSample(), nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), nidas::core::MessageStreamScanner::nextSampleSepEOM(), and nidas::core::MessageStreamScanner::requestBiggerSample().
|
virtualinherited |
Update the sensor sampling statistics: samples/sec, bytes/sec, min/max sample size, that can be accessed via getObservedSamplingRate(), getObservedDataRate() etc.
Should be called every periodUsec by a user of this sensor.
periodUsec | Statistics period. |
References nidas::core::SampleScanner::_currentIndex, nidas::core::SampleScanner::_dataRateObs, nidas::core::SampleScanner::_maxSampleLength, nidas::core::SampleScanner::_minSampleLength, nidas::core::SampleScanner::_nbytes, nidas::core::SampleScanner::_nsamples, nidas::core::SampleScanner::_reportIndex, nidas::core::SampleScanner::_sampleRateObs, and USECS_PER_SEC.
Referenced by nidas::core::DSMSensor::calcStatistics().
|
virtualinherited |
References nidas::core::SampleScanner::_bufhead, and nidas::core::SampleScanner::_buftail.
Referenced by nidas::core::DSMSensor::clearBuffer().
|
inlinevirtualinherited |
Returns an empty string.
Reimplemented in nidas::core::MessageStreamScanner, and nidas::core::MessageSampleScanner.
References nidas::core::SampleScanner::_emptyString.
|
inlineinherited |
References nidas::core::SampleScanner::_badTimeTags.
Referenced by nidas::core::DSMSensor::getBadTimeTagCount().
|
inlineinherited |
References nidas::core::SampleScanner::_bufhead, and nidas::core::SampleScanner::_buftail.
|
inlineinherited |
References nidas::core::SampleScanner::_maxSampleLength, and nidas::core::SampleScanner::_reportIndex.
Referenced by nidas::core::DSMSensor::getMaxSampleLength().
|
inlinevirtualinherited |
Returns 0.
Reimplemented in nidas::core::MessageStreamScanner, and nidas::core::MessageSampleScanner.
|
inlinevirtualinherited |
Returns an empty string.
Reimplemented in nidas::core::MessageStreamScanner, and nidas::core::MessageSampleScanner.
References nidas::core::SampleScanner::_emptyString.
|
inlinevirtualinherited |
Reimplemented in nidas::core::MessageStreamScanner, and nidas::core::MessageSampleScanner.
|
inlineinherited |
|
inlinevirtual |
Should the SampleScanner append a null character, '\0', to the messages.
Reimplemented from nidas::core::SampleScanner.
References _nullTerminate.
Referenced by nextSample().
|
inherited |
|
inherited |
|
inlineinherited |
|
inlineinherited |
References nidas::core::SampleScanner::_badTimeTags.
Referenced by nidas::core::DriverSampleScanner::nextSample().
|
virtualinherited |
Initialize the scanner.
Must be called by a user of SampleScanner prior to calling readSamples().
References nidas::core::SampleScanner::resetStatistics().
Extract the next sample from the buffer.
Returns NULL if there are no more samples in the buffer.
Implements nidas::core::SampleScanner.
References nidas::core::SampleScanner::_buffer, nidas::core::SampleScanner::_buftail, _packetLengths, _packetTimes, nidas::core::SampleScanner::addSampleToStats(), nidas::core::DSMSensor::getId(), getNullTerminate(), and nidas::core::Sample::setTimeTag().
|
virtualinherited |
Read from the sensor into the internal buffer of this SampleScanner, providing a timeout in milliseconds.
This will throw nidas::util::IOTimeoutException if the read fails due to a timeout.
Reimplemented in nidas::core::MessageStreamScanner.
References MSECS_PER_SEC, NLOG, NSECS_PER_MSEC, and nidas::core::SampleScanner::readBuffer().
|
virtual |
Read from the sensor into the internal buffer of this SampleScanner.
Reimplemented from nidas::core::SampleScanner.
References nidas::util::Logger::getInstance(), nidas::util::getSystemTime(), len, nidas::util::Logger::log(), and LOG_WARNING.
|
virtualinherited |
References nidas::core::SampleScanner::_badTimeTags, nidas::core::SampleScanner::_currentIndex, nidas::core::SampleScanner::_dataRateObs, nidas::core::SampleScanner::_initialTimeSecs, nidas::core::SampleScanner::_maxSampleLength, nidas::core::SampleScanner::_minSampleLength, nidas::core::SampleScanner::_nbytes, nidas::core::SampleScanner::_nsamples, nidas::core::SampleScanner::_reportIndex, and nidas::core::SampleScanner::_sampleRateObs.
Referenced by nidas::core::SampleScanner::init(), and nidas::core::SampleScanner::SampleScanner().
|
inlinevirtual |
setMessageSeparator is not implemented in DatagramSampleScanner.
Throws nidas::util::InvalidParameterException.
Implements nidas::core::SampleScanner.
|
inline |
User of DatagramSampleScanner should specify if they want the samples to be null terminated.
In general, if this SampleScanner is used by a CharacterSensor with a scanfFormat defined for one or more samples, then the samples should be null terminated.
References _nullTerminate.
Referenced by nidas::dynld::raf::PHIPS_UDP::buildSampleScanner(), nidas::dynld::UDPSocketSensor::buildSampleScanner(), and nidas::core::CharacterSensor::buildSampleScanner().
|
inlineinherited |
|
protectedinherited |
|
protectedinherited |
Referenced by nidas::core::SampleScanner::clearBuffer(), nidas::core::SampleScanner::getBytesInBuffer(), nidas::core::DriverSampleScanner::nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), and nidas::core::MessageStreamScanner::nextSampleSepEOM().
|
protectedinherited |
Referenced by nidas::core::SampleScanner::clearBuffer(), nidas::core::SampleScanner::getBytesInBuffer(), nidas::core::DriverSampleScanner::nextSample(), nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), and nidas::core::MessageStreamScanner::nextSampleSepEOM().
|
protectedinherited |
Referenced by nidas::core::DriverSampleScanner::nextSample().
|
protectedinherited |
|
protectedinherited |
|
private |
Referenced by getNullTerminate(), and setNullTerminate().
|
protectedinherited |
Referenced by nidas::core::DriverSampleScanner::nextSample(), nidas::core::MessageStreamScanner::nextSampleByLength(), nidas::core::MessageStreamScanner::nextSampleSepBOM(), nidas::core::MessageStreamScanner::nextSampleSepEOM(), nidas::core::MessageStreamScanner::requestBiggerSample(), and nidas::core::SampleScanner::~SampleScanner().
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Referenced by nidas::core::DriverSampleScanner::nextSample().
|
private |
Referenced by nextSample().
|
private |
Referenced by nextSample().
|
protectedinherited |
messageSeparator in a C string.
Referenced by nidas::core::MessageStreamScanner::nextSampleSepBOM(), nidas::core::MessageStreamScanner::nextSampleSepEOM(), and nidas::core::SampleScanner::~SampleScanner().
|
protectedinherited |
|
protectedinherited |
Length of messageSeparator.
Referenced by nidas::core::MessageStreamScanner::nextSampleSepBOM(), and nidas::core::MessageStreamScanner::nextSampleSepEOM().
|
protectedinherited |
Buffer size for reading from sensor.