From e685643ece095f7df3a4772be86d7a4086a77dd3 Mon Sep 17 00:00:00 2001 From: Nigel Williams <8898943+nrw505@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:11:52 +1000 Subject: [PATCH] chore(cpn): clean up now-unused code from telemetry log replayer (#5477) --- companion/src/simulation/telemetrysimu.cpp | 34 ++-------------------- companion/src/simulation/telemetrysimu.h | 7 +---- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/companion/src/simulation/telemetrysimu.cpp b/companion/src/simulation/telemetrysimu.cpp index 312cdaf477d..960dbe510eb 100644 --- a/companion/src/simulation/telemetrysimu.cpp +++ b/companion/src/simulation/telemetrysimu.cpp @@ -307,8 +307,6 @@ TelemetrySimulator::LogPlaybackController::LogPlaybackController(Ui::TelemetrySi TelemetrySimulator::LogPlaybackController::sim = sim; TelemetrySimulator::LogPlaybackController::ui = ui; stepping = false; - logFileGpsCordsInDecimalFormat = false; - } QString convertFeetToMeters(QString input) @@ -413,7 +411,7 @@ QString convertItemValue(QString sourceUnit, QString destUnit, QString value) return value; } -QDateTime TelemetrySimulator::LogPlaybackController::parseTransmittterTimestamp(QString row) +QDateTime TelemetrySimulator::LogPlaybackController::parseTransmitterTimestamp(QString row) { QStringList rowParts = row.simplified().split(','); if (rowParts.size() < 2) { @@ -433,31 +431,6 @@ QDateTime TelemetrySimulator::LogPlaybackController::parseTransmittterTimestamp( return QDateTime::fromString(datePart + " " + timePart, format); } -void TelemetrySimulator::LogPlaybackController::checkGpsFormat() -{ - // sample the first record to check if cords are in decimal format - logFileGpsCordsInDecimalFormat = false; - if(csvRecords.count() > 1) { - QStringList keys = csvRecords[0].split(','); - if(keys.contains("GPS")) { - int gpsColIndex = keys.indexOf("GPS"); - QStringList firstRowVlues = csvRecords[1].split(','); - QString gpsSample = firstRowVlues[gpsColIndex]; - QStringList cords = gpsSample.simplified().split(' '); - if (cords.count() == 2) { - // frsky and TBS crossfire GPS sensor logs cords in decimal format with a precision of 6 places - // if this format is met there is no need to call convertDegMin later on when processing the file - QRegularExpression decimalCoordinateFormatRegex("^[-+]?\\d{1,2}[.]\\d{6}$"); - QRegularExpressionMatch latFormatMatch = decimalCoordinateFormatRegex.match(cords[0]); - QRegularExpressionMatch lonFormatMatch = decimalCoordinateFormatRegex.match(cords[1]); - if (lonFormatMatch.hasMatch() && latFormatMatch.hasMatch()) { - logFileGpsCordsInDecimalFormat = true; - } - } - } - } -} - void TelemetrySimulator::LogPlaybackController::calcLogFrequency() { // examine up to 20 rows to determine log frequency in seconds @@ -466,7 +439,7 @@ void TelemetrySimulator::LogPlaybackController::calcLogFrequency() QDateTime lastTime; for (int i = 2; (i < 21) && (i < csvRecords.count()); i++) { - QDateTime logTime = parseTransmittterTimestamp(csvRecords[i]); + QDateTime logTime = parseTransmitterTimestamp(csvRecords[i]); // ugh - no timespan in this Qt version double timeDiff = (logTime.toMSecsSinceEpoch() - lastTime.toMSecsSinceEpoch()) / 1000.0; if ((timeDiff > 0.09) && (timeDiff < logFrequency)) { @@ -530,7 +503,6 @@ void TelemetrySimulator::LogPlaybackController::loadLogFile() ui->replayRate->setEnabled(true); recordIndex = 1; calcLogFrequency(); - checkGpsFormat(); } ui->logFileLabel->setText(QFileInfo(logFileNameAndPath).fileName()); rewind(); @@ -593,7 +565,7 @@ void TelemetrySimulator::LogPlaybackController::updatePositionLabel(int32_t perc } } // format the transmitter date info - QDateTime transmitterTimestamp = parseTransmittterTimestamp(csvRecords[recordIndex]); + QDateTime transmitterTimestamp = parseTransmitterTimestamp(csvRecords[recordIndex]); QString format("yyyy-MM-dd hh:mm:ss.z"); ui->positionLabel->setText("Row " + QString::number(recordIndex) + " of " + QString::number(csvRecords.count() - 1) + "\n" + transmitterTimestamp.toString(format)); diff --git a/companion/src/simulation/telemetrysimu.h b/companion/src/simulation/telemetrysimu.h index b47ac648e8b..3df7719b483 100644 --- a/companion/src/simulation/telemetrysimu.h +++ b/companion/src/simulation/telemetrysimu.h @@ -106,15 +106,10 @@ class TelemetrySimulator : public QWidget void updatePositionLabel(int32_t percentage); void setUiDataValues(); double logFrequency; // in seconds - bool logFileGpsCordsInDecimalFormat; private: - QString convertGPSDate(QString input); - QString convertGPS(QString input); - double convertDegMin(QString input); - QDateTime parseTransmittterTimestamp(QString row); + QDateTime parseTransmitterTimestamp(QString row); void calcLogFrequency(); - void checkGpsFormat(); Ui::TelemetrySimulator * ui; TelemetrySimulator * sim;