chore(cpn): clean up now-unused code from telemetry log replayer (#5477)
This commit is contained in:
@@ -307,8 +307,6 @@ TelemetrySimulator::LogPlaybackController::LogPlaybackController(Ui::TelemetrySi
|
|||||||
TelemetrySimulator::LogPlaybackController::sim = sim;
|
TelemetrySimulator::LogPlaybackController::sim = sim;
|
||||||
TelemetrySimulator::LogPlaybackController::ui = ui;
|
TelemetrySimulator::LogPlaybackController::ui = ui;
|
||||||
stepping = false;
|
stepping = false;
|
||||||
logFileGpsCordsInDecimalFormat = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString convertFeetToMeters(QString input)
|
QString convertFeetToMeters(QString input)
|
||||||
@@ -413,7 +411,7 @@ QString convertItemValue(QString sourceUnit, QString destUnit, QString value)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime TelemetrySimulator::LogPlaybackController::parseTransmittterTimestamp(QString row)
|
QDateTime TelemetrySimulator::LogPlaybackController::parseTransmitterTimestamp(QString row)
|
||||||
{
|
{
|
||||||
QStringList rowParts = row.simplified().split(',');
|
QStringList rowParts = row.simplified().split(',');
|
||||||
if (rowParts.size() < 2) {
|
if (rowParts.size() < 2) {
|
||||||
@@ -433,31 +431,6 @@ QDateTime TelemetrySimulator::LogPlaybackController::parseTransmittterTimestamp(
|
|||||||
return QDateTime::fromString(datePart + " " + timePart, format);
|
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()
|
void TelemetrySimulator::LogPlaybackController::calcLogFrequency()
|
||||||
{
|
{
|
||||||
// examine up to 20 rows to determine log frequency in seconds
|
// examine up to 20 rows to determine log frequency in seconds
|
||||||
@@ -466,7 +439,7 @@ void TelemetrySimulator::LogPlaybackController::calcLogFrequency()
|
|||||||
QDateTime lastTime;
|
QDateTime lastTime;
|
||||||
for (int i = 2; (i < 21) && (i < csvRecords.count()); i++)
|
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
|
// ugh - no timespan in this Qt version
|
||||||
double timeDiff = (logTime.toMSecsSinceEpoch() - lastTime.toMSecsSinceEpoch()) / 1000.0;
|
double timeDiff = (logTime.toMSecsSinceEpoch() - lastTime.toMSecsSinceEpoch()) / 1000.0;
|
||||||
if ((timeDiff > 0.09) && (timeDiff < logFrequency)) {
|
if ((timeDiff > 0.09) && (timeDiff < logFrequency)) {
|
||||||
@@ -530,7 +503,6 @@ void TelemetrySimulator::LogPlaybackController::loadLogFile()
|
|||||||
ui->replayRate->setEnabled(true);
|
ui->replayRate->setEnabled(true);
|
||||||
recordIndex = 1;
|
recordIndex = 1;
|
||||||
calcLogFrequency();
|
calcLogFrequency();
|
||||||
checkGpsFormat();
|
|
||||||
}
|
}
|
||||||
ui->logFileLabel->setText(QFileInfo(logFileNameAndPath).fileName());
|
ui->logFileLabel->setText(QFileInfo(logFileNameAndPath).fileName());
|
||||||
rewind();
|
rewind();
|
||||||
@@ -593,7 +565,7 @@ void TelemetrySimulator::LogPlaybackController::updatePositionLabel(int32_t perc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// format the transmitter date info
|
// format the transmitter date info
|
||||||
QDateTime transmitterTimestamp = parseTransmittterTimestamp(csvRecords[recordIndex]);
|
QDateTime transmitterTimestamp = parseTransmitterTimestamp(csvRecords[recordIndex]);
|
||||||
QString format("yyyy-MM-dd hh:mm:ss.z");
|
QString format("yyyy-MM-dd hh:mm:ss.z");
|
||||||
ui->positionLabel->setText("Row " + QString::number(recordIndex) + " of " + QString::number(csvRecords.count() - 1)
|
ui->positionLabel->setText("Row " + QString::number(recordIndex) + " of " + QString::number(csvRecords.count() - 1)
|
||||||
+ "\n" + transmitterTimestamp.toString(format));
|
+ "\n" + transmitterTimestamp.toString(format));
|
||||||
|
|||||||
@@ -106,15 +106,10 @@ class TelemetrySimulator : public QWidget
|
|||||||
void updatePositionLabel(int32_t percentage);
|
void updatePositionLabel(int32_t percentage);
|
||||||
void setUiDataValues();
|
void setUiDataValues();
|
||||||
double logFrequency; // in seconds
|
double logFrequency; // in seconds
|
||||||
bool logFileGpsCordsInDecimalFormat;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString convertGPSDate(QString input);
|
QDateTime parseTransmitterTimestamp(QString row);
|
||||||
QString convertGPS(QString input);
|
|
||||||
double convertDegMin(QString input);
|
|
||||||
QDateTime parseTransmittterTimestamp(QString row);
|
|
||||||
void calcLogFrequency();
|
void calcLogFrequency();
|
||||||
void checkGpsFormat();
|
|
||||||
|
|
||||||
Ui::TelemetrySimulator * ui;
|
Ui::TelemetrySimulator * ui;
|
||||||
TelemetrySimulator * sim;
|
TelemetrySimulator * sim;
|
||||||
|
|||||||
Reference in New Issue
Block a user