Commit 6ba5787c authored by Bryant Mairs's avatar Bryant Mairs

Refactored the LogCompressor. It wasn't properly handling certain message...

Refactored the LogCompressor. It wasn't properly handling certain message logging files that mixed messages (Issue #70).
One note is that this logger should work correctly as I've tested it, but could have some edge cases. It is pickier about the file format that it will sparse, but I don't know if the error-checking stuff from the old code would have actually worked. This can also be easily re-added.

This code is also much faster than the old stuff. From what I could tell it scanned through the log file at least twice, I think three times. It also copied a lot of data into memory instead of reading, processing, and writing one line at a time, so memory use should be much lower. Some memory leaks from the old code were also refactored out, so lifetime memory use should be down.
parent e2e1a38e
This diff is collapsed.
......@@ -8,29 +8,31 @@ class LogCompressor : public QThread
Q_OBJECT
public:
/** @brief Create the log compressor. It will only get active upon calling startCompression() */
LogCompressor(QString logFileName, QString outFileName="", int uasid = 0);
LogCompressor(QString logFileName, QString outFileName="", QString delimiter="\t");
/** @brief Start the compression of a raw, line-based logfile into a CSV file */
void startCompression(bool holeFilling=false);
bool isFinished();
int getDataLines();
int getCurrentLine();
protected:
void run();
QString logFileName;
QString outFileName;
bool running;
int currentDataLine;
int dataLines;
int uasid;
bool holeFillingEnabled; ///< Enables the filling of holes in the dataset with the previous value (or NaN if none exists)
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)
signals:
/** @brief This signal is emitted when there is a change in the status of the parsing algorithm. For instance if an error is encountered.
* @param status A status message
*/
void logProcessingStatusChanged(QString status);
/** @brief This signal is emitted once a logfile has been finished writing
* @param fileName The name out the output (CSV) file
* @param fileName The name of the output (CSV) file
*/
void logProcessingStatusChanged(QString);
void finishedFile(QString fileName);
};
#endif // LOGCOMPRESSOR_H
#endif // LOGCOMPRESSOR_H
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment