26 #ifndef NIDAS_CORE_SAMPLESCANNER_H
27 #define NIDAS_CORE_SAMPLESCANNER_H
34 namespace nidas {
namespace core {
311 throw(nidas::util::InvalidParameterException)
314 "setMessageSeparator not supported");
592 throw(nidas::util::InvalidParameterException)
595 "setMessageParameters not supported");
virtual Sample * nextSampleSepBOM(DSMSensor *sensor)
Method to read input and break it into samples where the message separator occurs at the beginning of...
Definition: SampleScanner.cc:590
virtual bool getNullTerminate() const
Should the SampleScanner append a null character, '\0', to the messages.
Definition: SampleScanner.h:127
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.
Definition: SampleScanner.cc:193
std::list< int > _packetLengths
Definition: SampleScanner.h:630
Sample * requestBiggerSample(unsigned int nc)
If a new sample can be allocated without exceeding MAX_MESSAGE_STREAM_SAMPLE_SIZE then get a new...
Definition: SampleScanner.cc:379
const std::string getBackslashedMessageSeparator() const
Get message separator with backslash sequences added back.
Definition: SampleScanner.cc:283
bool _separatorAtEOM
Definition: SampleScanner.h:241
dsm_time_t _lastSampleTime
Definition: SampleScanner.h:532
unsigned int _stepBackTimeTag
Number of time tags that were not monotonically increasing, due to backward step changes.
Definition: SampleScanner.h:569
void warnBackwardsStepTimeTag(const DSMSensor *sensor, dsm_time_t badtt, unsigned int nbad)
Definition: SampleScanner.cc:458
MessageStreamScanner(int bufsize=4096)
Definition: SampleScanner.cc:301
virtual void resetStatistics()
Definition: SampleScanner.cc:179
virtual unsigned int getMessageLength() const
Returns 0.
Definition: SampleScanner.h:118
virtual bool getMessageSeparatorAtEOM() const
Definition: SampleScanner.h:110
int _currentIndex
Definition: SampleScanner.h:263
SampleScanner(int bufsize=8192)
Definition: SampleScanner.cc:53
size_t readBuffer(DSMSensor *sensor, bool &exhausted)
Read from the sensor into the internal buffer of this SampleScanner.
Definition: SampleScanner.cc:414
long long dsm_time_t
Posix time in microseconds, the number of non-leap microseconds since 1970 Jan 1 00:00 UTC...
Definition: Sample.h:61
MessageSampleScanner(int bufsize=8192)
Definition: SampleScanner.cc:278
float getObservedSamplingRate() const
Definition: SampleScanner.cc:208
unsigned int getMessageLength() const
Returns 0.
Definition: SampleScanner.h:451
int _sampleOverflows
Definition: SampleScanner.h:540
void setMessageParameters(unsigned int len, const std::string &val, bool eom)
Set the parameters which delineate a message for this scanner.
Definition: SampleScanner.cc:288
dsm_time_t _lastBufferTime
Definition: SampleScanner.h:530
unsigned int _buftail
Definition: SampleScanner.h:225
size_t readBuffer(DSMSensor *sensor, bool &exhausted)
Read from the sensor into the internal buffer of this SampleScanner.
Definition: SampleScanner.cc:887
bool _nullTerminate
Definition: SampleScanner.h:634
float getObservedDataRate() const
Definition: SampleScanner.cc:216
void setUsecsPerByte(int val)
Definition: SampleScanner.h:132
unsigned int _sampleLengthAlloc
Size of samples to allocate.
Definition: SampleScanner.h:545
time_t _initialTimeSecs
Definition: SampleScanner.h:257
size_t _nsamples
Definition: SampleScanner.h:267
bool getMessageSeparatorAtEOM() const
Is the message separator at the end of the message (true), or at the beginning (false)?
Definition: SampleScanner.h:400
Definition: SampleScanner.h:581
unsigned int getBytesInBuffer() const
Definition: SampleScanner.h:166
unsigned int _outSampRead
Definition: SampleScanner.h:231
float _sampleRateObs
Observed number of samples per second.
Definition: SampleScanner.h:276
const std::string & getMessageSeparator() const
Get message separator string.
Definition: SampleScanner.h:436
int getUsecsPerByte() const
Definition: SampleScanner.h:137
dsm_time_t _tfirstchar
Definition: SampleScanner.h:528
struct dsm_sample _header
Definition: SampleScanner.h:229
DatagramSampleScanner(int bufsize=16384)
Definition: SampleScanner.cc:880
unsigned int _nonIncrTimeTag
Number of time tags that were not monotonically increasing, not because of backward step changes...
Definition: SampleScanner.h:577
unsigned int getMessageLength() const
Returns 0.
Definition: SampleScanner.h:405
unsigned int _maxSampleLength[2]
Definition: SampleScanner.h:261
void warnNonIncrTimeTag(const DSMSensor *sensor, dsm_time_t badtt, dsm_time_t cortt, unsigned int nbad)
Issue warning log message about a non-forward time tag.
Definition: SampleScanner.cc:447
float _dataRateObs
Definition: SampleScanner.h:278
dsm_time_t _bomtt
Definition: SampleScanner.h:538
char * _buffer
Definition: SampleScanner.h:221
unsigned int _bufhead
Definition: SampleScanner.h:223
Sample *(MessageStreamScanner::* _nextSampleFunc)(DSMSensor *)
Definition: SampleScanner.h:511
unsigned int getMaxSampleLength() const
Definition: SampleScanner.h:179
bool getNullTerminate() const
Should the SampleScanner append a null character, '\0', to the messages.
Definition: SampleScanner.h:461
bool getMessageSeparatorAtEOM() const
Definition: SampleScanner.h:446
virtual void setMessageParameters(unsigned int len, const std::string &val, bool eom)=0
Set the parameters associated with scanning of character messages.
int _messageLength
Definition: SampleScanner.h:239
unsigned int _badTimeTags
Definition: SampleScanner.h:271
int len
Definition: sing.cc:934
Interface to a data sample.
Definition: Sample.h:189
Sample * nextSample(DSMSensor *sensor)
Extract the next sample from the buffer.
Definition: SampleScanner.cc:228
int _nsmallSamples
Count of number of consecutive samples smaller than _sampleLengthAlloc.
Definition: SampleScanner.h:552
virtual void clearBuffer()
Definition: SampleScanner.cc:174
SampleScanner & operator=(const SampleScanner &)
No assignment (could be added if needed).
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition: DSMSensor.h:87
const unsigned int BUFSIZE
Buffer size for reading from sensor.
Definition: SampleScanner.h:219
std::list< dsm_time_t > _packetTimes
Definition: SampleScanner.h:632
void addSampleToStats(unsigned int val)
Definition: SampleScanner.h:200
size_t _nbytes
Definition: SampleScanner.h:269
Definition: IOException.h:37
std::string _messageSeparator
Definition: SampleScanner.h:237
void setMessageParameters(unsigned int len, const std::string &val, bool eom)
Set the parameters associated with scanning of character messages.
Definition: SampleScanner.cc:320
char * _outSampDataPtr
Definition: SampleScanner.h:235
A DriverSampleScanner which supports the set/get of message separation parameters.
Definition: SampleScanner.h:332
void incrementBadTimeTags()
Definition: SampleScanner.h:209
bool getNullTerminate() const
Should the SampleScanner append a null character, '\0', to the messages.
Definition: SampleScanner.h:623
void setNullTerminate(bool val)
User of DatagramSampleScanner should specify if they want the samples to be null terminated.
Definition: SampleScanner.h:618
unsigned int getMinSampleLength() const
Definition: SampleScanner.h:182
A scanner of sample data.
Definition: SampleScanner.h:73
unsigned int getBadTimeTagCount() const
Definition: SampleScanner.h:189
virtual ~SampleScanner()
Definition: SampleScanner.cc:70
A SampleScanner for reading samples that have been pre-formatted by a device driver - they already ha...
Definition: SampleScanner.h:300
unsigned int _minSampleLength[2]
Definition: SampleScanner.h:259
Sample * nextSample(DSMSensor *sensor)
Extract the next sample from the buffer.
Definition: SampleScanner.h:466
virtual Sample * nextSample(DSMSensor *sensor)=0
Extract the next sample from the buffer.
std::string _emptyString
Definition: SampleScanner.h:255
int _separatorLen
Length of messageSeparator.
Definition: SampleScanner.h:251
DriverSampleScanner(int bufsize=8192)
Definition: SampleScanner.cc:223
virtual Sample * nextSampleSepEOM(DSMSensor *sensor)
Method to read input and break it into samples where the message separator occurs at the end of the m...
Definition: SampleScanner.cc:467
void setMessageParameters(unsigned int, const std::string &, bool)
setMessageSeparator is not implemented in DriverSampleScanner.
Definition: SampleScanner.h:310
const std::string & getMessageSeparator() const
Get message separator string.
Definition: SampleScanner.h:386
char * _separator
messageSeparator in a C string.
Definition: SampleScanner.h:246
int _separatorCnt
Definition: SampleScanner.h:536
int _reportIndex
Definition: SampleScanner.h:265
void addNumBytesToStats(size_t val)
Definition: SampleScanner.h:198
virtual const std::string getBackslashedMessageSeparator() const
Returns an empty string.
Definition: SampleScanner.h:105
A SampleScanner which supports the set/get of message separation parameters and extracts samples from...
Definition: SampleScanner.h:423
void setMessageParameters(unsigned int, const std::string &, bool)
setMessageSeparator is not implemented in DatagramSampleScanner.
Definition: SampleScanner.h:591
int _usecsPerByte
Definition: SampleScanner.h:280
bool _nullTerminate
Definition: SampleScanner.h:547
Sample * nextSampleByLength(DSMSensor *sensor)
Method to read input and break it into samples strictly by record length.
Definition: SampleScanner.cc:816
virtual size_t readBuffer(DSMSensor *sensor, bool &exhausted)
Read from the sensor into the internal buffer of this SampleScanner.
Definition: SampleScanner.cc:82
const std::string getBackslashedMessageSeparator() const
Get message separator with backslash sequences added back.
Definition: SampleScanner.cc:315
virtual const std::string & getMessageSeparator() const
Returns an empty string.
Definition: SampleScanner.h:97
virtual void init()
Initialize the scanner.
Definition: SampleScanner.cc:77
void setNullTerminate(bool val)
Definition: SampleScanner.h:456
unsigned int _outSampLengthAlloc
Number of bytes allocated in data portion of current output sample.
Definition: SampleScanner.h:557
Sample * nextSample(DSMSensor *sensor)
Extract the next sample from the buffer.
Definition: SampleScanner.cc:944
const unsigned int MAX_MESSAGE_STREAM_SAMPLE_SIZE
Definition: SampleScanner.h:534
Definition: InvalidParameterException.h:35
Sample * _osamp
Definition: SampleScanner.h:227
unsigned int _outSampToRead
Definition: SampleScanner.h:233
bool _stepBackwards
If the system time of a buffer read is earlier than the previous read.
Definition: SampleScanner.h:563