From 6a9bd48442e9be1d828e54078fa117fae0cfe9f3 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 17 Mar 2019 18:30:10 -0400 Subject: [PATCH] Change formatting of CANAnalyzer ASC saving to hopefully better match the "Real" program's output --- framefileio.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/framefileio.cpp b/framefileio.cpp index 0e35579..f287c2f 100644 --- a/framefileio.cpp +++ b/framefileio.cpp @@ -708,6 +708,11 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector* fr { QFile *outFile = new QFile(filename); int lineCounter = 0; + uint64_t offsetTime = frames->at(0).timestamp; + for (int c = 0; c < frames->count(); c++) + { + if (frames->at(c).timestamp < offsetTime) offsetTime = frames->at(c).timestamp; + } if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -717,7 +722,12 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector* fr QDateTime now; now = QDateTime::currentDateTime(); - outFile->write("date " + now.toString("MMM-dd HH:mm:ss.zzz").toUtf8()); + if (offsetTime > 10000000000) //chances are the input file had times as system time so load it + { + now.setMSecsSinceEpoch(offsetTime / 1000); //offsetTime was in microseconds + } + outFile->write("date " + now.toString("ddd MMM dd h:mm:ss.zzz a yyyy").toUtf8()); + outFile->write("\nbase hex timestamps absolute\n"); outFile->write("no internal event logging\n"); outFile->write("// version 11.0.0\n"); @@ -731,7 +741,7 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector* fr lineCounter = 0; } - outFile->write(QString::number(frames->at(c).timestamp / 1000000.0, 'f', 6).toUtf8()); + outFile->write(QString::number((frames->at(c).timestamp - offsetTime) / 1000000.0, 'f', 5).toUtf8()); outFile->putChar(' '); outFile->write(QString::number(frames->at(c).bus).toUtf8()); outFile->write(" ");