dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
logfile.h
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 
27 #ifndef LOGFILE_H
28 #define LOGFILE_H
29 
30 #include <QIODevice>
31 #include <QTime>
32 #include <QTimer>
33 #include <QMutexLocker>
34 #include <QDebug>
35 #include <QBuffer>
37 #include <math.h>
38 
39 class LogFile : public QIODevice
40 {
41  Q_OBJECT
42 public:
43  explicit LogFile(QObject *parent = nullptr);
44  qint64 bytesAvailable() const;
45  qint64 bytesToWrite() const { return file.bytesToWrite(); }
46  bool open(OpenMode mode);
47  void setFileName(QString name) { file.setFileName(name); }
48  void close();
49  qint64 writeData(const char *data, qint64 dataSize);
50  qint64 readData(char *data, qint64 maxlen);
51 
52  bool startReplay();
53  bool stopReplay();
54 
55 public slots:
56  void setReplaySpeed(double val)
57  {
58  playbackSpeed = val;
59  qDebug() << "New playback speed: " << playbackSpeed;
60  }
61  void setReplayTime(double val);
62  void pauseReplay();
63  void resumeReplay();
64 
65 protected slots:
66  void timerFired();
67 
68 signals:
69  void readReady();
70  void replayStarted();
71  void replayFinished();
72 
73 protected:
74  QByteArray dataBuffer;
75  QTimer timer;
76  QTime myTime;
77  QFile file;
78  quint32 lastTimeStamp;
79  quint32 lastPlayTime;
80  QMutex mutex;
81 
83  double playbackSpeed;
84 
85 private:
86  QList<quint32> timestampBuffer;
87  QList<quint32> timestampPos;
88  quint32 timestampBufferIdx;
89  quint32 lastTimeStampPos;
90  quint32 firstTimestamp;
91 };
92 
93 #endif // LOGFILE_H
qint64 writeData(const char *data, qint64 dataSize)
Definition: logfile.cpp:170
QTimer timer
Definition: logfile.h:75
void setReplayTime(double val)
LogFile::setReplayTime, sets the playback time.
Definition: logfile.cpp:358
qint64 bytesAvailable() const
Definition: logfile.cpp:196
QTime myTime
Definition: logfile.h:76
QFile file
Definition: logfile.h:77
qint64 readData(char *data, qint64 maxlen)
Definition: logfile.cpp:187
bool open(OpenMode mode)
Definition: logfile.cpp:49
void replayStarted()
qint64 bytesToWrite() const
Definition: logfile.h:45
bool startReplay()
Definition: logfile.cpp:255
DataFields data
QByteArray dataBuffer
Definition: logfile.h:74
void timerFired()
Definition: logfile.cpp:201
void setReplaySpeed(double val)
Definition: logfile.h:56
bool stopReplay()
Definition: logfile.cpp:336
int lastPlayTimeOffset
Definition: logfile.h:82
double playbackSpeed
Definition: logfile.h:83
quint32 lastPlayTime
Definition: logfile.h:79
void setFileName(QString name)
Definition: logfile.h:47
void close()
Definition: logfile.cpp:160
QMutex mutex
Definition: logfile.h:80
void resumeReplay()
Definition: logfile.cpp:348
void pauseReplay()
Definition: logfile.cpp:343
quint32 lastTimeStamp
Definition: logfile.h:78
LogFile(QObject *parent=nullptr)
Definition: logfile.cpp:37
void replayFinished()
void readReady()