|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
10 #ifndef YARP_DEV_DATASOURCE_H
11 #define YARP_DEV_DATASOURCE_H
15 #if !defined(YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE)
19 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3
36 #ifndef DOXYGEN_SHOULD_SKIP_THIS
38 const int REPORT_TIME=5;
42 template <
class T>
class DataSource;
43 template <
class T>
class DataWriter;
44 template <
class T1,
class T2>
class DataSource2;
45 template <
class T1,
class T2>
class DataWriter2;
52 virtual ~DataSource() {}
53 virtual bool getDatum(T& datum) = 0;
63 IPreciselyTimed *pPrecTime;
76 IPreciselyTimed *pt=NULL) :
106 deltaT=
now-timePrevious;
118 if (
now-lastSpoke>REPORT_TIME)
120 yInfo(
"Read [%d] frames in %d[s], average period %.2lf[ms], min %.2lf[ms], max %.2lf[ms]\n",
123 (cumulativeT/counter)*1000,
124 minT*1000, maxT*1000);
133 T& datum = writer.
get();
135 dater.getDatum(datum);
139 stamp=pPrecTime->getLastInputStamp();
147 writer.
write(!canDrop);
153 template <
class T1,
class T2>
156 virtual ~DataSource2() {}
157 virtual bool getDatum(T1& datum1, T2& datum2) = 0;
161 template <
class T1,
class T2>
168 DataSource2<T1,T2>& dater;
175 DataSource2<T1,T2>& dater,
177 bool addStamp=
false) :
178 port1(port1), port2(port2), dater(dater), canDrop(canDrop),
185 void run()
override {
186 T1& datum1 = writer1.
get();
187 T2& datum2 = writer2.
get();
188 dater.getDatum(datum1,datum2);
194 writer1.
write(!canDrop);
195 writer2.
write(!canDrop);
200 #endif // DOXYGEN_SHOULD_SKIP_THIS
204 #endif // YARP_NO_DEPRECATED
206 #endif // YARP_DEV_DATASOURCE_H
yarp::rosmsg::std_msgs::Time Time
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
#define YARP_DEPRECATED
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Buffer outgoing data to a port.
A class that can be managed by another thread.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
A mini-server for network communication.
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
void attach(Port &port)
Set the Port to which objects will be written.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
The main, catch-all namespace for YARP.
T & get()
A synonym of PortWriterBuffer::prepare.
void write(bool forceStrict=false)
Try to write the last buffer returned by PortWriterBuffer::get.
#define YARP_COMPILER_WARNING(x)
Generate a warning at build time on supported compilers.
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
virtual void run()
Body to run - could be periodic or continuous.