From 35b478f791b8a0be285b8b2a0b4529a8e2df8964 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Wed, 20 Nov 2019 15:15:58 -0500 Subject: [PATCH] Fixed issue with datetime formatting in ALL.txt and duplicate entries in ALL.txt --- mainwindow.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index aa059d1..65a76f7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4697,27 +4697,8 @@ void MainWindow::processDecodedLine(QByteArray t){ } } - QFile f {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")}; - if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { - QTextStream out(&f); - if(m_RxLog==1) { - out << DriftingDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") - << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " - << "JS8" << endl; - m_RxLog=0; - } - int n=t.length(); - auto logText = t.mid(0, n-2); - auto dt = DecodedText(logText, false, m_config.my_grid()); - out << logText << " " << dt.message() << endl; - f.close(); - } else { - MessageBox::warning_message (this, tr ("File Open Error") - , tr ("Cannot open \"%1\" for append: %2") - .arg (f.fileName ()).arg (f.errorString ())); - } - - DecodedText decodedtext {QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"}), "FT8" == m_mode && + auto rawText = QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"}); + DecodedText decodedtext {rawText, "FT8" == m_mode && ui->cbVHFcontest->isChecked(), m_config.my_grid ()}; bool bValidFrame = decodedtext.snr() >= rxSnrThreshold(decodedtext.submode()); @@ -4744,6 +4725,11 @@ void MainWindow::processDecodedLine(QByteArray t){ return; } + // log valid frames to ALL.txt (and correct their timestamp format) + auto date = DriftingDateTime::currentDateTimeUtc().toString("yyyy-MM-dd"); + auto time = rawText.left(2) + ":" + rawText.mid(2, 2) + ":" + rawText.mid(4, 2); + writeAllTxt(date + " " + time + rawText.mid(7) + " " + decodedtext.message(), decodedtext.bits()); + ActivityDetail d = {}; CallDetail cd = {}; CommandDetail cmd = {};