22 ******************************************************************************
33 *
44 * @file logfile.h
5- * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
5+ * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017-2018 .
66 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
77 * @see The GNU Public License (GPL) Version 3
88 *
3232#include < QTimer>
3333#include < QMutexLocker>
3434#include < QDebug>
35- #include < QBuffer>
3635#include < QFile>
36+ #include < QVector>
37+
38+ typedef enum { PLAYING, PAUSED, STOPPED } ReplayState;
3739
3840class QTCREATOR_UTILS_EXPORT LogFile : public QIODevice {
3941 Q_OBJECT
@@ -75,6 +77,8 @@ class QTCREATOR_UTILS_EXPORT LogFile : public QIODevice {
7577 m_providedTimeStamp = providedTimestamp;
7678 }
7779
80+ ReplayState getReplayState ();
81+
7882public slots:
7983 void setReplaySpeed (double val)
8084 {
@@ -83,36 +87,48 @@ public slots:
8387 };
8488 bool startReplay ();
8589 bool stopReplay ();
90+
91+ bool resumeReplay (quint32);
8692 bool pauseReplay ();
87- bool resumeReplay ();
93+ bool pauseReplayAndResetPosition ();
8894
8995protected slots:
9096 void timerFired ();
9197
9298signals:
93- void readReady ();
9499 void replayStarted ();
95- void replayFinished ();
100+ void replayFinished (); // Emitted on error during replay or when logfile disconnected
101+ void replayCompleted (); // Emitted at the end of normal logfile playback
102+ void playbackPositionChanged (quint32);
103+ void timesChanged (quint32, quint32);
96104
97105protected:
98106 QByteArray m_dataBuffer;
99107 QTimer m_timer;
100108 QTime m_myTime;
101109 QFile m_file;
102- qint32 m_previousTimeStamp;
103- qint32 m_nextTimeStamp;
110+ quint32 m_previousTimeStamp;
111+ quint32 m_nextTimeStamp;
104112 double m_lastPlayed;
105113 // QMutex wants to be mutable
106114 // http://stackoverflow.com/questions/25521570/can-mutex-locking-function-be-marked-as-const
107115 mutable QMutex m_mutex;
108116
109117 int m_timeOffset;
110118 double m_playbackSpeed;
111- bool paused ;
119+ ReplayState m_replayState ;
112120
113121private:
114122 bool m_useProvidedTimeStamp;
115123 qint32 m_providedTimeStamp;
124+ quint32 m_beginTimeStamp;
125+ quint32 m_endTimeStamp;
126+ quint32 m_timerTick;
127+ QVector<quint32> m_timeStamps;
128+ QVector<qint64> m_timeStampPositions;
129+
130+ bool buildIndex ();
131+ bool resetReplay ();
116132};
117133
118134#endif // LOGFILE_H
0 commit comments