1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

OP-1119 Added option to base log flight time on the time when log started, not when the board was booted.

This commit is contained in:
Fredrik Arvidsson 2013-12-01 21:22:58 +01:00
parent f37f6540a9
commit 2d3683d511
3 changed files with 36 additions and 2 deletions

View File

@ -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

View File

@ -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++;
}

View File

@ -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