diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp index 3c87d624c..8f411c45c 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -40,7 +40,7 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) : QDialog(parent) { - qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry"); + qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry"); qmlRegisterType("org.openpilot", 1, 0, "UAVOLogSettingsWrapper"); setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index b836d4813..e023e59e0 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -43,9 +43,10 @@ FlightLogManager::FlightLogManager(QObject *parent) : m_adjustExportedTimestamps(true) { ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pluginManager); - m_objectManager = pluginManager->getObject(); + m_objectManager = pluginManager->getObject(); Q_ASSERT(m_objectManager); m_telemtryManager = pluginManager->getObject(); @@ -62,7 +63,7 @@ FlightLogManager::FlightLogManager(QObject *parent) : Q_ASSERT(m_flightLogStatus); connect(m_flightLogStatus, SIGNAL(FlightChanged(quint16)), this, SLOT(updateFlightEntries(quint16))); - m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); + m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); Q_ASSERT(m_flightLogEntry); m_flightLogSettings = DebugLogSettings::GetInstance(m_objectManager); @@ -287,13 +288,14 @@ void FlightLogManager::exportToOPL(QString fileName) void FlightLogManager::exportToCSV(QString fileName) { QFile csvFile(fileName); + if (csvFile.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream csvStream(&csvFile); quint32 baseTime = 0; quint32 currentFlight = 0; csvStream << "Flight" << '\t' << "Flight Time" << '\t' << "Entry" << '\t' << "Data" << '\n'; - foreach (ExtendedDebugLogEntry *entry , m_logEntries) { - if(m_adjustExportedTimestamps && entry->getFlight() != currentFlight) { + foreach(ExtendedDebugLogEntry * entry, m_logEntries) { + if (m_adjustExportedTimestamps && entry->getFlight() != currentFlight) { currentFlight = entry->getFlight(); baseTime = entry->getFlightTime(); } @@ -308,8 +310,8 @@ void FlightLogManager::exportToCSV(QString fileName) void FlightLogManager::exportToXML(QString fileName) { QFile xmlFile(fileName); - if (xmlFile.open(QFile::WriteOnly | QFile::Truncate)) { + if (xmlFile.open(QFile::WriteOnly | QFile::Truncate)) { QXmlStreamWriter xmlWriter(&xmlFile); xmlWriter.setAutoFormatting(true); xmlWriter.setAutoFormattingIndent(4); @@ -320,8 +322,8 @@ void FlightLogManager::exportToXML(QString fileName) quint32 baseTime = 0; quint32 currentFlight = 0; - foreach (ExtendedDebugLogEntry *entry , m_logEntries) { - if(m_adjustExportedTimestamps && entry->getFlight() != currentFlight) { + foreach(ExtendedDebugLogEntry * entry, m_logEntries) { + if (m_adjustExportedTimestamps && entry->getFlight() != currentFlight) { currentFlight = entry->getFlight(); baseTime = entry->getFlightTime(); } @@ -381,31 +383,23 @@ void FlightLogManager::cancelExportLogs() } void FlightLogManager::loadSettings() -{ - -} +{} void FlightLogManager::saveSettings() -{ - -} +{} void FlightLogManager::resetSettings() { - foreach (UAVOLogSettingsWrapper *wrapper, m_uavoEntries) { + foreach(UAVOLogSettingsWrapper * wrapper, m_uavoEntries) { wrapper->setSetting(UAVOLogSettingsWrapper::DISABLED); } } void FlightLogManager::applySettingsToBoard() -{ - -} +{} void FlightLogManager::saveSettingsToBoard() -{ - -} +{} void FlightLogManager::updateFlightEntries(quint16 currentFlight) { @@ -426,8 +420,9 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight) void FlightLogManager::setupUAVOWrappers() { - foreach(QList objectList , m_objectManager->getObjects()) { - UAVObject* object = objectList.at(0); + foreach(QList objectList, m_objectManager->getObjects()) { + UAVObject *object = objectList.at(0); + if (!object->isMetaDataObject() && !object->isSettingsObject()) { m_uavoEntries.append(new UAVOLogSettingsWrapper(object)); qDebug() << objectList.at(0)->getName(); @@ -493,12 +488,13 @@ void ExtendedDebugLogEntry::toXML(QXmlStreamWriter *xmlWriter, quint32 baseTime) xmlWriter->writeAttribute("type", "uavobject"); m_object->toXML(xmlWriter); } - xmlWriter->writeEndElement(); //entry + xmlWriter->writeEndElement(); // entry } void ExtendedDebugLogEntry::toCSV(QTextStream *csvStream, quint32 baseTime) { QString data; + if (getType() == DebugLogEntry::TYPE_TEXT) { data = QString((const char *)getData().Data); } else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) { diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 0a747fab1..a8f91514e 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -43,16 +43,15 @@ #include "uavtalk/telemetrymanager.h" class UAVOLogSettingsWrapper : public QObject { - Q_OBJECT - Q_PROPERTY(QString name READ name NOTIFY nameChanged) + Q_OBJECT Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(int setting READ setting WRITE setSetting NOTIFY settingChanged) Q_PROPERTY(int period READ period WRITE setPeriod NOTIFY periodChanged) public: - enum UAVLogSetting {DISABLED = 0, ON_CHANGE, THROTTLED, PERIODICALLY}; + enum UAVLogSetting { DISABLED = 0, ON_CHANGE, THROTTLED, PERIODICALLY }; explicit UAVOLogSettingsWrapper(); - explicit UAVOLogSettingsWrapper(UAVObject* object); + explicit UAVOLogSettingsWrapper(UAVObject *object); ~UAVOLogSettingsWrapper(); QString name() const @@ -99,8 +98,7 @@ private: }; class ExtendedDebugLogEntry : public DebugLogEntry { - Q_OBJECT - Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated) + Q_OBJECT Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated) public: explicit ExtendedDebugLogEntry(); @@ -130,10 +128,9 @@ private: }; class FlightLogManager : public QObject { - Q_OBJECT - Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) - Q_PROPERTY(DebugLogControl *flightLogControl READ flightLogControl) - Q_PROPERTY(DebugLogSettings *flightLogSettings READ flightLogSettings) + Q_OBJECT Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) + Q_PROPERTY(DebugLogControl * flightLogControl READ flightLogControl) + Q_PROPERTY(DebugLogSettings * flightLogSettings READ flightLogSettings) Q_PROPERTY(QQmlListProperty logEntries READ logEntries NOTIFY logEntriesChanged) Q_PROPERTY(QStringList flightEntries READ flightEntries NOTIFY flightEntriesChanged) Q_PROPERTY(bool disableControls READ disableControls WRITE setDisableControls NOTIFY disableControlsChanged) @@ -155,7 +152,8 @@ public: QStringList flightEntries(); - QStringList logSettings() { + QStringList logSettings() + { return m_logSettings; } @@ -191,12 +189,12 @@ public: return m_logStatuses; } - DebugLogControl * flightLogControl() const + DebugLogControl *flightLogControl() const { return m_flightLogControl; } - DebugLogSettings * flightLogSettings() const + DebugLogSettings *flightLogSettings() const { return m_flightLogSettings; } @@ -269,7 +267,7 @@ private: DebugLogControl *m_flightLogControl; DebugLogStatus *m_flightLogStatus; DebugLogEntry *m_flightLogEntry; - DebugLogSettings * m_flightLogSettings; + DebugLogSettings *m_flightLogSettings; QList m_logEntries; QStringList m_flightEntries; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp index ebbfe1292..8dc5754e2 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp @@ -525,7 +525,7 @@ void UAVObject::toXML(QXmlStreamWriter *xmlWriter) xmlWriter->writeAttribute("name", getName()); xmlWriter->writeAttribute("id", QString("%1-%2").arg(getObjID(), 1, 16).toUpper().arg(getInstID())); xmlWriter->writeStartElement("fields"); - foreach(UAVObjectField* field , fields) { + foreach(UAVObjectField * field, fields) { field->toXML(xmlWriter); } xmlWriter->writeEndElement(); // fields diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp index 19ea0a563..235448a57 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp @@ -664,7 +664,7 @@ void UAVObjectField::toXML(QXmlStreamWriter *xmlWriter) } for (unsigned int n = 0; n < numElements; ++n) { xmlWriter->writeStartElement("value"); - if(getElementNames().size() > 1) { + if (getElementNames().size() > 1) { xmlWriter->writeAttribute("name", getElementNames().at(n)); } xmlWriter->writeCharacters(getValue(n).toString());