LogCompressor.h 2.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/****************************************************************************
 *
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once
pixhawk's avatar
pixhawk committed
11 12 13

#include <QThread>

14 15 16 17 18 19 20
/**
 * @file
 *   @brief Declaration of class LogCompressor.
 *          This class reads in a file containing messages and translates it into a tab-delimited CSV file.
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
 */

pixhawk's avatar
pixhawk committed
21 22
class LogCompressor : public QThread
{
23
    Q_OBJECT
pixhawk's avatar
pixhawk committed
24
public:
25
    /** @brief Create the log compressor. It will only get active upon calling startCompression() */
26
    LogCompressor(QString logFileName, QString outFileName="", QString delimiter="\t");
27 28
    /** @brief Start the compression of a raw, line-based logfile into a CSV file */
    void startCompression(bool holeFilling=false);
29 30
    bool isFinished();
    int getCurrentLine();
31

pixhawk's avatar
pixhawk committed
32
protected:
33 34 35 36 37 38 39
    void run();                     ///< This function actually performs the compression. It's an overloaded function from QThread
    QString logFileName;            ///< The input file name.
    QString outFileName;            ///< The output file name. If blank defaults to logFileName
    bool running;                   ///< True when the startCompression() function is operating.
    int currentDataLine;            ///< The current line of data that is being processed. Only relevant when running==true
    QString delimiter;              ///< Delimiter between fields in the output file. Defaults to tab ('\t')
    bool holeFillingEnabled;        ///< Enables the filling of holes in the dataset with the previous value (or NaN if none exists)
40 41 42

signals:
    /** @brief This signal is emitted once a logfile has been finished writing
43
     * @param fileName The name of the output (CSV) file
44 45
     */
    void finishedFile(QString fileName);
46 47 48 49 50 51 52 53
    
    /// This signal is connected to QGCApplication::showCriticalMessage to show critical errors which come from the thread.
    /// There is no need for clients to connect to this signal.
    void logProcessingCriticalError(const QString& title, const QString& msg);
    
private:
    void _signalCriticalError(const QString& msg);
    
pixhawk's avatar
pixhawk committed
54
};