diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 0901aa8f4..4018e0e09 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -20,8 +20,10 @@ Rectangle { border.width: 1 radius: 4 ColumnLayout { + id: exportTab anchors.margins: 10 anchors.fill: parent + visible: true Text { Layout.fillWidth: true text: "" + qsTr("Log entries") + "" @@ -168,11 +170,64 @@ Rectangle { } } } + ColumnLayout { + id: settingsTab + visible: false + anchors.margins: 10 + anchors.fill: parent + Text { + Layout.fillWidth: true + text: "" + qsTr("Log entries") + "" + } + TableView { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredHeight: 1000; + model: logManager.uavoEntries + + TableViewColumn { + role: "Name"; + title: qsTr("UAVObject"); + width: 150; + delegate: + Text { + anchors.fill: parent + anchors.margins: 2 + anchors.leftMargin: 5 + font.pixelSize: 12 + text: styleData.value + } + + } + /* + TableViewColumn { + role: "Setting"; title: qsTr("Settings"); width: 150; + delegate: + ComboBox { + model: logManager.logSettings + } + } + */ + } + } } RowLayout { Layout.fillWidth: true height: 40 + Button { + id: settingsButton + enabled: !logManager.disableControls + text: qsTr("Log settings...") + activeFocusOnPress: true + property bool showSettings: false + onClicked: { + showSettings = !showSettings; + settingsTab.visible = showSettings; + exportTab.visible = !showSettings; + text = (showSettings ? qsTr("View logs...") : qsTr("Log settings...")); + } + } Rectangle { Layout.fillWidth: true } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp index 65f04f575..2397c744d 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -35,11 +35,13 @@ #include #include "flightlogmanager.h" +#include "uavobject.h" FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) : QDialog(parent) { qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry"); + qmlRegisterUncreatableType("org.openpilot", 1, 0, "UAVObject", ""); setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); setWindowTitle(tr("Manage flight side logs")); diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 60578532a..f34a931d5 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -57,6 +57,8 @@ FlightLogManager::FlightLogManager(QObject *parent) : Q_ASSERT(m_flightLogEntry); updateFlightEntries(m_flightLogStatus->getFlight()); + + updateUAVOS(); } FlightLogManager::~FlightLogManager() @@ -92,6 +94,32 @@ QQmlListProperty FlightLogManager::logEntries() return QQmlListProperty(this, &m_logEntries, &addLogEntries, &countLogEntries, &logEntryAt, &clearLogEntries); } +void addUAVOEntries(QQmlListProperty *list, UAVObject *entry) +{ + Q_UNUSED(list); + Q_UNUSED(entry); +} + +int countUAVOEntries(QQmlListProperty *list) +{ + return static_cast< QList *>(list->data)->size(); +} + +UAVObject *uavoEntryAt(QQmlListProperty *list, int index) +{ + return static_cast< QList *>(list->data)->at(index); +} + +void clearUAVOEntries(QQmlListProperty *list) +{ + return static_cast< QList *>(list->data)->clear(); +} + +QQmlListProperty FlightLogManager::uavoEntries() +{ + return QQmlListProperty(this, &m_uavoEntries, &addUAVOEntries, &countUAVOEntries, &uavoEntryAt, &clearUAVOEntries); +} + QStringList FlightLogManager::flightEntries() { return m_flightEntries; @@ -274,6 +302,18 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight) } } +void FlightLogManager::updateUAVOS() +{ + foreach(QList objectList , m_objectManager->getObjects()) { + UAVObject* object = objectList.at(0); + if (!object->isMetaDataObject() && !object->isSettingsObject()) { + m_uavoEntries.append(object); + qDebug() << objectList.at(0)->getName(); + } + } + emit uavoEntriesChanged(); +} + ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(), m_object(0) {} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index af01dd7e7..4458c4cc3 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -39,7 +39,8 @@ #include "debuglogcontrol.h" 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(); @@ -67,18 +68,25 @@ private: }; class FlightLogManager : public QObject { - Q_OBJECT Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) + Q_OBJECT + Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) 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) Q_PROPERTY(bool disableExport READ disableExport WRITE setDisableExport NOTIFY disableExportChanged) Q_PROPERTY(bool adjustExportedTimestamps READ adjustExportedTimestamps WRITE setAdjustExportedTimestamps NOTIFY adjustExportedTimestampsChanged) + Q_PROPERTY(QQmlListProperty uavoEntries READ uavoEntries NOTIFY uavoEntriesChanged) + Q_PROPERTY(QStringList logSettings READ logSettings NOTIFY logSettingsChanged) + + public: explicit FlightLogManager(QObject *parent = 0); ~FlightLogManager(); QQmlListProperty logEntries(); + QQmlListProperty uavoEntries(); + QStringList flightEntries(); DebugLogStatus *flightLogStatus() const @@ -103,9 +111,18 @@ public: return m_adjustExportedTimestamps; } + QStringList logSettings() const + { + return m_logSettings; + } + signals: void logEntriesChanged(); void flightEntriesChanged(); + + void uavoEntriesChanged(); + void logSettingsChanged(); + void disableControlsChanged(bool arg); void disableExportChanged(bool arg); @@ -143,15 +160,20 @@ public slots: private slots: void updateFlightEntries(quint16 currentFlight); + void updateUAVOS(); private: UAVObjectManager *m_objectManager; DebugLogControl *m_flightLogControl; DebugLogStatus *m_flightLogStatus; DebugLogEntry *m_flightLogEntry; + QList m_logEntries; QStringList m_flightEntries; + QList m_uavoEntries; + QStringList m_logSettings; + static const int UAVTALK_TIMEOUT = 4000; bool m_disableControls; bool m_disableExport; diff --git a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp index 74239e5c6..749038014 100644 --- a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp +++ b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp @@ -230,7 +230,7 @@ void LoggingThread::retrieveSettings() QList< QList > objs = objMngr->getDataObjects(); for (int n = 0; n < objs.length(); ++n) { UAVDataObject *obj = objs[n][0]; - if (obj->isSettings()) { + if (obj->isSettingsObject()) { queue.enqueue(obj); } } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index 6d8e0fd7d..c4a670704 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -517,7 +517,7 @@ bool VehicleConfigurationHelper::saveChangesToController(bool save) m_transactionOK = false; UAVDataObject *obj = objPair->first; QString objDescription = objPair->second; - if (UAVObject::GetGcsAccess(obj->getMetadata()) != UAVObject::ACCESS_READONLY && obj->isSettings()) { + if (UAVObject::GetGcsAccess(obj->getMetadata()) != UAVObject::ACCESS_READONLY && obj->isSettingsObject()) { emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, objDescription); m_currentTransactionObjectID = obj->getObjID(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp index f1665bd59..ee835daf6 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp @@ -99,7 +99,7 @@ void UAVObjectTreeModel::newObject(UAVObject *obj) void UAVObjectTreeModel::addDataObject(UAVDataObject *obj) { - TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree; + TopTreeItem *root = obj->isSettingsObject() ? m_settingsTree : m_nonSettingsTree; TreeItem *parent = root; @@ -461,7 +461,7 @@ ObjectTreeItem *UAVObjectTreeModel::findObjectTreeItem(UAVObject *object) DataObjectTreeItem *UAVObjectTreeModel::findDataObjectTreeItem(UAVDataObject *obj) { - TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree; + TopTreeItem *root = obj->isSettingsObject() ? m_settingsTree : m_nonSettingsTree; return root->findDataObjectTreeItemByObjectId(obj->getObjID()); } @@ -471,7 +471,7 @@ MetaObjectTreeItem *UAVObjectTreeModel::findMetaObjectTreeItem(UAVMetaObject *ob UAVDataObject *dataObject = qobject_cast(obj->getParentObject()); Q_ASSERT(dataObject); - TopTreeItem *root = dataObject->isSettings() ? m_settingsTree : m_nonSettingsTree; + TopTreeItem *root = dataObject->isSettingsObject() ? m_settingsTree : m_nonSettingsTree; return root->findMetaObjectTreeItemByObjectId(obj->getObjID()); } diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.cpp index 8a74eb97f..aaefd9926 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.cpp @@ -30,40 +30,40 @@ /** * Constructor */ -UAVDataObject::UAVDataObject(quint32 objID, bool isSingleInst, bool isSet, const QString & name) : +UAVDataObject::UAVDataObject(quint32 objID, bool isSingleInst, bool isSettings, const QString & name) : UAVObject(objID, isSingleInst, name) { - mobj = NULL; - this->isSet = isSet; + m_metaObject = NULL; + this->m_isSettings = isSettings; } /** * Initialize instance ID and assign a metaobject */ -void UAVDataObject::initialize(quint32 instID, UAVMetaObject *mobj) +void UAVDataObject::initialize(quint32 instID, UAVMetaObject *metaObject) { QMutexLocker locker(mutex); - this->mobj = mobj; + this->m_metaObject = metaObject; UAVObject::initialize(instID); } /** * Assign a metaobject */ -void UAVDataObject::initialize(UAVMetaObject *mobj) +void UAVDataObject::initialize(UAVMetaObject *metaObject) { QMutexLocker locker(mutex); - this->mobj = mobj; + this->m_metaObject = metaObject; } /** * Returns true if this is a data object holding module settings */ -bool UAVDataObject::isSettings() +bool UAVDataObject::isSettingsObject() { - return isSet; + return m_isSettings; } /** @@ -71,8 +71,8 @@ bool UAVDataObject::isSettings() */ void UAVDataObject::setMetadata(const Metadata & mdata) { - if (mobj != NULL) { - mobj->setData(mdata); + if (m_metaObject != NULL) { + m_metaObject->setData(mdata); } } @@ -81,8 +81,8 @@ void UAVDataObject::setMetadata(const Metadata & mdata) */ UAVObject::Metadata UAVDataObject::getMetadata(void) { - if (mobj != NULL) { - return mobj->getData(); + if (m_metaObject != NULL) { + return m_metaObject->getData(); } else { return getDefaultMetadata(); } @@ -93,5 +93,10 @@ UAVObject::Metadata UAVDataObject::getMetadata(void) */ UAVMetaObject *UAVDataObject::getMetaObject() { - return mobj; + return m_metaObject; +} + +bool UAVDataObject::isDataObject() +{ + return true; } diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.h b/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.h index fc679b7e1..34ca83569 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavdataobject.h @@ -38,19 +38,21 @@ class UAVOBJECTS_EXPORT UAVDataObject : public UAVObject { Q_OBJECT public: - UAVDataObject(quint32 objID, bool isSingleInst, bool isSet, const QString & name); - void initialize(quint32 instID, UAVMetaObject *mobj); - void initialize(UAVMetaObject *mobj); - bool isSettings(); + UAVDataObject(quint32 objID, bool isSingleInst, bool isSettingsObject, const QString & name); + void initialize(quint32 instID, UAVMetaObject *metaObject); + void initialize(UAVMetaObject *metaObject); void setMetadata(const Metadata & mdata); Metadata getMetadata(); UAVMetaObject *getMetaObject(); virtual UAVDataObject *clone(quint32 instID = 0) = 0; virtual UAVDataObject *dirtyClone() = 0; + bool isSettingsObject(); + bool isDataObject(); + private: - UAVMetaObject *mobj; - bool isSet; + UAVMetaObject *m_metaObject; + bool m_isSettings; }; #endif // UAVDATAOBJECT_H diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp index 80e4d5ed6..5c7d2755d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp @@ -107,3 +107,8 @@ UAVObject::Metadata UAVMetaObject::getData() return parentMetadata; } + +bool UAVMetaObject::isMetaDataObject() +{ + return true; +} diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.h b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.h index ef3be6a00..0c622ba90 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.h @@ -43,6 +43,8 @@ public: void setData(const Metadata & mdata); Metadata getData(); + bool isMetaDataObject(); + private: UAVObject *parent; Metadata ownMetadata; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp index 90a42be9e..200d4900d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp @@ -535,6 +535,21 @@ void UAVObject::emitNewInstance(UAVObject *obj) emit newInstance(obj); } +bool UAVObject::isSettingsObject() +{ + return false; +} + +bool UAVObject::isDataObject() +{ + return false; +} + +bool UAVObject::isMetaDataObject() +{ + return false; +} + /** * Initialize a UAVObjMetadata object. * \param[in] metadata The metadata object diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h index 9c34271c0..fd40c2940 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h @@ -54,6 +54,7 @@ class UAVOBJECTS_EXPORT UAVObject : public QObject { Q_OBJECT public: + Q_PROPERTY(QString Name READ getName) /** * Object update mode @@ -130,6 +131,10 @@ public: void emitTransactionCompleted(bool success); void emitNewInstance(UAVObject *); + virtual bool isSettingsObject(); + virtual bool isDataObject(); + virtual bool isMetaDataObject(); + // Metadata accessors static void MetadataInitialize(Metadata & meta); static AccessMode GetFlightAccess(const Metadata & meta); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp index eb421b9ef..454743191 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp @@ -114,7 +114,7 @@ void SmartSaveButton::processOperation(QPushButton *button, bool save) sv_result = false; current_objectID = obj->getObjID(); - if (save && (obj->isSettings())) { + if (save && (obj->isSettingsObject())) { for (int i = 0; i < 3; ++i) { qDebug() << "Saving" << obj->getName() << "to board."; connect(utilMngr, SIGNAL(saveCompleted(int, bool)), this, SLOT(saving_finished(int, bool))); diff --git a/ground/openpilotgcs/src/plugins/uavsettingsimportexport/uavsettingsimportexportfactory.cpp b/ground/openpilotgcs/src/plugins/uavsettingsimportexport/uavsettingsimportexportfactory.cpp index e3b058fae..b1d803aa3 100644 --- a/ground/openpilotgcs/src/plugins/uavsettingsimportexport/uavsettingsimportexportfactory.cpp +++ b/ground/openpilotgcs/src/plugins/uavsettingsimportexport/uavsettingsimportexportfactory.cpp @@ -276,8 +276,8 @@ QString UAVSettingsImportExportFactory::createXMLDocument(const enum storedData QList< QList > objList = objManager->getDataObjects(); foreach(QList list, objList) { foreach(UAVDataObject * obj, list) { - if (((what == Settings) && obj->isSettings()) || - ((what == Data) && !obj->isSettings()) || + if (((what == Settings) && obj->isSettingsObject()) || + ((what == Data) && !obj->isSettingsObject()) || (what == Both)) { // add each object to the XML QDomElement o = doc.createElement("object"); @@ -319,7 +319,7 @@ QString UAVSettingsImportExportFactory::createXMLDocument(const enum storedData } // append to the settings or data element - if (obj->isSettings()) { + if (obj->isSettingsObject()) { settings.appendChild(o); } else { data.appendChild(o); diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp index ad1148654..b488dc9b9 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp @@ -78,7 +78,7 @@ void TelemetryMonitor::startRetrievingObjects() if (mobj != NULL) { queue.enqueue(obj); } else if (dobj != NULL) { - if (dobj->isSettings()) { + if (dobj->isSettingsObject()) { queue.enqueue(obj); } else { if (UAVObject::GetFlightTelemetryUpdateMode(mdata) == UAVObject::UPDATEMODE_ONCHANGE) {