Files
gcs-nf/MavLinkNode/replay.h
T

89 lines
1.6 KiB
C++
Raw Normal View History

2020-08-19 14:12:36 +08:00
#ifndef REPLAY_H
#define REPLAY_H
#include <QObject>
#include "QThread"
#include "QMutex"
2020-08-19 14:12:36 +08:00
#include "QMessageBox"
#include "QDebug"
#include "QFile"
#include "replay.h"
#include "QDataStream"
2020-08-20 17:48:09 +08:00
#include "mavlink.h"
#include <QtEndian>
#include "QByteArray"
2020-08-19 14:12:36 +08:00
2020-08-20 17:48:09 +08:00
#ifdef QtMavlinkNode
#include <mavlinknodeglobal.h>
class MAVLINKNODESHARED_EXPORT Replay : public QObject {
2020-08-19 14:12:36 +08:00
#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();
2020-08-19 22:21:48 +08:00
void currentPercentage(float vlaue);
void replayComplete();
2020-08-19 14:12:36 +08:00
public slots:
//线程对外接口
void setRunFrq(uint32_t frq);
void start();
void stop();
bool isActive(void)
{
return running_flag;
}
2020-08-19 22:21:48 +08:00
//对外接口
void setLogfile(const QString name,float percent = 0);
void setPercentage(float value);
void startReplay(bool flag);
2020-08-19 14:12:36 +08:00
private slots:
//线程私有接口
void process();
protected:
bool running_flag = false;
2020-08-19 22:21:48 +08:00
bool isSleep = false;
2020-08-19 14:12:36 +08:00
quint32 running_frq = 200;//200Hz
QMutex mutex;
2020-08-19 14:12:36 +08:00
QThread *thread = nullptr;
QString logFile;
QFile *file = nullptr;
2020-08-19 22:21:48 +08:00
float percentage = 0.5;
2020-08-19 14:12:36 +08:00
int position = 0;
2020-08-19 22:21:48 +08:00
bool ispause = true;//控制暂停
2020-08-19 14:12:36 +08:00
bool isplaying = false;//控制开始和结束
QByteArray buff;
2020-08-19 14:12:36 +08:00
};
#endif // MAVLINKNODE_H