Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

DataStreamDriver Class Reference

A generic base class for drivers which are receiving a stream of data through a comm port, also providing an interface to be used as a data source in another driver. More...

#include <DataStreamDriver.h>

Inheritance diagram for DataStreamDriver:

Detailed Description

A generic base class for drivers which are receiving a stream of data through a comm port, also providing an interface to be used as a data source in another driver.

Definition at line 10 of file DataStreamDriver.h.

List of all members.

Public Member Functions

 DataStreamDriver (const std::string &className, const std::string &localName)
virtual unsigned int nextTimestamp ()
 Returns the simulator time of the next data segment.
virtual const std::string & nextName ()
 Returns a descriptive name of the next data segment for user feedback (e.g. a filename for logged data).
virtual bool advance ()
 Called when the simulator is stepping while paused or advancing a frozen data source, return true if successful, or false if no more data is available.
virtual void registerSource ()
 User hook, called when the data source should claim which outputs it provides feedback (providingOuput()).
virtual void deregisterSource ()
 User hook, called when the data source should release its claim on outputs with feedback (ignoringOuput()).

Public Attributes

plist::Primitive< std::string > commName
 The name of the comm port from which data will be read.
plist::Primitive< floatsrcFrameRate
 The expected source framerate, used to regulate buffering.
plist::Primitive< boolpaceInput
 If set to false, the driver will attempt to detect and run through any backlog on the comm port; if true, the driver will process each image in turn, enforcing SourceFPS.

Protected Member Functions

virtual void plistValueChanged (const plist::PrimitiveBase &pl)
virtual void * run ()
void doFreeze ()
 user hook for when frozen is set to true; advance() will be called by simulator at user discretion.
void doUnfreeze ()
 user hook for when frozen is set to false; if enteringRealtime() has been called then you should resume sending data.
virtual bool readData (std::istream &is)=0
 Called when data should be read from the specified data stream and then provided to the framework.
virtual CommPortgetComm (const std::string &name)
 allows subclasses to override the commport lookup
virtual void connect (CommPort *comm)
 called when connection initialization is required (opens comm port, etc.)
virtual void disconnect (CommPort *comm)
 called when connection destruction is required (closes comm port, etc.)
virtual bool requestFrame (CommPort &comm)
 called if no image data is readily available, should return true if thread should block for frame

Protected Attributes

unsigned int timestamp
 timestamp of last data received
unsigned int frameNumber
 image frame number
bool registered
 true if registerSource has been called and deregisterSource has not
bool realtime
 true if enteringRealtime has been called more recently than leavingRealtime

Private Member Functions

 DataStreamDriver (const DataStreamDriver &)
 don't call
DataStreamDriveroperator= (const DataStreamDriver &)
 don't call

Static Private Attributes

static const std::string autoRegisterDriver
 holds the class name, set via registration with the DeviceDriver registry

Constructor & Destructor Documentation

DataStreamDriver ( const std::string &  className,
const std::string &  localName 
) [explicit]

Definition at line 12 of file DataStreamDriver.h.

DataStreamDriver ( const DataStreamDriver  )  [private]

don't call


Member Function Documentation

bool advance (  )  [virtual]

Called when the simulator is stepping while paused or advancing a frozen data source, return true if successful, or false if no more data is available.

Implements DataSource.

Definition at line 12 of file DataStreamDriver.cc.

void connect ( CommPort comm  )  [protected, virtual]

called when connection initialization is required (opens comm port, etc.)

Reimplemented in ImageStreamDriver.

Definition at line 113 of file DataStreamDriver.cc.

Referenced by plistValueChanged(), and registerSource().

void deregisterSource (  )  [virtual]

User hook, called when the data source should release its claim on outputs with feedback (ignoringOuput()).

It would be wise to call this from your destructor as well.

Reimplemented from DataSource.

Reimplemented in ImageSubscription, DepthSubscription, and PListSensorDriver.

Definition at line 53 of file DataStreamDriver.cc.

void disconnect ( CommPort comm  )  [protected, virtual]

called when connection destruction is required (closes comm port, etc.)

Reimplemented in ImageStreamDriver.

Definition at line 124 of file DataStreamDriver.cc.

Referenced by deregisterSource(), and plistValueChanged().

void doFreeze (  )  [protected, virtual]

user hook for when frozen is set to true; advance() will be called by simulator at user discretion.

Reimplemented from DataSource.

Reimplemented in Subscription< PListSensorDriver >, and Subscription< ImageStreamDriver >.

Definition at line 66 of file DataStreamDriver.cc.

void doUnfreeze (  )  [protected, virtual]

user hook for when frozen is set to false; if enteringRealtime() has been called then you should resume sending data.

Reimplemented from DataSource.

Reimplemented in Subscription< PListSensorDriver >, and Subscription< ImageStreamDriver >.

