1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-08 19:46:06 +01:00
LibrePilot/ground/openpilotgcs/src/plugins/logging/logfile.h
edouard 823f814d85 OP-330 Log replay does not crash at the end anymore.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3039 ebee16cc-31ac-478f-84a7-5cbb03baadba
2011-03-13 22:27:26 +00:00

57 lines
1.2 KiB
C++

#ifndef LOGFILE_H
#define LOGFILE_H
#include <QIODevice>
#include <QTime>
#include <QTimer>
#include <QMutexLocker>
#include <QDebug>
#include <QBuffer>
#include "uavobjectmanager.h"
#include <math.h>
class LogFile : public QIODevice
{
Q_OBJECT
public:
explicit LogFile(QObject *parent = 0);
qint64 bytesAvailable() const;
qint64 bytesToWrite() { return file.bytesToWrite(); };
bool open(OpenMode mode);
void setFileName(QString name) { file.setFileName(name); };
void close();
qint64 writeData(const char * data, qint64 dataSize);
qint64 readData(char * data, qint64 maxlen);
bool startReplay();
bool stopReplay();
public slots:
void setReplaySpeed(double val) { playbackSpeed = pow(10,(val)/100); qDebug() << playbackSpeed; };
void pauseReplay();
void resumeReplay();
protected slots:
void timerFired();
signals:
void readReady();
void replayStarted();
void replayFinished();
protected:
QByteArray dataBuffer;
QTimer timer;
QTime myTime;
QFile file;
qint32 lastTimeStamp;
QMutex mutex;
int timeOffset;
int pausedTime;
double playbackSpeed;
};
#endif // LOGFILE_H