Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef RQT_MULTIPLOT_CURVE_DATA_SEQUENCER_H
00020 #define RQT_MULTIPLOT_CURVE_DATA_SEQUENCER_H
00021
00022 #include <QLinkedList>
00023 #include <QMap>
00024 #include <QObject>
00025 #include <QPointF>
00026 #include <QVector>
00027
00028 #include <ros/time.h>
00029
00030 #include <rqt_multiplot/CurveConfig.h>
00031 #include <rqt_multiplot/MessageBroker.h>
00032
00033 namespace rqt_multiplot {
00034 class CurveDataSequencer :
00035 public QObject {
00036 Q_OBJECT
00037 public:
00038 CurveDataSequencer(QObject* parent = 0);
00039 virtual ~CurveDataSequencer();
00040
00041 void setConfig(CurveConfig* config);
00042 CurveConfig* getConfig() const;
00043 void setBroker(MessageBroker* broker);
00044 MessageBroker* getBroker() const;
00045 bool isSubscribed() const;
00046
00047 void subscribe();
00048 void unsubscribe();
00049
00050 signals:
00051 void subscribed();
00052 void pointReceived(const QPointF& point);
00053 void unsubscribed();
00054
00055 private:
00056 class TimeValue {
00057 public:
00058 inline TimeValue(const ros::Time& time = ros::Time(),
00059 double value = 0.0) :
00060 time_(time),
00061 value_(value) {
00062 };
00063
00064 inline TimeValue(const TimeValue& src) :
00065 time_(src.time_),
00066 value_(src.value_) {
00067 };
00068
00069 inline bool operator==(const TimeValue& timeValue) const {
00070 return (time_ == timeValue.time_);
00071 };
00072
00073 inline bool operator>(const TimeValue& timeValue) const {
00074 return (time_ > timeValue.time_);
00075 };
00076
00077 inline bool operator<(const TimeValue& timeValue) const {
00078 return (time_ < timeValue.time_);
00079 };
00080
00081 ros::Time time_;
00082 double value_;
00083 };
00084
00085 typedef QLinkedList<TimeValue> TimeValueList;
00086
00087 CurveConfig* config_;
00088
00089 MessageBroker* broker_;
00090
00091 QMap<CurveConfig::Axis, QString> subscribedTopics_;
00092 QMap<CurveConfig::Axis, QString> timeFields_;
00093 QMap<CurveConfig::Axis, TimeValueList> timeValues_;
00094
00095 void processMessage(const Message& message);
00096 void processMessage(CurveConfig::Axis axis, const Message& message);
00097 void interpolate();
00098
00099 private slots:
00100 void configAxisConfigChanged();
00101 void configSubscriberQueueSizeChanged(size_t queueSize);
00102
00103 void subscriberMessageReceived(const QString& topic, const
00104 Message& message);
00105 void subscriberXAxisMessageReceived(const QString& topic, const
00106 Message& message);
00107 void subscriberYAxisMessageReceived(const QString& topic, const
00108 Message& message);
00109 };
00110 };
00111
00112 #endif