91 lines
1.6 KiB
C++
91 lines
1.6 KiB
C++
#ifndef REPLAY_H
|
|
#define REPLAY_H
|
|
|
|
#include <QObject>
|
|
#include "QThread"
|
|
#include "QMutex"
|
|
#include "QMessageBox"
|
|
#include "QDebug"
|
|
#include "QFile"
|
|
#include "replay.h"
|
|
#include "QDataStream"
|
|
#include "mavlink.h"
|
|
#include <QtEndian>
|
|
#include "QByteArray"
|
|
|
|
#ifdef QtMavlinkNode
|
|
#include <mavlinknodeglobal.h>
|
|
class MAVLINKNODESHARED_EXPORT Replay : public QObject {
|
|
#else
|
|
class Replay : public QObject
|
|
{
|
|
#endif
|
|
Q_OBJECT
|
|
|
|
typedef struct {
|
|
qint32 max_size;
|
|
quint8 select;
|
|
QByteArray buff[2];
|
|
}_buffdef;
|
|
|
|
public:
|
|
explicit Replay(QObject *parent = nullptr);
|
|
~Replay();
|
|
|
|
|
|
QByteArray readAll(void);
|
|
|
|
signals:
|
|
void showMessage(const QString &message,int TimeOut = 0);
|
|
|
|
void readReady();
|
|
|
|
|
|
void currentPercentage(float vlaue);
|
|
void replayComplete();
|
|
|
|
|
|
public slots:
|
|
//线程对外接口
|
|
void setRunFrq(uint32_t frq);
|
|
void start();
|
|
void stop();
|
|
bool isActive(void)
|
|
{
|
|
return running_flag;
|
|
}
|
|
|
|
//对外接口
|
|
void setLogfile(const QString name,float percent = 0);
|
|
void setPercentage(float value);
|
|
void startReplay(bool flag);
|
|
void setMultiple(double value);
|
|
private slots:
|
|
//线程私有接口
|
|
void process();
|
|
|
|
protected:
|
|
|
|
bool running_flag = false;
|
|
bool isSleep = false;
|
|
quint32 running_frq = 200;//200Hz
|
|
QMutex mutex;
|
|
|
|
|
|
QThread *thread = nullptr;
|
|
QString logFile;
|
|
QFile *file = nullptr;
|
|
|
|
float percentage = 0.5;
|
|
int position = 0;
|
|
bool ispause = true;//控制暂停
|
|
bool isplaying = false;//控制开始和结束
|
|
QByteArray buff;
|
|
|
|
|
|
double multiple = 1000;
|
|
|
|
};
|
|
|
|
#endif // MAVLINKNODE_H
|