From 2d3683d511e2ca2af1b92e0de25723ec28535b99 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sun, 1 Dec 2013 21:22:58 +0100 Subject: [PATCH] OP-1119 Added option to base log flight time on the time when log started, not when the board was booted. --- .../src/plugins/flightlog/FlightLogDialog.qml | 9 +++++++++ .../src/plugins/flightlog/flightlogmanager.cpp | 12 ++++++++++-- .../src/plugins/flightlog/flightlogmanager.h | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 33f917b18..9f33efebd 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -150,6 +150,15 @@ Rectangle { activeFocusOnPress: true onClicked: logManager.exportLogs() } + CheckBox { + id: exportRelativeTimeCB + enabled: !logManager.disableControls && !logManager.disableExport + text: qsTr("Adjust timestamps") + activeFocusOnPress: true + checked: logManager.adjustExportedTimestamps + onCheckedChanged: logManager.setAdjustExportedTimestamps(checked) + } + Button { id: clearButton enabled: !logManager.disableControls diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 764e5ef47..04bd822a4 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -37,7 +37,9 @@ #include "utils/logfile.h" FlightLogManager::FlightLogManager(QObject *parent) : - QObject(parent), m_disableControls(false), m_cancelDownload(false), m_disableExport(true) + QObject(parent), m_disableControls(false), + m_disableExport(true), m_cancelDownload(false), + m_adjustExportedTimestamps(true) { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -208,9 +210,14 @@ void FlightLogManager::exportLogs() fileName = fileName.replace(QString(".opl"), QString("%1.opl")); int currentEntry = 0; int currentFlight = 0; + quint32 adjustedBaseTime = 0; // Continue until all entries are exported while(currentEntry < m_logEntries.count()) { + if (m_adjustExportedTimestamps) { + adjustedBaseTime = m_logEntries[currentEntry]->getFlightTime(); + } + // Get current flight currentFlight = m_logEntries[currentEntry]->getFlight(); @@ -229,10 +236,11 @@ void FlightLogManager::exportLogs() // Only log uavobjects if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT) { // Set timestamp that should be logged for this entry - logFile.setNextTimeStamp(entry->getFlightTime()); + logFile.setNextTimeStamp(entry->getFlightTime() - adjustedBaseTime); // Use UAVTalk to log complete message to file uavTalk.sendObject(entry->uavObject(), false, false); + qDebug() << entry->getFlightTime() - adjustedBaseTime << "=" << entry->toStringBrief(); } currentEntry++; } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 2b53c3982..eb5915d07 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -72,6 +72,7 @@ class FlightLogManager : public QObject { Q_PROPERTY(QStringList flightEntries READ flightEntries NOTIFY flightEntriesChanged) Q_PROPERTY(bool disableControls READ disableControls WRITE setDisableControls NOTIFY disableControlsChanged) Q_PROPERTY(bool disableExport READ disableExport WRITE setDisableExport NOTIFY disableExportChanged) + Q_PROPERTY(bool adjustExportedTimestamps READ adjustExportedTimestamps WRITE setAdjustExportedTimestamps NOTIFY adjustExportedTimestampsChanged) public: explicit FlightLogManager(QObject *parent = 0); @@ -97,12 +98,19 @@ public: void clearLogList(); + bool adjustExportedTimestamps() const + { + return m_adjustExportedTimestamps; + } + signals: void logEntriesChanged(); void flightEntriesChanged(); void disableControlsChanged(bool arg); void disableExportChanged(bool arg); + void adjustExportedTimestampsChanged(bool arg); + public slots: void clearAllLogs(); void retrieveLogs(int flightToRetrieve = -1); @@ -125,6 +133,14 @@ public slots: } } + void setAdjustExportedTimestamps(bool arg) + { + if (m_adjustExportedTimestamps != arg) { + m_adjustExportedTimestamps = arg; + emit adjustExportedTimestampsChanged(arg); + } + } + private slots: void updateFlightEntries(quint16 currentFlight); @@ -140,6 +156,7 @@ private: bool m_disableControls; bool m_disableExport; bool m_cancelDownload; + bool m_adjustExportedTimestamps; }; #endif // FLIGHTLOGMANAGER_H