Definition at line 58 of file DataStreamDriver.cc.

virtual CommPort* getComm ( const std::string &  name  )  [protected, virtual]

allows subclasses to override the commport lookup

Reimplemented in Subscription< PListSensorDriver >, and Subscription< ImageStreamDriver >.

Definition at line 54 of file DataStreamDriver.h.

Referenced by advance(), deregisterSource(), nextTimestamp(), ImageStreamDriver::plistValueChanged(), plistValueChanged(), registerSource(), and run().

virtual const std::string& nextName (  )  [virtual]

Returns a descriptive name of the next data segment for user feedback (e.g. a filename for logged data).

Just use your class name if you don't have a useful name for individual samples.

Implements DataSource.

Reimplemented in Subscription< PListSensorDriver >, and Subscription< ImageStreamDriver >.

Definition at line 23 of file DataStreamDriver.h.

Referenced by ImageStreamDriver::readImage().

unsigned int nextTimestamp (  )  [virtual]

Returns the simulator time of the next data segment.

Should be in the future if nothing new since last data segment, otherwise should be the timestamp of the most recent data segment (older segments are skipped), return -1U if there is no more data

Implements DataSource.

Definition at line 5 of file DataStreamDriver.cc.

Referenced by run().

DataStreamDriver& operator= ( const DataStreamDriver  )  [private]

don't call

void plistValueChanged ( const plist::PrimitiveBase pl  )  [protected, virtual]
virtual bool readData ( std::istream &  is  )  [protected, pure virtual]

Called when data should be read from the specified data stream and then provided to the framework.

If paceInput is set, your implementation should use readsome() to skim through to the last available data packet, and provide only that data to the framework

Implemented in ImageStreamDriver, and PListSensorDriver.

Referenced by advance(), and run().

void registerSource (  )  [virtual]

User hook, called when the data source should claim which outputs it provides feedback (providingOuput()).

Does not indicate the data source should start sending updates yet — wait for enteringRealtime() or advance() to be called

Reimplemented from DataSource.

Reimplemented in ImageSubscription, and DepthSubscription.

Definition at line 48 of file DataStreamDriver.cc.

virtual bool requestFrame ( CommPort comm  )  [protected, virtual]

called if no image data is readily available, should return true if thread should block for frame

Reimplemented in Subscription< PListSensorDriver >, and Subscription< ImageStreamDriver >.

Definition at line 60 of file DataStreamDriver.h.

Referenced by advance().

void * run (  )  [protected, virtual]

Reimplemented from Thread.

Definition at line 89 of file DataStreamDriver.cc.


Member Data Documentation

const std::string autoRegisterDriver [static, private]

holds the class name, set via registration with the DeviceDriver registry

Reimplemented in ImageStreamDriver, and PListSensorDriver.

Definition at line 70 of file DataStreamDriver.h.

plist::Primitive<std::string> commName

The name of the comm port from which data will be read.

Definition at line 29 of file DataStreamDriver.h.

Referenced by advance(), connect(), DataStreamDriver(), deregisterSource(), disconnect(), nextTimestamp(), ImageStreamDriver::plistValueChanged(), plistValueChanged(), registerSource(), and run().

unsigned int frameNumber [protected]

image frame number

Definition at line 63 of file DataStreamDriver.h.

Referenced by ImageStreamDriver::readImage().

If set to false, the driver will attempt to detect and run through any backlog on the comm port; if true, the driver will process each image in turn, enforcing SourceFPS.

This mainly comes up if you do something like 'mkfifo pipe; cat *.jpg > pipe', and then open 'pipe' as the input for ImageStreamDriver... if paceInput is turned off, you'll only get the last image. However, using PaceInput on 'live' sources may cause a backlog to form.

Definition at line 38 of file DataStreamDriver.h.

Referenced by DataStreamDriver(), PListSensorDriver::readData(), ImageStreamDriver::readData(), and run().

bool realtime [protected]

true if enteringRealtime has been called more recently than leavingRealtime

Definition at line 66 of file DataStreamDriver.h.

Referenced by connect(), doFreeze(), doUnfreeze(), and plistValueChanged().

bool registered [protected]

true if registerSource has been called and deregisterSource has not

Definition at line 65 of file DataStreamDriver.h.

Referenced by deregisterSource(), and registerSource().

The expected source framerate, used to regulate buffering.

Definition at line 32 of file DataStreamDriver.h.

Referenced by advance(), connect(), DataStreamDriver(), disconnect(), doFreeze(), doUnfreeze(), nextTimestamp(), plistValueChanged(), and run().

unsigned int timestamp [protected]

timestamp of last data received

Definition at line 62 of file DataStreamDriver.h.

Referenced by advance(), nextTimestamp(), PListSensorDriver::readData(), and ImageStreamDriver::readImage().


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

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:41 2016 by Doxygen 1.6.3