QGCMAVLinkLogPlayer.h 1.81 KB
Newer Older
1 2 3 4 5 6 7
#ifndef QGCMAVLINKLOGPLAYER_H
#define QGCMAVLINKLOGPLAYER_H

#include <QWidget>
#include <QFile>

#include "MAVLinkProtocol.h"
8
#include "LinkInterface.h"
9
#include "MAVLinkSimulationLink.h"
10

11 12 13
namespace Ui
{
class QGCMAVLinkLogPlayer;
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
}

/**
 * @brief Replays MAVLink log files
 *
 * This class allows to replay MAVLink logs at varying speeds.
 * captured flights can be replayed, shown to others and analyzed
 * in-depth later on.
 */
class QGCMAVLinkLogPlayer : public QWidget
{
    Q_OBJECT

public:
    explicit QGCMAVLinkLogPlayer(MAVLinkProtocol* mavlink, QWidget *parent = 0);
    ~QGCMAVLinkLogPlayer();

public slots:
    /** @brief Replay the logfile */
    void play();
    /** @brief Pause the logfile */
    void pause();
36
    /** @brief Reset the logfile */
37
    bool reset(int packetIndex=0);
38 39 40 41
    /** @brief Select logfile */
    void selectLogFile();
    /** @brief Load log file */
    void loadLogFile(const QString& file);
42 43
    /** @brief Jump to a position in the logfile */
    void jumpToSliderVal(int slidervalue);
44 45 46 47
    /** @brief The logging mainloop */
    void logLoop();
    /** @brief Set acceleration factor in percent */
    void setAccelerationFactorInt(int factor);
48

49 50 51 52
signals:
    /** @brief Send ready bytes */
    void bytesReady(LinkInterface* link, const QByteArray& bytes);

53 54 55 56 57
protected:
    int lineCounter;
    int totalLines;
    quint64 startTime;
    quint64 endTime;
58 59
    quint64 currentStartTime;
    float accelerationFactor;
60
    MAVLinkProtocol* mavlink;
61
    MAVLinkSimulationLink* logLink;
62 63
    QFile logFile;
    QTimer loopTimer;
64
    int loopCounter;
65 66
    bool mavlinkLogFormat;
    int binaryBaudRate;
67 68
    static const int packetLen = MAVLINK_MAX_PACKET_LEN;
    static const int timeLen = sizeof(quint64);
69 70 71 72 73 74 75
    void changeEvent(QEvent *e);

private:
    Ui::QGCMAVLinkLogPlayer *ui;
};

#endif // QGCMAVLINKLOGPLAYER_H