DataStreamDriver.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_DataStreamDriver_h_
00003 #define INCLUDED_DataStreamDriver_h_
00004
00005 #include "local/DeviceDriver.h"
00006 #include "local/DataSource.h"
00007 #include "local/CommPort.h"
00008
00009
00010 class DataStreamDriver : public virtual DeviceDriver, public DataSource, public virtual plist::PrimitiveListener, protected Thread {
00011 public:
00012 explicit DataStreamDriver(const std::string& className, const std::string& localName)
00013 : DeviceDriver(className,localName), DataSource(),
00014 commName(), srcFrameRate(0), paceInput(false),
00015 timestamp(0), frameNumber(0), registered(false), realtime(false)
00016 {
00017 addEntry("CommPort",commName,"The name of the comm port from which data will be read.");
00018 addEntry("SourceFPS",srcFrameRate,"The expected source framerate, used to regulate buffering");
00019 addEntry("PaceInput",paceInput,"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.\nThis 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.\nHowever, using PaceInput on 'live' sources may cause a backlog to form.");
00020 }
00021
00022 virtual unsigned int nextTimestamp();
00023 virtual const std::string& nextName() { return instanceName; }
00024 virtual bool advance();
00025 virtual void registerSource();
00026 virtual void deregisterSource();
00027
00028
00029 plist::Primitive<std::string> commName;
00030
00031
00032 plist::Primitive<float> srcFrameRate;
00033
00034
00035
00036
00037
00038 plist::Primitive<bool> paceInput;
00039
00040 protected:
00041 virtual void plistValueChanged(const plist::PrimitiveBase& pl);
00042
00043 virtual void* run();
00044
00045 void doFreeze();
00046 void doUnfreeze();
00047
00048
00049
00050
00051 virtual bool readData(std::istream& is)=0;
00052
00053
00054 virtual CommPort * getComm(const std::string& name) { return CommPort::getRegistry().getInstance(name); }
00055
00056 virtual void connect(CommPort* comm);
00057
00058 virtual void disconnect(CommPort* comm);
00059
00060 virtual bool requestFrame(CommPort& comm) { return false; }
00061
00062 unsigned int timestamp;
00063 unsigned int frameNumber;
00064
00065 bool registered;
00066 bool realtime;
00067
00068 private:
00069
00070 static const std::string autoRegisterDriver;
00071 DataStreamDriver(const DataStreamDriver&);
00072 DataStreamDriver& operator=(const DataStreamDriver&);
00073 };
00074
00075
00076
00077
00078
00079
00080 #endif