From 7486263262f70bdbe5bbd3d765afa92a62be8321 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 28 Apr 2013 19:41:15 +0200 Subject: [PATCH 001/116] OP-963 made TelemetryMonitorWidget skinnable - moved telemetry monitor widget from coreplugin to new telemetry plugin - added a telemetry monitor gadget based on monitor widget. - cleaned up telemetry monitor widget and made it skinnable Dependencies have changed: - connection manager (in coreplugin) is now unaware of the telemetry monitor widget - the widget is added to the connection manager tray by the telemetry plugin - the telemetry plugin depends on coreplugin and uavtalk --- .../default_configurations/OpenPilotGCS.xml | 11 + .../plugins/coreplugin/connectionmanager.cpp | 51 +-- .../plugins/coreplugin/connectionmanager.h | 16 +- .../src/plugins/coreplugin/core.qrc | 1 - .../src/plugins/coreplugin/coreplugin.pro | 6 +- .../src/plugins/coreplugin/images/tx-rx.svg | 399 ------------------ .../src/plugins/coreplugin/mainwindow.cpp | 14 +- .../coreplugin/telemetrymonitorwidget.cpp | 176 -------- .../coreplugin/uavgadgetinstancemanager.cpp | 4 + .../plugins/coreplugin/workspacesettings.cpp | 14 +- .../plugins/coreplugin/workspacesettings.h | 1 + .../plugins/coreplugin/workspacesettings.ui | 123 +++--- ground/openpilotgcs/src/plugins/plugins.pro | 6 + .../plugins/telemetry/Telemetry.pluginspec | 11 + .../src/plugins/telemetry/images/tx-rx.svg | 397 +++++++++++++++++ .../src/plugins/telemetry/monitorgadget.cpp | 53 +++ .../src/plugins/telemetry/monitorgadget.h | 58 +++ .../telemetry/monitorgadgetconfiguration.cpp | 54 +++ .../telemetry/monitorgadgetconfiguration.h | 44 ++ .../telemetry/monitorgadgetfactory.cpp | 86 ++++ .../plugins/telemetry/monitorgadgetfactory.h | 55 +++ .../telemetry/monitorgadgetoptionspage.cpp | 107 +++++ .../telemetry/monitorgadgetoptionspage.h | 61 +++ .../src/plugins/telemetry/monitorwidget.cpp | 286 +++++++++++++ .../monitorwidget.h} | 51 ++- .../src/plugins/telemetry/telemetry.pri | 3 + .../src/plugins/telemetry/telemetry.pro | 29 ++ .../src/plugins/telemetry/telemetry.qrc | 5 + .../telemetry/telemetry_dependencies.pri | 3 + .../src/plugins/telemetry/telemetry_global.h | 39 ++ .../src/plugins/telemetry/telemetryplugin.cpp | 249 +++++++++++ .../src/plugins/telemetry/telemetryplugin.h | 47 +++ .../src/plugins/uavtalk/telemetrymanager.cpp | 16 +- .../src/plugins/uavtalk/telemetrymanager.h | 2 + .../src/plugins/uavtalk/telemetrymonitor.cpp | 8 +- .../src/plugins/uavtalk/uavtalk.pro | 8 +- 36 files changed, 1769 insertions(+), 725 deletions(-) delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/images/tx-rx.svg delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/telemetrymonitorwidget.cpp create mode 100644 ground/openpilotgcs/src/plugins/telemetry/Telemetry.pluginspec create mode 100644 ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.h create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.h create mode 100644 ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp rename ground/openpilotgcs/src/plugins/{coreplugin/telemetrymonitorwidget.h => telemetry/monitorwidget.h} (52%) create mode 100644 ground/openpilotgcs/src/plugins/telemetry/telemetry.pri create mode 100644 ground/openpilotgcs/src/plugins/telemetry/telemetry.pro create mode 100644 ground/openpilotgcs/src/plugins/telemetry/telemetry.qrc create mode 100644 ground/openpilotgcs/src/plugins/telemetry/telemetry_dependencies.pri create mode 100644 ground/openpilotgcs/src/plugins/telemetry/telemetry_global.h create mode 100644 ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp create mode 100644 ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml index bee98b3e0..0f33070ee 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml @@ -2512,6 +2512,17 @@ + + + + true + 0.0.0 + + + %%DATAPATH%%diagrams/default/system-health.svg + + + diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index db684e4c1..2decdb550 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -33,6 +33,7 @@ #include #include "qextserialport/src/qextserialenumerator.h" #include "qextserialport/src/qextserialport.h" + #include #include #include @@ -40,7 +41,8 @@ #include namespace Core { -ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack) : + +ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow) : QWidget(mainWindow), m_availableDevList(0), m_connectBtn(0), @@ -48,9 +50,6 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidge polling(true), m_mainWindow(mainWindow) { - // monitor widget - m_monitorWidget = new TelemetryMonitorWidget(this); - // device list m_availableDevList = new QComboBox; m_availableDevList->setMinimumWidth(120); @@ -65,16 +64,12 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidge QHBoxLayout *layout = new QHBoxLayout; layout->setSpacing(5); layout->setContentsMargins(5, 2, 5, 2); + setLayout(layout); - layout->addWidget(m_monitorWidget, 0, Qt::AlignVCenter); layout->addWidget(new QLabel(tr("Connections:")), 0, Qt::AlignVCenter); layout->addWidget(m_availableDevList, 0, Qt::AlignVCenter); layout->addWidget(m_connectBtn, 0, Qt::AlignVCenter); - setLayout(layout); - - modeStack->setCornerWidget(this, Qt::TopRightCorner); - QObject::connect(m_connectBtn, SIGNAL(clicked()), this, SLOT(onConnectClicked())); QObject::connect(m_availableDevList, SIGNAL(currentIndexChanged(int)), this, SLOT(onDeviceSelectionChanged(int))); @@ -89,9 +84,6 @@ ConnectionManager::~ConnectionManager() { disconnectDevice(); suspendPolling(); - if (m_monitorWidget) { - delete m_monitorWidget; - } } void ConnectionManager::init() @@ -102,6 +94,14 @@ void ConnectionManager::init() QObject::connect(ExtensionSystem::PluginManager::instance(), SIGNAL(aboutToRemoveObject(QObject *)), this, SLOT(aboutToRemoveObject(QObject *))); } + +// TODO needs documentation? +void ConnectionManager::addWidget(QWidget *widget) +{ + QHBoxLayout *l = (QHBoxLayout *) layout(); + l->insertWidget(0, widget, 0, Qt::AlignVCenter); +} + /** * Method called when the user clicks the "Connect" button */ @@ -135,11 +135,9 @@ bool ConnectionManager::connectDevice(DevListItem device) // signal interested plugins that we connected to the device emit deviceConnected(io_dev); - m_connectBtn->setText("Disconnect"); - m_availableDevList->setEnabled(false); - // tell the monitorwidget we're conneced - m_monitorWidget->connect(); + m_connectBtn->setText(tr("Disconnect")); + m_availableDevList->setEnabled(false); return true; } @@ -150,9 +148,6 @@ bool ConnectionManager::connectDevice(DevListItem device) */ bool ConnectionManager::disconnectDevice() { - // tell the monitor widget we're disconnected - m_monitorWidget->disconnect(); - if (!m_ioDev) { // apparently we are already disconnected: this can // happen if a plugin tries to force a disconnect whereas @@ -184,8 +179,10 @@ bool ConnectionManager::disconnectDevice() m_connectionDevice.connection = NULL; m_ioDev = NULL; + // signal interested plugins that we disconnected from the device emit deviceDisconnected(); - m_connectBtn->setText("Connect"); + + m_connectBtn->setText(tr("Connect")); m_availableDevList->setEnabled(true); return true; @@ -280,9 +277,6 @@ void ConnectionManager::telemetryConnected() if (reconnectCheck->isActive()) { reconnectCheck->stop(); } - - // tell the monitor we're connected - m_monitorWidget->connect(); } /** @@ -299,17 +293,6 @@ void ConnectionManager::telemetryDisconnected() } } } - - // tell the monitor we're disconnected - m_monitorWidget->disconnect(); -} - -/** - * Slot called when the telemetry rates are updated - */ -void ConnectionManager::telemetryUpdated(double txRate, double rxRate) -{ - m_monitorWidget->updateTelemetry(txRate, rxRate); } void ConnectionManager::reconnectSlot() diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h index 71eee425f..b886a3071 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h @@ -32,7 +32,6 @@ #include #include "mainwindow.h" #include "generalsettings.h" -#include "telemetrymonitorwidget.h" #include #include #include @@ -43,16 +42,11 @@ #include "core_global.h" #include -QT_BEGIN_NAMESPACE -class QTabWidget; -QT_END_NAMESPACE - namespace Core { + class IConnection; namespace Internal { -class FancyTabWidget; -class FancyActionBar; class MainWindow; } // namespace Internal @@ -86,7 +80,7 @@ class CORE_EXPORT ConnectionManager : public QWidget { Q_OBJECT public: - ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack); + ConnectionManager(Internal::MainWindow *mainWindow); virtual ~ConnectionManager(); void init(); @@ -111,6 +105,8 @@ public: return m_ioDev != 0; } + void addWidget(QWidget *widget); + bool connectDevice(DevListItem device); bool disconnectDevice(); void suspendPolling(); @@ -130,7 +126,6 @@ signals: public slots: void telemetryConnected(); void telemetryDisconnected(); - void telemetryUpdated(double txRate, double rxRate); private slots: void objectAdded(QObject *obj); @@ -151,9 +146,6 @@ protected: QLinkedList m_devList; QList m_connectionsList; - // tx/rx telemetry monitor - TelemetryMonitorWidget *m_monitorWidget; - // currently connected connection plugin DevListItem m_connectionDevice; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/core.qrc b/ground/openpilotgcs/src/plugins/coreplugin/core.qrc index 8a4418c53..bc34195ef 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/core.qrc +++ b/ground/openpilotgcs/src/plugins/coreplugin/core.qrc @@ -60,7 +60,6 @@ images/cog.png images/helpicon.svg images/cpu.png - images/tx-rx.svg qml/images/tab.png qml/ScrollDecorator.qml qml/TabWidget.qml diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 1631fda8f..f250fd484 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -70,8 +70,7 @@ SOURCES += mainwindow.cpp \ uavgadgetdecorator.cpp \ workspacesettings.cpp \ uavconfiginfo.cpp \ - authorsdialog.cpp \ - telemetrymonitorwidget.cpp + authorsdialog.cpp HEADERS += mainwindow.h \ tabpositionindicator.h \ @@ -132,8 +131,7 @@ HEADERS += mainwindow.h \ workspacesettings.h \ uavconfiginfo.h \ authorsdialog.h \ - iconfigurableplugin.h \ - telemetrymonitorwidget.h + iconfigurableplugin.h FORMS += dialogs/settingsdialog.ui \ dialogs/shortcutsettings.ui \ diff --git a/ground/openpilotgcs/src/plugins/coreplugin/images/tx-rx.svg b/ground/openpilotgcs/src/plugins/coreplugin/images/tx-rx.svg deleted file mode 100644 index e69e36e19..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/images/tx-rx.svg +++ /dev/null @@ -1,399 +0,0 @@ - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - Tx - Tx - Rx - - - - - - - - - - - - 0 b/s - - - - - - - - - - 0 b/s - - diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index d57393baf..8bd2982de 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -177,7 +177,8 @@ MainWindow::MainWindow() : #endif m_modeManager = new ModeManager(this, m_modeStack); - m_connectionManager = new ConnectionManager(this, m_modeStack); + m_connectionManager = new ConnectionManager(this); + m_modeStack->setCornerWidget(m_connectionManager, Qt::TopRightCorner); m_messageManager = new MessageManager; setCentralWidget(m_modeStack); @@ -1214,8 +1215,9 @@ void MainWindow::readSettings(QSettings *qs, bool workspaceDiffOnly) createWorkspaces(qs); - // Read tab ordering + // Restore tab ordering qs->beginGroup(QLatin1String(modePriorities)); + QStringList modeNames = qs->childKeys(); QMap map; foreach(QString modeName, modeNames) { @@ -1224,6 +1226,10 @@ void MainWindow::readSettings(QSettings *qs, bool workspaceDiffOnly) m_modeManager->reorderModes(map); qs->endGroup(); + + // Restore selected tab + int index = qs->value(QLatin1String("SelectedWorkspace")).toInt(); + m_modeStack->setCurrentIndex(index); } @@ -1262,12 +1268,16 @@ void MainWindow::saveSettings(QSettings *qs) } qs->endGroup(); + // Write selected tab + qs->setValue(QLatin1String("SelectedWorkspace"), m_modeStack->currentIndex()); + foreach(UAVGadgetManager * manager, m_uavGadgetManagers) { manager->saveSettings(qs); } m_actionManager->saveSettings(qs); m_generalSettings->saveSettings(qs); + qs->beginGroup("General"); qs->setValue("Description", m_config_description); qs->setValue("Details", m_config_details); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/telemetrymonitorwidget.cpp b/ground/openpilotgcs/src/plugins/coreplugin/telemetrymonitorwidget.cpp deleted file mode 100644 index 0463d68d2..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/telemetrymonitorwidget.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "telemetrymonitorwidget.h" - -#include -#include -#include -#include - -TelemetryMonitorWidget::TelemetryMonitorWidget(QWidget *parent) : QGraphicsView(parent) -{ - setMinimumSize(180, 25); // From 100->25 to shorten the qwidget. - setMaximumSize(180, 25); // as above. - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setAlignment(Qt::AlignCenter); - setFrameStyle(QFrame::NoFrame); - setStyleSheet("background:transparent;"); - setAttribute(Qt::WA_TranslucentBackground); - setWindowFlags(Qt::FramelessWindowHint); - - QGraphicsScene *scene = new QGraphicsScene(0, 0, 180, 25, this); // keeping the scene in line with the widget for testing. - - QSvgRenderer *renderer = new QSvgRenderer(); - if (renderer->load(QString(":/core/images/tx-rx.svg"))) { - graph = new QGraphicsSvgItem(); - graph->setSharedRenderer(renderer); - graph->setElementId("txrxBackground"); - - QString name; - QGraphicsSvgItem *pt; - - for (int i = 0; i < NODE_NUMELEM; i++) { - name = QString("tx%0").arg(i); - if (renderer->elementExists(name)) { - pt = new QGraphicsSvgItem(); - pt->setSharedRenderer(renderer); - pt->setElementId(name); - pt->setParentItem(graph); - txNodes.append(pt); - } - - name = QString("rx%0").arg(i); - if (renderer->elementExists(name)) { - pt = new QGraphicsSvgItem(); - pt->setSharedRenderer(renderer); - pt->setElementId(name); - pt->setParentItem(graph); - rxNodes.append(pt); - } - } - - scene->addItem(graph); - - txSpeed = new QGraphicsTextItem(); - txSpeed->setDefaultTextColor(Qt::white); - txSpeed->setFont(QFont("Helvetica", 22, 2)); - txSpeed->setParentItem(graph); - scene->addItem(txSpeed); - - rxSpeed = new QGraphicsTextItem(); - rxSpeed->setDefaultTextColor(Qt::white); - rxSpeed->setFont(QFont("Helvetica", 22, 2)); - rxSpeed->setParentItem(graph); - scene->addItem(rxSpeed); - - scene->setSceneRect(graph->boundingRect()); - setScene(scene); - } - - connected = false; - txValue = 0.0; - rxValue = 0.0; - - setMin(0.0); - setMax(1200.0); - - showTelemetry(); -} - -TelemetryMonitorWidget::~TelemetryMonitorWidget() -{ - while (!txNodes.isEmpty()) { - delete txNodes.takeFirst(); - } - - while (!rxNodes.isEmpty()) { - delete rxNodes.takeFirst(); - } -} - -void TelemetryMonitorWidget::connect() -{ - connected = true; - - // flash the lights - updateTelemetry(maxValue, maxValue); -} - -void TelemetryMonitorWidget::disconnect() -{ - // flash the lights - updateTelemetry(maxValue, maxValue); - - connected = false; - updateTelemetry(0.0, 0.0); -} -/*! - \brief Called by the UAVObject which got updated - - Updates the numeric value and/or the icon if the dial wants this. - */ -void TelemetryMonitorWidget::updateTelemetry(double txRate, double rxRate) -{ - txValue = txRate; - rxValue = rxRate; - - showTelemetry(); -} - -// Converts the value into an percentage: -// this enables smooth movement in moveIndex below -void TelemetryMonitorWidget::showTelemetry() -{ - txIndex = (txValue - minValue) / (maxValue - minValue) * NODE_NUMELEM; - rxIndex = (rxValue - minValue) / (maxValue - minValue) * NODE_NUMELEM; - - if (connected) { - this->setToolTip(QString("Tx: %0 bytes/sec\nRx: %1 bytes/sec").arg(txValue).arg(rxValue)); - } else { - this->setToolTip(QString("Disconnected")); - } - - int i; - int nodeMargin = 8; - int leftMargin = 60; - QGraphicsItem *node; - - for (i = 0; i < txNodes.count(); i++) { - node = txNodes.at(i); - node->setPos((i * (node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height() / 2) - 2); - node->setVisible(connected && i < txIndex); - node->update(); - } - - for (i = 0; i < rxNodes.count(); i++) { - node = rxNodes.at(i); - node->setPos((i * (node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height() * 2) - 2); - node->setVisible(connected && i < rxIndex); - node->update(); - } - - QRectF rect = graph->boundingRect(); - txSpeed->setPos(rect.right() - 110, rect.top()); - txSpeed->setPlainText(QString("%0").arg(txValue)); - txSpeed->setVisible(connected); - - rxSpeed->setPos(rect.right() - 110, rect.top() + (rect.height() / 2)); - rxSpeed->setPlainText(QString("%0").arg(rxValue)); - rxSpeed->setVisible(connected); - - update(); -} - -void TelemetryMonitorWidget::showEvent(QShowEvent *event) -{ - Q_UNUSED(event); - - fitInView(graph, Qt::KeepAspectRatio); -} - -void TelemetryMonitorWidget::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - - fitInView(graph, Qt::KeepAspectRatio); -} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp index 1aa28d890..e8431254d 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp @@ -238,6 +238,10 @@ void UAVGadgetInstanceManager::createOptionsPages() while (ite.hasNext()) { IUAVGadgetConfiguration *config = ite.next(); IUAVGadgetFactory *f = factory(config->classId()); + if (!f) { + qWarning() << "No gadget factory for configuration " + config->classId(); + continue; + } IOptionsPage *p = f->createOptionsPage(config); if (p) { IOptionsPage *page = new UAVGadgetOptionsPageDecorator(p, config, f->isSingleConfigurationGadget()); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp index 43d552f44..471faae1a 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp @@ -33,18 +33,19 @@ #include "ui_workspacesettings.h" - using namespace Core; using namespace Core::Internal; const int WorkspaceSettings::MAX_WORKSPACES = 10; WorkspaceSettings::WorkspaceSettings(QObject *parent) : - IOptionsPage(parent) -{} + IOptionsPage(parent) +{ +} WorkspaceSettings::~WorkspaceSettings() -{} +{ +} // IOptionsPage @@ -97,6 +98,7 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent) m_page->comboBoxTabBarPlacement->setCurrentIndex(m_tabBarPlacementIndex); } m_page->checkBoxAllowTabMovement->setChecked(m_allowTabBarMovement); + m_page->checkBoxRestoreSelectedOnStartup->setChecked(m_restoreSelectedOnStartup); return w; } @@ -122,7 +124,10 @@ void WorkspaceSettings::readSettings(QSettings *qs) } m_tabBarPlacementIndex = qs->value(QLatin1String("TabBarPlacementIndex"), 1).toInt(); // 1 == "Bottom" m_allowTabBarMovement = qs->value(QLatin1String("AllowTabBarMovement"), false).toBool(); + m_restoreSelectedOnStartup = qs->value(QLatin1String("RestoreSelectedOnStartup"), false).toBool(); + qs->endGroup(); + QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South; emit tabBarSettingsApplied(pos, m_allowTabBarMovement); } @@ -142,6 +147,7 @@ void WorkspaceSettings::saveSettings(QSettings *qs) } qs->setValue(QLatin1String("TabBarPlacementIndex"), m_tabBarPlacementIndex); qs->setValue(QLatin1String("AllowTabBarMovement"), m_allowTabBarMovement); + qs->setValue(QLatin1String("RestoreSelectedOnStartup"), m_restoreSelectedOnStartup); qs->endGroup(); } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h index 37d2897ae..101faefaf 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h @@ -98,6 +98,7 @@ private: int m_numberOfWorkspaces; int m_tabBarPlacementIndex; bool m_allowTabBarMovement; + bool m_restoreSelectedOnStartup; static const int MAX_WORKSPACES; }; } // namespace Internal diff --git a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui index 206f7acdd..4be345c22 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui +++ b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui @@ -47,62 +47,20 @@ 0 - - - - - 0 - 0 - - - - Details - - - - - - Icon: - - - - - - - - - - - - - Name: - - - - - - - Workspace panel + General - + Placement: - - - - Allow reordering: - - - - + @@ -125,14 +83,7 @@ - - - - - - - - + Qt::Horizontal @@ -145,6 +96,37 @@ + + + + Allow reordering: + + + + + + + + + + + + + + Restore last selected workspace on startup + + + Remember last used workspace on restart + + + + + + + + + + @@ -216,6 +198,41 @@ + + + + + 0 + 0 + + + + Details + + + + + + Icon: + + + + + + + + + + + + + Name: + + + + + + diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro index 20b402704..54a2660c0 100644 --- a/ground/openpilotgcs/src/plugins/plugins.pro +++ b/ground/openpilotgcs/src/plugins/plugins.pro @@ -49,6 +49,12 @@ plugin_uavtalk.subdir = uavtalk plugin_uavtalk.depends = plugin_uavobjects plugin_uavtalk.depends += plugin_coreplugin +# Telemetry plugin +SUBDIRS += plugin_telemetry +plugin_telemetry.subdir = telemetry +plugin_telemetry.depends += plugin_uavtalk +plugin_telemetry.depends += plugin_coreplugin + # OPMap UAVGadget plugin_opmap.subdir = opmap plugin_opmap.depends = plugin_coreplugin diff --git a/ground/openpilotgcs/src/plugins/telemetry/Telemetry.pluginspec b/ground/openpilotgcs/src/plugins/telemetry/Telemetry.pluginspec new file mode 100644 index 000000000..0a003600e --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/Telemetry.pluginspec @@ -0,0 +1,11 @@ + + The OpenPilot Project + (C) 2010 OpenPilot Project + The GNU Public License (GPL) Version 3 + UAVTalk telemetry protocol + http://www.openpilot.org + + + + + diff --git a/ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg b/ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg new file mode 100644 index 000000000..1dd94fbba --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + transform="translate(0,0)" + + + Tx + + + + + + + + Rx + + + + + + + + + + + + inkscape:label="txSpeed" /> + + inkscape:label="rxSpeed" /> + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp new file mode 100644 index 000000000..bdfc9506c --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp @@ -0,0 +1,53 @@ +/** + ****************************************************************************** + * + * @file monitorgadget.cpp + * @author Philippe Renon + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup MonitorPlugin Telemetry Plugin + * @{ + * @brief The Telemetry Monitor gadget + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "monitorgadget.h" +#include "monitorgadgetconfiguration.h" +#include "monitorwidget.h" + +MonitorGadget::MonitorGadget(QString classId, MonitorWidget *widget, QWidget *parent) : + IUAVGadget(classId, parent), m_widget(widget) +{ +} + +MonitorGadget::~MonitorGadget() +{ + delete m_widget; +} + +/* + This is called when a configuration is loaded, and updates the plugin's settings. + Careful: the plugin is already drawn before the loadConfiguration method is called the + first time, so you have to be careful not to assume all the plugin values are initialized + the first time you use them + */ +void MonitorGadget::loadConfiguration(IUAVGadgetConfiguration *config) +{ + MonitorGadgetConfiguration *m = qobject_cast(config); + + //m_widget->setSystemFile(m->getSystemFile()); // Triggers widget repaint +} diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h new file mode 100644 index 000000000..90f9dcb74 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h @@ -0,0 +1,58 @@ +/** + ****************************************************************************** + * + * @file monitorgadget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup telemetry + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MONITORGADGET_H +#define MONITORGADGET_H + +#include +#include "monitorwidget.h" + +//class IUAVGadget; +//class QWidget; +//class QString; +// class NotifyPluginGadgetWidget; + +using namespace Core; + +class MonitorGadget: public IUAVGadget { + Q_OBJECT +public: + MonitorGadget(QString classId, MonitorWidget *widget, QWidget *parent = 0); + ~MonitorGadget(); + + QWidget *widget() + { + return m_widget; + } + + void loadConfiguration(IUAVGadgetConfiguration *config); + +private: + MonitorWidget *m_widget; +}; + +#endif // MONITORGADGET_H diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp new file mode 100644 index 000000000..9c15744a8 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp @@ -0,0 +1,54 @@ +/** + ****************************************************************************** + * + * @file monitorgadgetconfiguration.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup TelemetryPlugin Telemetry Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "monitorgadgetconfiguration.h" + +MonitorGadgetConfiguration::MonitorGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) : + IUAVGadgetConfiguration(classId, parent) +{ + // if a saved configuration exists load it + if (qSettings != 0) { + } +} + +IUAVGadgetConfiguration *MonitorGadgetConfiguration::clone() +{ + MonitorGadgetConfiguration *mv = new MonitorGadgetConfiguration(this->classId()); + + return mv; +} + +/** + * Saves a configuration. + * + */ +void MonitorGadgetConfiguration::saveConfig(QSettings *qSettings) const +{ +// qSettings->setValue("acFilename", Utils::PathUtils().RemoveDataPath(m_acFilename)); +// qSettings->setValue("bgFilename", Utils::PathUtils().RemoveDataPath(m_bgFilename)); +// qSettings->setValue("enableVbo", m_enableVbo); +} diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.h b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.h new file mode 100644 index 000000000..20c570a78 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.h @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * + * @file monitorgadgetconfiguration.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup TelemetryPlugin Telemetry Plugin + * @{ + * @brief A gadget that displays telemetry connection speed monitoring + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MONITORGADGETCONFIGURATION_H +#define MONITORGADGETCONFIGURATION_H + +#include + +using namespace Core; + +class MonitorGadgetConfiguration : public IUAVGadgetConfiguration { + Q_OBJECT +public: + explicit MonitorGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0); + + void saveConfig(QSettings *settings) const; + IUAVGadgetConfiguration *clone(); +}; + +#endif // MONITORGADGETCONFIGURATION_H diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp new file mode 100644 index 000000000..6506ce521 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp @@ -0,0 +1,86 @@ +/** + ****************************************************************************** + * + * @file monitorgadgetfactory.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup telemetryplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "monitorgadgetfactory.h" +#include "uavtalk/telemetrymanager.h" +#include "extensionsystem/pluginmanager.h" +#include "monitorgadgetconfiguration.h" +#include "monitorgadget.h" +#include "monitorgadgetoptionspage.h" + +#include +#include + +MonitorGadgetFactory::MonitorGadgetFactory(QObject *parent) : + IUAVGadgetFactory(QString("TelemetryMonitorGadget"), tr("Telemetry Monitor"), parent) +{ +} + +MonitorGadgetFactory::~MonitorGadgetFactory() +{ +} + +Core::IUAVGadget *MonitorGadgetFactory::createGadget(QWidget *parent) +{ + MonitorWidget *widget = createMonitorWidget(parent); + + return new MonitorGadget(QString("TelemetryMonitorGadget"), widget, parent); +} + +MonitorWidget *MonitorGadgetFactory::createMonitorWidget(QWidget *parent) +{ + MonitorWidget *widget = new MonitorWidget(parent); + + // connect widget to telemetry manager + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + TelemetryManager *tm = pm->getObject(); + + connect(tm, SIGNAL(connected()), widget, SLOT(telemetryConnected())); + connect(tm, SIGNAL(disconnected()), widget, SLOT(telemetryDisconnected())); + connect(tm, SIGNAL(telemetryUpdated(double, double)), widget, SLOT(telemetryUpdated(double, double))); + + // and connect widget to connection manager (for retro compatibility) + Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); + + connect(cm, SIGNAL(deviceConnected(QIODevice *)), widget, SLOT(telemetryConnected())); + connect(cm, SIGNAL(deviceDisconnected()), widget, SLOT(telemetryDisconnected())); + + if (tm->isConnected()) { + widget->telemetryConnected(); + } + + return widget; +} + +IUAVGadgetConfiguration *MonitorGadgetFactory::createConfiguration(QSettings *qSettings) +{ + return new MonitorGadgetConfiguration(QString("TelemetryMonitorGadget"), qSettings); +} + +IOptionsPage *MonitorGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) +{ + return new MonitorGadgetOptionsPage(qobject_cast(config)); +} diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h new file mode 100644 index 000000000..f1663156b --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h @@ -0,0 +1,55 @@ +/** + ****************************************************************************** + * + * @file monitorgadgetfactory.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup monitorgadget + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MONITORGADGETFACTORY_H +#define MONITORGADGETFACTORY_H + +#include "monitorwidget.h" +#include + + +namespace Core { + class IUAVGadget; + class IUAVGadgetFactory; +} + +using namespace Core; + +class MonitorGadgetFactory: public IUAVGadgetFactory { +Q_OBJECT +public: + MonitorGadgetFactory(QObject *parent = 0); + ~MonitorGadgetFactory(); + + Core::IUAVGadget *createGadget(QWidget *parent); + IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings); + IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); + + MonitorWidget *createMonitorWidget(QWidget *parent); +}; + +#endif // MONITORGADGETFACTORY_H diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp new file mode 100644 index 000000000..fcd4bd37f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp @@ -0,0 +1,107 @@ +/** + ****************************************************************************** + * + * @file monitorgadgetoptionspage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Telemetry Gadget options page + * @see The GNU Public License (GPL) Version 3 + * @defgroup monitorgadget + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "monitorgadgetoptionspage.h" +#include +//#include "ui_telemetrypluginoptionspage.h" +#include "extensionsystem/pluginmanager.h" + +MonitorGadgetOptionsPage::MonitorGadgetOptionsPage(MonitorGadgetConfiguration *config, QObject *parent) + : IOptionsPage(parent) +{ +} + +MonitorGadgetOptionsPage::~MonitorGadgetOptionsPage() +{ +} + +QWidget *MonitorGadgetOptionsPage::createPage(QWidget * /* parent */) +{ +// _optionsPage.reset(new Ui::TelemetryPluginOptionsPage()); +// // main widget +// QWidget *optionsPageWidget = new QWidget; +// _dynamicFieldWidget = NULL; +// _dynamicFieldCondition = NULL; +// resetFieldType(); +// // save ref to form, needed for binding dynamic fields in future +// _form = optionsPageWidget; +// // main layout +// _optionsPage->setupUi(optionsPageWidget); +// +// _optionsPage->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory); +// _optionsPage->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory")); +// +// connect(_optionsPage->SoundDirectoryPathChooser, SIGNAL(changed(const QString &)), +// this, SLOT(on_clicked_buttonSoundFolder(const QString &))); +// connect(_optionsPage->SoundCollectionList, SIGNAL(currentIndexChanged(int)), +// this, SLOT(on_changedIndex_soundLanguage(int))); +// +// connect(this, SIGNAL(updateNotifications(QList)), +// _owner, SLOT(updateNotificationList(QList))); +// // connect(this, SIGNAL(resetNotification()),owner, SLOT(resetNotification())); +// +// _privListNotifications = _owner->getListNotifications(); +// +// +// // [1] +// setSelectedNotification(_owner->getCurrentNotification()); +// addDynamicFieldLayout(); +// // [2] +// updateConfigView(_selectedNotification); +// +// initRulesTable(); +// initButtons(); +// initPhononPlayer(); +// +// int curr_row = _privListNotifications.indexOf(_selectedNotification); +// _telemetryRulesSelection->setCurrentIndex(_telemetryRulesModel->index(curr_row, 0, QModelIndex()), +// QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); +// +// return optionsPageWidget; + return NULL; +} + +void MonitorGadgetOptionsPage::apply() +{ +// getOptionsPageValues(_owner->getCurrentNotification()); +// _owner->setEnableSound(_optionsPage->chkEnableSound->isChecked()); +// emit updateNotifications(_privListNotifications); +} + +void MonitorGadgetOptionsPage::finish() +{ +// disconnect(_optionsPage->UAVObjectField, SIGNAL(currentIndexChanged(QString)), +// this, SLOT(on_changedIndex_UAVField(QString))); +// +// disconnect(_testSound.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), +// this, SLOT(on_changed_playButtonText(Phonon::State, Phonon::State))); +// if (_testSound) { +// _testSound->stop(); +// _testSound->clear(); +// } +} + diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.h b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.h new file mode 100644 index 000000000..107e83fc8 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.h @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * + * @file monitorgadgetoptionspage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Telemetry Gadget options page header + * @see The GNU Public License (GPL) Version 3 + * @defgroup telemetry + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MONITORGADGETOPTIONSPAGE_H +#define MONITORGADGETOPTIONSPAGE_H + +#include "coreplugin/dialogs/ioptionspage.h" +#include "uavobjectmanager.h" +#include "uavobject.h" + +#include "QString" +#include +#include + +namespace Ui { +class MonitorGadgetOptionsPage; +}; + +class MonitorGadgetConfiguration; + +using namespace Core; + +class MonitorGadgetOptionsPage : public IOptionsPage { + Q_OBJECT + +public: + MonitorGadgetOptionsPage(MonitorGadgetConfiguration *config, QObject *parent = 0); + ~MonitorGadgetOptionsPage(); + + QWidget *createPage(QWidget *parent); + void apply(); + void finish(); + +private: +}; + +#endif // MONITORGADGETOPTIONSPAGE_H diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp new file mode 100644 index 000000000..b3aa65c75 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp @@ -0,0 +1,286 @@ +#include "monitorwidget.h" + +#include + +#include +#include +#include + +namespace { + + /** + * Create an SVG item and connect it to an element of the SVG file previously loaded into the parent item. + * This then allows to show, hide, move, scale and rotate the element. + * Opacity can also be changed. + * Other characteristics (color, ...) of the element cannot be modified. + */ + // TODO move to some utility class that can be reused by other SVG manipulating code + QGraphicsSvgItem *createSvgItem(QGraphicsSvgItem *parent, QString elementId) + { + QGraphicsSvgItem *item = new QGraphicsSvgItem(parent); + + QSvgRenderer *renderer = parent->renderer(); + + // connect item to its corresponding element + item->setSharedRenderer(renderer); + item->setElementId(elementId); + + // move item to its location + QMatrix elementMatrix = renderer->matrixForElement(elementId); + QRectF elementRect = elementMatrix.mapRect(renderer->boundsOnElement(elementId)); + item->setPos(elementRect.x(), elementRect.y()); + + return item; + } + + // TODO elementId must be a rectangle and not a text element... + // TODO move to some utility class that can be reused by other SVG manipulating code + QGraphicsTextItem *createTextItem(QGraphicsSvgItem *parent, QString elementId, QString fontName) + { +#ifdef DEBUG_TEXT + // create and display the text rectangle + createSvgItem(parent, elementId); +#endif + + QGraphicsTextItem *item = new QGraphicsTextItem(); + + QSvgRenderer *renderer = parent->renderer(); + + // move new text item to location of target element + QMatrix elementMatrix = renderer->matrixForElement(elementId); + QRectF elementRect = elementMatrix.mapRect(renderer->boundsOnElement(elementId)); + + qreal fontPointSizeF = elementRect.height(); + + QTransform matrix; + matrix.translate(elementRect.x(), elementRect.y() - (fontPointSizeF / 2.0)); + + item->setParentItem(parent); + item->setTransform(matrix, false); + //item->setTextWidth(elementRect.width()); + + QFont font(fontName); + //font.setStyleHint(QFont::TypeWriter); + font.setStyleStrategy(QFont::PreferMatch); + font.setPointSizeF(fontPointSizeF); + + item->setFont(font); + +// qDebug() << "Font point size: " << fontPointSizeF; +// qDebug() << "Font pixel size: " << font.pixelSize(); +// qDebug() << "Font point size: " << font.pointSize(); +// qDebug() << "Font point size F: " << font.pointSizeF(); +// qDebug() << "Font exact match: " << font.exactMatch(); + +// QFontInfo fontInfo(font); +// qDebug() << "Font info pixel size: " << fontInfo.pixelSize(); +// qDebug() << "Font info point size: " << fontInfo.pointSize(); +// qDebug() << "Font info point size F: " << fontInfo.pointSizeF(); +// qDebug() << "Font info exact match: " << fontInfo.exactMatch(); + return item; + } + +} // anonymous namespace + +MonitorWidget::MonitorWidget(QWidget *parent) : + QGraphicsView(parent), aspectRatioMode(Qt::KeepAspectRatio) +{ +// setMinimumWidth(180); + + QGraphicsScene *scene = new QGraphicsScene(); + setScene(scene); + + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + + // no scroll bars + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor())); + + setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); + + QSvgRenderer *renderer = new QSvgRenderer(); + + if (renderer->load(QString(":/telemetry/images/tx-rx.svg"))) { + // create graph + graph = new QGraphicsSvgItem(); + graph->setSharedRenderer(renderer); + graph->setElementId("background"); + graph->setFlags(QGraphicsItem::ItemClipsChildrenToShape | QGraphicsItem::ItemClipsToShape); + + scene->addItem(graph); + + int i; + + // create tx nodes + i = 0; + while (true) { + QString id = QString("tx%0").arg(i); + QString bgId = QString("bg_tx%0").arg(i); + if (!renderer->elementExists(id) || !renderer->elementExists(bgId)) { + break; + } + QGraphicsSvgItem *item = createSvgItem(graph, bgId); + item->setElementId(id); + txNodes.append(item); + i++; + } + + // create rx nodes + i = 0; + while (true) { + QString id = QString("rx%0").arg(i); + QString bgId = QString("bg_rx%0").arg(i); + if (!renderer->elementExists(id) || !renderer->elementExists(bgId)) { + break; + } + QGraphicsSvgItem *item = createSvgItem(graph, bgId); + item->setElementId(id); + rxNodes.append(item); + i++; + } + + if (renderer->elementExists("txSpeed")) { + txSpeed = createTextItem(graph, "txSpeed", "Helvetica"); + txSpeed->setDefaultTextColor(Qt::white); + } else { + txSpeed = NULL; + } + + if (renderer->elementExists("rxSpeed")) { + rxSpeed = createTextItem(graph, "rxSpeed", "Helvetica"); + rxSpeed->setDefaultTextColor(Qt::white); + } else { + rxSpeed = NULL; + } + //scene->setSceneRect(graph->boundingRect()); + } + + connected = false; + + setMin(0.0); + setMax(1200.0); + + telemetryUpdated(0.0, 0.0); +} + +MonitorWidget::~MonitorWidget() +{ + while (!txNodes.isEmpty()) { + delete txNodes.takeFirst(); + } + while (!rxNodes.isEmpty()) { + delete rxNodes.takeFirst(); + } + if (txSpeed) { + delete txSpeed; + } + if (rxSpeed) { + delete rxSpeed; + } +} + +/*! + \brief Enables/Disables OpenGL + */ +//void LineardialGadgetWidget::enableOpenGL(bool flag) +//{ +// if (flag) { +// setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); +// } else { +// setViewport(new QWidget); +// } +//} + +void MonitorWidget::telemetryConnected() +{ + qDebug() << "telemetry connected"; + if (!connected) { + // flash the lights + setToolTip(tr("Connected")); + telemetryUpdated(maxValue, maxValue); + connected = true; + } +} + +void MonitorWidget::telemetryDisconnected() +{ + qDebug() << "telemetry disconnected"; + if (connected) { + connected = false; + + setToolTip(tr("Disconnected")); + + // flash the lights??? + telemetryUpdated(maxValue, maxValue); + + telemetryUpdated(0.0, 0.0); + } +} + +/*! + \brief Called by the UAVObject which got updated + + Updates the numeric value and/or the icon if the dial wants this. + */ +void MonitorWidget::telemetryUpdated(double txRate, double rxRate) +{ + double txIndex = (txRate - minValue) / (maxValue - minValue) * txNodes.count(); + double rxIndex = (rxRate - minValue) / (maxValue - minValue) * rxNodes.count(); + + if (connected) { + this->setToolTip(QString("Tx: %0 bytes/s, Rx: %1 bytes/s").arg(txRate).arg(rxRate)); + } + + for (int i = 0; i < txNodes.count(); i++) { + QGraphicsItem *node = txNodes.at(i); + bool visible = (/*connected &&*/ (i < txIndex)); + if (visible != node->isVisible()) { + node->setVisible(visible); + node->update(); + } + //node->setOpacity(0.25); + } + + for (int i = 0; i < rxNodes.count(); i++) { + QGraphicsItem *node = rxNodes.at(i); + bool visible = (/*connected &&*/ (i < rxIndex)); + if (visible != node->isVisible()) { + node->setVisible(visible); + node->update(); + } + } + + if (txSpeed) { + if (connected) { + txSpeed->setPlainText(QString("%0").arg(txRate)); + } + txSpeed->setVisible(connected); + txSpeed->update(); + } + + if (rxSpeed) { + if (connected) { + rxSpeed->setPlainText(QString("%0").arg(rxRate)); + } + rxSpeed->setVisible(connected); + rxSpeed->update(); + } + + update(); +} + +void MonitorWidget::showEvent(QShowEvent *event) +{ + Q_UNUSED(event); + + fitInView(graph, aspectRatioMode); +} + +void MonitorWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + + fitInView(graph, aspectRatioMode); +} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/telemetrymonitorwidget.h b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h similarity index 52% rename from ground/openpilotgcs/src/plugins/coreplugin/telemetrymonitorwidget.h rename to ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h index b157d734d..8bfc76adf 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/telemetrymonitorwidget.h +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h @@ -1,5 +1,5 @@ -#ifndef TELEMETRYMONITORWIDGET_H -#define TELEMETRYMONITORWIDGET_H +#ifndef MONITORWIDGET_H +#define MONITORWIDGET_H #include #include @@ -8,59 +8,56 @@ #include #include -class TelemetryMonitorWidget : public QGraphicsView { - Q_OBJECT +class MonitorWidget: public QGraphicsView { +Q_OBJECT public: - explicit TelemetryMonitorWidget(QWidget *parent = 0); - ~TelemetryMonitorWidget(); + explicit MonitorWidget(QWidget *parent = 0); + ~MonitorWidget(); void setMin(double min) { minValue = min; } + double getMin() { return minValue; } + void setMax(double max) { maxValue = max; } + double getMax() { return maxValue; } - // number of tx/rx nodes in the graph - static const int NODE_NUMELEM = 7; - -signals: - public slots: - void connect(); - void disconnect(); - - void updateTelemetry(double txRate, double rxRate); - void showTelemetry(); + void telemetryConnected(); + void telemetryDisconnected(); + void telemetryUpdated(double txRate, double rxRate); protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); private: - QGraphicsSvgItem *graph; - QPointer txSpeed; - QPointer rxSpeed; - QList txNodes; - QList rxNodes; - bool connected; - double txIndex; - double txValue; - double rxIndex; - double rxValue; + double minValue; double maxValue; + + Qt::AspectRatioMode aspectRatioMode; + + QGraphicsSvgItem *graph; + + QPointer txSpeed; + QPointer rxSpeed; + + QList txNodes; + QList rxNodes; }; -#endif // TELEMETRYMONITORWIDGET_H +#endif // MONITORWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetry.pri b/ground/openpilotgcs/src/plugins/telemetry/telemetry.pri new file mode 100644 index 000000000..c5054c34f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetry.pri @@ -0,0 +1,3 @@ +include(telemetry_dependencies.pri) + +LIBS *= -l$$qtLibraryName(Telemetry) diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetry.pro b/ground/openpilotgcs/src/plugins/telemetry/telemetry.pro new file mode 100644 index 000000000..f8e4d2331 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetry.pro @@ -0,0 +1,29 @@ +TEMPLATE = lib +TARGET = Telemetry + +QT += svg + +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(telemetry_dependencies.pri) + +HEADERS += telemetry_global.h \ + telemetryplugin.h \ + monitorwidget.h \ + monitorgadgetconfiguration.h \ + monitorgadget.h \ + monitorgadgetfactory.h \ + monitorgadgetoptionspage.h + +SOURCES += telemetryplugin.cpp \ + monitorwidget.cpp \ + monitorgadgetconfiguration.cpp \ + monitorgadget.cpp \ + monitorgadgetfactory.cpp \ + monitorgadgetoptionspage.cpp + +DEFINES += TELEMETRY_LIBRARY + +RESOURCES += telemetry.qrc + +OTHER_FILES += Telemetry.pluginspec diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetry.qrc b/ground/openpilotgcs/src/plugins/telemetry/telemetry.qrc new file mode 100644 index 000000000..a21691073 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetry.qrc @@ -0,0 +1,5 @@ + + + images/tx-rx.svg + + diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetry_dependencies.pri b/ground/openpilotgcs/src/plugins/telemetry/telemetry_dependencies.pri new file mode 100644 index 000000000..883e47127 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetry_dependencies.pri @@ -0,0 +1,3 @@ +include(../../plugins/uavtalk/uavtalk.pri) +include(../../plugins/uavobjects/uavobjects.pri) + diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetry_global.h b/ground/openpilotgcs/src/plugins/telemetry/telemetry_global.h new file mode 100644 index 000000000..ee868c9e5 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetry_global.h @@ -0,0 +1,39 @@ +/** + ****************************************************************************** + * + * @file telemetry_global.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup TelemetryPlugin Telemetry Plugin + * @{ + * @brief The Telemetry plugin + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef TELEMETRY_GLOBAL_H +#define TELEMETRY_GLOBAL_H + +#include + +#if defined(TELEMETRY_LIBRARY) +# define TELEMETRY_EXPORT Q_DECL_EXPORT +#else +# define TELEMETRY_EXPORT Q_DECL_IMPORT +#endif + +#endif // TELEMETRY_GLOBAL_H diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp new file mode 100644 index 000000000..b4937d0e9 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp @@ -0,0 +1,249 @@ +/** + ****************************************************************************** + * + * @file telemetryplugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup telemetryplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "telemetryplugin.h" +#include "monitorgadgetfactory.h" + +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include "coreplugin/icore.h" +#include "coreplugin/connectionmanager.h" + +#include +#include +#include + +#include +#include +#include + +TelemetryPlugin::TelemetryPlugin() +{ +} + +TelemetryPlugin::~TelemetryPlugin() +{ +// Core::ICore::instance()->saveSettings(this); +} + +bool TelemetryPlugin::initialize(const QStringList & args, QString *errMsg) +{ + Q_UNUSED(args); + Q_UNUSED(errMsg); + + MonitorGadgetFactory *mf = new MonitorGadgetFactory(this); + addAutoReleasedObject(mf); + + // mop = new TelemetryPluginOptionsPage(this); + //addAutoReleasedObject(mop); + + // TODO not so good... g is probalby leaked... + MonitorWidget *w = mf->createMonitorWidget(NULL); + w->setMaximumWidth(180); + + // + //setAlignment(Qt::AlignCenter); + + // no border + w->setFrameStyle(QFrame::NoFrame); + w->setWindowFlags(Qt::FramelessWindowHint); + + // set svg background translucent + w->setStyleSheet("background:transparent;"); + // set widget background translucent + w->setAttribute(Qt::WA_TranslucentBackground); + + w->setBackgroundBrush(Qt::NoBrush); + + // add monitor widget to connection manager + Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); +// connect(cm, SIGNAL(deviceConnected(QIODevice *)), w, SLOT(telemetryConnected())); +// connect(cm, SIGNAL(deviceDisconnected()), w, SLOT(telemetryDisconnected())); + + cm->addWidget(w); + + return true; +} + +void TelemetryPlugin::extensionsInitialized() +{ +// Core::ICore::instance()->readSettings(this); + + //ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + +// connect(pm, SIGNAL(objectAdded(QObject *)), this, SLOT(onTelemetryManagerAdded(QObject *))); +// _toRemoveNotifications.clear(); +// connectNotifications(); +} + +//void TelemetryPlugin::saveConfig(QSettings *settings, UAVConfigInfo *configInfo) +//{ +// configInfo->setVersion(VERSION); +// +// settings->beginWriteArray("Current"); +// settings->setArrayIndex(0); +// currentNotification.saveState(settings); +// settings->endArray(); +// +// settings->beginGroup("listNotifies"); +// settings->remove(""); +// settings->endGroup(); +// +// settings->beginWriteArray("listNotifies"); +// for (int i = 0; i < _notificationList.size(); i++) { +// settings->setArrayIndex(i); +// _notificationList.at(i)->saveState(settings); +// } +// settings->endArray(); +// settings->setValue(QLatin1String("Enable"), enable); +//} + +//void TelemetryPlugin::readConfig(QSettings *settings, UAVConfigInfo * /* configInfo */) +//{ +// // Just for migration to the new format. +// // Q_ASSERT(configInfo->version() == UAVConfigVersion()); +// +// settings->beginReadArray("Current"); +// settings->setArrayIndex(0); +// currentNotification.restoreState(settings); +// settings->endArray(); +// +// // read list of notifications from settings +// int size = settings->beginReadArray("listNotifies"); +// for (int i = 0; i < size; ++i) { +// settings->setArrayIndex(i); +// NotificationItem *notification = new NotificationItem; +// notification->restoreState(settings); +// _notificationList.append(notification); +// } +// settings->endArray(); +// setEnable(settings->value(QLatin1String("Enable"), 0).toBool()); +//} + +//void TelemetryPlugin::onTelemetryManagerAdded(QObject *obj) +//{ +// telMngr = qobject_cast(obj); +// if (telMngr) { +// connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); +// } +//} + +void TelemetryPlugin::shutdown() +{ + // Do nothing +} + +//void TelemetryPlugin::onAutopilotDisconnect() +//{ +// connectNotifications(); +//} + +///*! +// clear any telemetry timers from previous flight; +// reset will be perform on start of option page +// */ +//void TelemetryPlugin::resetNotification(void) +//{ +// // first, reject empty args and unknown fields. +// foreach(NotificationItem * ntf, _notificationList) { +// ntf->disposeTimer(); +// disconnect(ntf->getTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification())); +// ntf->disposeExpireTimer(); +// disconnect(ntf->getExpireTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification())); +// } +//} + +//void TelemetryPlugin::connectNotifications() +//{ +// foreach(UAVDataObject * obj, lstNotifiedUAVObjects) { +// if (obj != NULL) { +// disconnect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(on_arrived_Notification(UAVObject *))); +// } +// } +// if (phonon.mo != NULL) { +// delete phonon.mo; +// phonon.mo = NULL; +// } +// +// if (!enable) { +// return; +// } +// +// ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); +// UAVObjectManager *objManager = pm->getObject(); +// +// lstNotifiedUAVObjects.clear(); +// _pendingNotifications.clear(); +// _notificationList.append(_toRemoveNotifications); +// _toRemoveNotifications.clear(); +// +// // first, reject empty args and unknown fields. +// foreach(NotificationItem * telemetry, _notificationList) { +// telemetry->_isPlayed = false; +// telemetry->isNowPlaying = false; +// +// if (telemetry->mute()) { +// continue; +// } +// // check is all sounds presented for notification, +// // if not - we must not subscribe to it at all +// if (telemetry->toList().isEmpty()) { +// continue; +// } +// +// UAVDataObject *obj = dynamic_cast(objManager->getObject(telemetry->getDataObject())); +// if (obj != NULL) { +// if (!lstNotifiedUAVObjects.contains(obj)) { +// lstNotifiedUAVObjects.append(obj); +// +// connect(obj, SIGNAL(objectUpdated(UAVObject *)), +// this, SLOT(on_arrived_Notification(UAVObject *)), +// Qt::QueuedConnection); +// } +// } else { +// qTelemetryDebug() << "Error: Object is unknown (" << telemetry->getDataObject() << ")."; +// } +// } +// +// if (_notificationList.isEmpty()) { +// return; +// } +// // set notification message to current event +// phonon.mo = Phonon::createPlayer(Phonon::NotificationCategory); +// phonon.mo->clearQueue(); +// phonon.firstPlay = true; +// QList audioOutputDevices = +// Phonon::BackendCapabilities::availableAudioOutputDevices(); +// foreach(Phonon::AudioOutputDevice dev, audioOutputDevices) { +// qTelemetryDebug() << "Telemetry: Audio Output device: " << dev.name() << " - " << dev.description(); +// } +// connect(phonon.mo, SIGNAL(stateChanged(Phonon::State, Phonon::State)), +// this, SLOT(stateChanged(Phonon::State, Phonon::State))); +//} + +Q_EXPORT_PLUGIN(TelemetryPlugin) diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h new file mode 100644 index 000000000..304b752e0 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h @@ -0,0 +1,47 @@ +/** + ****************************************************************************** + * + * @file telemetryplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup telemetryplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef TELEMETRYPLUGIN_H +#define TELEMETRYPLUGIN_H + +#include + +class MonitorGadgetFactory; + +class TelemetryPlugin : public ExtensionSystem::IPlugin { +public: + TelemetryPlugin(); + ~TelemetryPlugin(); + + void extensionsInitialized(); + bool initialize(const QStringList &arguments, QString *errorString); + void shutdown(); + +private: + MonitorGadgetFactory *mf; +}; + +#endif // TELEMETRYPLUGIN_H diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp index 008e3af73..c38566db8 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp @@ -31,7 +31,7 @@ #include TelemetryManager::TelemetryManager() : - autopilotConnected(false) + autopilotConnected(false) { moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread()); // Get UAVObjectManager instance @@ -44,7 +44,8 @@ TelemetryManager::TelemetryManager() : } TelemetryManager::~TelemetryManager() -{} +{ +} bool TelemetryManager::isConnected() { @@ -59,14 +60,14 @@ void TelemetryManager::start(QIODevice *dev) void TelemetryManager::onStart() { - utalk = new UAVTalk(device, objMngr); - telemetry = new Telemetry(utalk, objMngr); + utalk = new UAVTalk(device, objMngr); + telemetry = new Telemetry(utalk, objMngr); telemetryMon = new TelemetryMonitor(objMngr, telemetry); connect(telemetryMon, SIGNAL(connected()), this, SLOT(onConnect())); connect(telemetryMon, SIGNAL(disconnected()), this, SLOT(onDisconnect())); + connect(telemetryMon, SIGNAL(telemetryUpdated(double, double)), this, SLOT(onTelemetryUpdate(double, double))); } - void TelemetryManager::stop() { emit myStop(); @@ -92,3 +93,8 @@ void TelemetryManager::onDisconnect() autopilotConnected = false; emit disconnected(); } + +void TelemetryManager::onTelemetryUpdate(double txRate, double rxRate) +{ + emit telemetryUpdated(txRate, rxRate); +} diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h index c4e7301ec..be956bf4f 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.h @@ -50,12 +50,14 @@ public: signals: void connected(); void disconnected(); + void telemetryUpdated(double txRate, double rxRate); void myStart(); void myStop(); private slots: void onConnect(); void onDisconnect(); + void onTelemetryUpdate(double txRate, double rxRate); void onStart(); void onStop(); diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp index 6d1a8268e..9236e0ea4 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp @@ -27,7 +27,6 @@ #include "telemetrymonitor.h" #include "qxtlogger.h" -#include "coreplugin/connectionmanager.h" #include "coreplugin/icore.h" /** @@ -54,11 +53,6 @@ TelemetryMonitor::TelemetryMonitor(UAVObjectManager *objMngr, Telemetry *tel) statsTimer = new QTimer(this); connect(statsTimer, SIGNAL(timeout()), this, SLOT(processStatsUpdates())); statsTimer->start(STATS_CONNECT_PERIOD_MS); - - Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); - connect(this, SIGNAL(connected()), cm, SLOT(telemetryConnected())); - connect(this, SIGNAL(disconnected()), cm, SLOT(telemetryDisconnected())); - connect(this, SIGNAL(telemetryUpdated(double, double)), cm, SLOT(telemetryUpdated(double, double))); } TelemetryMonitor::~TelemetryMonitor() @@ -218,7 +212,7 @@ void TelemetryMonitor::processStatsUpdates() } } - emit telemetryUpdated((double)gcsStats.TxDataRate, (double)gcsStats.RxDataRate); + emit telemetryUpdated((double) gcsStats.TxDataRate, (double) gcsStats.RxDataRate); // Set data gcsStatsObj->setData(gcsStats); diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.pro b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.pro index 731cdf0ed..64fd2289e 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.pro +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.pro @@ -1,18 +1,24 @@ -QT += network TEMPLATE = lib TARGET = UAVTalk + +QT += network + include(../../openpilotgcsplugin.pri) include(uavtalk_dependencies.pri) + HEADERS += uavtalk.h \ uavtalkplugin.h \ telemetrymonitor.h \ telemetrymanager.h \ uavtalk_global.h \ telemetry.h + SOURCES += uavtalk.cpp \ uavtalkplugin.cpp \ telemetrymonitor.cpp \ telemetrymanager.cpp \ telemetry.cpp + DEFINES += UAVTALK_LIBRARY + OTHER_FILES += UAVTalk.pluginspec From 9a93d88388daa3d31e01f2bfb9608253de03ebcc Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 14 Jun 2013 00:15:03 +0200 Subject: [PATCH 002/116] OP-963 TelemetryMonitorWidget added some doc + polishing --- .../src/plugins/telemetry/images/tx-rx.svg | 28 ++++----- .../src/plugins/telemetry/monitorgadget.cpp | 2 +- .../src/plugins/telemetry/monitorwidget.cpp | 59 ++++++++++++------- .../src/plugins/telemetry/monitorwidget.h | 4 +- 4 files changed, 54 insertions(+), 39 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg b/ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg index 1dd94fbba..babda9af1 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg +++ b/ground/openpilotgcs/src/plugins/telemetry/images/tx-rx.svg @@ -106,7 +106,7 @@ x="13" y="35">Tx Rx (config); + //MonitorGadgetConfiguration *m = qobject_cast(config); //m_widget->setSystemFile(m->getSystemFile()); // Triggers widget repaint } diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp index b3aa65c75..c75e301c2 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp @@ -33,20 +33,29 @@ namespace { return item; } - // TODO elementId must be a rectangle and not a text element... + /** + * Create a text item based on a svg rectangle. + * The rectangle must be in the correct location (hint: use a "text" layer on top of the "background layer") + * The font size will be set to match as well as possible the rectangle height but it is not guaranteed. + * + * It is possible to show the text rectangle to help understand layout issues. + * + */ // TODO move to some utility class that can be reused by other SVG manipulating code - QGraphicsTextItem *createTextItem(QGraphicsSvgItem *parent, QString elementId, QString fontName) + QGraphicsTextItem *createTextItem(QGraphicsSvgItem *parent, QString elementId, QString fontName, + bool showRect = false) { -#ifdef DEBUG_TEXT - // create and display the text rectangle - createSvgItem(parent, elementId); -#endif + if (showRect) { + // create and display the text rectangle + // needs to be done first otherwise the rectangle will blank out the text. + createSvgItem(parent, elementId); + } QGraphicsTextItem *item = new QGraphicsTextItem(); QSvgRenderer *renderer = parent->renderer(); - // move new text item to location of target element + // move new text item to location of rectangle element QMatrix elementMatrix = renderer->matrixForElement(elementId); QRectF elementRect = elementMatrix.mapRect(renderer->boundsOnElement(elementId)); @@ -57,26 +66,32 @@ namespace { item->setParentItem(parent); item->setTransform(matrix, false); + // to right align or center text we must provide a text width //item->setTextWidth(elementRect.width()); + // create font to match the rectangle height + // there is not guaranteed that all fonts will play well... QFont font(fontName); - //font.setStyleHint(QFont::TypeWriter); + // not sure if PreferMatch helps to get the correct font size (i.e. that fits the text rectangle nicely) font.setStyleStrategy(QFont::PreferMatch); font.setPointSizeF(fontPointSizeF); item->setFont(font); -// qDebug() << "Font point size: " << fontPointSizeF; -// qDebug() << "Font pixel size: " << font.pixelSize(); -// qDebug() << "Font point size: " << font.pointSize(); -// qDebug() << "Font point size F: " << font.pointSizeF(); -// qDebug() << "Font exact match: " << font.exactMatch(); +#ifdef DEBUG_FONT + // just in case + qDebug() << "Font point size: " << fontPointSizeF; + qDebug() << "Font pixel size: " << font.pixelSize(); + qDebug() << "Font point size: " << font.pointSize(); + qDebug() << "Font point size F: " << font.pointSizeF(); + qDebug() << "Font exact match: " << font.exactMatch(); -// QFontInfo fontInfo(font); -// qDebug() << "Font info pixel size: " << fontInfo.pixelSize(); -// qDebug() << "Font info point size: " << fontInfo.pointSize(); -// qDebug() << "Font info point size F: " << fontInfo.pointSizeF(); -// qDebug() << "Font info exact match: " << fontInfo.exactMatch(); + QFontInfo fontInfo(font); + qDebug() << "Font info pixel size: " << fontInfo.pixelSize(); + qDebug() << "Font info point size: " << fontInfo.pointSize(); + qDebug() << "Font info point size F: " << fontInfo.pointSizeF(); + qDebug() << "Font info exact match: " << fontInfo.exactMatch(); +#endif return item; } @@ -85,7 +100,7 @@ namespace { MonitorWidget::MonitorWidget(QWidget *parent) : QGraphicsView(parent), aspectRatioMode(Qt::KeepAspectRatio) { -// setMinimumWidth(180); + //setMinimumWidth(180); QGraphicsScene *scene = new QGraphicsScene(); setScene(scene); @@ -107,6 +122,7 @@ MonitorWidget::MonitorWidget(QWidget *parent) : graph = new QGraphicsSvgItem(); graph->setSharedRenderer(renderer); graph->setElementId("background"); + graph->setFlags(QGraphicsItem::ItemClipsChildrenToShape | QGraphicsItem::ItemClipsToShape); scene->addItem(graph); @@ -117,7 +133,7 @@ MonitorWidget::MonitorWidget(QWidget *parent) : i = 0; while (true) { QString id = QString("tx%0").arg(i); - QString bgId = QString("bg_tx%0").arg(i); + QString bgId = QString("tx_bg%0").arg(i); if (!renderer->elementExists(id) || !renderer->elementExists(bgId)) { break; } @@ -131,7 +147,7 @@ MonitorWidget::MonitorWidget(QWidget *parent) : i = 0; while (true) { QString id = QString("rx%0").arg(i); - QString bgId = QString("bg_rx%0").arg(i); + QString bgId = QString("rx_bg%0").arg(i); if (!renderer->elementExists(id) || !renderer->elementExists(bgId)) { break; } @@ -240,7 +256,6 @@ void MonitorWidget::telemetryUpdated(double txRate, double rxRate) node->setVisible(visible); node->update(); } - //node->setOpacity(0.25); } for (int i = 0; i < rxNodes.count(); i++) { diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h index 8bfc76adf..380cd3b00 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h @@ -49,8 +49,6 @@ private: double minValue; double maxValue; - Qt::AspectRatioMode aspectRatioMode; - QGraphicsSvgItem *graph; QPointer txSpeed; @@ -58,6 +56,8 @@ private: QList txNodes; QList rxNodes; + + Qt::AspectRatioMode aspectRatioMode; }; #endif // MONITORWIDGET_H From c3e3521001213aae4485b1855ce8452303d755b2 Mon Sep 17 00:00:00 2001 From: "Richard Flay (Hyper)" Date: Sun, 28 Jul 2013 01:16:22 +0930 Subject: [PATCH 003/116] OP-1049: Hotfix to 13.06.02 for MPU6000 FIFO overflow on CC3D when board initialisation takes longer than 150ms. --- flight/pios/common/pios_mpu6000.c | 93 +++++++++++++++++++++++-- flight/pios/inc/pios_mpu6000.h | 109 +++++++++++++++--------------- 2 files changed, 143 insertions(+), 59 deletions(-) diff --git a/flight/pios/common/pios_mpu6000.c b/flight/pios/common/pios_mpu6000.c index 371068e0c..5ea27f0c8 100644 --- a/flight/pios/common/pios_mpu6000.c +++ b/flight/pios/common/pios_mpu6000.c @@ -64,7 +64,13 @@ static void PIOS_MPU6000_Config(struct pios_mpu6000_cfg const *cfg); static int32_t PIOS_MPU6000_SetReg(uint8_t address, uint8_t buffer); static int32_t PIOS_MPU6000_GetReg(uint8_t address); -#define GRAV 9.81f +#define GRAV 9.81f + +#ifdef PIOS_MPU6000_ACCEL +#define PIOS_MPU6000_SAMPLES_BYTES 14 +#else +#define PIOS_MPU6000_SAMPLES_BYTES 8 +#endif /** * @brief Allocate a new device @@ -489,6 +495,62 @@ int32_t PIOS_MPU6000_Test(void) return 0; } +/** + * @brief Reads the contents of the MPU6000 Interrupt Status register from an ISR + * @return The register value or -1 on failure to claim the bus + */ +static int32_t PIOS_MPU6000_GetInterruptStatusRegISR(bool *woken) +{ + /* Interrupt Status register can be read at high SPI clock speed */ + uint8_t data; + + if (PIOS_MPU6000_ClaimBusISR(woken) != 0) { + return -1; + } + PIOS_SPI_TransferByte(dev->spi_id, (0x80 | PIOS_MPU6000_INT_STATUS_REG)); + data = PIOS_SPI_TransferByte(dev->spi_id, 0); + PIOS_MPU6000_ReleaseBusISR(woken); + return data; +} + +/** + * @brief Resets the MPU6000 FIFO from an ISR + * @param woken[in,out] If non-NULL, will be set to true if woken was false and a higher priority + * task has is now eligible to run, else unchanged + * @return 0 if operation was successful + * @return -1 if unable to claim SPI bus + * @return -2 if write to the device failed + */ +static int32_t PIOS_MPU6000_ResetFifoISR(bool *woken) +{ + int32_t result = 0; + + /* Register writes must be at < 1MHz SPI clock. + * Speed can only be changed when SPI bus semaphore is held, but + * device chip select must not be enabled, so we use the direct + * SPI bus claim call here */ + if (PIOS_SPI_ClaimBusISR(dev->spi_id, woken) != 0) { + return -1; + } + /* Reduce SPI clock speed. */ + PIOS_SPI_SetClockSpeed(dev->spi_id, PIOS_SPI_PRESCALER_256); + /* Enable chip select */ + PIOS_SPI_RC_PinSet(dev->spi_id, dev->slave_num, 0); + /* Reset FIFO. */ + if (PIOS_SPI_TransferByte(dev->spi_id, 0x7f & PIOS_MPU6000_USER_CTRL_REG) != 0) { + result = -2; + } else if (PIOS_SPI_TransferByte(dev->spi_id, (dev->cfg->User_ctl | PIOS_MPU6000_USERCTL_FIFO_RST)) != 0) { + result = -2; + } + /* Disable chip select. */ + PIOS_SPI_RC_PinSet(dev->spi_id, dev->slave_num, 1); + /* Increase SPI clock speed. */ + PIOS_SPI_SetClockSpeed(dev->spi_id, PIOS_SPI_PRESCALER_16); + /* Release the SPI bus semaphore. */ + PIOS_SPI_ReleaseBusISR(dev->spi_id, woken); + return result; +} + /** * @brief Obtains the number of bytes in the FIFO. Call from ISR only. * @return the number of bytes in the FIFO @@ -542,8 +604,29 @@ bool PIOS_MPU6000_IRQHandler(void) return false; } + /* Temporary fix for OP-1049. Expected to be superceded for next major release + * by code changes for OP-1039. + * Read interrupt status register to check for FIFO overflow. Must be the + * first read after interrupt, in case the device is configured so that + * any read clears in the status register (PIOS_MPU6000_INT_CLR_ANYRD set in + * interrupt config register) */ + int32_t result; + if ((result = PIOS_MPU6000_GetInterruptStatusRegISR(&woken)) < 0) { + return woken; + } + if (result & PIOS_MPU6000_INT_STATUS_FIFO_OVERFLOW) { + /* The FIFO has overflowed, so reset it, + * to enable sample sync to be recovered. + * If the reset fails, we are in trouble, but + * we keep trying on subsequent interrupts. */ + PIOS_MPU6000_ResetFifoISR(&woken); + /* Return and wait for the next new sample. */ + return woken; + } + + /* Usual case - FIFO has not overflowed. */ mpu6000_count = PIOS_MPU6000_FifoDepthISR(&woken); - if (mpu6000_count < (int32_t)sizeof(struct pios_mpu6000_data)) { + if (mpu6000_count < PIOS_MPU6000_SAMPLES_BYTES) { return woken; } @@ -551,8 +634,8 @@ bool PIOS_MPU6000_IRQHandler(void) return woken; } - static uint8_t mpu6000_send_buf[1 + sizeof(struct pios_mpu6000_data)] = { PIOS_MPU6000_FIFO_REG | 0x80, 0, 0, 0, 0, 0, 0, 0, 0 }; - static uint8_t mpu6000_rec_buf[1 + sizeof(struct pios_mpu6000_data)]; + static uint8_t mpu6000_send_buf[1 + PIOS_MPU6000_SAMPLES_BYTES] = { PIOS_MPU6000_FIFO_REG | 0x80 }; + static uint8_t mpu6000_rec_buf[1 + PIOS_MPU6000_SAMPLES_BYTES]; if (PIOS_SPI_TransferBlock(dev->spi_id, &mpu6000_send_buf[0], &mpu6000_rec_buf[0], sizeof(mpu6000_send_buf), NULL) < 0) { PIOS_MPU6000_ReleaseBusISR(&woken); @@ -565,7 +648,7 @@ bool PIOS_MPU6000_IRQHandler(void) static struct pios_mpu6000_data data; // In the case where extras samples backed up grabbed an extra - if (mpu6000_count >= (int32_t)(sizeof(data) * 2)) { + if (mpu6000_count >= PIOS_MPU6000_SAMPLES_BYTES * 2) { mpu6000_fifo_backup++; if (PIOS_MPU6000_ClaimBusISR(&woken) != 0) { return woken; diff --git a/flight/pios/inc/pios_mpu6000.h b/flight/pios/inc/pios_mpu6000.h index 91ea89d3e..cda019edf 100644 --- a/flight/pios/inc/pios_mpu6000.h +++ b/flight/pios/inc/pios_mpu6000.h @@ -33,71 +33,72 @@ #define PIOS_MPU6000_H /* MPU6000 Addresses */ -#define PIOS_MPU6000_SMPLRT_DIV_REG 0X19 -#define PIOS_MPU6000_DLPF_CFG_REG 0X1A -#define PIOS_MPU6000_GYRO_CFG_REG 0X1B -#define PIOS_MPU6000_ACCEL_CFG_REG 0X1C -#define PIOS_MPU6000_FIFO_EN_REG 0x23 -#define PIOS_MPU6000_INT_CFG_REG 0x37 -#define PIOS_MPU6000_INT_EN_REG 0x38 -#define PIOS_MPU6000_INT_STATUS_REG 0x3A -#define PIOS_MPU6000_ACCEL_X_OUT_MSB 0x3B -#define PIOS_MPU6000_ACCEL_X_OUT_LSB 0x3C -#define PIOS_MPU6000_ACCEL_Y_OUT_MSB 0x3D -#define PIOS_MPU6000_ACCEL_Y_OUT_LSB 0x3E -#define PIOS_MPU6000_ACCEL_Z_OUT_MSB 0x3F -#define PIOS_MPU6000_ACCEL_Z_OUT_LSB 0x40 -#define PIOS_MPU6000_TEMP_OUT_MSB 0x41 -#define PIOS_MPU6000_TEMP_OUT_LSB 0x42 -#define PIOS_MPU6000_GYRO_X_OUT_MSB 0x43 -#define PIOS_MPU6000_GYRO_X_OUT_LSB 0x44 -#define PIOS_MPU6000_GYRO_Y_OUT_MSB 0x45 -#define PIOS_MPU6000_GYRO_Y_OUT_LSB 0x46 -#define PIOS_MPU6000_GYRO_Z_OUT_MSB 0x47 -#define PIOS_MPU6000_GYRO_Z_OUT_LSB 0x48 -#define PIOS_MPU6000_USER_CTRL_REG 0x6A -#define PIOS_MPU6000_PWR_MGMT_REG 0x6B -#define PIOS_MPU6000_FIFO_CNT_MSB 0x72 -#define PIOS_MPU6000_FIFO_CNT_LSB 0x73 -#define PIOS_MPU6000_FIFO_REG 0x74 -#define PIOS_MPU6000_WHOAMI 0x75 +#define PIOS_MPU6000_SMPLRT_DIV_REG 0X19 +#define PIOS_MPU6000_DLPF_CFG_REG 0X1A +#define PIOS_MPU6000_GYRO_CFG_REG 0X1B +#define PIOS_MPU6000_ACCEL_CFG_REG 0X1C +#define PIOS_MPU6000_FIFO_EN_REG 0x23 +#define PIOS_MPU6000_INT_CFG_REG 0x37 +#define PIOS_MPU6000_INT_EN_REG 0x38 +#define PIOS_MPU6000_INT_STATUS_REG 0x3A +#define PIOS_MPU6000_ACCEL_X_OUT_MSB 0x3B +#define PIOS_MPU6000_ACCEL_X_OUT_LSB 0x3C +#define PIOS_MPU6000_ACCEL_Y_OUT_MSB 0x3D +#define PIOS_MPU6000_ACCEL_Y_OUT_LSB 0x3E +#define PIOS_MPU6000_ACCEL_Z_OUT_MSB 0x3F +#define PIOS_MPU6000_ACCEL_Z_OUT_LSB 0x40 +#define PIOS_MPU6000_TEMP_OUT_MSB 0x41 +#define PIOS_MPU6000_TEMP_OUT_LSB 0x42 +#define PIOS_MPU6000_GYRO_X_OUT_MSB 0x43 +#define PIOS_MPU6000_GYRO_X_OUT_LSB 0x44 +#define PIOS_MPU6000_GYRO_Y_OUT_MSB 0x45 +#define PIOS_MPU6000_GYRO_Y_OUT_LSB 0x46 +#define PIOS_MPU6000_GYRO_Z_OUT_MSB 0x47 +#define PIOS_MPU6000_GYRO_Z_OUT_LSB 0x48 +#define PIOS_MPU6000_USER_CTRL_REG 0x6A +#define PIOS_MPU6000_PWR_MGMT_REG 0x6B +#define PIOS_MPU6000_FIFO_CNT_MSB 0x72 +#define PIOS_MPU6000_FIFO_CNT_LSB 0x73 +#define PIOS_MPU6000_FIFO_REG 0x74 +#define PIOS_MPU6000_WHOAMI 0x75 /* FIFO enable for storing different values */ -#define PIOS_MPU6000_FIFO_TEMP_OUT 0x80 -#define PIOS_MPU6000_FIFO_GYRO_X_OUT 0x40 -#define PIOS_MPU6000_FIFO_GYRO_Y_OUT 0x20 -#define PIOS_MPU6000_FIFO_GYRO_Z_OUT 0x10 -#define PIOS_MPU6000_ACCEL_OUT 0x08 +#define PIOS_MPU6000_FIFO_TEMP_OUT 0x80 +#define PIOS_MPU6000_FIFO_GYRO_X_OUT 0x40 +#define PIOS_MPU6000_FIFO_GYRO_Y_OUT 0x20 +#define PIOS_MPU6000_FIFO_GYRO_Z_OUT 0x10 +#define PIOS_MPU6000_ACCEL_OUT 0x08 /* Interrupt Configuration */ -#define PIOS_MPU6000_INT_ACTL 0x80 -#define PIOS_MPU6000_INT_OPEN 0x40 -#define PIOS_MPU6000_INT_LATCH_EN 0x20 -#define PIOS_MPU6000_INT_CLR_ANYRD 0x10 +#define PIOS_MPU6000_INT_ACTL 0x80 +#define PIOS_MPU6000_INT_OPEN 0x40 +#define PIOS_MPU6000_INT_LATCH_EN 0x20 +#define PIOS_MPU6000_INT_CLR_ANYRD 0x10 -#define PIOS_MPU6000_INTEN_OVERFLOW 0x10 -#define PIOS_MPU6000_INTEN_DATA_RDY 0x01 +#define PIOS_MPU6000_INTEN_OVERFLOW 0x10 +#define PIOS_MPU6000_INTEN_DATA_RDY 0x01 /* Interrupt status */ -#define PIOS_MPU6000_INT_STATUS_FIFO_FULL 0x80 -#define PIOS_MPU6000_INT_STATUS_IMU_RDY 0X04 -#define PIOS_MPU6000_INT_STATUS_DATA_RDY 0X01 +#define PIOS_MPU6000_INT_STATUS_FIFO_FULL 0x80 +#define PIOS_MPU6000_INT_STATUS_FIFO_OVERFLOW 0x10 +#define PIOS_MPU6000_INT_STATUS_IMU_RDY 0X04 +#define PIOS_MPU6000_INT_STATUS_DATA_RDY 0X01 /* User control functionality */ -#define PIOS_MPU6000_USERCTL_FIFO_EN 0X40 -#define PIOS_MPU6000_USERCTL_I2C_MST_EN 0x20 -#define PIOS_MPU6000_USERCTL_DIS_I2C 0X10 -#define PIOS_MPU6000_USERCTL_FIFO_RST 0X04 -#define PIOS_MPU6000_USERCTL_SIG_COND 0X02 -#define PIOS_MPU6000_USERCTL_GYRO_RST 0X01 +#define PIOS_MPU6000_USERCTL_FIFO_EN 0X40 +#define PIOS_MPU6000_USERCTL_I2C_MST_EN 0x20 +#define PIOS_MPU6000_USERCTL_DIS_I2C 0X10 +#define PIOS_MPU6000_USERCTL_FIFO_RST 0X04 +#define PIOS_MPU6000_USERCTL_SIG_COND 0X02 +#define PIOS_MPU6000_USERCTL_GYRO_RST 0X01 /* Power management and clock selection */ -#define PIOS_MPU6000_PWRMGMT_IMU_RST 0X80 -#define PIOS_MPU6000_PWRMGMT_INTERN_CLK 0X00 -#define PIOS_MPU6000_PWRMGMT_PLL_X_CLK 0X01 -#define PIOS_MPU6000_PWRMGMT_PLL_Y_CLK 0X02 -#define PIOS_MPU6000_PWRMGMT_PLL_Z_CLK 0X03 -#define PIOS_MPU6000_PWRMGMT_STOP_CLK 0X07 +#define PIOS_MPU6000_PWRMGMT_IMU_RST 0X80 +#define PIOS_MPU6000_PWRMGMT_INTERN_CLK 0X00 +#define PIOS_MPU6000_PWRMGMT_PLL_X_CLK 0X01 +#define PIOS_MPU6000_PWRMGMT_PLL_Y_CLK 0X02 +#define PIOS_MPU6000_PWRMGMT_PLL_Z_CLK 0X03 +#define PIOS_MPU6000_PWRMGMT_STOP_CLK 0X07 enum pios_mpu6000_range { PIOS_MPU6000_SCALE_250_DEG = 0x00, From 2340f4f0d9cf1d77969e7c4cfe732ec6120a5cfe Mon Sep 17 00:00:00 2001 From: Brian Webb Date: Mon, 29 Jul 2013 20:37:00 -0700 Subject: [PATCH 004/116] OP-1050: Moves LED configuration above settings erase in OPLink pios_board.c to prevent crashing when settings are erased. --- flight/targets/boards/oplinkmini/firmware/pios_board.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/targets/boards/oplinkmini/firmware/pios_board.c b/flight/targets/boards/oplinkmini/firmware/pios_board.c index 5c429d57e..7192b0a4f 100644 --- a/flight/targets/boards/oplinkmini/firmware/pios_board.c +++ b/flight/targets/boards/oplinkmini/firmware/pios_board.c @@ -124,6 +124,10 @@ void PIOS_Board_Init(void) PIOS_RTC_Init(&pios_rtc_main_cfg); #endif /* PIOS_INCLUDE_RTC */ +#if defined(PIOS_INCLUDE_LED) + PIOS_LED_Init(&pios_led_cfg); +#endif /* PIOS_INCLUDE_LED */ + /* IAP System Setup */ PIOS_IAP_Init(); // check for safe mode commands from gcs @@ -141,10 +145,6 @@ void PIOS_Board_Init(void) OPLinkStatusInitialize(); #endif /* PIOS_INCLUDE_RFM22B */ -#if defined(PIOS_INCLUDE_LED) - PIOS_LED_Init(&pios_led_cfg); -#endif /* PIOS_INCLUDE_LED */ - /* Initialize the delayed callback library */ CallbackSchedulerInitialize(); From 011c0b35ab6c83947e3f5eb66b8c0595ea7e82ca Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 1 Aug 2013 22:36:37 +0200 Subject: [PATCH 005/116] OP-910 Updated WHATSNEW.txt for 13.06.03 --- WHATSNEW.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WHATSNEW.txt b/WHATSNEW.txt index 236577e43..9f6e282ea 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -1,3 +1,12 @@ +--- RELEASE-13.06.03 --- + +This maintenance release addresses the following issues: +- FIxed CC3D attitude estimation failure after multiple settings changes and reboots. +- Fixed OPLink crashes when erasing settings + +JIRA issues addressed in this maintenance release: +OP-1049, OP-1050 + --- RELEASE-13.06.02 --- Refactoring of OPLink radio driver. Auto-configuration was removed, and a From 6ab83e5d3320b574529252f9852dcf7ce89dcab4 Mon Sep 17 00:00:00 2001 From: Voha Date: Sat, 10 Aug 2013 21:27:36 +0300 Subject: [PATCH 006/116] fixed build errors with clang in MacOsX 10.9(DP5) and xCode 5.0(DP5) --- ground/openpilotgcs/src/plugins/config/twostep.cpp | 3 ++- ground/openpilotgcs/src/plugins/ophid/ophid.pro | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/twostep.cpp b/ground/openpilotgcs/src/plugins/config/twostep.cpp index e1562af29..d6534d7cc 100644 --- a/ground/openpilotgcs/src/plugins/config/twostep.cpp +++ b/ground/openpilotgcs/src/plugins/config/twostep.cpp @@ -126,7 +126,7 @@ Vector3f twostep_bias_only(const Vector3f samples[], const float noise) { // \tilde{H} - Vector3f centeredSamples[n_samples]; + Vector3f* centeredSamples = new Vector3f[n_samples]; // z_k float sampleDeltaMag[n_samples]; // eq 7 and 8 applied to samples @@ -172,6 +172,7 @@ Vector3f twostep_bias_only(const Vector3f samples[], // Note that the negative has been done twice estimate += neg_increment; } + delete[] centeredSamples; return estimate; } diff --git a/ground/openpilotgcs/src/plugins/ophid/ophid.pro b/ground/openpilotgcs/src/plugins/ophid/ophid.pro index d5f2d04cb..9f67ce6c8 100644 --- a/ground/openpilotgcs/src/plugins/ophid/ophid.pro +++ b/ground/openpilotgcs/src/plugins/ophid/ophid.pro @@ -39,9 +39,9 @@ macx { -arch ppc \ -arch i386 LIBS += $(ARCH) \ - -Wl,-syslibroot,$(SDK) \ - -framework IOKit \ - -framework CoreFoundation + -framework IOKit \ + -framework CoreFoundation \ + -Wl -syslibroot $(SDK) } linux-g++ { From 1c1ec8c959e9dd31679a61900862fd99a68ada06 Mon Sep 17 00:00:00 2001 From: Mathieu Rondonneau Date: Wed, 14 Aug 2013 17:01:54 -0700 Subject: [PATCH 007/116] OP-1070 GrountTruth object sent to FC. this should not be the case so remove it from periodic list. --- shared/uavobjectdefinition/groundtruth.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/uavobjectdefinition/groundtruth.xml b/shared/uavobjectdefinition/groundtruth.xml index c852754ee..cb272ed65 100644 --- a/shared/uavobjectdefinition/groundtruth.xml +++ b/shared/uavobjectdefinition/groundtruth.xml @@ -11,8 +11,8 @@ - - + + From 42ff8a24bb5c2d2f2e23192dd86f81d3a83b9d64 Mon Sep 17 00:00:00 2001 From: Andrew Finegan Date: Fri, 19 Jul 2013 01:34:09 -0400 Subject: [PATCH 008/116] Updated urlfactory file, google maps now require ssl then recieving tiles, also updated the google map version parser to ssl --- .../libs/opmapcontrol/src/core/urlfactory.cpp | 76 +++++++++++-------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index cd4e4d0d0..d422813c4 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -27,11 +27,14 @@ #include "urlfactory.h" #include + namespace core { const double UrlFactory::EarthRadiusKm = 6378.137; // WGS-84 UrlFactory::UrlFactory() { + + /// /// timeout for map connections /// @@ -87,8 +90,11 @@ void UrlFactory::TryCorrectGoogleVersions() { QMutexLocker locker(&mutex); + if (CorrectGoogleVersions && !IsCorrectGoogleVersions()) { - QNetworkReply *reply; + + + QNetworkReply *reply; QNetworkRequest qheader; QNetworkAccessManager network; QEventLoop q; @@ -101,10 +107,10 @@ void UrlFactory::TryCorrectGoogleVersions() #ifdef DEBUG_URLFACTORY qDebug() << "Correct GoogleVersion"; #endif // DEBUG_URLFACTORY - setIsCorrectGoogleVersions(true); - QString url = "http://maps.google.com"; - - qheader.setUrl(QUrl(url)); + //setIsCorrectGoogleVersions(true); + QString url = "https://maps.google.com"; + + qheader.setUrl(QUrl(url)); qheader.setRawHeader("User-Agent", UserAgent); reply = network.get(qheader); tT.start(Timeout); @@ -120,39 +126,42 @@ void UrlFactory::TryCorrectGoogleVersions() return; } QString html = QString(reply->readAll()); - QRegExp reg("\"*http://mt0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive); + QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); VersionGoogleMap = QString("m@%1").arg(gc[1]); VersionGoogleMapChina = VersionGoogleMap; + VersionGoogleMapKorea = VersionGoogleMap; #ifdef DEBUG_URLFACTORY qDebug() << "TryCorrectGoogleVersions, VersionGoogleMap: " << VersionGoogleMap; #endif // DEBUG_URLFACTORY } - reg = QRegExp("\"*http://mt0.google.com/vt/lyrs=h@(\\d*)", Qt::CaseInsensitive); + reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=h@(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); VersionGoogleLabels = QString("h@%1").arg(gc[1]); VersionGoogleLabelsChina = VersionGoogleLabels; + VersionGoogleLabelsKorea = VersionGoogleLabels; #ifdef DEBUG_URLFACTORY qDebug() << "TryCorrectGoogleVersions, VersionGoogleLabels: " << VersionGoogleLabels; #endif // DEBUG_URLFACTORY } - reg = QRegExp("\"*http://khm0.google.com/kh/v=(\\d*)", Qt::CaseInsensitive); + reg = QRegExp("\"*https://khms0.google.com/kh/v=(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); - VersionGoogleSatellite = gc[1]; + VersionGoogleSatellite = gc[1]; VersionGoogleSatelliteKorea = VersionGoogleSatellite; VersionGoogleSatelliteChina = "s@" + VersionGoogleSatellite; qDebug() << "TryCorrectGoogleVersions, VersionGoogleSatellite: " << VersionGoogleSatellite; } - reg = QRegExp("\"*http://mt0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive); + reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); VersionGoogleTerrain = QString("t@%1,r@%2").arg(gc[1]).arg(gc[2]); VersionGoogleTerrainChina = VersionGoogleTerrain; + VersionGoogleTerrainChina = VersionGoogleTerrain; #ifdef DEBUG_URLFACTORY qDebug() << "TryCorrectGoogleVersions, VersionGoogleTerrain: " << VersionGoogleTerrain; #endif // DEBUG_URLFACTORY @@ -169,48 +178,48 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c switch (type) { case MapType::GoogleMap: { - QString server = "mt"; + QString server = "mts"; QString request = "vt"; QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); TryCorrectGoogleVersions(); - - return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMap).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + return QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMap).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); } break; case MapType::GoogleSatellite: { - QString server = "khm"; + QString server = "khms"; QString request = "kh"; QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); TryCorrectGoogleVersions(); - return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + QString VersionGoogleSatellite = "132"; + return QString("https://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); } break; case MapType::GoogleLabels: { - QString server = "mt"; + QString server = "mts"; QString request = "vt"; QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); TryCorrectGoogleVersions(); - return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabels).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + return QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabels).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); } break; case MapType::GoogleTerrain: { - QString server = "mt"; + QString server = "mts"; QString request = "vt"; QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); TryCorrectGoogleVersions(); - return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrain).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + return QString("https://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrain).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); } break; case MapType::GoogleMapChina: @@ -233,7 +242,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); - // TryCorrectGoogleVersions(); + TryCorrectGoogleVersions(); // http://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga return QString("http://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteChina).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); @@ -267,42 +276,45 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c break; case MapType::GoogleMapKorea: { - QString server = "mt"; - QString request = "mt"; + QString server = "mts"; + QString request = "vt"; QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); + TryCorrectGoogleVersions(); + // https://mts0.google.com/vt/lyrs=m@224000000&hl=ko&gl=KR&src=app&x=107&y=50&z=7&s=Gal + // https://mts0.google.com/mt/v=kr1.11&hl=ko&x=109&y=49&z=7&s= + + qDebug() << QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); - // http://mt3.gmaptiles.co.kr/mt/v=kr1.11&hl=lt&x=109&y=49&z=7&s= - - QString ret = QString("http://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + QString ret = QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); return ret; } break; case MapType::GoogleSatelliteKorea: { - QString server = "khm"; + QString server = "khms"; QString request = "kh"; QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); - + TryCorrectGoogleVersions(); // http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s= - return QString("http://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + return QString("https://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); } break; case MapType::GoogleLabelsKorea: { - QString server = "mt"; + QString server = "mts"; QString request = "mt"; QString sec1 = ""; // after &x=... QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); + TryCorrectGoogleVersions(); + // https://mts1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G - // http://mt1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G - - return QString("http://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + return QString("https://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); } break; case MapType::YahooMap: From 27aa911af2b753c282fac366979434caa23c5871 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Fri, 19 Jul 2013 14:14:24 +0000 Subject: [PATCH 009/116] OP-1044 fix slow tiles loading preventig to ask for version at each request --- .../src/libs/opmapcontrol/src/core/urlfactory.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index d422813c4..39d2dc4c2 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -88,6 +88,10 @@ bool UrlFactory::IsCorrectGoogleVersions() void UrlFactory::TryCorrectGoogleVersions() { + static bool versionRetrieved = false; + if (versionRetrieved){ + return; + } QMutexLocker locker(&mutex); @@ -167,6 +171,7 @@ void UrlFactory::TryCorrectGoogleVersions() #endif // DEBUG_URLFACTORY } reply->deleteLater(); + versionRetrieved = true; } } From 05c6d12eacf6fd7d433d8ae7b9cc1682c3d7c30f Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Fri, 19 Jul 2013 14:23:41 +0000 Subject: [PATCH 010/116] OP-1044 Uncrustify --- .../libs/opmapcontrol/src/core/urlfactory.cpp | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index 39d2dc4c2..0bc943ff4 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -33,8 +33,6 @@ const double UrlFactory::EarthRadiusKm = 6378.137; // WGS-84 UrlFactory::UrlFactory() { - - /// /// timeout for map connections /// @@ -89,16 +87,15 @@ bool UrlFactory::IsCorrectGoogleVersions() void UrlFactory::TryCorrectGoogleVersions() { static bool versionRetrieved = false; - if (versionRetrieved){ + + if (versionRetrieved) { return; } QMutexLocker locker(&mutex); if (CorrectGoogleVersions && !IsCorrectGoogleVersions()) { - - - QNetworkReply *reply; + QNetworkReply *reply; QNetworkRequest qheader; QNetworkAccessManager network; QEventLoop q; @@ -111,10 +108,10 @@ void UrlFactory::TryCorrectGoogleVersions() #ifdef DEBUG_URLFACTORY qDebug() << "Correct GoogleVersion"; #endif // DEBUG_URLFACTORY - //setIsCorrectGoogleVersions(true); + // setIsCorrectGoogleVersions(true); QString url = "https://maps.google.com"; - - qheader.setUrl(QUrl(url)); + + qheader.setUrl(QUrl(url)); qheader.setRawHeader("User-Agent", UserAgent); reply = network.get(qheader); tT.start(Timeout); @@ -135,7 +132,7 @@ void UrlFactory::TryCorrectGoogleVersions() QStringList gc = reg.capturedTexts(); VersionGoogleMap = QString("m@%1").arg(gc[1]); VersionGoogleMapChina = VersionGoogleMap; - VersionGoogleMapKorea = VersionGoogleMap; + VersionGoogleMapKorea = VersionGoogleMap; #ifdef DEBUG_URLFACTORY qDebug() << "TryCorrectGoogleVersions, VersionGoogleMap: " << VersionGoogleMap; #endif // DEBUG_URLFACTORY @@ -146,7 +143,7 @@ void UrlFactory::TryCorrectGoogleVersions() QStringList gc = reg.capturedTexts(); VersionGoogleLabels = QString("h@%1").arg(gc[1]); VersionGoogleLabelsChina = VersionGoogleLabels; - VersionGoogleLabelsKorea = VersionGoogleLabels; + VersionGoogleLabelsKorea = VersionGoogleLabels; #ifdef DEBUG_URLFACTORY qDebug() << "TryCorrectGoogleVersions, VersionGoogleLabels: " << VersionGoogleLabels; #endif // DEBUG_URLFACTORY @@ -154,7 +151,7 @@ void UrlFactory::TryCorrectGoogleVersions() reg = QRegExp("\"*https://khms0.google.com/kh/v=(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); - VersionGoogleSatellite = gc[1]; + VersionGoogleSatellite = gc[1]; VersionGoogleSatelliteKorea = VersionGoogleSatellite; VersionGoogleSatelliteChina = "s@" + VersionGoogleSatellite; @@ -200,8 +197,8 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); TryCorrectGoogleVersions(); - QString VersionGoogleSatellite = "132"; - return QString("https://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + QString VersionGoogleSatellite = "132"; + return QString("https://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); } break; case MapType::GoogleLabels: @@ -287,10 +284,10 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); TryCorrectGoogleVersions(); - // https://mts0.google.com/vt/lyrs=m@224000000&hl=ko&gl=KR&src=app&x=107&y=50&z=7&s=Gal + // https://mts0.google.com/vt/lyrs=m@224000000&hl=ko&gl=KR&src=app&x=107&y=50&z=7&s=Gal // https://mts0.google.com/mt/v=kr1.11&hl=ko&x=109&y=49&z=7&s= - - qDebug() << QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); + + qDebug() << QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); QString ret = QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); return ret; From 86a02d693e55c948d48185f7f5473ed1f9f421b3 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 17 Aug 2013 00:51:09 +1000 Subject: [PATCH 011/116] Update copy data for ssl, readme is way out of date, changed one line but on a read through, it's very out of date now as things are easier now. Might be best to link to the Wiki... --- ground/openpilotgcs/copydata.pro | 10 ++++++---- make/winx86/README.txt | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 4c3289264..8cef1495f 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -46,7 +46,7 @@ equals(copydata, 1) { for(dll, QT_IMAGEFORMAT_DLLS) { data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_PLUGINS]/imageformats/$$dll\") $$targetPath(\"$$GCS_APP_PATH/imageformats/$$dll\") $$addNewline() } - + # copy phonon_backend QT_PHONON_BACKEND_DLLS = phonon_ds94.dll data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_APP_PATH/phonon_backend\") $$addNewline() @@ -74,9 +74,11 @@ equals(copydata, 1) { # xcopy /s /e \bin\SDL.dll C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\SDL.dll # xcopy /s /e \include\SDL\* C:\QtSDK\Desktop\Qt\4.7.3\mingw\include\SDL # xcopy /s /e \lib\* C:\QtSDK\Desktop\Qt\4.7.3\mingw\lib - SDL_DLL = SDL.dll - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$(QTMINGW)/$$SDL_DLL\") $$targetPath(\"$$GCS_APP_PATH/$$SDL_DLL\") $$addNewline() - + 3PARTYDLL_DLLS = SDL.dll ssleay32.dll libeay32.dll + for(dll, 3PARTYDLL_DLLS) { + data_copy.commands += $(COPY_FILE) $$targetPath(\"$$(QTMINGW)/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + } + data_copy.target = FORCE QMAKE_EXTRA_TARGETS += data_copy } diff --git a/make/winx86/README.txt b/make/winx86/README.txt index 3bc070ee1..1dc0a1668 100644 --- a/make/winx86/README.txt +++ b/make/winx86/README.txt @@ -27,7 +27,7 @@ OpenPilot. ------------------ Fortunately, it requires only few small text files since all others components should already be installed on your system as parts of msysGit, QtSDK and -CodeSourcery G++ packages required to build the OpenPilot. +Arm compiler packages required to build the OpenPilot. It is expected that you have the following tools installed into the listed locations (but any other locations are fine as well): @@ -39,8 +39,8 @@ locations (but any other locations are fine as well): - Unicode NSIS in %ProgramFiles%\NSIS\Unicode - OpenOCD in C:\OpenOCD\0.4.0\bin (optional) -The SDL library and headers should be installed into Qt directories to build -the GCS. Check the wiki or ground/openpilotgcs/copydata.pro for details. +The SDL and SSL libraries and headers should be installed into Qt directories to +build the GCS. Check the wiki or ground/openpilotgcs/copydata.pro for details. Also it is assumed that you have the C:\Program Files\Git\cmd\ directory in the PATH. Usually this is the case for msysGit installation if you have chosen From 1a27b473d553da761417bec44bb950bd115dff91 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 17 Aug 2013 04:04:22 +1000 Subject: [PATCH 012/116] New CDC driver revsion --- flight/Project/Windows USB/OpenPilot-CDC.inf | 4 +++- .../Project/Windows USB/openpilot-cdc_amd64.cat | Bin 0 -> 5008 bytes flight/Project/Windows USB/openpilot-cdc_x86.cat | Bin 0 -> 5032 bytes 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 flight/Project/Windows USB/openpilot-cdc_amd64.cat create mode 100644 flight/Project/Windows USB/openpilot-cdc_x86.cat diff --git a/flight/Project/Windows USB/OpenPilot-CDC.inf b/flight/Project/Windows USB/OpenPilot-CDC.inf index 17ea68f15..cb81d5239 100644 --- a/flight/Project/Windows USB/OpenPilot-CDC.inf +++ b/flight/Project/Windows USB/OpenPilot-CDC.inf @@ -3,7 +3,9 @@ Signature = "$Windows NT$" Class = Ports ClassGuid = {4D36E978-E325-11CE-BFC1-08002BE10318} Provider = %ProviderName% -DriverVer = 10/15/2009,1.0.0.0 +DriverVer=02/22/2013,2.0.0.0 +CatalogFile.NTx86 = OpenPilot-CDC_x86.cat +CatalogFile.NTamd64 = OpenPilot-CDC_amd64.cat [MANUFACTURER] %ProviderName% = DeviceList, NTx86, NTamd64 diff --git a/flight/Project/Windows USB/openpilot-cdc_amd64.cat b/flight/Project/Windows USB/openpilot-cdc_amd64.cat new file mode 100644 index 0000000000000000000000000000000000000000..a0ad8ffe659f64ba284f9e50cf784b8de519e52b GIT binary patch literal 5008 zcmeHLd011&7N2_)!Xlf12#S~o5=Df}g|J8wfdEB7p++bQ6+?&+jRcY)nxshP7e(m%9)9-!X<9>ITIdkSW=boAT zeseEYSuSK54lN8Td~QPMlWLV^K2}-gkOV>X!iFq87gGk=PY+=g<08w@g+(w4mA4V0 zRxwV1=_od48Fd+r34&?9y)t0MtJnu&U*0Ay7aa61>T5!IU?0kh^5zYv@C0nC<4)43 z#6Gxdm}A|MHwr-%;zP+to(LlzltG${u2X0@3Pi!k9jqSE4uq0|(g*wl;o?Ef6NPF< zV&sJoqEtjY4t+ZxNl-r6%iaK-BuI+HB-5Ng1apuKr6Vy)gOWDOkP^8f5lV*J4J>JB zGGO8G9yos3*WMUKApuORgiEf)a!0-}w;M!13?h9~r*!J>G?uU%izJwo0Dppq=~!$l z>1$X*C!%~O*%9>nLW$(|=<))j0N^ka>U583pF8itDxHxE+A2mj$PHUzGG zk|dE@MI48vJA#9C<|3G0m}k$VQ`40aPAnu*0nrOl9HfQ^$?)#3`E=DFDG5DL#^6YM zBNT={MWY}pUKf^6CLkrD1T-BmlTjjsgaH>Lj%M*_%bShj36^Q#lL&p7PWhjqdwdwW zCv1!lKzIL8bn%CvQy+?+^bWdOWikb;SZb`&D^fE^f+Wq2e!g6%I^9IIoZVv>WdDSR zO}goU(1V|>Lc^RU>JBMO(&?p7^*imqo**iG>Damlrp(QNLgTW+N5u3I7TK{rix@rG1VX2 z(l#SYi>P#QTC_weQ?doJ$;vFDyt|X}zE0Tq4!U_E^bkWun9+P@M5+h^t-p5jUV3eB zlbf}-*2On>Iy~059cQ&4HSTEi86`fj-u<-Qpv)&j#-E%RFl}X3Q~gz|gwW#hd7Gsd zR{oN9uJvpG)r?i2JKAv0=d4|4sTz zudEfcOlb;wwrX|wE{VaNniuxLeb<$6JvxGIUd-+|(Xo78XX&d{uEQCZxEmwL?4oIWYu`LB#Qj)cj{#tw&v*X+Jg=U0q5XP!26t<|wb zt|SAvwNl0K0FmJ0fso|^j!YYDU0}5$jB&q@!PEo0;vCPExwW4XHz$|i0knfD)0%0e zztnUBmHFwW!M_c5l>ZV}ZFXGX1*!qvW(3j6WHLzo0?m#a;KVe>Ml1tRA3Z&N1_MiI zr-95QJPEt0hpC4a4oOui(|x&IkzDH0V+V3mg{~rnE9@Rh=mx!i^ymG#zlu0PPsV1d zh(oaC8VO?=PAUu|3Ol3>0!&rdR~s5hSi5ya^6pQ8t58T?Md=Dxxj0>>kibUG0oQ3T zKDm1|39VRr6)_gHCJp5vHlkTj4F6>yO>AJ+R1L$jfuhAo4s8k8CBRZbjb^Z+CWDbQ z2TS12)L0cTQV2aF7?TbbA$ZVrT~xXi3}aH@)?(AML?f=I6lgHgfQjEkLHmyd3@JoO z3ug+nqXC(YiHq6jqT9WCg>G5=o^jtI| zJr_L({cLi00=j(jytGFu^wU1H2OCi6(R6!qm;KGNy5ZS{+BC!2B^PJoLE1JZ3T?U; zO(s&L_t*|Ny4#B^4AyQkACa4dIT@+g@MY{@`v)!Pak^ zHtXLWutNXYjN)>(ASP*uY)F~c%EPA`wmA)p*+0}aY-(bplc&@+as1%=!$Gmri?*G; znLYSM;#{0i;O8*B+;v>@vbt2KkDl_cMK+w7b!EQwxjPNRi)wR|Q zPdi!psK58!76*&6dWP-p?_EcatY~@6dU}14=Z;BV=tWI$baSZvvP}JG-n8dItLj!K zta&{r$R+x~<*$DI#O`QuS;V3E=PmL}+!0ThUtQf}XJa9dZV5>6_UT()Te#LdB!y#A za%IMOp6!U72fM0rx0!)P!D&OUx=W+T6Bk-O4^K6Y{i2dNbLQy8cT$F>I&$z|X_O0g zh9v=wa?q|J`yGu6iDi$KfnM+fHR1$fL{VL8)Yrt_3!2^H^tUMHUn$hdmySP`4L(s| zRaM}g7*P3zEd6MUS4M_!W>s~+C1u4Ew>V}rj!DT699exkVqe~oHODskluEe1gYIRG zx2T)U}7;D+g&&eRzN2lWpb`Wrr{1tQv1K zspXOL9>&nBruI3uQ4&4H5X0Xb%$GW-7uoiUq@G-KxjL7>-A~k6ex2QH=rZnDTgQ|+ zt>%>$8P6_X`OzZx(hso{n%ao?RB`;Vk#S=^HhBuiI5f^~@T#Cg=jmwqRr&^|l zOs^~>&U&ESuwP|`RDGpZEkB79F?)!v$Wo@93V1C-nNdqk9j*CDI9^`(oyH}lI}*wCw}l~R#x ztRn45g21rQe}^u-=l$;OM;^5dUXrxmb4bFNqE90>-LHR!462vTHy~`MQ&h zwONI?291^63Bz@>mu)VYFmVSbu-*B3^E5%yv1|37>az^9gzS-Aw~9x{lZTisk8tFc z7XCo)j=3Z`n{Apg&VT+TqBQBs(bk;P^CVIH9h*W=yC-)Y_xAOj>1k2=yk+0syzK9q^qKs)r)>!%dBYi{5&rzD zhYL4uGzzMZJn!7M7dOcIDEntYx^wRDb@A%Zh|^(G3fD05I_^E4w1n8uZn7nBjmgwe u`JJ2_;lWSNH0PZaEO35y@b;1H>Gh5C+7GcfFG_z6C7hYeMtUl7M={7?XL1*;ph{h*|v^a6iBxHwRAN8^Jgh+%0B-4OE1ap`er6K`Jfs!_hkqkK@K1zh!87wJi z7GUA1J~%;myrnJ*MG-Ku3@%9z7IsD65P>s9<_M8`LmbZVB=73#c2^pg*NaOMOez9@ zf*sW?W?L<@EzlU{6^as&6vBhZVMYP+p)WjCZHbu1!*4g&GiMxTn(eaXln-86859@B z!U?^Ax+FEnX` zC>R?E*CLW6kwQ*1!!kDFFtxb|ra$(zWYTHsNsntZ3PaH_kq4wC3X&^@C*k#4JbP&Ft6bIp9z{SW;xu~?|?FMoO%Utk@ zgFZ~B|Ig6fJ`UX-Hq1w$yM8RX;A7CKk3~;-4_zVGn~mix1(s_RC>SI`k_I|IwVjcl zZKgWT@7MOXe8$0gy|h7Sz)xAK5ephRM!EsQBq3KIk+CPH@F_Dq zh&J~#GRVlta886SK6E+r#d9fFjOi|hk$vxoAYoE6+fOP@m+(^f0ybBiC}2kjlTw5! zNo=m46NN2R1cQ}-)1k?suq&p)Fz`)^T2OwG)BvncPoZU`6(!`$#1bKoGQDR?iEeff#Z^pXNCo zQce(P+x7MbsdWSN+UxFYnQ^h(`l+VbRO17v>6<36iGqXMT+dnzOMf5$(>*zqSYn0l$n3N( zFdqKez&W*Q`;y!%nTwybn<>k2S^mD6>qYu%ReePi<- zz6+EEx-^B>c%KXiDSDng`i5Tj_>B4d;^^(KHJCGPKPlYvkF=#WgkF79m-XZ87MB!@ zwoYj=NEx}=_(YKt$pFqRmowZzJY299WO;}U(-fOz8?O&yJRGPs=iuIGn{&m^Kc5y{ zOk9bF&<_2XCQM_^wf(14>7VWx{@ZXH$*<9s`X?hiKuw@qpCG!KOa`f$t=w@#Y?-=P zhouFoq@kh7U|=EbWW`Lt@z`16s2G_yB3UL&^>%ULOGIvccA!f#&xtQ}g55*$oT2xR z{+vJemlLPx$=FOeaTu2TTez!P+VOcoL|&JOK|r$td#get2@~g@NZ$V`xJacUCw{8b zNg_xUONFpeGr@H(j8E(xO+qWmQci?}2Bn}(#6~m=3gEvOB#RBqnyh44Hqf;INuVtR zyAW84r_>KN)Wk57=3pV*=}M~UqoDo60Yd~)(t?@Q&4E?kZ?ZE~VdNkdh)nkAAtj;(mPnBjk z(`4cKc$lhn!(?87YLoG3ev|fbbW!meO>e#IMw43)x6#xF z8&C$PE7(p(^adwEvHB7&5DS4qoi!iUEl9rc`Oj9nep|D{VO;xTpWQ!QTbz4vl3izG zu+7WP->>d|biX5e*R|%aHSZ2tulamoVJSNzGGT;xM6pL%?dirUTgS))Bh7;5#D&

$4T zYc%se(8!ZJg{5ut`exDG`tm2{p7%Sf4T~EXX8UeBO&+(k<0ohPFa0;1*%-6w_oe<0VF%ley!gc8cwzCR!!urXNG`jKea1X;b-#tFVT5R> zZ;YqcpvtzCxUOyu%|c%{#rKa`2ks!q}ZQX-!j-7Ws{d8t{bP(wOG`!{QYwbqIvv%w+MvsQ;J6(zrgy2y=1F} zS-`m@f$$O)rGpSiaoT?<1QS)GKnTWuv=9VF(FDTvQz}5tDmp4FW==lN$;G}3AH|qF zZx!Sp4lpWG>LV;_c%nZdymzGeYlL@avJW2F)X#K#eCmXZSH~t0mrCshYmra+i4Jw| zQL<9SCO%vkf3)gp!@}zNLz5EQO@w#y-q>HeRl01E?<_kvmw?F1%AyDEsXCmatyNQ< zR|-&DmMhywWOtx+$EZEEC1)xhJbyBN*6Hf|hOesEZ|ass%Q;`9hwThlb$?CsqR;iI zb!WbB9e_(^CZ{{*1kNijCeFK|te_X-JgOne!Oi;eE21W#dHKG^f{QaX^Vh$IGLn|I@w6rAks>tz8xYi}?2AJ--NYTkl3_gjZ2sc#Z^hl2Ao zB7cvWejw&}|7{D>y@j2DHSDr^u_5bnbG|f^p6`6af0aMfZ%BLEO3$EgtE29gKbD!; zy|BBq{QQd1%Sz))T&luCVzrXvj%~94yyn^o+na}CwOdoljL+I#%HEQlJ}i7@@Va3u z%3}Gux;3UAt({%0`{razi|d@xx2bk-QlU5%JGgcA?bZn!@@{@_J|X0i?XrUY+YdGE zjEo=V=zjT_wzQcOUt_qWzF&z`k*K}!B^qRS?qb{#*NuAE7Ld93 zs`inhwj?W8!Gxzn+ehs2(6}`-r)6lvqVO%53vHgv536~s_xP1}S3*9K{zmuOjDrh| MOJ;2}baa3CZw;8IX#fBK literal 0 HcmV?d00001 From c267d73b42a55a4003d352eb0c3d6185391e4c9b Mon Sep 17 00:00:00 2001 From: David Date: Sat, 17 Aug 2013 04:12:09 +1000 Subject: [PATCH 013/116] Update install script for new drivers --- package/winx86/openpilotgcs.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/winx86/openpilotgcs.nsi b/package/winx86/openpilotgcs.nsi index df5d34152..db6fcf7eb 100644 --- a/package/winx86/openpilotgcs.nsi +++ b/package/winx86/openpilotgcs.nsi @@ -238,7 +238,7 @@ SectionEnd ; Copy driver files Section "-Drivers" InSecDrivers SetOutPath "$INSTDIR\drivers" - File "${PROJECT_ROOT}\flight\Project\Windows USB\OpenPilot-CDC.inf" + File /r "${PROJECT_ROOT}\flight\Project\Windows USB\*" SectionEnd ; Preinstall OpenPilot CDC driver From 974367a0fc2f4b874f92345a56d877a321986f44 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sat, 17 Aug 2013 16:12:52 +0200 Subject: [PATCH 014/116] OP-910 Updated WHATSNEW.txt for 13.06.04 --- WHATSNEW.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/WHATSNEW.txt b/WHATSNEW.txt index 9f6e282ea..cb979bac2 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -1,11 +1,21 @@ +--- RELEASE-13.06.04 --- +This maintenance release includes the following fixes missing in the previously not released to public RELEASE-13.06.03. +- Fixed issues with Google Maps; +- Includes new signed version of CDC drivers for Windows platforms; + +JIRA issues addressed in this maintenance release: +OP-1044, OP-1070, OP-1072 +Use the following link for a comprehensive list of issues addressed by this release +http://progress.openpilot.org/browse/OP-1070 + --- RELEASE-13.06.03 --- This maintenance release addresses the following issues: -- FIxed CC3D attitude estimation failure after multiple settings changes and reboots. +- Fixed CC3D attitude estimation failure after multiple settings changes and reboots. - Fixed OPLink crashes when erasing settings JIRA issues addressed in this maintenance release: -OP-1049, OP-1050 +OP-1049, OP-1050 --- RELEASE-13.06.02 --- From 5a83ef65e50588c80c16a5c53023439d8478e858 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sat, 24 Aug 2013 16:18:10 +0200 Subject: [PATCH 015/116] OP-910 Updated WHATSNEW.txt for 13.06.04 --- WHATSNEW.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WHATSNEW.txt b/WHATSNEW.txt index cb979bac2..f1d379956 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -1,5 +1,5 @@ --- RELEASE-13.06.04 --- -This maintenance release includes the following fixes missing in the previously not released to public RELEASE-13.06.03. +This maintenance release includes the following fixes missing in (previously not released to public) RELEASE-13.06.03. - Fixed issues with Google Maps; - Includes new signed version of CDC drivers for Windows platforms; From 6d57536ff31fbd1f531b2f310bf62dfa24492c3f Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 11 Nov 2013 10:01:16 +0100 Subject: [PATCH 016/116] OP-1107 Still not working but all gui elements are in place. --- .../{authorsdialog.cpp => aboutdialog.cpp} | 46 ++-- .../{authorsdialog.h => aboutdialog.h} | 37 ++-- .../src/plugins/coreplugin/aboutdialog.ui | 36 ++++ .../src/plugins/coreplugin/core.qrc | 2 - .../src/plugins/coreplugin/coreplugin.pro | 15 +- .../src/plugins/coreplugin/mainwindow.cpp | 87 ++------ .../src/plugins/coreplugin/mainwindow.h | 13 +- .../plugins/coreplugin/qml/AboutDialog.qml | 200 +++++++++--------- .../coreplugin/qml/AuthorsModel.qml.template | 2 +- .../coreplugin/qml/ScrollDecorator.qml | 40 ---- .../src/plugins/coreplugin/qml/TabWidget.qml | 102 --------- .../src/plugins/coreplugin/versiondialog.cpp | 109 ---------- .../src/plugins/coreplugin/versiondialog.h | 44 ---- 13 files changed, 195 insertions(+), 538 deletions(-) rename ground/openpilotgcs/src/plugins/coreplugin/{authorsdialog.cpp => aboutdialog.cpp} (77%) rename ground/openpilotgcs/src/plugins/coreplugin/{authorsdialog.h => aboutdialog.h} (74%) create mode 100644 ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h diff --git a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp similarity index 77% rename from ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.cpp rename to ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp index c4f94d6aa..b6a9016a0 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp @@ -1,14 +1,9 @@ /** ****************************************************************************** * - * @file authorsdialog.cpp + * @file aboutdialog.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup CorePlugin Core Plugin - * @{ - * @brief The Core GCS plugin *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -26,46 +21,38 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "authorsdialog.h" +#include "aboutdialog.h" +#include "ui_aboutdialog.h" #include "version_info/version_info.h" #include "coreconstants.h" #include "icore.h" -#include - #include #include #include -#include -#include -#include -#include -#include +#include +#include -#include -#include -#include -#include - -using namespace Core; -using namespace Core::Internal; using namespace Core::Constants; -AuthorsDialog::AuthorsDialog(QWidget *parent) - : QDialog(parent) +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutDialog) { - // We need to set the window icon explicitly here since for some reason the - // application icon isn't used when the size of the dialog is fixed (at least not on X11/GNOME) + ui->setupUi(this); setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); setWindowTitle(tr("About OpenPilot")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - // This loads a QML doc containing a Tabbed view - QDeclarativeView *view = new QDeclarativeView(this); + + // This loads a QML doc + QQuickView *view = new QQuickView(); + QWidget *container = QWidget::createWindowContainer(view, this); view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); + ui->verticalLayout->addWidget(container); QString version = QLatin1String(GCS_VERSION_LONG); version += QDate(2007, 25, 10).toString(Qt::SystemLocaleDate); @@ -108,3 +95,8 @@ AuthorsDialog::AuthorsDialog(QWidget *parent) // Expose the version description to the QML doc view->rootContext()->setContextProperty("version", description); } + +AboutDialog::~AboutDialog() +{ + delete ui; +} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.h b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h similarity index 74% rename from ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.h rename to ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h index 7c88cdf0e..d9d97f1eb 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h @@ -1,14 +1,9 @@ /** ****************************************************************************** * - * @file authors.h + * @file aboutdialog.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup CorePlugin Core Plugin - * @{ - * @brief The Core GCS plugin *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -26,19 +21,25 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef AUTHORSDIALOG_H -#define AUTHORSDIALOG_H +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H #include -namespace Core { -namespace Internal { -class AuthorsDialog : public QDialog { - Q_OBJECT -public: - explicit AuthorsDialog(QWidget *parent); -}; -} // namespace Internal -} // namespace Core +namespace Ui { +class AboutDialog; +} -#endif // AUTHORSDIALOG_H +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_H diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui new file mode 100644 index 000000000..6e50a77c3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui @@ -0,0 +1,36 @@ + + + AboutDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/ground/openpilotgcs/src/plugins/coreplugin/core.qrc b/ground/openpilotgcs/src/plugins/coreplugin/core.qrc index 8a4418c53..f8158f9be 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/core.qrc +++ b/ground/openpilotgcs/src/plugins/coreplugin/core.qrc @@ -62,8 +62,6 @@ images/cpu.png images/tx-rx.svg qml/images/tab.png - qml/ScrollDecorator.qml - qml/TabWidget.qml qml/AboutDialog.qml ../../../../../build/openpilotgcs-synthetics/AuthorsModel.qml diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 1631fda8f..312fc2acb 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -2,7 +2,7 @@ TEMPLATE = lib TARGET = Core DEFINES += CORE_LIBRARY -QT += declarative \ +QT += quick \ xml \ network \ script \ @@ -32,7 +32,6 @@ SOURCES += mainwindow.cpp \ uniqueidmanager.cpp \ messagemanager.cpp \ messageoutputwindow.cpp \ - versiondialog.cpp \ iuavgadget.cpp \ uavgadgetmanager/uavgadgetmanager.cpp \ uavgadgetmanager/uavgadgetview.cpp \ @@ -70,8 +69,8 @@ SOURCES += mainwindow.cpp \ uavgadgetdecorator.cpp \ workspacesettings.cpp \ uavconfiginfo.cpp \ - authorsdialog.cpp \ - telemetrymonitorwidget.cpp + telemetrymonitorwidget.cpp \ + aboutdialog.cpp HEADERS += mainwindow.h \ tabpositionindicator.h \ @@ -105,7 +104,6 @@ HEADERS += mainwindow.h \ iversioncontrol.h \ iview.h \ icorelistener.h \ - versiondialog.h \ core_global.h \ basemode.h \ baseview.h \ @@ -131,15 +129,16 @@ HEADERS += mainwindow.h \ uavgadgetdecorator.h \ workspacesettings.h \ uavconfiginfo.h \ - authorsdialog.h \ iconfigurableplugin.h \ - telemetrymonitorwidget.h + telemetrymonitorwidget.h \ + aboutdialog.h FORMS += dialogs/settingsdialog.ui \ dialogs/shortcutsettings.ui \ generalsettings.ui \ uavgadgetoptionspage.ui \ - workspacesettings.ui + workspacesettings.ui \ + aboutdialog.ui RESOURCES += core.qrc \ fancyactionbar.qrc diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index ecb57a0b2..179ca92f7 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -45,7 +45,7 @@ #include "uavgadgetinstancemanager.h" #include "workspacesettings.h" -#include "authorsdialog.h" +#include "aboutdialog.h" #include "baseview.h" #include "ioutputpane.h" #include "icorelistener.h" @@ -56,7 +56,6 @@ #include "threadmanager.h" #include "uniqueidmanager.h" #include "variablemanager.h" -#include "versiondialog.h" #include #include @@ -114,8 +113,7 @@ MainWindow::MainWindow() : m_modeManager(0), m_connectionManager(0), m_mimeDatabase(new MimeDatabase), - m_versionDialog(0), - m_authorsDialog(0), + m_aboutDialog(0), m_activeContext(0), m_generalSettings(new GeneralSettings), m_shortcutSettings(new ShortcutSettings), @@ -793,7 +791,7 @@ void MainWindow::registerDefaultActions() #ifdef Q_WS_MAC cmd->action()->setMenuRole(QAction::ApplicationSpecificRole); #endif - connect(tmpaction, SIGNAL(triggered()), this, SLOT(aboutOpenPilotAuthors())); + connect(tmpaction, SIGNAL(triggered()), this, SLOT(showAboutDialog())); } void MainWindow::newFile() @@ -802,42 +800,6 @@ void MainWindow::newFile() void MainWindow::openFile() {} -/*static QList getNonEditorFileFactories() - { - QList tmp; - return tmp; - } - - static IFileFactory *findFileFactory(const QList &fileFactories, - const MimeDatabase *db, - const QFileInfo &fi) - { - if (const MimeType mt = db->findByFile(fi)) { - const QString type = mt.type(); - foreach (IFileFactory *factory, fileFactories) { - if (factory->mimeTypes().contains(type)) - return factory; - } - } - return 0; - } - - // opens either an editor or loads a project - void MainWindow::openFiles(const QStringList &fileNames) - { - QList nonEditorFileFactories = getNonEditorFileFactories(); - - foreach (const QString &fileName, fileNames) { - const QFileInfo fi(fileName); - const QString absoluteFilePath = fi.absoluteFilePath(); - if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) { - fileFactory->open(absoluteFilePath); - } else { - - } - } - }*/ - void MainWindow::setFocusToEditor() {} @@ -1404,43 +1366,24 @@ void MainWindow::openRecentFile() if (!fileName.isEmpty()) {} } -void MainWindow::aboutOpenPilotGCS() +void MainWindow::showAboutDialog() { - if (!m_versionDialog) { - m_versionDialog = new VersionDialog(this); - connect(m_versionDialog, SIGNAL(finished(int)), - this, SLOT(destroyVersionDialog())); + if (!m_aboutDialog) { + m_aboutDialog = new AboutDialog(this); + connect(m_aboutDialog, SIGNAL(finished(int)), + this, SLOT(destroyAboutDialog())); } - m_versionDialog->show(); + m_aboutDialog->show(); } -void MainWindow::destroyVersionDialog() +void MainWindow::destroyAboutDialog() { - if (m_versionDialog) { - m_versionDialog->deleteLater(); - m_versionDialog = 0; + if (m_aboutDialog) { + m_aboutDialog->deleteLater(); + m_aboutDialog = 0; } } -void MainWindow::aboutOpenPilotAuthors() -{ - if (!m_authorsDialog) { - m_authorsDialog = new AuthorsDialog(this); - connect(m_authorsDialog, SIGNAL(finished(int)), - this, SLOT(destroyAuthorsDialog())); - } - m_authorsDialog->show(); -} - -void MainWindow::destroyAuthorsDialog() -{ - if (m_authorsDialog) { - m_authorsDialog->deleteLater(); - m_authorsDialog = 0; - } -} - - void MainWindow::aboutPlugins() { PluginDialog dialog(this); @@ -1456,12 +1399,8 @@ void MainWindow::setFullScreen(bool on) if (on) { setWindowState(windowState() | Qt::WindowFullScreen); - // statusBar()->hide(); - // menuBar()->hide(); } else { setWindowState(windowState() & ~Qt::WindowFullScreen); - // menuBar()->show(); - // statusBar()->show(); } } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h index a1aa1f508..c19903424 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h @@ -43,6 +43,8 @@ class QToolButton; class MyTabWidget; QT_END_NAMESPACE +class AboutDialog; + namespace Core { class ActionManager; class BaseMode; @@ -72,8 +74,6 @@ class FancyTabWidget; class GeneralSettings; class ShortcutSettings; class WorkspaceSettings; -class VersionDialog; -class AuthorsDialog; class CORE_EXPORT MainWindow : public EventFilteringMainWindow { Q_OBJECT @@ -154,12 +154,10 @@ private slots: void openRecentFile(); void setFocusToEditor(); void saveAll(); - void aboutOpenPilotGCS(); + void showAboutDialog(); + void destroyAboutDialog(); void aboutPlugins(); - void aboutOpenPilotAuthors(); void updateFocusWidget(QWidget *old, QWidget *now); - void destroyVersionDialog(); - void destroyAuthorsDialog(); void modeChanged(Core::IMode *mode); void showUavGadgetMenus(bool show, bool hasSplitter); void applyTabBarSettings(QTabWidget::TabPosition pos, bool movable); @@ -191,8 +189,7 @@ private: MimeDatabase *m_mimeDatabase; MyTabWidget *m_modeStack; Core::BaseView *m_outputView; - VersionDialog *m_versionDialog; - AuthorsDialog *m_authorsDialog; + AboutDialog *m_aboutDialog; IContext *m_activeContext; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml index 9e1d64f20..b6e7b7299 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml @@ -1,110 +1,100 @@ - /**************************************************************************** - ** - ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - ** All rights reserved. - ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:BSD$ - ** You may use this file under the terms of the BSD license as follows: - ** - ** "Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are - ** met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in - ** the documentation and/or other materials provided with the - ** distribution. - ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor - ** the names of its contributors may be used to endorse or promote - ** products derived from this software without specific prior written - ** permission. - ** - ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ +/** + ****************************************************************************** + * + * @file aboutdialog.qml + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ - import QtQuick 1.1 - - // This is a tabbed pane element. Add a nested Rectangle to add a tab. - TabWidget { - // Define AuthorsModel as type - property AuthorsModel authors: AuthorsModel {} - - id: tabs - width: 640; height: 480 - // This tab is for the GCS version information - Rectangle { - property string title: "OpenPilot GCS" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#e3e3e3" - Image { - source: "../images/openpilot_logo_128.png" - x: 0; y: 0; z: 100 - fillMode: Image.PreserveAspectFit - } - Flickable { - anchors.fill: parent - anchors.centerIn: parent - Text { - id: versionLabel - x: 156; y: 0 - width: 430; height: 379 - horizontalAlignment: Qt.AlignLeft - font.pixelSize: 12 - wrapMode: Text.WordWrap - // @var version exposed in authorsdialog.cpp - text: version - } +import QtQuick 2.0 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 1.0 + +GridLayout { + width: 600 + height: 400 + ColumnLayout { + id: columnLayout1 + anchors.fill: parent + spacing: 10 + RowLayout { + id: rowLayout1 + Image { + id: logo + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 + source: "../images/openpilot_logo_128.png" + z: 100 + fillMode: Image.PreserveAspectFit + } + TabView { + id: tabs + anchors.left: logo.right + anchors.leftMargin: 10 + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 + Layout.fillHeight: true + Layout.fillWidth: true + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + Tab { + title: qsTr("About") + Text { + id: versionLabel + anchors.fill: parent + anchors.margins: 10 + font.pixelSize: 12 + wrapMode: Text.WordWrap + text: version + } + } + + Tab { + title: qsTr("Contributors") + ListView { + id: authorsView + anchors.fill: parent + anchors.margins: 10 + + spacing: 3 + model: authors + delegate: Text { + text: name + } + clip: true + } } } } - // This tab is for the authors/contributors/credits - Rectangle { - property string title: "Contributors" - anchors.fill: parent; color: "#e3e3e3" - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#e3e3e3" - Text { - id: description - text: "

These people have been key contributors to the OpenPilot project. Without the work of the people in this list, OpenPilot would not be what it is today.

This list is sorted alphabetically by name

" - width: 600 - wrapMode: Text.WordWrap - - } - ListView { - id: authorsView - y: description.y + description.height + 20 - width: parent.width; height: parent.height - description.height - 20 - spacing: 3 - model: authors - delegate: Text { - text: name - } - clip: true - } - ScrollDecorator { - flickableItem: authorsView - } - } - } + Button { + id: button + x: 512 + y: 369 + text: qsTr("Ok") + activeFocusOnPress: true + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + } + } } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template b/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template index 63d7e45cc..8bbabc0ab 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template @@ -1,7 +1,7 @@ /* This list model was created for the AuthorsDialog. */ -import QtQuick 1.1 +import QtQuick 2.0 ListModel { ${LIST_ELEMENTS} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml deleted file mode 100644 index 24c79c927..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - id: scrollDecorator - - property Flickable flickableItem: null - - Loader { - id: scrollLoader - sourceComponent: scrollDecorator.flickableItem ? scrollBar : undefined - } - - Component.onDestruction: scrollLoader.sourceComponent = undefined - - Component { - id: scrollBar - Rectangle { - property Flickable flickable: scrollDecorator.flickableItem - - parent: flickable - anchors.right: parent.right - - smooth: true - radius: 2 - color: "gray" - border.color: "lightgray" - border.width: 1.0 - opacity: flickable.moving ? 0.8 : 0.4 - - Behavior on opacity { - NumberAnimation { duration: 500 } - } - - width: 4 - height: flickable.height * (flickable.height / flickable.contentHeight) - y: flickable.height * (flickable.contentY / flickable.contentHeight) - visible: flickable.height < flickable.contentHeight - } - } -} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml deleted file mode 100644 index b6ce6bd41..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Item { - id: tabWidget - - // Setting the default property to stack.children means any child items - // of the TabWidget are actually added to the 'stack' item's children. - // See the "Property Binding" - // documentation for details on default properties. - default property alias content: stack.children - - property int current: 0 - - onCurrentChanged: setOpacities() - Component.onCompleted: setOpacities() - - function setOpacities() { - for (var i = 0; i < stack.children.length; ++i) { - stack.children[i].opacity = (i == current ? 1 : 0) - } - } - - Row { - id: header - - Repeater { - model: stack.children.length - delegate: Rectangle { - width: tabWidget.width / stack.children.length; height: 36 - - Rectangle { - width: parent.width; height: 1 - anchors { bottom: parent.bottom; bottomMargin: 1 } - color: "#acb2c2" - } - BorderImage { - anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } - border { left: 7; right: 7 } - source: "images/tab.png" - visible: tabWidget.current == index - } - Text { - horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter - anchors.fill: parent - text: stack.children[index].title - elide: Text.ElideRight - font.bold: tabWidget.current == index - } - MouseArea { - anchors.fill: parent - onClicked: tabWidget.current = index - } - } - } - } - - Item { - id: stack - width: tabWidget.width - anchors.top: header.bottom; anchors.bottom: tabWidget.bottom - } -} \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp deleted file mode 100644 index 6887239fe..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/** - ****************************************************************************** - * - * @file versiondialog.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup CorePlugin Core Plugin - * @{ - * @brief The Core GCS plugin - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "versiondialog.h" -#include "version_info/version_info.h" -#include "coreconstants.h" -#include "icore.h" - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace Core; -using namespace Core::Internal; -using namespace Core::Constants; - -VersionDialog::VersionDialog(QWidget *parent) - : QDialog(parent) -{ - // We need to set the window icon explicitly here since for some reason the - // application icon isn't used when the size of the dialog is fixed (at least not on X11/GNOME) - setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); - - setWindowTitle(tr("About OpenPilot GCS")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - QGridLayout *layout = new QGridLayout(this); - layout->setSizeConstraint(QLayout::SetFixedSize); - - const QString description = tr( - "

OpenPilot Ground Control Station

" - "GCS Revision: %1
" - "UAVO Hash: %2
" - "
" - "Built from %3
" - "Built on %4 at %5
" - "Based on Qt %6 (%7 bit)
" - "
" - "© %8, 2010-%9. All rights reserved.
" - "
" - "This program is free software; you can redistribute it and/or modify
" - "it under the terms of the GNU General Public License as published by
" - "the Free Software Foundation; either version 3 of the License, or
" - "(at your option) any later version.
" - "
" - "The program is provided AS IS with NO WARRANTY OF ANY KIND, " - "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A " - "PARTICULAR PURPOSE.
" - ).arg( - VersionInfo::revision().left(60), // %1 - VersionInfo::uavoHash().left(8), // %2 - VersionInfo::origin(), // $3 - QLatin1String(__DATE__), // %4 - QLatin1String(__TIME__), // %5 - QLatin1String(QT_VERSION_STR), // %6 - QString::number(QSysInfo::WordSize), // %7 - QLatin1String(GCS_AUTHOR), // %8 - VersionInfo::year() // %9 - ); - - QLabel *copyRightLabel = new QLabel(description); - copyRightLabel->setWordWrap(true); - copyRightLabel->setOpenExternalLinks(true); - copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); - QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close); - QTC_ASSERT(closeButton, /**/); - buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole)); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - - QLabel *logoLabel = new QLabel; - logoLabel->setPixmap(QPixmap(QLatin1String(":/core/images/openpilot_logo_128.png"))); - layout->addWidget(logoLabel, 0, 0, 1, 1); - layout->addWidget(copyRightLabel, 0, 1, 4, 4); - layout->addWidget(buttonBox, 4, 0, 1, 5); -} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h b/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h deleted file mode 100644 index 58fd217b7..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - ****************************************************************************** - * - * @file versiondialog.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup CorePlugin Core Plugin - * @{ - * @brief The Core GCS plugin - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef VERSIONDIALOG_H -#define VERSIONDIALOG_H - -#include - -namespace Core { -namespace Internal { -class VersionDialog : public QDialog { - Q_OBJECT -public: - explicit VersionDialog(QWidget *parent); -}; -} // namespace Internal -} // namespace Core - -#endif // VERSIONDIALOG_H From c06bbdb5cc6270b9d42e8fdb9e09e243f6d392c2 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 20 Oct 2013 14:49:59 +1000 Subject: [PATCH 017/116] Updated pfd.svg and related PFD qml files Still WIP, implemented: * horizont rendering * altitude scale * speed scale * vsi scale * basic compass, without extra marks/points * fixed horizont center mark --- artwork/PFD/pfd.svg | 8229 ++++++++--------- .../pfd/default/AltitudeScale.qml | 45 +- .../openpilotgcs/pfd/default/Compass.qml | 63 +- .../pfd/default/HorizontCenter.qml | 25 + .../share/openpilotgcs/pfd/default/Pfd.qml | 22 +- .../openpilotgcs/pfd/default/PfdWorldView.qml | 66 +- .../openpilotgcs/pfd/default/RollScale.qml | 28 + .../openpilotgcs/pfd/default/SpeedScale.qml | 42 +- .../openpilotgcs/pfd/default/VsiScale.qml | 39 +- .../share/openpilotgcs/pfd/default/pfd.svg | 8219 ++++++++-------- 10 files changed, 7538 insertions(+), 9240 deletions(-) create mode 100644 ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml create mode 100644 ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml diff --git a/artwork/PFD/pfd.svg b/artwork/PFD/pfd.svg index abdc4f8c5..d6c1f8278 100644 --- a/artwork/PFD/pfd.svg +++ b/artwork/PFD/pfd.svg @@ -7,1607 +7,19 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="1038.8931" - height="707.56323" + width="640" + height="480" id="svg2" version="1.1" - inkscape:version="0.48.3.1 r9886" - sodipodi:docname="pfd-11.svg" - style="display:inline" - inkscape:export-filename="C:\Users\Nuno\Desktop\OpenPilot\PFD\PFD-4.png" - inkscape:export-xdpi="71.993568" - inkscape:export-ydpi="71.993568"> + inkscape:version="0.48.2 r9819" + sodipodi:docname="pfd.svg" + inkscape:export-filename="/Users/muralha/Desktop/new PFD ideas/pfd/test2.png" + inkscape:export-xdpi="72" + inkscape:export-ydpi="72"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="defs4" /> - - - - - - - - + inkscape:guide-bbox="true"> + position="320,275.14994" + id="guide4799" /> - + position="299.42715,305" + id="guide7549" /> + position="215.3671,225.48102" + id="guide8295" /> - - - - - - + position="273.07596,436.08863" + id="guide8297" /> + position="328.00768,112" + id="guide8892" /> @@ -1721,2998 +73,3739 @@ image/svg+xml - + - - - - - + id="horizon" + inkscape:label="#g4445" + transform="translate(0,10)"> + + - - - 10 - - - 10 - - - 20 - - - 20 - - - -10 - - - -10 - - - -20 - - - -20 - - - - - - - - - - - - - - + id="path4731" + d="m -163.61586,169.00008 970.78709,0" + style="fill:none;stroke:#ffffff;stroke-width:2.99985003;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> - - - Link - - - - Bat. - - - - GPS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SPD - - ALT - m/s - m - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2 - 1 - 2 - 1 + + id="pitch-scale" + inkscape:label="#g8154" + transform="translate(0,10)"> + + ft/s + style="font-size:12px;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;-inkscape-font-specification:Sans" + y="133.48935" + x="268.41406" + id="tspan6198" + sodipodi:role="line">10 + 10 + + + 20 VSI + style="font-size:12px;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;-inkscape-font-specification:Sans" + y="93.489349" + x="356.41406" + id="tspan6314" + sodipodi:role="line">20 + + + 20 + 20 + + + 10 + 10 + + + 30 + 30 + + + 40 + 40 + + + 50 + 50 + + + 60 + 60 + + + 70 + 70 + + + 80 + 80 + + + 90 + 90 + + + 40 + 40 + + + 30 + 30 + + + 60 + 60 + + + 50 + 50 + + + 80 + 80 + + + 70 + 70 + + + 90 + 90 - - - - - - - - - - - - - - - - - - - - - - - - - 00:00:00 + id="home-eta-text"> + + + + + + + + + - + 0000000 - 000 + id="path6537" + inkscape:connector-curvature="0" /> + + + + + + + - + inkscape:label="home-heading-text" + style="display:inline"> + + + + + + - + + GPS - Sats - + Tx - Rx - Throttle + id="path6284" + inkscape:connector-curvature="0" /> + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1018,98 +1259,138 @@ x="551" y="21" /> - + mA + id="path6812" + inkscape:connector-curvature="0" /> + + - V - WPT - HDG - DIST - MODE - ETA + style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;display:inline;font-family:Sans" + id="battery-volt-label"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1122,45 +1403,76 @@ inkscape:groupmode="layer" id="layer66" inkscape:label="battery-milliamp-text"> - 99999 + + + + + + + - 12.60 + + + + + + + + style="display:inline"> - 00:00:00 + id="waypoint-eta-text"> + + + + + + + + + - 00000000 + id="waypoint-distance-text"> + + + + + + + + + - 000 + id="waypoint-heading-text"> + + + + - Drive Circle Right + id="waypoint-mode-text"> + + + + + + + + + + + + + + + + + - + description or # + id="waypoint-description-text"> + + + + + + + + + + + + + + + + style="display:inline"> + style="display:inline"> + style="display:inline"> - 3D + + + + @@ -1827,7 +2338,8 @@ id="layer7" inkscape:label="compass" style="display:inline" - transform="translate(0,-4)"> + transform="translate(0,-4)" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> @@ -2190,10 +2703,11 @@ + inkscape:transform-center-x="-0.112375" + inkscape:label="#path5060" /> - + N - + + 33 - + + + + + 30 - + + + W - 24 - 21 - + S - + + + + + + + + + + + + + 15 - + + + + + 12 - + + + E - + + + + 6 - + + 3 + inkscape:transform-center-x="-36.348111" + inkscape:transform-center-y="-62.956749" + style="font-size:33.9886322px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;display:inline;font-family:Sans" + id="compass30" + inkscape:label="#compass-30"> + + + style="display:inline" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> + style="font-size:13.59545326px;text-align:center;text-anchor:middle;fill:#ffffff" + id="path6227" + inkscape:connector-curvature="0" /> + style="font-size:13.59545326px;text-align:center;text-anchor:middle;fill:#ffffff" + id="path6229" + inkscape:connector-curvature="0" /> + style="font-size:13.59545326px;text-align:center;text-anchor:middle;fill:#ffffff" + id="path6231" + inkscape:connector-curvature="0" /> + style="display:inline" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> - + + m/s + id="path6208" + inkscape:connector-curvature="0" /> + + + + style="display:inline"> + id="speed1" + inkscape:connector-curvature="0" + inkscape:label="#path8333" /> + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="#path8335" /> + id="speed-2" + inkscape:connector-curvature="0" + inkscape:label="#path8373" /> + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="#path8375" /> + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="#path3522" /> + id="speed-3" + inkscape:connector-curvature="0" + inkscape:label="#path3524" /> + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="#path3530" /> + id="speed4" + inkscape:connector-curvature="0" + inkscape:label="#path3532" /> + + @@ -3169,19 +3720,35 @@ id="layer21" inkscape:label="speed-text" style="display:inline"> - 00000 + + + + + + + - m + inkscape:label="altitude-unit" + style="display:inline"> + + + + inkscape:groupmode="layer"> + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="#path9780" /> + id="altitude2" + inkscape:connector-curvature="0" + inkscape:label="#path9782" /> + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="#path9806" /> + id="altitude-1" + inkscape:connector-curvature="0" + inkscape:label="#path9808" /> + id="altitude-4" + inkscape:connector-curvature="0" + inkscape:label="#path3492" /> + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="#path3494" /> + + + - @@ -3375,7 +3959,8 @@ inkscape:groupmode="layer" id="layer46" inkscape:label="altitude-waypoint" - style="display:inline"> + style="display:inline" + sodipodi:insensitive="true"> - 00000 + id="altitude-text"> + + + + + + - ft/s + inkscape:label="vsi-unit" + style="display:inline"> + + + + + + + style="display:inline" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> + inkscape:label="vsi-scale" + style="display:inline" + sodipodi:insensitive="true"> @@ -3538,7 +4156,8 @@ inkscape:groupmode="layer" id="layer42" inkscape:label="vsi-centerline" - style="display:inline"> + style="display:inline" + sodipodi:insensitive="true"> - + AUTOPILOT + id="path6165" + inkscape:connector-curvature="0" /> + + + + + + + + + + inkscape:label="warning-master-caution" + style="display:inline"> @@ -3613,18 +4269,76 @@ width="125" id="rect4803" style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none" /> - MASTER CAUTION + + + + + + + + + + + + + + + - + RC INPUT + id="path6123" + inkscape:connector-curvature="0" /> + + + + + + + + style="display:inline" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> Date: Sat, 9 Nov 2013 11:03:04 +1000 Subject: [PATCH 022/116] Correctly find the position of GPS fix element using coordinates of "gps-mode-text" element --- .../share/openpilotgcs/pfd/default/Info.qml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml index 741a2ea78..7759188d6 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml @@ -25,14 +25,16 @@ Item { } } - Text { - text: ["No GPS", "No Fix", "Fix2D", "Fix3D"][GPSPositionSensor.Status] + SvgElementPositionItem { + sceneSize: info.sceneSize + elementName: "gps-mode-text" - // TODO: get coords from svg file, as soon as "gps-mode-text" text is converted to path - x: info.sceneSize.width * 0.05 - y: info.sceneSize.height * 0.006 + Text { + text: ["No GPS", "No Fix", "Fix2D", "Fix3D"][GPSPositionSensor.Status] - font.pixelSize: info.sceneSize.height * 0.02 - color: "white" + anchors.centerIn: parent + font.pixelSize: parent.height*1.2 + color: "white" + } } } From 071f81370a8c1ddbba18227852a106006bc712e1 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sat, 9 Nov 2013 11:03:33 +1000 Subject: [PATCH 023/116] Display the speed waypoint element if not 0 --- .../share/openpilotgcs/pfd/default/SpeedScale.qml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml index 4d59b5351..215fca11e 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml @@ -56,6 +56,18 @@ Item { } } } + + SvgElementImage { + id: speed_waypoint + elementName: "speed-waypoint" + sceneSize: sceneItem.sceneSize + visible: PathDesired.EndingVelocity !== 0.0 + + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + anchors.verticalCenterOffset: speed_scale.height/30 * (sceneItem.groundSpeed - PathDesired.EndingVelocity) + } } SvgElementImage { From 40629f62db28fc172688a958153e9f5640169d15 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sat, 9 Nov 2013 11:13:23 +1000 Subject: [PATCH 024/116] Display the altitude waypoint --- .../share/openpilotgcs/pfd/default/AltitudeScale.qml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml index 7c207c67e..9a4b05697 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml @@ -50,6 +50,18 @@ Item { } } } + + SvgElementImage { + id: altitude_waypoint + elementName: "altitude-waypoint" + sceneSize: sceneItem.sceneSize + visible: PathDesired.End_Down !== 0.0 + + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + + anchors.verticalCenterOffset: -altitude_scale.height/30 * (PositionState.Down - PathDesired.End_Down) + } } SvgElementImage { From cab2d22bbb29df831c4cf145268a4219e22ffe94 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sat, 9 Nov 2013 11:20:38 +1000 Subject: [PATCH 025/116] PFD: Display altitude vector bar --- .../share/openpilotgcs/pfd/default/AltitudeScale.qml | 11 +++++++++++ .../src/plugins/pfdqml/pfdqmlgadgetwidget.cpp | 1 + 2 files changed, 12 insertions(+) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml index 9a4b05697..800cf4bd5 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml @@ -51,6 +51,17 @@ Item { } } + SvgElementImage { + id: altitude_vector + elementName: "altitude-vector" + sceneSize: sceneItem.sceneSize + + height: -NedAccel.Down * altitude_scale.height/30 + + anchors.left: parent.left + anchors.bottom: parent.verticalCenter + } + SvgElementImage { id: altitude_waypoint elementName: "altitude-waypoint" diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp index bf6a74c08..d0f599dd8 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp @@ -64,6 +64,7 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : "GPSPositionSensor" << "GCSTelemetryStats" << "SystemAlarms" << + "NedAccel" << "FlightBatteryState"; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); From 9507431cd681c1b83d53d2b13051656da63c00e7 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 13 Nov 2013 23:07:03 +0100 Subject: [PATCH 026/116] OP-1109: port libs/utils - swgImageProvider --- ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp | 2 +- ground/openpilotgcs/src/libs/utils/svgimageprovider.h | 4 ++-- ground/openpilotgcs/src/libs/utils/utils.pro | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp index 2b9a8c79a..14804dbc5 100644 --- a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp +++ b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp @@ -32,7 +32,7 @@ SvgImageProvider::SvgImageProvider(const QString &basePath) : QObject(), - QDeclarativeImageProvider(QDeclarativeImageProvider::Image), + QQuickImageProvider(QQuickImageProvider::Image), m_basePath(basePath) {} diff --git a/ground/openpilotgcs/src/libs/utils/svgimageprovider.h b/ground/openpilotgcs/src/libs/utils/svgimageprovider.h index e24f51e5a..a58b312b5 100644 --- a/ground/openpilotgcs/src/libs/utils/svgimageprovider.h +++ b/ground/openpilotgcs/src/libs/utils/svgimageprovider.h @@ -29,13 +29,13 @@ #define SVGIMAGEPROVIDER_H_ #include -#include +#include #include #include #include "utils_global.h" -class QTCREATOR_UTILS_EXPORT SvgImageProvider : public QObject, public QDeclarativeImageProvider { +class QTCREATOR_UTILS_EXPORT SvgImageProvider : public QObject, public QQuickImageProvider { Q_OBJECT public: SvgImageProvider(const QString &basePath); diff --git a/ground/openpilotgcs/src/libs/utils/utils.pro b/ground/openpilotgcs/src/libs/utils/utils.pro index aff6db1e0..202751020 100644 --- a/ground/openpilotgcs/src/libs/utils/utils.pro +++ b/ground/openpilotgcs/src/libs/utils/utils.pro @@ -6,7 +6,7 @@ QT += gui \ xml \ svg \ opengl \ - declarative \ + qml quick \ widgets DEFINES += QTCREATOR_UTILS_LIB From 067b2e61ae20ddbdfb570a0886982ace4afab522 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 14 Nov 2013 00:04:12 +0100 Subject: [PATCH 027/116] OP-1109: port plugins/QMLView --- .../src/plugins/qmlview/qmlview.pro | 2 +- .../src/plugins/qmlview/qmlviewgadget.cpp | 4 +++- .../src/plugins/qmlview/qmlviewgadget.h | 9 ++++++++- .../plugins/qmlview/qmlviewgadgetfactory.cpp | 2 +- .../plugins/qmlview/qmlviewgadgetwidget.cpp | 18 ++++++------------ .../src/plugins/qmlview/qmlviewgadgetwidget.h | 6 +++--- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlview.pro b/ground/openpilotgcs/src/plugins/qmlview/qmlview.pro index c2897f3a0..de95a7218 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlview.pro +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlview.pro @@ -2,7 +2,7 @@ TEMPLATE = lib TARGET = QMLView QT += svg QT += opengl -QT += declarative +QT += qml quick include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp index d5aa1749c..53db5d56e 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp @@ -33,7 +33,9 @@ QmlViewGadget::QmlViewGadget(QString classId, QmlViewGadgetWidget *widget, QWidget *parent) : IUAVGadget(classId, parent), m_widget(widget) -{} +{ + m_parent = parent; +} QmlViewGadget::~QmlViewGadget() { diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h index 152c58042..fe7fac302 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h @@ -46,11 +46,18 @@ public: QWidget *widget() { - return m_widget; + if(!m_container){ + m_container = QWidget::createWindowContainer(m_widget, m_parent); + m_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + m_container->setMinimumSize(64, 64); + } + return m_container; } void loadConfiguration(IUAVGadgetConfiguration *config); private: + QWidget *m_container; + QWidget *m_parent; QmlViewGadgetWidget *m_widget; }; diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetfactory.cpp index 20b7693bb..619f15179 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetfactory.cpp @@ -42,7 +42,7 @@ QmlViewGadgetFactory::~QmlViewGadgetFactory() Core::IUAVGadget *QmlViewGadgetFactory::createGadget(QWidget *parent) { - QmlViewGadgetWidget *gadgetWidget = new QmlViewGadgetWidget(parent); + QmlViewGadgetWidget *gadgetWidget = new QmlViewGadgetWidget(); return new QmlViewGadget(QString("QmlViewGadget"), gadgetWidget, parent); } diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.cpp index 9abbb4b23..808cf3e80 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.cpp @@ -38,14 +38,12 @@ #include #include -#include -#include +#include +#include -QmlViewGadgetWidget::QmlViewGadgetWidget(QWidget *parent) : - QDeclarativeView(parent) +QmlViewGadgetWidget::QmlViewGadgetWidget(QWindow *parent) : + QQuickView(parent) { - setMinimumSize(64, 64); - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setResizeMode(SizeRootObjectToView); QStringList objectsToExport; @@ -90,7 +88,7 @@ void QmlViewGadgetWidget::setQmlFile(QString fn) qDebug() << Q_FUNC_INFO << fn; setSource(QUrl::fromLocalFile(fn)); - foreach(const QDeclarativeError &error, errors()) { + foreach(const QQmlError &error, errors()) { qDebug() << error.description(); } } @@ -100,9 +98,5 @@ void QmlViewGadgetWidget::setQmlFile(QString fn) */ void QmlViewGadgetWidget::enableOpenGL(bool flag) { - if (flag) { - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); - } else { - setViewport(new QWidget); - } + Q_UNUSED(flag) } diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.h b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.h index 783cc963e..ef54fcf1b 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.h @@ -30,7 +30,7 @@ #include "qmlviewgadgetconfiguration.h" -#include +#include #include #include @@ -40,11 +40,11 @@ class UAVObject; -class QmlViewGadgetWidget : public QDeclarativeView { +class QmlViewGadgetWidget : public QQuickView { Q_OBJECT public: - QmlViewGadgetWidget(QWidget *parent = 0); + QmlViewGadgetWidget(QWindow *parent = 0); ~QmlViewGadgetWidget(); void setQmlFile(QString fn); From 1c23dcd2e497344e78f08ecc217848ad1ddf28ff Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 14 Nov 2013 00:04:34 +0100 Subject: [PATCH 028/116] OP-1109: port plugin/welcome --- .../src/plugins/welcome/qml/ActivityPanel.qml | 3 ++- .../plugins/welcome/qml/CommunityPanel.qml | 2 +- .../src/plugins/welcome/qml/NewsPanel.qml | 3 ++- .../plugins/welcome/qml/ScrollDecorator.qml | 2 +- .../src/plugins/welcome/qml/SitesPanel.qml | 2 +- .../plugins/welcome/qml/WelcomePageButton.qml | 2 +- .../src/plugins/welcome/qml/main.qml | 2 +- .../src/plugins/welcome/welcome.pro | 2 +- .../src/plugins/welcome/welcomemode.cpp | 27 +++++++++++-------- .../src/plugins/welcome/welcomemode.h | 1 + 10 files changed, 27 insertions(+), 19 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/ActivityPanel.qml b/ground/openpilotgcs/src/plugins/welcome/qml/ActivityPanel.qml index 111c4d7e9..fdc258500 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/ActivityPanel.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/ActivityPanel.qml @@ -1,4 +1,5 @@ -import QtQuick 1.1 +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 Item { id: container diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/CommunityPanel.qml b/ground/openpilotgcs/src/plugins/welcome/qml/CommunityPanel.qml index caa3678b2..20f19fd70 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/CommunityPanel.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/CommunityPanel.qml @@ -1,5 +1,5 @@ // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5 -import QtQuick 1.1 +import QtQuick 2.0 Item { property alias sourceSize: background.sourceSize diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml b/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml index 6d794b210..0e6a8ef99 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml @@ -1,5 +1,6 @@ // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5 -import QtQuick 1.1 +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 Item { id: container diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/ScrollDecorator.qml b/ground/openpilotgcs/src/plugins/welcome/qml/ScrollDecorator.qml index 24c79c927..5e4e7e8d9 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/ScrollDecorator.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/ScrollDecorator.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Rectangle { id: scrollDecorator diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml b/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml index c94f243e2..00f2e3664 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml @@ -1,5 +1,5 @@ // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5 -import QtQuick 1.1 +import QtQuick 2.0 Item { id: container diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/WelcomePageButton.qml b/ground/openpilotgcs/src/plugins/welcome/qml/WelcomePageButton.qml index 9e5c1a74f..618baee73 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/WelcomePageButton.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/WelcomePageButton.qml @@ -1,5 +1,5 @@ // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5 -import QtQuick 1.1 +import QtQuick 2.0 Item { id: welcomeButton diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/main.qml b/ground/openpilotgcs/src/plugins/welcome/qml/main.qml index 82e7b1064..7a58a8fa3 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/main.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/main.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Rectangle { id: container diff --git a/ground/openpilotgcs/src/plugins/welcome/welcome.pro b/ground/openpilotgcs/src/plugins/welcome/welcome.pro index eb44bc8da..40eba229c 100644 --- a/ground/openpilotgcs/src/plugins/welcome/welcome.pro +++ b/ground/openpilotgcs/src/plugins/welcome/welcome.pro @@ -1,6 +1,6 @@ TEMPLATE = lib TARGET = Welcome -QT += network declarative +QT += network qml quick include(../../openpilotgcsplugin.pri) include(welcome_dependencies.pri) diff --git a/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp b/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp index 501c4ba7a..838d28ff7 100644 --- a/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp +++ b/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp @@ -45,10 +45,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -59,7 +59,7 @@ namespace Welcome { struct WelcomeModePrivate { WelcomeModePrivate(); - QDeclarativeView *declarativeView; + QQuickView *quickView; }; WelcomeModePrivate::WelcomeModePrivate() @@ -70,15 +70,15 @@ WelcomeMode::WelcomeMode() : m_d(new WelcomeModePrivate), m_priority(Core::Constants::P_MODE_WELCOME) { - m_d->declarativeView = new QDeclarativeView; - m_d->declarativeView->setResizeMode(QDeclarativeView::SizeRootObjectToView); - m_d->declarativeView->engine()->rootContext()->setContextProperty("welcomePlugin", this); - m_d->declarativeView->setSource(QUrl("qrc:/welcome/qml/main.qml")); + m_d->quickView = new QQuickView; + m_d->quickView->setResizeMode(QQuickView::SizeRootObjectToView); + m_d->quickView->engine()->rootContext()->setContextProperty("welcomePlugin", this); + m_d->quickView->setSource(QUrl("qrc:/welcome/qml/main.qml")); } WelcomeMode::~WelcomeMode() { - delete m_d->declarativeView; + delete m_d->quickView; delete m_d; } @@ -99,7 +99,12 @@ int WelcomeMode::priority() const QWidget *WelcomeMode::widget() { - return m_d->declarativeView; + if(!m_container){ + m_container = QWidget::createWindowContainer(m_d->quickView); + m_container->setMinimumSize(64, 64); + m_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + } + return m_container; } const char *WelcomeMode::uniqueModeName() const diff --git a/ground/openpilotgcs/src/plugins/welcome/welcomemode.h b/ground/openpilotgcs/src/plugins/welcome/welcomemode.h index fa3f22856..b6e837cc9 100644 --- a/ground/openpilotgcs/src/plugins/welcome/welcomemode.h +++ b/ground/openpilotgcs/src/plugins/welcome/welcomemode.h @@ -72,6 +72,7 @@ public slots: void triggerAction(const QString &actionId); private: + QWidget *m_container; WelcomeModePrivate *m_d; int m_priority; }; From 710f73d219a594edde335eff85590c3e966f891b Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 14 Nov 2013 00:25:24 +0100 Subject: [PATCH 029/116] OP-1109: port coreplugin/AutorsDialog. TODO: fix dialog/view size handling --- .../src/plugins/coreplugin/authorsdialog.cpp | 16 +++++++++------- .../src/plugins/coreplugin/coreplugin.pro | 2 +- .../src/plugins/coreplugin/qml/AboutDialog.qml | 2 +- .../coreplugin/qml/AuthorsModel.qml.template | 2 +- .../plugins/coreplugin/qml/ScrollDecorator.qml | 2 +- .../src/plugins/coreplugin/qml/TabWidget.qml | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.cpp index c4f94d6aa..8bb2713d1 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.cpp @@ -44,10 +44,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include using namespace Core; using namespace Core::Internal; @@ -63,9 +63,7 @@ AuthorsDialog::AuthorsDialog(QWidget *parent) setWindowTitle(tr("About OpenPilot")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // This loads a QML doc containing a Tabbed view - QDeclarativeView *view = new QDeclarativeView(this); - view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); - + QQuickView *view = new QQuickView(); QString version = QLatin1String(GCS_VERSION_LONG); version += QDate(2007, 25, 10).toString(Qt::SystemLocaleDate); @@ -107,4 +105,8 @@ AuthorsDialog::AuthorsDialog(QWidget *parent) ); // Expose the version description to the QML doc view->rootContext()->setContextProperty("version", description); + view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); + view->setResizeMode(QQuickView::SizeRootObjectToView); + QWidget * container = QWidget::createWindowContainer(view,this); + container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 1631fda8f..667e99192 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -2,7 +2,7 @@ TEMPLATE = lib TARGET = Core DEFINES += CORE_LIBRARY -QT += declarative \ +QT += qml quick \ xml \ network \ script \ diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml index 9e1d64f20..68993a098 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ - import QtQuick 1.1 + import QtQuick 2.0 // This is a tabbed pane element. Add a nested Rectangle to add a tab. TabWidget { diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template b/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template index 63d7e45cc..8bbabc0ab 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml.template @@ -1,7 +1,7 @@ /* This list model was created for the AuthorsDialog. */ -import QtQuick 1.1 +import QtQuick 2.0 ListModel { ${LIST_ELEMENTS} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml index 24c79c927..5e4e7e8d9 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Rectangle { id: scrollDecorator diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml index b6ce6bd41..47e982442 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/TabWidget.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 1.1 +import QtQuick 2.0 Item { id: tabWidget @@ -99,4 +99,4 @@ Item { width: tabWidget.width anchors.top: header.bottom; anchors.bottom: tabWidget.bottom } -} \ No newline at end of file +} From bac4f96d1cf4b8fbcb671f4f303cc6cf32030e37 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 14 Nov 2013 00:48:00 +0100 Subject: [PATCH 030/116] OP-1109: port plugins/pfdqml --- .../pfd/default/AltitudeScale.qml | 2 +- .../openpilotgcs/pfd/default/Compass.qml | 2 +- .../pfd/default/HorizontCenter.qml | 2 +- .../share/openpilotgcs/pfd/default/Info.qml | 2 +- .../share/openpilotgcs/pfd/default/Pfd.qml | 2 +- .../pfd/default/PfdIndicators.qml | 2 +- .../pfd/default/PfdTerrainView.qml | 2 +- .../openpilotgcs/pfd/default/PfdWorldView.qml | 2 +- .../openpilotgcs/pfd/default/RollScale.qml | 2 +- .../openpilotgcs/pfd/default/SpeedScale.qml | 2 +- .../pfd/default/SvgElementImage.qml | 2 +- .../pfd/default/SvgElementPositionItem.qml | 2 +- .../openpilotgcs/pfd/default/VsiScale.qml | 2 +- .../openpilotgcs/pfd/default/Warnings.qml | 2 +- .../src/plugins/pfdqml/pfdqml.pro | 2 +- .../src/plugins/pfdqml/pfdqmlgadget.cpp | 5 +++- .../src/plugins/pfdqml/pfdqmlgadget.h | 9 ++++++- .../plugins/pfdqml/pfdqmlgadgetfactory.cpp | 2 +- .../src/plugins/pfdqml/pfdqmlgadgetwidget.cpp | 27 +++++-------------- .../src/plugins/pfdqml/pfdqmlgadgetwidget.h | 6 ++--- 20 files changed, 37 insertions(+), 42 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml index 800cf4bd5..18df7808e 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml index 45daff990..198b9502c 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 import "." Item { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml index e49145fca..c5f7c36f1 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml index 7759188d6..2697019a6 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: info diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index 18fd41c40..0670e1f36 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Rectangle { color: "#666666" diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml index 641bbbb2e..a254f231e 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml index 2beebf05f..21355d16f 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 import org.OpenPilot 1.0 OsgEarth { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml index ef21f0a20..5fa6f764d 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: worldView diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml index d3551046c..66263efd6 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 import "." Item { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml index 215fca11e..e0b971afa 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml index 2830ac941..6006380f0 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Image { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml index fc1d81cb6..cc43a024b 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml index 29f846859..c40591424 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml index 12af0d24b..0f86755e0 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: warnings diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro b/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro index 55f15b4d2..0d7da9e26 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro @@ -2,7 +2,7 @@ TEMPLATE = lib TARGET = PfdQml QT += svg QT += opengl -QT += declarative +QT += qml quick OSG { DEFINES += USE_OSG } diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp index 365a323b7..30e803f33 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp @@ -21,7 +21,10 @@ PfdQmlGadget::PfdQmlGadget(QString classId, PfdQmlGadgetWidget *widget, QWidget *parent) : IUAVGadget(classId, parent), m_widget(widget) -{} +{ + m_container = NULL; + m_parent = parent; +} PfdQmlGadget::~PfdQmlGadget() { diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h index b6525007f..131ab9b31 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h @@ -35,11 +35,18 @@ public: QWidget *widget() { - return m_widget; + if(!m_container){ + m_container = QWidget::createWindowContainer(m_widget, m_parent); + m_container->setMinimumSize(64, 64); + m_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + } + return m_container; } void loadConfiguration(IUAVGadgetConfiguration *config); private: + QWidget *m_container; + QWidget *m_parent; PfdQmlGadgetWidget *m_widget; }; diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp index f7d6b1f66..197f1929d 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp @@ -31,7 +31,7 @@ PfdQmlGadgetFactory::~PfdQmlGadgetFactory() Core::IUAVGadget *PfdQmlGadgetFactory::createGadget(QWidget *parent) { - PfdQmlGadgetWidget *gadgetWidget = new PfdQmlGadgetWidget(parent); + PfdQmlGadgetWidget *gadgetWidget = new PfdQmlGadgetWidget(); return new PfdQmlGadget(QString("PfdQmlGadget"), gadgetWidget, parent); } diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp index d0f599dd8..7f0262ad3 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp @@ -29,12 +29,11 @@ #include #include -#include -#include -#include +#include +#include -PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : - QDeclarativeView(parent), +PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWindow *parent) : + QQuickView(parent), m_openGLEnabled(false), m_terrainEnabled(false), m_actualPositionUsed(false), @@ -46,8 +45,6 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : m_altitudeUnit("m"), m_altitudeFactor(1.0) { - setMinimumSize(64, 64); - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setResizeMode(SizeRootObjectToView); // setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); @@ -107,7 +104,7 @@ void PfdQmlGadgetWidget::setQmlFile(QString fn) qDebug() << Q_FUNC_INFO << fn; setSource(QUrl::fromLocalFile(fn)); - foreach(const QDeclarativeError &error, errors()) { + foreach(const QQmlError &error, errors()) { qDebug() << error.description(); } } @@ -165,19 +162,7 @@ void PfdQmlGadgetWidget::setAltitudeFactor(double factor) void PfdQmlGadgetWidget::setOpenGLEnabled(bool arg) { - if (m_openGLEnabled != arg) { - m_openGLEnabled = arg; - - qDebug() << Q_FUNC_INFO << "Set OPENGL" << m_openGLEnabled; - if (m_openGLEnabled) { - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); - } else { - setViewport(new QWidget); - } - - // update terrainEnabled status with opengl status chaged setTerrainEnabled(m_terrainEnabled); - } } // Switch between PositionState UAVObject position @@ -197,7 +182,7 @@ void PfdQmlGadgetWidget::mouseReleaseEvent(QMouseEvent *event) setQmlFile(m_qmlFileName); } - QDeclarativeView::mouseReleaseEvent(event); + QQuickView::mouseReleaseEvent(event); } void PfdQmlGadgetWidget::setLatitude(double arg) diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h index 42b21edee..222fb8ce4 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h @@ -18,9 +18,9 @@ #define PFDQMLGADGETWIDGET_H_ #include "pfdqmlgadgetconfiguration.h" -#include +#include -class PfdQmlGadgetWidget : public QDeclarativeView { +class PfdQmlGadgetWidget : public QQuickView { Q_OBJECT Q_PROPERTY(QString earthFile READ earthFile WRITE setEarthFile NOTIFY earthFileChanged) Q_PROPERTY(bool terrainEnabled READ terrainEnabled WRITE setTerrainEnabled NOTIFY terrainEnabledChanged) @@ -37,7 +37,7 @@ class PfdQmlGadgetWidget : public QDeclarativeView { Q_PROPERTY(double altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged) public: - PfdQmlGadgetWidget(QWidget *parent = 0); + PfdQmlGadgetWidget(QWindow *parent = 0); ~PfdQmlGadgetWidget(); void setQmlFile(QString fn); From c179d388e32aa9057fc034245df117e40dda2e68 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Thu, 14 Nov 2013 00:48:34 +0100 Subject: [PATCH 031/116] OP-1109: fix uninitialized use of m_container --- ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp index 53db5d56e..aa071e893 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp @@ -34,6 +34,7 @@ QmlViewGadget::QmlViewGadget(QString classId, QmlViewGadgetWidget *widget, QWidg IUAVGadget(classId, parent), m_widget(widget) { + m_container = NULL; m_parent = parent; } From 89e261c3f8fa2685d34a93a95c18f7e7572dee5c Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Thu, 14 Nov 2013 22:41:39 +0100 Subject: [PATCH 032/116] OP-1109: added required DLLs --- ground/openpilotgcs/copydata.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 0f30ae9fc..257e19d4d 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -31,6 +31,9 @@ equals(copydata, 1) { Qt5SerialPort$${DS}.dll \ Qt5Multimedia$${DS}.dll \ Qt5MultimediaWidgets$${DS}.dll \ + Qt5Quick$${DS}.dll \ + Qt5Qml$${DS}.dll \ + Qt5V8$${DS}.dll \ icuin51.dll \ icudt51.dll \ icuuc51.dll From 300888e8b125ce008c7b8f68af4562a1d0ed4407 Mon Sep 17 00:00:00 2001 From: m_thread Date: Fri, 15 Nov 2013 11:58:59 +0100 Subject: [PATCH 033/116] OP-1107 Implements the new About dialog in QtQuick 2.0. --- .../src/plugins/coreplugin/aboutdialog.cpp | 62 ++++++------ .../src/plugins/coreplugin/aboutdialog.h | 9 +- .../src/plugins/coreplugin/aboutdialog.ui | 36 ------- .../src/plugins/coreplugin/coreplugin.pro | 6 +- .../plugins/coreplugin/qml/AboutDialog.qml | 98 +++++++++++++------ 5 files changed, 103 insertions(+), 108 deletions(-) delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp index b6a9016a0..9f6077a97 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp @@ -31,56 +31,33 @@ #include #include #include +#include -#include +#include +#include +#include #include using namespace Core::Constants; AboutDialog::AboutDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutDialog) + QDialog(parent) { - ui->setupUi(this); - setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); setWindowTitle(tr("About OpenPilot")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - - // This loads a QML doc - QQuickView *view = new QQuickView(); - QWidget *container = QWidget::createWindowContainer(view, this); - view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); - - ui->verticalLayout->addWidget(container); - - QString version = QLatin1String(GCS_VERSION_LONG); - version += QDate(2007, 25, 10).toString(Qt::SystemLocaleDate); - - QString ideRev; - - // : This gets conditionally inserted as argument %8 into the description string. - ideRev = tr("From revision %1
").arg(VersionInfo::revision().left(10)); + setMinimumSize(600, 400); + setMaximumSize(800, 600); const QString description = tr( - "

OpenPilot Ground Control Station

" - "GCS Revision: %1
" + "Revision: %1
" "UAVO Hash: %2
" "
" "Built from %3
" "Built on %4 at %5
" "Based on Qt %6 (%7 bit)
" "
" - "© %8, 2010-%9. All rights reserved.
" - "
" - "This program is free software; you can redistribute it and/or modify
" - "it under the terms of the GNU General Public License as published by
" - "the Free Software Foundation; either version 3 of the License, or
" - "(at your option) any later version.
" - "
" - "The program is provided AS IS with NO WARRANTY OF ANY KIND, " - "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A " - "PARTICULAR PURPOSE.
" + "© %8, 2010-%9. All rights reserved.
" ).arg( VersionInfo::revision().left(60), // %1 VersionInfo::uavoHash().left(8), // %2 @@ -92,11 +69,28 @@ AboutDialog::AboutDialog(QWidget *parent) : QLatin1String(GCS_AUTHOR), // %8 VersionInfo::year() // %9 ); - // Expose the version description to the QML doc + + QQuickView *view = new QQuickView(); + view->rootContext()->setContextProperty("dialog", this); view->rootContext()->setContextProperty("version", description); + view->setResizeMode(QQuickView::SizeRootObjectToView); + view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); + + QWidget * container = QWidget::createWindowContainer(view); + container->setMinimumSize(600, 400); + container->setMaximumSize(800, 600); + container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + QVBoxLayout *lay = new QVBoxLayout(); + lay->setContentsMargins(0,0,0,0); + setLayout(lay); + layout()->addWidget(container); +} + +void AboutDialog::openUrl(const QString &url) +{ + QDesktopServices::openUrl(QUrl(url)); } AboutDialog::~AboutDialog() { - delete ui; } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h index d9d97f1eb..6bce8d24b 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h @@ -26,10 +26,6 @@ #include -namespace Ui { -class AboutDialog; -} - class AboutDialog : public QDialog { Q_OBJECT @@ -38,8 +34,9 @@ public: explicit AboutDialog(QWidget *parent = 0); ~AboutDialog(); -private: - Ui::AboutDialog *ui; +public slots: + void openUrl(const QString &url); + }; #endif // ABOUTDIALOG_H diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui deleted file mode 100644 index 6e50a77c3..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.ui +++ /dev/null @@ -1,36 +0,0 @@ - - - AboutDialog - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 312fc2acb..f566a71e0 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -2,7 +2,8 @@ TEMPLATE = lib TARGET = Core DEFINES += CORE_LIBRARY -QT += quick \ +QT += qml \ + quick \ xml \ network \ script \ @@ -137,8 +138,7 @@ FORMS += dialogs/settingsdialog.ui \ dialogs/shortcutsettings.ui \ generalsettings.ui \ uavgadgetoptionspage.ui \ - workspacesettings.ui \ - aboutdialog.ui + workspacesettings.ui RESOURCES += core.qrc \ fancyactionbar.qrc diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml index b6e7b7299..bd3d9c9e6 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml @@ -2,8 +2,8 @@ ****************************************************************************** * * @file aboutdialog.qml - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -20,20 +20,24 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -import QtQuick 2.0 +import QtQuick 2.1 import QtQuick.Layouts 1.0 import QtQuick.Controls 1.0 -GridLayout { +Rectangle { + id: container width: 600 height: 400 + + property AuthorsModel authors: AuthorsModel {} + ColumnLayout { id: columnLayout1 anchors.fill: parent spacing: 10 RowLayout { id: rowLayout1 + opacity: 1 Image { id: logo anchors.left: parent.left @@ -43,58 +47,94 @@ GridLayout { source: "../images/openpilot_logo_128.png" z: 100 fillMode: Image.PreserveAspectFit + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: { + dialog.openUrl("http://www.openpilot.org") + } + } } - TabView { - id: tabs + + Rectangle { anchors.left: logo.right - anchors.leftMargin: 10 + anchors.margins: 10 anchors.right: parent.right - anchors.rightMargin: 10 anchors.top: parent.top - anchors.topMargin: 10 Layout.fillHeight: true Layout.fillWidth: true anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - Tab { - title: qsTr("About") + color: "transparent" + + ColumnLayout { + anchors.fill: parent + Text { + id: headerLabel + text: qsTr("OpenPilot Ground Control Station") + Layout.fillWidth: true + font.pixelSize: 14 + font.bold: true + + } Text { id: versionLabel - anchors.fill: parent - anchors.margins: 10 + Layout.fillWidth: true font.pixelSize: 12 wrapMode: Text.WordWrap text: version } - } + Text { + id: licenseLabel + Layout.fillWidth: true + font.pixelSize: 9 + wrapMode: Text.WordWrap + text: qsTr("This program is free software; you can redistribute it and/or " + + "modify it under the terms of the GNU General Public License " + + "as published by the Free Software Foundation; either version 3 " + + "of the License, or (at your option) any later version.\n" + + "The program is provided AS IS with NO WARRANTY OF ANY KIND, " + + "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.") + } - Tab { - title: qsTr("Contributors") - ListView { - id: authorsView - anchors.fill: parent - anchors.margins: 10 + Text { + id: contributorLabel + text: qsTr("Contributors") + Layout.fillWidth: true + font.pixelSize: 14 + font.bold: true - spacing: 3 - model: authors - delegate: Text { - text: name + } + ScrollView { + Layout.fillWidth: true + Layout.fillHeight: true + frameVisible: true + ListView { + id: authorsView + anchors.fill: parent + + spacing: 3 + model: authors + delegate: Text { + font.pixelSize: 12 + text: name + } + clip: true } - clip: true } } } } Button { id: button - x: 512 - y: 369 text: qsTr("Ok") activeFocusOnPress: true anchors.right: parent.right anchors.rightMargin: 10 anchors.bottom: parent.bottom anchors.bottomMargin: 10 + onClicked: dialog.close() } } } From c48c4f5088cc8ea6886c791678c51a52cd18a998 Mon Sep 17 00:00:00 2001 From: m_thread Date: Fri, 15 Nov 2013 12:58:43 +0100 Subject: [PATCH 034/116] OP-1107 removed a faulty include --- ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp index 9f6077a97..abb08535a 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp @@ -22,7 +22,6 @@ */ #include "aboutdialog.h" -#include "ui_aboutdialog.h" #include "version_info/version_info.h" #include "coreconstants.h" From 01423dba8a30d8382de95b121d0d89d96284b5a5 Mon Sep 17 00:00:00 2001 From: m_thread Date: Fri, 15 Nov 2013 13:16:11 +0100 Subject: [PATCH 035/116] OP-1107 Another mistake --- ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp index abb08535a..0e24b4209 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include From 674af2cf35669a31a1dba6eee614e7358f249966 Mon Sep 17 00:00:00 2001 From: m_thread Date: Fri, 15 Nov 2013 13:18:35 +0100 Subject: [PATCH 036/116] OP-1107 :/ --- ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp index 0e24b4209..e47015051 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include From 16c157591b7480aa5a6f162b649ced1674425761 Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Sat, 16 Nov 2013 03:42:11 +1100 Subject: [PATCH 037/116] Create QtQuick directories --- ground/openpilotgcs/copydata.pro | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 257e19d4d..5e3c82727 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -70,6 +70,22 @@ equals(copydata, 1) { data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_PLUGINS]/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() } + # create QtQuick2 plugin directories + QT_QUICK2_DIRS = qtquick \ + qtquick2 \ + qtquick/controls \ + qtquick/dialogs \ + qtquick/layouts \ + qtquick/localstorage \ + qtquick/controls \ + qtquick/particles.2 \ + qtquick/privatewidgets \ + qtquick/window.2 \ + qtquick/xmllistmodel + for(dir, QT_QUICK2_DIRS) { + data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_APP_PATH/$$dir\") $$addNewline() + } + # copy MinGW DLLs MINGW_DLLS = SDL.dll for(dll, MINGW_DLLS) { From 85387f000a093c4901fa6861218a83b136d9f0f3 Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Sat, 16 Nov 2013 03:46:04 +1100 Subject: [PATCH 038/116] Only make controls directory once --- ground/openpilotgcs/copydata.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 5e3c82727..31e020d1d 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -77,7 +77,6 @@ equals(copydata, 1) { qtquick/dialogs \ qtquick/layouts \ qtquick/localstorage \ - qtquick/controls \ qtquick/particles.2 \ qtquick/privatewidgets \ qtquick/window.2 \ From d868c12a09279652c19cb38a44e0177ffdadb394 Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Sat, 16 Nov 2013 04:11:53 +1100 Subject: [PATCH 039/116] QtQuick2 DLLs copied, fixed directory name with missing period also --- ground/openpilotgcs/copydata.pro | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 31e020d1d..fc8e89c78 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -72,7 +72,7 @@ equals(copydata, 1) { # create QtQuick2 plugin directories QT_QUICK2_DIRS = qtquick \ - qtquick2 \ + qtquick.2 \ qtquick/controls \ qtquick/dialogs \ qtquick/layouts \ @@ -85,6 +85,14 @@ equals(copydata, 1) { data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_APP_PATH/$$dir\") $$addNewline() } + # copy QtQuick plugin DLLs + QT_QUICK2_DLLS = QtQuick.2/qtquick2plugin$${DS}.dll \ + QtQuick.2/plugins.qmltypes \ + QtQuick.2/qmldir + for(dll, QT_QUICK2_DLLS) { + data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_QML]/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + } + # copy MinGW DLLs MINGW_DLLS = SDL.dll for(dll, MINGW_DLLS) { From f1dd376b79a1d632bd6cd5dea5067a249f8e5bb3 Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Sat, 16 Nov 2013 04:35:09 +1100 Subject: [PATCH 040/116] Standard QtQuick2 working, welcome, PFD etc --- ground/openpilotgcs/copydata.pro | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index fc8e89c78..0b661c32b 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -88,7 +88,32 @@ equals(copydata, 1) { # copy QtQuick plugin DLLs QT_QUICK2_DLLS = QtQuick.2/qtquick2plugin$${DS}.dll \ QtQuick.2/plugins.qmltypes \ - QtQuick.2/qmldir + QtQuick.2/qmldir \ + qtquick/controls/qtquickcontrolsplugin$${DS}.dll \ + qtquick/controls/plugins.qmltypes \ + qtquick/controls/qmldir \ + qtquick/dialogs/dialogplugin$${DS}.dll \ + qtquick/dialogs/plugins.qmltypes \ + qtquick/dialogs/qmldir \ + qtquick/layouts/qquicklayoutsplugin$${DS}.dll \ + qtquick/layouts/plugins.qmltypes \ + qtquick/layouts/qmldir \ + qtquick/localstorage/qmllocalstorageplugin$${DS}.dll \ + qtquick/localstorage/plugins.qmltypes \ + qtquick/localstorage/qmldir \ + qtquick/particles.2/particlesplugin$${DS}.dll \ + qtquick/particles.2/plugins.qmltypes \ + qtquick/particles.2/qmldir \ + qtquick/privatewidgets/widgetsplugin$${DS}.dll \ + qtquick/privatewidgets/plugins.qmltypes \ + qtquick/privatewidgets/qmldir \ + qtquick/window.2/windowplugin$${DS}.dll \ + qtquick/window.2/plugins.qmltypes \ + qtquick/window.2/qmldir \ + qtquick/XmlListModel/qmlxmllistmodelplugin$${DS}.dll \ + qtquick/XmlListModel/plugins.qmltypes \ + qtquick/XmlListModel/qmldir + for(dll, QT_QUICK2_DLLS) { data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_QML]/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() } From e53db99d899ef16db510ec4b1cb4a4a7e9bbbc98 Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Sat, 16 Nov 2013 05:57:39 +1100 Subject: [PATCH 041/116] Add private shared QtQuick types --- ground/openpilotgcs/copydata.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 0b661c32b..9a462bd91 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -74,6 +74,7 @@ equals(copydata, 1) { QT_QUICK2_DIRS = qtquick \ qtquick.2 \ qtquick/controls \ + qtquick/controls/private \ qtquick/dialogs \ qtquick/layouts \ qtquick/localstorage \ @@ -92,6 +93,8 @@ equals(copydata, 1) { qtquick/controls/qtquickcontrolsplugin$${DS}.dll \ qtquick/controls/plugins.qmltypes \ qtquick/controls/qmldir \ + qtquick/controls/private/qtquickcontrolsprivateplugin$${DS}.dll \ + qtquick/controls/private/qmldir \ qtquick/dialogs/dialogplugin$${DS}.dll \ qtquick/dialogs/plugins.qmltypes \ qtquick/dialogs/qmldir \ From b1fd5db4f5952e3c041d7d7731ca341931a3aa41 Mon Sep 17 00:00:00 2001 From: Patrick Huebner Date: Sat, 16 Nov 2013 17:22:51 +1100 Subject: [PATCH 042/116] OP-1118 Fix for QComboBox focus bug in UAVObjectBrowser on Mac OSX --- .../openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h index cbdab0cb5..2876c6f0f 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h @@ -114,7 +114,8 @@ public: QWidget *createEditor(QWidget *parent) { QComboBox *editor = new QComboBox(parent); - + // Setting ClickFocus lets the ComboBox stay open on Mac OSX. + editor->setFocusPolicy(Qt::ClickFocus); foreach(QString option, m_enumOptions) editor->addItem(option); return editor; From 1edfd56d48f55480bf2259174a366c9c20baebe5 Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Sat, 16 Nov 2013 19:18:36 +1100 Subject: [PATCH 043/116] For controls and Dialogs, use Copydir directive as all qml files are needed and this is the "easy way", the other solution is to list every single qml file by hand, these will likely be added to in upcomming releases of Qt and cause maintaince. The downside is three debug DLLs get copied also, if required I can expand copydata.pro to delete them after the copy if required. As we are making some changes to the build system, this at least enables working builds of QtQuick2, if before packaging we do not have a better solution, I will make sure the extra debug DLLs are removed. --- ground/openpilotgcs/copydata.pro | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 9a462bd91..8212cc25b 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -73,9 +73,6 @@ equals(copydata, 1) { # create QtQuick2 plugin directories QT_QUICK2_DIRS = qtquick \ qtquick.2 \ - qtquick/controls \ - qtquick/controls/private \ - qtquick/dialogs \ qtquick/layouts \ qtquick/localstorage \ qtquick/particles.2 \ @@ -86,18 +83,19 @@ equals(copydata, 1) { data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_APP_PATH/$$dir\") $$addNewline() } + # Copy QtQuick2 complete directories + # These directories have a lot of files + # Easier to copy everything + QTQ_WHOLE_DIRS = qtquick/controls \ + qtquick/dialogs + for(dir, QTQ_WHOLE_DIRS) { + data_copy.commands += $(COPY_DIR) $$targetPath(\"$$[QT_INSTALL_QML]/$$dir\") $$targetPath(\"$$GCS_APP_PATH/$$dir\") $$addNewline() + } + # copy QtQuick plugin DLLs QT_QUICK2_DLLS = QtQuick.2/qtquick2plugin$${DS}.dll \ QtQuick.2/plugins.qmltypes \ QtQuick.2/qmldir \ - qtquick/controls/qtquickcontrolsplugin$${DS}.dll \ - qtquick/controls/plugins.qmltypes \ - qtquick/controls/qmldir \ - qtquick/controls/private/qtquickcontrolsprivateplugin$${DS}.dll \ - qtquick/controls/private/qmldir \ - qtquick/dialogs/dialogplugin$${DS}.dll \ - qtquick/dialogs/plugins.qmltypes \ - qtquick/dialogs/qmldir \ qtquick/layouts/qquicklayoutsplugin$${DS}.dll \ qtquick/layouts/plugins.qmltypes \ qtquick/layouts/qmldir \ From 00321b09dcf7b869ed27dcce2e717938f2994806 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sat, 16 Nov 2013 17:30:40 +0100 Subject: [PATCH 044/116] Modified uavobjectmanager to only use logfs calls for UAVObject flash transactions, abstracted dosfs calls to use logfs wrapper class for simpiosix and SD-card access --- flight/pios/common/pios_dosfs_logfs.c | 273 +++++++++++++++++ flight/pios/pios_sim_posix.h | 2 + flight/pios/posix/pios_dosfs_logfs.c | 273 +++++++++++++++++ .../targets/boards/simposix/board_hw_defs.c | 4 + .../boards/simposix/firmware/pios_board.c | 8 + flight/uavobjects/uavobjectmanager.c | 281 ------------------ 6 files changed, 560 insertions(+), 281 deletions(-) create mode 100644 flight/pios/common/pios_dosfs_logfs.c create mode 100644 flight/pios/posix/pios_dosfs_logfs.c diff --git a/flight/pios/common/pios_dosfs_logfs.c b/flight/pios/common/pios_dosfs_logfs.c new file mode 100644 index 000000000..83a83bbd7 --- /dev/null +++ b/flight/pios/common/pios_dosfs_logfs.c @@ -0,0 +1,273 @@ +/** + ****************************************************************************** + * @file pios_dosfs_logfs.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @brief Log Structured Filesystem wrapper implemented using dosfs + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "pios.h" + +#ifdef PIOS_USE_SETTINGS_ON_SDCARD + +#include + +#if defined(PIOS_INCLUDE_FREERTOS) +static xSemaphoreHandle mutex; +#endif + +struct flashfs_logfs_cfg; + + +/** + * Wrapper for the unimplemented sprintf function + * warning, no buffer length boundary checks, use with caution! + */ +static void customSPrintf(uint8_t *buffer, uint8_t *format, ...) +{ + va_list args; + + va_start(args, format); + vsprintf((char *)buffer, (char *)format, args); +} + + +/** + * Get an 8 character (plus extension) filename for the object. + * @param[in] obj The object handle. + * @param[in] instId The instance ID + * @param[in] file Filename string pointer WARNING, must be 14 bytes long and allocated, no checks! + */ +static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename) +{ + uint32_t prefix = obj_id + (obj_inst_id / 256); + uint8_t suffix = obj_inst_id & 0xff; + + customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix); +} + + +/** + * @brief Initialize the flash object setting FS + * @return 0 if success, -1 if failure + */ +int32_t PIOS_FLASHFS_Logfs_Init(__attribute__((unused)) uintptr_t *fs_id, __attribute__((unused)) const struct flashfs_logfs_cfg *cfg, __attribute__((unused)) const struct pios_flash_driver *driver, __attribute__((unused)) uintptr_t flash_id) +{ +#if defined(PIOS_INCLUDE_FREERTOS) + if (!mutex) { + mutex = xSemaphoreCreateRecursiveMutex(); + } +#endif + return 0; +} + +int32_t PIOS_FLASHFS_Logfs_Destroy(__attribute__((unused)) uintptr_t fs_id) +{ + // stub, only wrapper for dosfs, does not need destroying + return 0; +} + +/********************************** + * + * Provide a PIOS_FLASHFS_* driver + * + *********************************/ +#include "pios_flashfs.h" /* API for flash filesystem */ + +/** + * @brief Saves one object instance to the filesystem + * @param[in] fs_id The filesystem to use for this action + * @param[in] obj UAVObject ID of the object to save + * @param[in] obj_inst_id The instance number of the object being saved + * @param[in] obj_data Contents of the object being saved + * @param[in] obj_size Size of the object being saved + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if failure to delete any previous versions of the object + * @retval -4 if filesystem is entirely full and garbage collection won't help + * @retval -5 if garbage collection failed + * @retval -6 if filesystem is full even after garbage collection should have freed space + * @retval -7 if writing the new object to the filesystem failed + */ +int32_t PIOS_FLASHFS_ObjSave(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) +{ + FILEINFO file; + uint8_t filename[14]; + + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + + // Lock + +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); +#endif + + // Get filename + objectFilename(obj_id, obj_inst_id, filename); + + // Open file + if (PIOS_FOPEN_WRITE(filename, file)) { +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + return -2; + } + // Append object + uint32_t bytes_written = 0; + PIOS_FWRITE(&file, obj_data, obj_size, &bytes_written); + + // Done, close file and unlock + PIOS_FCLOSE(file); +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + + if (bytes_written != obj_size) { + return -7; + } + + return 0; +} + +/** + * @brief Load one object instance from the filesystem + * @param[in] fs_id The filesystem to use for this action + * @param[in] obj UAVObject ID of the object to load + * @param[in] obj_inst_id The instance of the object to load + * @param[in] obj_data Buffer to hold the contents of the loaded object + * @param[in] obj_size Size of the object to be loaded + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if object not found in filesystem + * @retval -4 if object size in filesystem does not exactly match buffer size + * @retval -5 if reading the object data from flash fails + */ +int32_t PIOS_FLASHFS_ObjLoad(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) +{ + FILEINFO file; + uint8_t filename[14]; + + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + +#if defined(PIOS_INCLUDE_FREERTOS) + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); +#endif + // Get filename + objectFilename(obj_id, obj_inst_id, filename); + + // Open file + if (PIOS_FOPEN_READ(filename, file)) { +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + return -1; + } + // Load object + uint32_t bytes_read = 0; + uint32_t result = PIOS_FREAD(&file, obj_data, obj_size, &bytes_read); + + // Done, close file and unlock + PIOS_FCLOSE(file); +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + if (result != 0) { + return -1; + } + return 0; +} + +/** + * @brief Delete one instance of an object from the filesystem + * @param[in] fs_id The filesystem to use for this action + * @param[in] obj UAVObject ID of the object to delete + * @param[in] obj_inst_id The instance of the object to delete + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if failed to delete the object from the filesystem + */ +int32_t PIOS_FLASHFS_ObjDelete(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id) +{ + uint8_t filename[14]; + + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } +#if defined(PIOS_INCLUDE_FREERTOS) + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); +#endif + // Get filename + objectFilename(obj_id, obj_inst_id, filename); + + // Delete file + PIOS_FUNLINK(filename); + + // Done +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + return 0; +} + +/** + * @brief Erases all filesystem arenas and activate the first arena + * @param[in] fs_id The filesystem to use for this action + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if failed to erase all arenas + * @retval -4 if failed to activate arena 0 + * @retval -5 if failed to mount arena 0 + */ +int32_t PIOS_FLASHFS_Format(__attribute__((unused)) uintptr_t fs_id) +{ + /* stub - not implemented */ + return -1; +} + +/** + * @brief Returs stats for the filesystems + * @param[in] fs_id The filesystem to use for this action + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + */ +int32_t PIOS_FLASHFS_GetStats(__attribute__((unused)) uintptr_t fs_id, __attribute__((unused)) struct PIOS_FLASHFS_Stats *stats) +{ + /* stub - not implemented */ + return 0; +} + +#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ + +/** + * @} + * @} + */ diff --git a/flight/pios/pios_sim_posix.h b/flight/pios/pios_sim_posix.h index 642c0b6e9..fbef644c0 100644 --- a/flight/pios/pios_sim_posix.h +++ b/flight/pios/pios_sim_posix.h @@ -80,6 +80,8 @@ extern void PIOS_LED_Init(void); #include #include #include +#include +#include #if defined(PIOS_INCLUDE_IAP) #include diff --git a/flight/pios/posix/pios_dosfs_logfs.c b/flight/pios/posix/pios_dosfs_logfs.c new file mode 100644 index 000000000..83a83bbd7 --- /dev/null +++ b/flight/pios/posix/pios_dosfs_logfs.c @@ -0,0 +1,273 @@ +/** + ****************************************************************************** + * @file pios_dosfs_logfs.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @brief Log Structured Filesystem wrapper implemented using dosfs + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "pios.h" + +#ifdef PIOS_USE_SETTINGS_ON_SDCARD + +#include + +#if defined(PIOS_INCLUDE_FREERTOS) +static xSemaphoreHandle mutex; +#endif + +struct flashfs_logfs_cfg; + + +/** + * Wrapper for the unimplemented sprintf function + * warning, no buffer length boundary checks, use with caution! + */ +static void customSPrintf(uint8_t *buffer, uint8_t *format, ...) +{ + va_list args; + + va_start(args, format); + vsprintf((char *)buffer, (char *)format, args); +} + + +/** + * Get an 8 character (plus extension) filename for the object. + * @param[in] obj The object handle. + * @param[in] instId The instance ID + * @param[in] file Filename string pointer WARNING, must be 14 bytes long and allocated, no checks! + */ +static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename) +{ + uint32_t prefix = obj_id + (obj_inst_id / 256); + uint8_t suffix = obj_inst_id & 0xff; + + customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix); +} + + +/** + * @brief Initialize the flash object setting FS + * @return 0 if success, -1 if failure + */ +int32_t PIOS_FLASHFS_Logfs_Init(__attribute__((unused)) uintptr_t *fs_id, __attribute__((unused)) const struct flashfs_logfs_cfg *cfg, __attribute__((unused)) const struct pios_flash_driver *driver, __attribute__((unused)) uintptr_t flash_id) +{ +#if defined(PIOS_INCLUDE_FREERTOS) + if (!mutex) { + mutex = xSemaphoreCreateRecursiveMutex(); + } +#endif + return 0; +} + +int32_t PIOS_FLASHFS_Logfs_Destroy(__attribute__((unused)) uintptr_t fs_id) +{ + // stub, only wrapper for dosfs, does not need destroying + return 0; +} + +/********************************** + * + * Provide a PIOS_FLASHFS_* driver + * + *********************************/ +#include "pios_flashfs.h" /* API for flash filesystem */ + +/** + * @brief Saves one object instance to the filesystem + * @param[in] fs_id The filesystem to use for this action + * @param[in] obj UAVObject ID of the object to save + * @param[in] obj_inst_id The instance number of the object being saved + * @param[in] obj_data Contents of the object being saved + * @param[in] obj_size Size of the object being saved + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if failure to delete any previous versions of the object + * @retval -4 if filesystem is entirely full and garbage collection won't help + * @retval -5 if garbage collection failed + * @retval -6 if filesystem is full even after garbage collection should have freed space + * @retval -7 if writing the new object to the filesystem failed + */ +int32_t PIOS_FLASHFS_ObjSave(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) +{ + FILEINFO file; + uint8_t filename[14]; + + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + + // Lock + +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); +#endif + + // Get filename + objectFilename(obj_id, obj_inst_id, filename); + + // Open file + if (PIOS_FOPEN_WRITE(filename, file)) { +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + return -2; + } + // Append object + uint32_t bytes_written = 0; + PIOS_FWRITE(&file, obj_data, obj_size, &bytes_written); + + // Done, close file and unlock + PIOS_FCLOSE(file); +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + + if (bytes_written != obj_size) { + return -7; + } + + return 0; +} + +/** + * @brief Load one object instance from the filesystem + * @param[in] fs_id The filesystem to use for this action + * @param[in] obj UAVObject ID of the object to load + * @param[in] obj_inst_id The instance of the object to load + * @param[in] obj_data Buffer to hold the contents of the loaded object + * @param[in] obj_size Size of the object to be loaded + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if object not found in filesystem + * @retval -4 if object size in filesystem does not exactly match buffer size + * @retval -5 if reading the object data from flash fails + */ +int32_t PIOS_FLASHFS_ObjLoad(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) +{ + FILEINFO file; + uint8_t filename[14]; + + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + +#if defined(PIOS_INCLUDE_FREERTOS) + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); +#endif + // Get filename + objectFilename(obj_id, obj_inst_id, filename); + + // Open file + if (PIOS_FOPEN_READ(filename, file)) { +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + return -1; + } + // Load object + uint32_t bytes_read = 0; + uint32_t result = PIOS_FREAD(&file, obj_data, obj_size, &bytes_read); + + // Done, close file and unlock + PIOS_FCLOSE(file); +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + if (result != 0) { + return -1; + } + return 0; +} + +/** + * @brief Delete one instance of an object from the filesystem + * @param[in] fs_id The filesystem to use for this action + * @param[in] obj UAVObject ID of the object to delete + * @param[in] obj_inst_id The instance of the object to delete + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if failed to delete the object from the filesystem + */ +int32_t PIOS_FLASHFS_ObjDelete(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id) +{ + uint8_t filename[14]; + + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } +#if defined(PIOS_INCLUDE_FREERTOS) + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); +#endif + // Get filename + objectFilename(obj_id, obj_inst_id, filename); + + // Delete file + PIOS_FUNLINK(filename); + + // Done +#if defined(PIOS_INCLUDE_FREERTOS) + xSemaphoreGiveRecursive(mutex); +#endif + return 0; +} + +/** + * @brief Erases all filesystem arenas and activate the first arena + * @param[in] fs_id The filesystem to use for this action + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if failed to erase all arenas + * @retval -4 if failed to activate arena 0 + * @retval -5 if failed to mount arena 0 + */ +int32_t PIOS_FLASHFS_Format(__attribute__((unused)) uintptr_t fs_id) +{ + /* stub - not implemented */ + return -1; +} + +/** + * @brief Returs stats for the filesystems + * @param[in] fs_id The filesystem to use for this action + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + */ +int32_t PIOS_FLASHFS_GetStats(__attribute__((unused)) uintptr_t fs_id, __attribute__((unused)) struct PIOS_FLASHFS_Stats *stats) +{ + /* stub - not implemented */ + return 0; +} + +#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ + +/** + * @} + * @} + */ diff --git a/flight/targets/boards/simposix/board_hw_defs.c b/flight/targets/boards/simposix/board_hw_defs.c index 9971a8d30..6c78422f9 100644 --- a/flight/targets/boards/simposix/board_hw_defs.c +++ b/flight/targets/boards/simposix/board_hw_defs.c @@ -69,3 +69,7 @@ const struct pios_udp_cfg pios_udp_aux_cfg = { #include #endif /* PIOS_INCLUDE_COM */ + +#if defined(PIOS_INCLUDE_FLASH) +#include "pios_flashfs_logfs_priv.h" +#endif diff --git a/flight/targets/boards/simposix/firmware/pios_board.c b/flight/targets/boards/simposix/firmware/pios_board.c index 51c800df6..07f93d80a 100644 --- a/flight/targets/boards/simposix/firmware/pios_board.c +++ b/flight/targets/boards/simposix/firmware/pios_board.c @@ -75,6 +75,7 @@ uint32_t pios_com_telem_rf_id = 0; uint32_t pios_com_bridge_id = 0; uintptr_t pios_uavo_settings_fs_id; +uintptr_t pios_user_fs_id; /* * Setup a com port based on the passed cfg, driver and buffer sizes. tx size of -1 make the port rx only @@ -118,6 +119,13 @@ void PIOS_Board_Init(void) /* Delay system */ PIOS_DELAY_Init(); + // Initialize dosfs fake flash logfs + if (PIOS_FLASHFS_Logfs_Init(&pios_uavo_settings_fs_id, NULL, NULL, 0)) { + PIOS_DEBUG_Assert(0); + } + pios_user_fs_id = pios_uavo_settings_fs_id; + + /* Initialize the task monitor */ if (PIOS_TASK_MONITOR_Initialize(TASKINFO_RUNNING_NUMELEM)) { PIOS_Assert(0); diff --git a/flight/uavobjects/uavobjectmanager.c b/flight/uavobjects/uavobjectmanager.c index 0ed0e1cfe..e62ecbb7e 100644 --- a/flight/uavobjects/uavobjectmanager.c +++ b/flight/uavobjects/uavobjectmanager.c @@ -184,15 +184,6 @@ static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue, static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue, UAVObjEventCallback cb); -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) && defined(PIOS_INCLUDE_FLASH_LOGFS_SETTINGS) -#error Both PIOS_USE_SETTINGS_ON_SDCARD and PIOS_INCLUDE_FLASH_LOGFS_SETTINGS. Only one settings storage allowed. -#endif - -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) -static void objectFilename(UAVObjHandle obj_handle, uint8_t *filename); -static void customSPrintf(uint8_t *buffer, uint8_t *format, ...); -#endif - // Private variables static xSemaphoreHandle mutex; static const UAVObjMetadata defMetadata = { @@ -713,82 +704,6 @@ unlock_exit: return rc; } -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) -/** - * Save the data of the specified object instance to the file system (SD card). - * The object will be appended and the file will not be closed. - * The object data can be restored using the UAVObjLoad function. - * @param[in] obj The object handle. - * @param[in] instId The instance ID - * @param[in] file File to append to - * @return 0 if success or -1 if failure - */ -int32_t UAVObjSaveToFile(UAVObjHandle obj_handle, uint16_t instId, - FILEINFO *file) -{ - PIOS_Assert(obj_handle); - - uint32_t bytesWritten; - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - if (UAVObjIsMetaobject(obj_handle)) { - // Get the instance information - if (instId != 0) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Write the object ID - uint32_t objId = UAVObjGetID(obj_handle); - PIOS_FWRITE(file, &objId, sizeof(objId), - &bytesWritten); - - // Write the data and check that the write was successful - PIOS_FWRITE(file, MetaDataPtr((struct UAVOMeta *)obj_handle), MetaNumBytes, - &bytesWritten); - if (bytesWritten != MetaNumBytes) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } else { - struct UAVOData *uavo; - InstanceHandle instEntry; - - // Cast to object - uavo = (struct UAVOData *)obj_handle; - - // Get the instance information - instEntry = getInstance(uavo, instId); - if (instEntry == NULL) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Write the object ID - PIOS_FWRITE(file, &uavo->id, sizeof(uavo->id), - &bytesWritten); - - // Write the instance ID - if (!UAVObjIsSingleInstance(obj_handle)) { - PIOS_FWRITE(file, &instId, - sizeof(instId), &bytesWritten); - } - // Write the data and check that the write was successful - PIOS_FWRITE(file, InstanceData(instEntry), uavo->instance_size, - &bytesWritten); - if (bytesWritten != uavo->instance_size) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - // Done - xSemaphoreGiveRecursive(mutex); - return 0; -} -#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ /** * Save the data of the specified object to the file system (SD card). @@ -804,7 +719,6 @@ int32_t UAVObjSave(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t ins { PIOS_Assert(obj_handle); -#if defined(PIOS_INCLUDE_FLASH_LOGFS_SETTINGS) if (UAVObjIsMetaobject(obj_handle)) { if (instId != 0) { return -1; @@ -828,131 +742,9 @@ int32_t UAVObjSave(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t ins return -1; } } -#endif /* if defined(PIOS_INCLUDE_FLASH_LOGFS_SETTINGS) */ -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) - FILEINFO file; - uint8_t filename[14]; - - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Get filename - objectFilename(obj_handle, filename); - - // Open file - if (PIOS_FOPEN_WRITE(filename, file)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Append object - if (UAVObjSaveToFile(obj_handle, instId, &file) == -1) { - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Done, close file and unlock - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); -#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ return 0; } -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) -/** - * Load an object from the file system (SD card). - * @param[in] obj The object handle. - * @param[in] file File to read from - * @return 0 if success or -1 if failure - */ -int32_t UAVObjLoadFromFile(UAVObjHandle obj_handle, FILEINFO *file) -{ - uint32_t bytesRead; - struct UAVOBase *objEntry; - InstanceHandle instEntry; - uint32_t objId; - uint16_t instId; - - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Get the object - if (obj_handle == 0) { - return -1; - } - objEntry = (struct UAVOBase *)obj_handle; - - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Read the object ID - if (PIOS_FREAD(file, &objId, sizeof(objId), &bytesRead)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - - // Check that the IDs match - if (objId != UAVObjGetID(obj_handle)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - - // Get the instance ID - instId = 0; - if (!UAVObjIsSingleInstance(obj_handle)) { - if (PIOS_FREAD - (file, &instId, sizeof(instId), &bytesRead)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - - if (UAVObjIsMetaobject(obj_handle)) { - // If the instance does not exist create it and any other instances before it - if (instId != 0) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Read the instance data - if (PIOS_FREAD - (file, MetaDataPtr((struct UAVOMeta *)obj_handle), MetaNumBytes, &bytesRead)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } else { - // Get the instance information - instEntry = getInstance((struct UAVOData *)objEntry, instId); - - // If the instance does not exist create it and any other instances before it - if (instEntry == NULL) { - instEntry = createInstance((struct UAVOData *)objEntry, instId); - if (instEntry == NULL) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - // Read the instance data - if (PIOS_FREAD - (file, InstanceData(instEntry), ((struct UAVOData *)objEntry)->instance_size, &bytesRead)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - - // Fire event - sendEvent(objEntry, instId, EV_UNPACKED); - - // Unlock - xSemaphoreGiveRecursive(mutex); - return 0; -} -#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ /** * Load an object from the file system (SD card). @@ -966,7 +758,6 @@ int32_t UAVObjLoad(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t ins { PIOS_Assert(obj_handle); -#if defined(PIOS_INCLUDE_FLASH_LOGFS_SETTINGS) if (UAVObjIsMetaobject(obj_handle)) { if (instId != 0) { return -1; @@ -993,37 +784,7 @@ int32_t UAVObjLoad(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t ins } } -#endif /* if defined(PIOS_INCLUDE_FLASH_LOGFS_SETTINGS) */ -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) - FILEINFO file; - uint8_t filename[14]; - - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Get filename - objectFilename(obj_handle, filename); - - // Open file - if (PIOS_FOPEN_READ(filename, file)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Load object - if (UAVObjLoadFromFile(obj_handle, &file) != 0) { - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Done, close file and unlock - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); -#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ return 0; } @@ -1036,28 +797,7 @@ int32_t UAVObjLoad(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t ins int32_t UAVObjDelete(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t instId) { PIOS_Assert(obj_handle); -#if defined(PIOS_INCLUDE_FLASH_LOGFS_SETTINGS) PIOS_FLASHFS_ObjDelete(pios_uavo_settings_fs_id, UAVObjGetID(obj_handle), instId); -#endif -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) - uint8_t filename[14]; - - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Get filename - objectFilename(obj_handle, filename); - - // Delete file - PIOS_FUNLINK(filename); - - // Done - xSemaphoreGiveRecursive(mutex); -#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ return 0; } @@ -2043,24 +1783,3 @@ static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue, // If this point is reached the queue was not found return -1; } - -#if defined(PIOS_USE_SETTINGS_ON_SDCARD) -/** - * Wrapper for the sprintf function - */ -static void customSPrintf(uint8_t *buffer, uint8_t *format, ...) -{ - va_list args; - - va_start(args, format); - vsprintf((char *)buffer, (char *)format, args); -} - -/** - * Get an 8 character (plus extension) filename for the object. - */ -static void objectFilename(UAVObjHandle obj_handle, uint8_t *filename) -{ - customSPrintf(filename, (uint8_t *)"%X.obj", UAVObjGetID(obj_handle)); -} -#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ From 314d526e941b98222d483a6e510ca9922309cb99 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sat, 16 Nov 2013 18:55:54 +0100 Subject: [PATCH 045/116] corrected instance id encoding in filename to not conflict with metadata uavobject ids --- flight/pios/common/pios_dosfs_logfs.c | 3 ++- flight/pios/posix/pios_dosfs_logfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/flight/pios/common/pios_dosfs_logfs.c b/flight/pios/common/pios_dosfs_logfs.c index 83a83bbd7..2628646f8 100644 --- a/flight/pios/common/pios_dosfs_logfs.c +++ b/flight/pios/common/pios_dosfs_logfs.c @@ -57,7 +57,8 @@ static void customSPrintf(uint8_t *buffer, uint8_t *format, ...) */ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename) { - uint32_t prefix = obj_id + (obj_inst_id / 256); + uint32_t prefix = obj_id + (obj_inst_id / 256) * 16; // put upper 8 bit of instance id into object id modification, + // skip least sig nibble since that is used for meta object id uint8_t suffix = obj_inst_id & 0xff; customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix); diff --git a/flight/pios/posix/pios_dosfs_logfs.c b/flight/pios/posix/pios_dosfs_logfs.c index 83a83bbd7..2628646f8 100644 --- a/flight/pios/posix/pios_dosfs_logfs.c +++ b/flight/pios/posix/pios_dosfs_logfs.c @@ -57,7 +57,8 @@ static void customSPrintf(uint8_t *buffer, uint8_t *format, ...) */ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename) { - uint32_t prefix = obj_id + (obj_inst_id / 256); + uint32_t prefix = obj_id + (obj_inst_id / 256) * 16; // put upper 8 bit of instance id into object id modification, + // skip least sig nibble since that is used for meta object id uint8_t suffix = obj_inst_id & 0xff; customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix); From 320bbcf4347a346204c41f9788b1ae687dc261fc Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 02:47:58 +0100 Subject: [PATCH 046/116] Made printf-stdarg check maximum string length limit (supports snprintf now) --- flight/libraries/printf-stdarg.c | 63 ++++++++++++++++---------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/flight/libraries/printf-stdarg.c b/flight/libraries/printf-stdarg.c index e4c01552d..5f4f0c40b 100644 --- a/flight/libraries/printf-stdarg.c +++ b/flight/libraries/printf-stdarg.c @@ -54,9 +54,9 @@ static void printchar(char * *str, int c) #define PAD_RIGHT 1 #define PAD_ZERO 2 -static int prints(char * *out, const char *string, int width, int pad) +static int prints(char * *out, const char *string, int width, int pad, int limit) { - register int pc = 0, padchar = ' '; + register int pc = limit, padchar = ' '; if (width > 0) { register int len = 0; @@ -74,37 +74,37 @@ static int prints(char * *out, const char *string, int width, int pad) } } if (!(pad & PAD_RIGHT)) { - for (; width > 0; --width) { + for (; width > 0 && pc; --width) { printchar(out, padchar); - ++pc; + --pc; } } - for (; *string; ++string) { + for (; *string && pc; ++string) { printchar(out, *string); - ++pc; + --pc; } - for (; width > 0; --width) { + for (; width > 0 && pc; --width) { printchar(out, padchar); - ++pc; + --pc; } - return pc; + return limit - pc; } /* the following should be enough for 32 bit int */ #define PRINT_BUF_LEN 12 -static int printi(char * *out, int i, int b, int sg, int width, int pad, int letbase) +static int printi(char * *out, int i, int b, int sg, int width, int pad, int letbase, int limit) { char print_buf[PRINT_BUF_LEN]; register char *s; - register int t, neg = 0, pc = 0; + register int t, neg = 0, pc = limit; register unsigned int u = i; if (i == 0) { print_buf[0] = '0'; print_buf[1] = '\0'; - return prints(out, print_buf, width, pad); + return prints(out, print_buf, width, pad, limit); } if (sg && b == 10 && i < 0) { @@ -124,26 +124,26 @@ static int printi(char * *out, int i, int b, int sg, int width, int pad, int let u /= b; } - if (neg) { + if (neg && pc) { if (width && (pad & PAD_ZERO)) { printchar(out, '-'); - ++pc; + --pc; --width; } else { *--s = '-'; } } - return pc + prints(out, s, width, pad); + return (limit - pc) + prints(out, s, width, pad, pc); } -static int print(char * *out, const char *format, va_list args) +static int print(int limit, char * *out, const char *format, va_list args) { register int width, pad; - register int pc = 0; + register int pc = limit; char scr[2]; - for (; *format != 0; ++format) { + for (; *format != 0 && pc; ++format) { if (*format == '%') { ++format; width = pad = 0; @@ -167,43 +167,43 @@ static int print(char * *out, const char *format, va_list args) } if (*format == 's') { register char *s = (char *)va_arg(args, int); - pc += prints(out, s ? s : "(null)", width, pad); + pc -= prints(out, s ? s : "(null)", width, pad, pc); continue; } if (*format == 'd') { - pc += printi(out, va_arg(args, int), 10, 1, width, pad, 'a'); + pc -= printi(out, va_arg(args, int), 10, 1, width, pad, 'a', pc); continue; } if (*format == 'x') { - pc += printi(out, va_arg(args, int), 16, 0, width, pad, 'a'); + pc -= printi(out, va_arg(args, int), 16, 0, width, pad, 'a', pc); continue; } if (*format == 'X') { - pc += printi(out, va_arg(args, int), 16, 0, width, pad, 'A'); + pc -= printi(out, va_arg(args, int), 16, 0, width, pad, 'A', pc); continue; } if (*format == 'u') { - pc += printi(out, va_arg(args, int), 10, 0, width, pad, 'a'); + pc -= printi(out, va_arg(args, int), 10, 0, width, pad, 'a', pc); continue; } if (*format == 'c') { /* char are converted to int then pushed on the stack */ scr[0] = (char)va_arg(args, int); scr[1] = '\0'; - pc += prints(out, scr, width, pad); + pc -= prints(out, scr, width, pad, pc); continue; } } else { out: printchar(out, *format); - ++pc; + --pc; } } if (out) { **out = '\0'; } va_end(args); - return pc; + return limit - pc; } int printf(const char *format, ...) @@ -211,13 +211,13 @@ int printf(const char *format, ...) va_list args; va_start(args, format); - return print(0, format, args); + return print(-1, 0, format, args); } // TK: added for alternative parameter passing int vprintf(const char *format, va_list args) { - return print(0, format, args); + return print(-1, 0, format, args); } int sprintf(char *out, const char *format, ...) @@ -225,7 +225,7 @@ int sprintf(char *out, const char *format, ...) va_list args; va_start(args, format); - return print(&out, format, args); + return print(-1, &out, format, args); } // TK: added for alternative parameter passing @@ -234,17 +234,16 @@ int vsprintf(char *out, const char *format, va_list args) char *_out; _out = out; - return print(&_out, format, args); + return print(-1, &_out, format, args); } int snprintf(char *buf, size_t count, const char *format, ...) { va_list args; - (void)count; va_start(args, format); - return print(&buf, format, args); + return print(count, &buf, format, args); } /** From adfbdfae38fb777651ec2e0c8c3e9f1c1063889c Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 02:49:53 +0100 Subject: [PATCH 047/116] Make use of (now supported) standard snprintf in stdarg-printf when used in logfs --- flight/pios/common/pios_dosfs_logfs.c | 19 +++---------------- flight/pios/posix/pios_dosfs_logfs.c | 19 +++---------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/flight/pios/common/pios_dosfs_logfs.c b/flight/pios/common/pios_dosfs_logfs.c index 2628646f8..0b627e542 100644 --- a/flight/pios/common/pios_dosfs_logfs.c +++ b/flight/pios/common/pios_dosfs_logfs.c @@ -30,30 +30,17 @@ #include #if defined(PIOS_INCLUDE_FREERTOS) -static xSemaphoreHandle mutex; +static xSemaphoreHandle mutex = 0; #endif struct flashfs_logfs_cfg; -/** - * Wrapper for the unimplemented sprintf function - * warning, no buffer length boundary checks, use with caution! - */ -static void customSPrintf(uint8_t *buffer, uint8_t *format, ...) -{ - va_list args; - - va_start(args, format); - vsprintf((char *)buffer, (char *)format, args); -} - - /** * Get an 8 character (plus extension) filename for the object. * @param[in] obj The object handle. * @param[in] instId The instance ID - * @param[in] file Filename string pointer WARNING, must be 14 bytes long and allocated, no checks! + * @param[in] file Filename string pointer -- must be 14 bytes long and allocated */ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename) { @@ -61,7 +48,7 @@ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filen // skip least sig nibble since that is used for meta object id uint8_t suffix = obj_inst_id & 0xff; - customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix); + snprintf((char *)filename, 13, "%08X.o%02X", prefix, suffix); } diff --git a/flight/pios/posix/pios_dosfs_logfs.c b/flight/pios/posix/pios_dosfs_logfs.c index 2628646f8..0b627e542 100644 --- a/flight/pios/posix/pios_dosfs_logfs.c +++ b/flight/pios/posix/pios_dosfs_logfs.c @@ -30,30 +30,17 @@ #include #if defined(PIOS_INCLUDE_FREERTOS) -static xSemaphoreHandle mutex; +static xSemaphoreHandle mutex = 0; #endif struct flashfs_logfs_cfg; -/** - * Wrapper for the unimplemented sprintf function - * warning, no buffer length boundary checks, use with caution! - */ -static void customSPrintf(uint8_t *buffer, uint8_t *format, ...) -{ - va_list args; - - va_start(args, format); - vsprintf((char *)buffer, (char *)format, args); -} - - /** * Get an 8 character (plus extension) filename for the object. * @param[in] obj The object handle. * @param[in] instId The instance ID - * @param[in] file Filename string pointer WARNING, must be 14 bytes long and allocated, no checks! + * @param[in] file Filename string pointer -- must be 14 bytes long and allocated */ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename) { @@ -61,7 +48,7 @@ static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filen // skip least sig nibble since that is used for meta object id uint8_t suffix = obj_inst_id & 0xff; - customSPrintf(filename, (uint8_t *)"%08X.o%02X", prefix, suffix); + snprintf((char *)filename, 13, "%08X.o%02X", prefix, suffix); } From a0746d87fa6c07cac17944807e85937e446998b1 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 02:54:26 +0100 Subject: [PATCH 048/116] Logging facility: logs debug data to logfs and exports it through container UAVObject --- flight/modules/Logging/Logging.c | 106 ++++++++++ flight/pios/inc/pios_debuglog.h | 90 ++++++++ flight/pios/pios_sim_posix.h | 1 + flight/pios/posix/pios_debuglog.c | 192 ++++++++++++++++++ .../targets/boards/simposix/firmware/Makefile | 1 + .../boards/simposix/firmware/UAVObjects.inc | 3 + .../src/plugins/uavobjects/uavobjects.pro | 6 + .../uavobjectdefinition/debuglogcontrol.xml | 11 + shared/uavobjectdefinition/debuglogentry.xml | 17 ++ .../uavobjectdefinition/debuglogsettings.xml | 11 + 10 files changed, 438 insertions(+) create mode 100644 flight/modules/Logging/Logging.c create mode 100644 flight/pios/inc/pios_debuglog.h create mode 100644 flight/pios/posix/pios_debuglog.c create mode 100644 shared/uavobjectdefinition/debuglogcontrol.xml create mode 100644 shared/uavobjectdefinition/debuglogentry.xml create mode 100644 shared/uavobjectdefinition/debuglogsettings.xml diff --git a/flight/modules/Logging/Logging.c b/flight/modules/Logging/Logging.c new file mode 100644 index 000000000..12441ffa4 --- /dev/null +++ b/flight/modules/Logging/Logging.c @@ -0,0 +1,106 @@ +/** + ****************************************************************************** + * @addtogroup OpenPilotModules OpenPilot Modules + * @{ + * @addtogroup LoggingModule Logging Module + * @brief Features for on board logging + * @{ + * + * @file Logging.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * @brief Logging module, provides features for on board logging + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +// **************** + +#include "openpilot.h" +#include "debuglogsettings.h" +#include "debuglogcontrol.h" +#include "debuglogentry.h" + +// private variables +static DebugLogSettingsData settings; +static DebugLogControlData control; +static DebugLogEntryData *entry; // would be better on stack but event dispatcher stack might be insufficient + +// private functions +static void SettingsUpdatedCb(UAVObjEvent *ev); +static void ControlUpdatedCb(UAVObjEvent *ev); + +int32_t LoggingInitialize(void) +{ + DebugLogSettingsInitialize(); + DebugLogControlInitialize(); + DebugLogEntryInitialize(); + PIOS_DEBUGLOG_Initialize(); + entry = pvPortMalloc(sizeof(DebugLogEntryData)); + if (!entry) { + return -1; + } + + return 0; +} + +int32_t LoggingStart(void) +{ + DebugLogSettingsConnectCallback(SettingsUpdatedCb); + DebugLogControlConnectCallback(ControlUpdatedCb); + SettingsUpdatedCb(DebugLogSettingsHandle()); + return 0; +} +MODULE_INITCALL(LoggingInitialize, LoggingStart); + + +static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) +{ + DebugLogSettingsGet(&settings); + PIOS_DEBUGLOG_Enable(settings.LoggingEnabled); + PIOS_DEBUGLOG_Printf("Logging enabled"); +} + +static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) +{ + static bool ignore = 0; // this little hack allows us to set our own uavobject in the callback + + if (ignore) { + ignore = 0; + return; + } + + DebugLogControlGet(&control); + if (PIOS_DEBUGLOG_Read(entry, control.Flight, control.Entry) != 0) { + // reading from log failed, mark as non existent in output + memset(entry, 0, sizeof(DebugLogEntryData)); + entry->Flight = control.Flight; + entry->Entry = control.Entry; + entry->Type = DEBUGLOGENTRY_TYPE_EMPTY; + } + PIOS_DEBUGLOG_Info(&control.Flight, &control.Entry); + + ignore = 1; // set ignore flag before setting object - creates loop otherwise!!! + DebugLogEntrySet(entry); + DebugLogControlSet(&control); +} + + +/** + * @} + * @} + */ diff --git a/flight/pios/inc/pios_debuglog.h b/flight/pios/inc/pios_debuglog.h new file mode 100644 index 000000000..ba32631ee --- /dev/null +++ b/flight/pios/inc/pios_debuglog.h @@ -0,0 +1,90 @@ +/** + ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @defgroup PIOS_DEBUGLOG Flash log debugging Functions + * @brief Debugging functionality + * @{ + * + * @file pios_debuglog.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * @brief Debugging Functions + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PIOS_DEBUGLOG_H +#define PIOS_DEBUGLOG_H + + +/** + * @brief Initialize the log facility + */ +void PIOS_DEBUGLOG_Initialize(); + +/** + * @brief Enables or Disables logging globally + * @param[in] enable or disable logging + */ +void PIOS_DEBUGLOG_Enable(bool enabled); + +/** + * @brief Write a debug log entry with a uavobject + * @param[in] objectid + * @param[in] instanceid + * @param[in] instanceid + * @param[in] size of object + * @param[in] data buffer + */ +void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8_t *data); + +/** + * @brief Write a debug log entry with text + * @param[in] format - as in printf + * @param[in] variable arguments for printf + * @param... + */ +void PIOS_DEBUGLOG_Printf(char *format, ...); + +/** + * @brief Load one object instance from the filesystem + * @param[out] buffer where to store the uavobject + * @param[in] log entry from which flight + * @param[in] log entry sequence number + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if object not found in filesystem + * @retval -4 if object size in filesystem does not exactly match buffer size + * @retval -5 if reading the object data from flash fails + */ +int32_t PIOS_DEBUGLOG_Read(void *buffer, uint16_t flight, uint16_t inst); + +/** + * @brief Retrieve run time info of logging system + * @param[out] buffer where to store the uavobject + * @param[in] log entry from which flight + */ +void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry); + +#endif // ifndef PIOS_DEBUGLOG_H + +/** + * @} + * @} + */ diff --git a/flight/pios/pios_sim_posix.h b/flight/pios/pios_sim_posix.h index fbef644c0..84fd5440a 100644 --- a/flight/pios/pios_sim_posix.h +++ b/flight/pios/pios_sim_posix.h @@ -78,6 +78,7 @@ extern void PIOS_LED_Init(void); #include #include #include +#include #include #include #include diff --git a/flight/pios/posix/pios_debuglog.c b/flight/pios/posix/pios_debuglog.c new file mode 100644 index 000000000..369778137 --- /dev/null +++ b/flight/pios/posix/pios_debuglog.c @@ -0,0 +1,192 @@ +/** + ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @defgroup PIOS_DEBUGLOG Flash log debugging Functions + * @brief Debugging functionality + * @{ + * + * @file pios_debuglog.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * @brief Debugging Functions + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Project Includes */ +#include "pios.h" +#include "uavobjectmanager.h" +#include "debuglogentry.h" + +// global definitions + + +// Global variables +extern uintptr_t pios_user_fs_id; // flash filesystem for logging + +#if defined(PIOS_INCLUDE_FREERTOS) +static xSemaphoreHandle mutex = 0; +#define mutexlock() xSemaphoreTakeRecursive(mutex, portMAX_DELAY) +#define mutexunlock() xSemaphoreGiveRecursive(mutex) +#else +#define mutexlock() +#define mutexunlock() +#endif + +static bool logging_enabled = false; +static uint16_t flightnum = 0; +static uint16_t lognum = 0; +static DebugLogEntryData buffer; + +/* Private Function Prototypes */ + +/** + * @brief Initialize the log facility + */ +void PIOS_DEBUGLOG_Initialize() +{ +#if defined(PIOS_INCLUDE_FREERTOS) + if (!mutex) { + mutex = xSemaphoreCreateRecursiveMutex(); + } +#endif + mutexlock(); + lognum = 0; + flightnum = 0; + while (PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)&buffer, sizeof(DebugLogEntryData)) == 0) { + flightnum++; + } + mutexunlock(); +} + + +/** + * @brief Enables or Disables logging globally + * @param[in] enable or disable logging + */ +void PIOS_DEBUGLOG_Enable(bool enabled) +{ + logging_enabled = enabled; +} + +/** + * @brief Write a debug log entry with a uavobject + * @param[in] objectid + * @param[in] instanceid + * @param[in] instanceid + * @param[in] size of object + * @param[in] data buffer + */ +void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8_t *data) +{ + if (!logging_enabled) { + return; + } + mutexlock(); + buffer.Flight = flightnum; +#if defined(PIOS_INCLUDE_FREERTOS) + buffer.FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; +#else + buffer.FlightTime = 0; +#endif + buffer.Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; + buffer.ObjectID = objid; + buffer.InstanceID = instid; + buffer.Size = size; + uint16_t t = 0; + for (; t < size && t < sizeof(buffer.Data); t++) { + buffer.Data[t] = data[t]; + } + + if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)&buffer, sizeof(DebugLogEntryData)) == 0) { + lognum++; + } + mutexunlock(); +} +/** + * @brief Write a debug log entry with text + * @param[in] format - as in printf + * @param[in] variable arguments for printf + * @param... + */ +void PIOS_DEBUGLOG_Printf(char *format, ...) +{ + if (!logging_enabled) { + return; + } + va_list args; + va_start(args, format); + mutexlock(); + vsnprintf((char *)buffer.Data, sizeof(buffer.Data), (char *)format, args); + buffer.Flight = flightnum; +#if defined(PIOS_INCLUDE_FREERTOS) + buffer.FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; +#else + buffer.FlightTime = 0; +#endif + buffer.Entry = lognum; + buffer.Type = DEBUGLOGENTRY_TYPE_TEXT; + buffer.ObjectID = 0; + buffer.InstanceID = 0; + buffer.Size = strlen((const char *)buffer.Data); + + if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)&buffer, sizeof(DebugLogEntryData)) == 0) { + lognum++; + } + mutexunlock(); +} + + +/** + * @brief Load one object instance from the filesystem + * @param[out] buffer where to store the uavobject + * @param[in] log entry from which flight + * @param[in] log entry sequence number + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if object not found in filesystem + * @retval -4 if object size in filesystem does not exactly match buffer size + * @retval -5 if reading the object data from flash fails + */ +int32_t PIOS_DEBUGLOG_Read(void *buffer, uint16_t flight, uint16_t inst) +{ + PIOS_Assert(buffer); + return PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flight * 256, inst, (uint8_t *)buffer, sizeof(DebugLogEntryData)); +} + +/** + * @brief Retrieve run time info of logging system + * @param[out] buffer where to store the uavobject + * @param[in] log entry from which flight + */ +void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry) +{ + if (flight) { + *flight = flightnum; + } + if (entry) { + *entry = lognum; + } +} + + +/** + * @} + * @} + */ diff --git a/flight/targets/boards/simposix/firmware/Makefile b/flight/targets/boards/simposix/firmware/Makefile index 76524166e..ed04e470f 100644 --- a/flight/targets/boards/simposix/firmware/Makefile +++ b/flight/targets/boards/simposix/firmware/Makefile @@ -37,6 +37,7 @@ MODULES += FixedWingPathFollower MODULES += VtolPathFollower MODULES += CameraStab MODULES += Telemetry +MODULES += Logging MODULES += FirmwareIAP MODULES += StateEstimation #MODULES += Sensors/simulated/Sensors diff --git a/flight/targets/boards/simposix/firmware/UAVObjects.inc b/flight/targets/boards/simposix/firmware/UAVObjects.inc index 4cdf923a3..c404b272a 100644 --- a/flight/targets/boards/simposix/firmware/UAVObjects.inc +++ b/flight/targets/boards/simposix/firmware/UAVObjects.inc @@ -42,6 +42,9 @@ UAVOBJSRCFILENAMES += barosensor UAVOBJSRCFILENAMES += airspeedsensor UAVOBJSRCFILENAMES += airspeedsettings UAVOBJSRCFILENAMES += airspeedstate +UAVOBJSRCFILENAMES += debuglogsettings +UAVOBJSRCFILENAMES += debuglogcontrol +UAVOBJSRCFILENAMES += debuglogentry UAVOBJSRCFILENAMES += flightbatterysettings UAVOBJSRCFILENAMES += firmwareiapobj UAVOBJSRCFILENAMES += flightbatterystate diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index 44b96a580..4051a027f 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -34,6 +34,9 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ $$UAVOBJECT_SYNTHETICS/altitudeholddesired.h \ $$UAVOBJECT_SYNTHETICS/altitudeholdsettings.h \ $$UAVOBJECT_SYNTHETICS/altitudefiltersettings.h \ + $$UAVOBJECT_SYNTHETICS/debuglogsettings.h \ + $$UAVOBJECT_SYNTHETICS/debuglogcontrol.h \ + $$UAVOBJECT_SYNTHETICS/debuglogentry.h \ $$UAVOBJECT_SYNTHETICS/ekfconfiguration.h \ $$UAVOBJECT_SYNTHETICS/ekfstatevariance.h \ $$UAVOBJECT_SYNTHETICS/revocalibration.h \ @@ -120,6 +123,9 @@ SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ $$UAVOBJECT_SYNTHETICS/altholdsmoothed.cpp \ $$UAVOBJECT_SYNTHETICS/altitudeholddesired.cpp \ $$UAVOBJECT_SYNTHETICS/altitudeholdsettings.cpp \ + $$UAVOBJECT_SYNTHETICS/debuglogsettings.cpp \ + $$UAVOBJECT_SYNTHETICS/debuglogcontrol.cpp \ + $$UAVOBJECT_SYNTHETICS/debuglogentry.cpp \ $$UAVOBJECT_SYNTHETICS/altitudefiltersettings.cpp \ $$UAVOBJECT_SYNTHETICS/ekfconfiguration.cpp \ $$UAVOBJECT_SYNTHETICS/ekfstatevariance.cpp \ diff --git a/shared/uavobjectdefinition/debuglogcontrol.xml b/shared/uavobjectdefinition/debuglogcontrol.xml new file mode 100644 index 000000000..6af9106f9 --- /dev/null +++ b/shared/uavobjectdefinition/debuglogcontrol.xml @@ -0,0 +1,11 @@ + + + Log Control Object + + + + + + + + diff --git a/shared/uavobjectdefinition/debuglogentry.xml b/shared/uavobjectdefinition/debuglogentry.xml new file mode 100644 index 000000000..9a9acda83 --- /dev/null +++ b/shared/uavobjectdefinition/debuglogentry.xml @@ -0,0 +1,17 @@ + + + Log Entry in Flash + + + + + + + + + + + + + + diff --git a/shared/uavobjectdefinition/debuglogsettings.xml b/shared/uavobjectdefinition/debuglogsettings.xml new file mode 100644 index 000000000..05587dedc --- /dev/null +++ b/shared/uavobjectdefinition/debuglogsettings.xml @@ -0,0 +1,11 @@ + + + Configure On Board Logging Facilities + + + + + + + + From 354ca88cd61d3c173faafc1055a6a951197946f3 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 14:00:42 +0100 Subject: [PATCH 049/116] Updated UAVObject metadata to include correct flags needed for on board logging --- flight/uavobjects/inc/uavobjectmanager.h | 16 ++++++++++------ flight/uavobjects/uavobject.c.template | 3 ++- .../templates/uavobject.java.template | 1 + .../src/plugins/uavobjects/uavmetaobject.cpp | 2 +- .../src/plugins/uavobjects/uavobject.cpp | 4 +++- .../plugins/uavobjects/uavobject.cpp.template | 3 ++- .../src/plugins/uavobjects/uavobject.h | 4 +++- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/flight/uavobjects/inc/uavobjectmanager.h b/flight/uavobjects/inc/uavobjectmanager.h index 202c17f2e..9e681ea6b 100644 --- a/flight/uavobjects/inc/uavobjectmanager.h +++ b/flight/uavobjects/inc/uavobjectmanager.h @@ -44,6 +44,7 @@ #define UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT 3 #define UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT 4 #define UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT 6 +#define UAVOBJ_LOGGING_UPDATE_MODE_SHIFT 8 #define UAVOBJ_UPDATE_MODE_MASK 0x3 typedef void *UAVObjHandle; @@ -73,9 +74,10 @@ typedef enum { * 3 gcsTelemetryAcked Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) * 4-5 telemetryUpdateMode Update mode used by the telemetry module (UAVObjUpdateMode) * 6-7 gcsTelemetryUpdateMode Update mode used by the GCS (UAVObjUpdateMode) + * 8-9 loggingUpdateMode Update mode used by the logging module (UAVObjUpdateMode) */ typedef struct { - uint8_t flags; /** Defines flags for update and logging modes and whether an update should be ACK'd (bits defined above) */ + uint16_t flags; /** Defines flags for update and logging modes and whether an update should be ACK'd (bits defined above) */ uint16_t telemetryUpdatePeriod; /** Update period used by the telemetry module (only if telemetry mode is PERIODIC) */ uint16_t gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */ uint16_t loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */ @@ -85,19 +87,21 @@ typedef struct { * Event types generated by the objects. */ typedef enum { - EV_NONE = 0x00, /** No event */ - EV_UNPACKED = 0x01, /** Object data updated by unpacking */ - EV_UPDATED = 0x02, /** Object data updated by changing the data structure */ + EV_NONE = 0x00, /** No event */ + EV_UNPACKED = 0x01, /** Object data updated by unpacking */ + EV_UPDATED = 0x02, /** Object data updated by changing the data structure */ EV_UPDATED_MANUAL = 0x04, /** Object update event manually generated */ EV_UPDATED_PERIODIC = 0x08, /** Object update from periodic event */ - EV_UPDATE_REQ = 0x10 /** Request to update object data */ + EV_LOGGING_MANUAL = 0x10, /** Object update event manually generated */ + EV_LOGGING_PERIODIC = 0x20, /** Object update from periodic event */ + EV_UPDATE_REQ = 0x40 /** Request to update object data */ } UAVObjEventType; /** * Helper macros for event masks */ #define EV_MASK_ALL 0 -#define EV_MASK_ALL_UPDATES (EV_UNPACKED | EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATED_PERIODIC) +#define EV_MASK_ALL_UPDATES (EV_UNPACKED | EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATED_PERIODIC | EV_LOGGING_MANUAL | EV_LOGGING_PERIODIC) /** * Access types diff --git a/flight/uavobjects/uavobject.c.template b/flight/uavobjects/uavobject.c.template index f7e37723f..b9f45b5ae 100644 --- a/flight/uavobjects/uavobject.c.template +++ b/flight/uavobjects/uavobject.c.template @@ -94,7 +94,8 @@ $(INITFIELDS) $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | - $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; + $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT | + $(LOGGING_UPDATEMODE) << UAVOBJ_LOGGING_UPDATE_MODE_SHIFT; metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); diff --git a/ground/openpilotgcs/src/libs/juavobjects/templates/uavobject.java.template b/ground/openpilotgcs/src/libs/juavobjects/templates/uavobject.java.template index 2944f1270..d720bf898 100644 --- a/ground/openpilotgcs/src/libs/juavobjects/templates/uavobject.java.template +++ b/ground/openpilotgcs/src/libs/juavobjects/templates/uavobject.java.template @@ -81,6 +81,7 @@ $(FIELDSINIT) $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | UAVObject.Metadata.UpdateModeNum(UAVObject.UpdateMode.$(FLIGHTTELEM_UPDATEMODE)) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | UAVObject.Metadata.UpdateModeNum(UAVObject.UpdateMode.$(GCSTELEM_UPDATEMODE)) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; + UAVObject.Metadata.UpdateModeNum(UAVObject.UpdateMode.$(LOGGING_UPDATEMODE)) << UAVOBJ_LOGGING_UPDATE_MODE_SHIFT; metadata.flightTelemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp index 92c6d8c3b..80e4d5ed6 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp @@ -39,7 +39,7 @@ UAVMetaObject::UAVMetaObject(quint32 objID, const QString & name, UAVObject *par UAVObject::MetadataInitialize(ownMetadata); // Setup fields QStringList modesBitField; - modesBitField << tr("FlightReadOnly") << tr("GCSReadOnly") << tr("FlightTelemetryAcked") << tr("GCSTelemetryAcked") << tr("FlightUpdatePeriodic") << tr("FlightUpdateOnChange") << tr("GCSUpdatePeriodic") << tr("GCSUpdateOnChange"); + modesBitField << tr("FlightReadOnly") << tr("GCSReadOnly") << tr("FlightTelemetryAcked") << tr("GCSTelemetryAcked") << tr("FlightUpdatePeriodic") << tr("FlightUpdateOnChange") << tr("GCSUpdatePeriodic") << tr("GCSUpdateOnChange") << tr("LoggingUpdatePeriodic") << tr("LoggingUpdateOnChange"); QList fields; fields.append(new UAVObjectField(tr("Modes"), tr("boolean"), UAVObjectField::BITFIELD, modesBitField, QStringList())); fields.append(new UAVObjectField(tr("Flight Telemetry Update Period"), tr("ms"), UAVObjectField::UINT16, 1, QStringList())); diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp index d795e8cb3..7f6c02a15 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp @@ -36,6 +36,7 @@ #define UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT 3 #define UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT 4 #define UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT 6 +#define UAVOBJ_LOGGING_UPDATE_MODE_SHIFT 8 #define UAVOBJ_UPDATE_MODE_MASK 0x3 // Macros @@ -498,7 +499,8 @@ void UAVObject::MetadataInitialize(UAVObject::Metadata & metadata) 1 << UAVOBJ_TELEMETRY_ACKED_SHIFT | 1 << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | UPDATEMODE_ONCHANGE << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | - UPDATEMODE_ONCHANGE << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; + UPDATEMODE_ONCHANGE << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT | + UPDATEMODE_ONCHANGE << UAVOBJ_LOGGING_UPDATE_MODE_SHIFT; metadata.flightTelemetryUpdatePeriod = 0; metadata.gcsTelemetryUpdatePeriod = 0; metadata.loggingUpdatePeriod = 0; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp.template b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp.template index df78735bb..a91754136 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp.template +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp.template @@ -71,7 +71,8 @@ UAVObject::Metadata $(NAME)::getDefaultMetadata() $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | - $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; + $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT | + $(LOGGING_UPDATEMODE) << UAVOBJ_LOGGING_UPDATE_MODE_SHIFT; metadata.flightTelemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h index 882378e7a..c7d9941d2 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h @@ -45,6 +45,7 @@ #define UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT 3 #define UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT 4 #define UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT 6 +#define UAVOBJ_LOGGING_UPDATE_MODE_SHIFT 8 #define UAVOBJ_UPDATE_MODE_MASK 0x3 class UAVObjectField; @@ -87,9 +88,10 @@ public: * 3 gcsTelemetryAcked Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) * 4-5 telemetryUpdateMode Update mode used by the telemetry module (UAVObjUpdateMode) * 6-7 gcsTelemetryUpdateMode Update mode used by the GCS (UAVObjUpdateMode) + * 8-9 loggingUpdateMode Update mode used by the logging module (UAVObjUpdateMode) */ typedef struct { - quint8 flags; /** Defines flags for update and logging modes and whether an update should be ACK'd (bits defined above) */ + quint16 flags; /** Defines flags for update and logging modes and whether an update should be ACK'd (bits defined above) */ quint16 flightTelemetryUpdatePeriod; /** Update period used by the telemetry module (only if telemetry mode is PERIODIC) */ quint16 gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */ quint16 loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */ From d9a9536b61a5710b28120de1f7a5bc9a743861f8 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 14:53:08 +0100 Subject: [PATCH 050/116] modified uavobjectmanager to have accessor functions for the new flags --- flight/uavobjects/inc/uavobject.h.template | 2 + flight/uavobjects/inc/uavobjectmanager.h | 4 ++ flight/uavobjects/uavobjectmanager.c | 44 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/flight/uavobjects/inc/uavobject.h.template b/flight/uavobjects/inc/uavobject.h.template index 572317f01..599ba4fb8 100644 --- a/flight/uavobjects/inc/uavobject.h.template +++ b/flight/uavobjects/inc/uavobject.h.template @@ -79,6 +79,8 @@ static inline void $(NAME)RequestUpdate() { UAVObjRequestUpdate($(NAME)Handle()) static inline void $(NAME)RequestInstUpdate(uint16_t instId) { UAVObjRequestInstanceUpdate($(NAME)Handle(), instId); } static inline void $(NAME)Updated() { UAVObjUpdated($(NAME)Handle()); } static inline void $(NAME)InstUpdated(uint16_t instId) { UAVObjInstanceUpdated($(NAME)Handle(), instId); } +static inline void $(NAME)Logging() { UAVObjLogging($(NAME)Handle()); } +static inline void $(NAME)InstLogging(uint16_t instId) { UAVObjInstanceLogging($(NAME)Handle(), instId); } static inline int32_t $(NAME)GetMetadata(UAVObjMetadata *dataOut) { return UAVObjGetMetadata($(NAME)Handle(), dataOut); } static inline int32_t $(NAME)SetMetadata(const UAVObjMetadata *dataIn) { return UAVObjSetMetadata($(NAME)Handle(), dataIn); } static inline int8_t $(NAME)ReadOnly() { return UAVObjReadOnly($(NAME)Handle()); } diff --git a/flight/uavobjects/inc/uavobjectmanager.h b/flight/uavobjects/inc/uavobjectmanager.h index 9e681ea6b..a7af203fb 100644 --- a/flight/uavobjects/inc/uavobjectmanager.h +++ b/flight/uavobjects/inc/uavobjectmanager.h @@ -194,6 +194,8 @@ UAVObjUpdateMode UAVObjGetTelemetryUpdateMode(const UAVObjMetadata *dataOut); void UAVObjSetTelemetryUpdateMode(UAVObjMetadata *dataOut, UAVObjUpdateMode val); UAVObjUpdateMode UAVObjGetGcsTelemetryUpdateMode(const UAVObjMetadata *dataOut); void UAVObjSetTelemetryGcsUpdateMode(UAVObjMetadata *dataOut, UAVObjUpdateMode val); +UAVObjUpdateMode UAVObjGetLoggingUpdateMode(const UAVObjMetadata *dataOut); +void UAVObjSetLoggingUpdateMode(UAVObjMetadata *dataOut, UAVObjUpdateMode val); int8_t UAVObjReadOnly(UAVObjHandle obj); int32_t UAVObjConnectQueue(UAVObjHandle obj_handle, xQueueHandle queue, uint8_t eventMask); int32_t UAVObjDisconnectQueue(UAVObjHandle obj_handle, xQueueHandle queue); @@ -203,6 +205,8 @@ void UAVObjRequestUpdate(UAVObjHandle obj); void UAVObjRequestInstanceUpdate(UAVObjHandle obj_handle, uint16_t instId); void UAVObjUpdated(UAVObjHandle obj); void UAVObjInstanceUpdated(UAVObjHandle obj_handle, uint16_t instId); +void UAVObjLogging(UAVObjHandle obj); +void UAVObjInstanceLogging(UAVObjHandle obj_handle, uint16_t instId); void UAVObjIterate(void (*iterator)(UAVObjHandle obj)); #endif // UAVOBJECTMANAGER_H diff --git a/flight/uavobjects/uavobjectmanager.c b/flight/uavobjects/uavobjectmanager.c index e62ecbb7e..8b2120a4b 100644 --- a/flight/uavobjects/uavobjectmanager.c +++ b/flight/uavobjects/uavobjectmanager.c @@ -1423,6 +1423,28 @@ void UAVObjSetGcsTelemetryUpdateMode(UAVObjMetadata *metadata, UAVObjUpdateMode SET_BITS(metadata->flags, UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT, val, UAVOBJ_UPDATE_MODE_MASK); } +/** + * Get the UAVObject metadata logging update mode + * \param[in] metadata The metadata object + * \return the GCS telemetry update mode + */ +UAVObjUpdateMode UAVObjGetLoggingUpdateMode(const UAVObjMetadata *metadata) +{ + PIOS_Assert(metadata); + return (metadata->flags >> UAVOBJ_LOGGING_UPDATE_MODE_SHIFT) & UAVOBJ_UPDATE_MODE_MASK; +} + +/** + * Set the UAVObject metadata logging update mode member + * \param[in] metadata The metadata object + * \param[in] val The GCS telemetry update mode + */ +void UAVObjSetLoggingUpdateMode(UAVObjMetadata *metadata, UAVObjUpdateMode val) +{ + PIOS_Assert(metadata); + SET_BITS(metadata->flags, UAVOBJ_LOGGING_UPDATE_MODE_SHIFT, val, UAVOBJ_UPDATE_MODE_MASK); +} + /** * Check if an object is read only @@ -1559,6 +1581,28 @@ void UAVObjInstanceUpdated(UAVObjHandle obj_handle, uint16_t instId) xSemaphoreGiveRecursive(mutex); } +/** + * Log the object's data (triggers a EV_LOGGING_MANUAL event on this object). + * \param[in] obj The object handle + */ +void UAVObjLogging(UAVObjHandle obj_handle) +{ + UAVObjInstanceLogging(obj_handle, UAVOBJ_ALL_INSTANCES); +} + +/** + * Log the object's data (triggers a EV_LOGGING_MANUAL event on this object). + * \param[in] obj The object handle + * \param[in] instId The object instance ID + */ +void UAVObjInstanceLogging(UAVObjHandle obj_handle, uint16_t instId) +{ + PIOS_Assert(obj_handle); + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + sendEvent((struct UAVOBase *)obj_handle, instId, EV_LOGGING_MANUAL); + xSemaphoreGiveRecursive(mutex); +} + /** * Iterate through all objects in the list. * \param iterator This function will be called once for each object, From 243e261411f7463b4bf04a9aee6c899aa87b7046 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 17:15:23 +0100 Subject: [PATCH 051/116] UAVObject logging through telemetry module and uavobjectmanager --- flight/modules/Telemetry/telemetry.c | 116 ++++++++++++++++++----- flight/uavobjects/inc/uavobjectmanager.h | 1 + flight/uavobjects/uavobjectmanager.c | 44 ++++++++- 3 files changed, 132 insertions(+), 29 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 2ddb3f5aa..2749121a2 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -88,6 +88,7 @@ static int32_t transmitData(uint8_t *data, int32_t length); static void registerObject(UAVObjHandle obj); static void updateObject(UAVObjHandle obj, int32_t eventType); static int32_t setUpdatePeriod(UAVObjHandle obj, int32_t updatePeriodMs); +static int32_t setLoggingPeriod(UAVObjHandle obj, int32_t updatePeriodMs); static void processObjEvent(UAVObjEvent *ev); static void updateTelemetryStats(); static void gcsTelemetryStatsUpdated(); @@ -181,21 +182,18 @@ static void registerObject(UAVObjHandle obj) return; } else { UAVObjMetadata metadata; - UAVObjUpdateMode updateMode; + UAVObjUpdateMode updateMode, loggingMode; UAVObjGetMetadata(obj, &metadata); - updateMode = UAVObjGetTelemetryUpdateMode(&metadata); + updateMode = UAVObjGetTelemetryUpdateMode(&metadata); + loggingMode = UAVObjGetLoggingUpdateMode(&metadata); - /* Only create a periodic event for objects that are periodic */ - if ((updateMode == UPDATEMODE_PERIODIC) || - (updateMode == UPDATEMODE_THROTTLED)) { - // Setup object for periodic updates - UAVObjEvent ev = { - .obj = obj, - .instId = UAVOBJ_ALL_INSTANCES, - .event = EV_UPDATED_PERIODIC, - }; - EventPeriodicQueueCreate(&ev, queue, 0); - } + // Setup object for periodic updates + UAVObjEvent ev = { + .obj = obj, + .instId = UAVOBJ_ALL_INSTANCES, + .event = (updateMode == UPDATEMODE_PERIODIC || updateMode == UPDATEMODE_THROTTLED) ? EV_UPDATED_PERIODIC : 0 | (loggingMode == UPDATEMODE_PERIODIC || loggingMode == UPDATEMODE_THROTTLED) ? EV_LOGGING_PERIODIC : 0, + }; + EventPeriodicQueueCreate(&ev, queue, 0); // Setup object for telemetry updates updateObject(obj, EV_NONE); @@ -209,7 +207,7 @@ static void registerObject(UAVObjHandle obj) static void updateObject(UAVObjHandle obj, int32_t eventType) { UAVObjMetadata metadata; - UAVObjUpdateMode updateMode; + UAVObjUpdateMode updateMode, loggingMode; int32_t eventMask; if (UAVObjIsMetaobject(obj)) { @@ -222,46 +220,78 @@ static void updateObject(UAVObjHandle obj, int32_t eventType) // Get metadata UAVObjGetMetadata(obj, &metadata); - updateMode = UAVObjGetTelemetryUpdateMode(&metadata); + updateMode = UAVObjGetTelemetryUpdateMode(&metadata); + loggingMode = UAVObjGetLoggingUpdateMode(&metadata); // Setup object depending on update mode + eventMask = 0; switch (updateMode) { case UPDATEMODE_PERIODIC: // Set update period setUpdatePeriod(obj, metadata.telemetryUpdatePeriod); // Connect queue - eventMask = EV_UPDATED_PERIODIC | EV_UPDATED_MANUAL | EV_UPDATE_REQ; - UAVObjConnectQueue(obj, priorityQueue, eventMask); + eventMask |= EV_UPDATED_PERIODIC | EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; case UPDATEMODE_ONCHANGE: // Set update period setUpdatePeriod(obj, 0); // Connect queue - eventMask = EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; - UAVObjConnectQueue(obj, priorityQueue, eventMask); + eventMask |= EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; case UPDATEMODE_THROTTLED: if ((eventType == EV_UPDATED_PERIODIC) || (eventType == EV_NONE)) { // If we received a periodic update, we can change back to update on change - eventMask = EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; + eventMask |= EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; // Set update period on initialization and metadata change if (eventType == EV_NONE) { setUpdatePeriod(obj, metadata.telemetryUpdatePeriod); } } else { // Otherwise, we just received an object update, so switch to periodic for the timeout period to prevent more updates - eventMask = EV_UPDATED_PERIODIC | EV_UPDATED_MANUAL | EV_UPDATE_REQ; + eventMask |= EV_UPDATED_PERIODIC | EV_UPDATED_MANUAL | EV_UPDATE_REQ; } - UAVObjConnectQueue(obj, priorityQueue, eventMask); break; case UPDATEMODE_MANUAL: // Set update period setUpdatePeriod(obj, 0); // Connect queue - eventMask = EV_UPDATED_MANUAL | EV_UPDATE_REQ; - UAVObjConnectQueue(obj, priorityQueue, eventMask); + eventMask |= EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; } + switch (loggingMode) { + case UPDATEMODE_PERIODIC: + // Set update period + setLoggingPeriod(obj, metadata.loggingUpdatePeriod); + // Connect queue + eventMask |= EV_LOGGING_PERIODIC | EV_LOGGING_MANUAL; + break; + case UPDATEMODE_ONCHANGE: + // Set update period + setLoggingPeriod(obj, 0); + // Connect queue + eventMask |= EV_UPDATED | EV_LOGGING_MANUAL; + break; + case UPDATEMODE_THROTTLED: + if ((eventType == EV_LOGGING_PERIODIC) || (eventType == EV_NONE)) { + // If we received a periodic update, we can change back to update on change + eventMask |= EV_UPDATED | EV_LOGGING_MANUAL; + // Set update period on initialization and metadata change + if (eventType == EV_NONE) { + setLoggingPeriod(obj, metadata.loggingUpdatePeriod); + } + } else { + // Otherwise, we just received an object update, so switch to periodic for the timeout period to prevent more updates + eventMask |= EV_LOGGING_PERIODIC | EV_LOGGING_MANUAL; + } + break; + case UPDATEMODE_MANUAL: + // Set update period + setLoggingPeriod(obj, 0); + // Connect queue + eventMask |= EV_LOGGING_MANUAL; + break; + } + UAVObjConnectQueue(obj, priorityQueue, eventMask); } /** @@ -288,7 +318,7 @@ static void processObjEvent(UAVObjEvent *ev) // Act on event retries = 0; success = -1; - if (ev->event == EV_UPDATED || ev->event == EV_UPDATED_MANUAL || ((ev->event == EV_UPDATED_PERIODIC) && (updateMode != UPDATEMODE_THROTTLED))) { + if ((ev->event == EV_UPDATED && (updateMode == UPDATEMODE_ONCHANGE || updateMode == UPDATEMODE_THROTTLED)) || ev->event == EV_UPDATED_MANUAL || ((ev->event == EV_UPDATED_PERIODIC) && (updateMode != UPDATEMODE_THROTTLED))) { // Send update to GCS (with retries) while (retries < MAX_RETRIES && success == -1) { success = UAVTalkSendObject(uavTalkCon, ev->obj, ev->instId, UAVObjGetTelemetryAcked(&metadata), REQ_TIMEOUT_MS); // call blocks until ack is received or timeout @@ -321,6 +351,24 @@ static void processObjEvent(UAVObjEvent *ev) } } } + // Log UAVObject if necessary + if (ev->obj) { + updateMode = UAVObjGetLoggingUpdateMode(&metadata); + if ((ev->event == EV_UPDATED && (updateMode == UPDATEMODE_ONCHANGE || updateMode == UPDATEMODE_THROTTLED)) || ev->event == EV_LOGGING_MANUAL || ((ev->event == EV_LOGGING_PERIODIC) && (updateMode != UPDATEMODE_THROTTLED))) { + if (ev->instId == UAVOBJ_ALL_INSTANCES) { + success = UAVObjGetNumInstances(ev->obj); + for (retries = 0; retries < success; retries++) { + UAVObjInstanceWriteToLog(ev->obj, retries); + } + } else { + UAVObjInstanceWriteToLog(ev->obj, ev->instId); + } + } + if (updateMode == UPDATEMODE_THROTTLED) { + // If this is UPDATEMODE_THROTTLED, the event mask changes on every event. + updateObject(ev->obj, ev->event); + } + } } /** @@ -447,6 +495,24 @@ static int32_t setUpdatePeriod(UAVObjHandle obj, int32_t updatePeriodMs) return EventPeriodicQueueUpdate(&ev, queue, updatePeriodMs); } +/** + * Set logging update period of object (it must be already setup for periodic updates) + * \param[in] obj The object to update + * \param[in] updatePeriodMs The update period in ms, if zero then periodic updates are disabled + * \return 0 Success + * \return -1 Failure + */ +static int32_t setLoggingPeriod(UAVObjHandle obj, int32_t updatePeriodMs) +{ + UAVObjEvent ev; + + // Add object for periodic updates + ev.obj = obj; + ev.instId = UAVOBJ_ALL_INSTANCES; + ev.event = EV_LOGGING_PERIODIC; + return EventPeriodicQueueUpdate(&ev, queue, updatePeriodMs); +} + /** * Called each time the GCS telemetry stats object is updated. * Trigger a flight telemetry stats update if a connection is not diff --git a/flight/uavobjects/inc/uavobjectmanager.h b/flight/uavobjects/inc/uavobjectmanager.h index a7af203fb..349d7c3dd 100644 --- a/flight/uavobjects/inc/uavobjectmanager.h +++ b/flight/uavobjects/inc/uavobjectmanager.h @@ -208,6 +208,7 @@ void UAVObjInstanceUpdated(UAVObjHandle obj_handle, uint16_t instId); void UAVObjLogging(UAVObjHandle obj); void UAVObjInstanceLogging(UAVObjHandle obj_handle, uint16_t instId); void UAVObjIterate(void (*iterator)(UAVObjHandle obj)); +void UAVObjInstanceWriteToLog(UAVObjHandle obj_handle, uint16_t instId); #endif // UAVOBJECTMANAGER_H diff --git a/flight/uavobjects/uavobjectmanager.c b/flight/uavobjects/uavobjectmanager.c index 8b2120a4b..66117a1da 100644 --- a/flight/uavobjects/uavobjectmanager.c +++ b/flight/uavobjects/uavobjectmanager.c @@ -705,6 +705,43 @@ unlock_exit: } +/** + * Actually write the object's data to the logfile + * \param[in] obj The object handle + * \param[in] instId The object instance ID + */ +void UAVObjInstanceWriteToLog(UAVObjHandle obj_handle, uint16_t instId) +{ + PIOS_Assert(obj_handle); + + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + + if (UAVObjIsMetaobject(obj_handle)) { + if (instId != 0) { + goto unlock_exit; + } + PIOS_DEBUGLOG_UAVObject(UAVObjGetID(obj_handle), instId, MetaNumBytes, (uint8_t *)MetaDataPtr((struct UAVOMeta *)obj_handle)); + } else { + struct UAVOData *obj; + InstanceHandle instEntry; + + // Cast handle to object + obj = (struct UAVOData *)obj_handle; + + // Get the instance + instEntry = getInstance(obj, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + // Pack data + PIOS_DEBUGLOG_UAVObject(UAVObjGetID(obj_handle), instId, obj->instance_size, (uint8_t *)InstanceData(instEntry)); + } + +unlock_exit: + xSemaphoreGiveRecursive(mutex); +} + /** * Save the data of the specified object to the file system (SD card). * If the object contains multiple instances, all of them will be saved. @@ -712,10 +749,9 @@ unlock_exit: * The object data can be restored using the UAVObjLoad function. * @param[in] obj The object handle. * @param[in] instId The instance ID - * @param[in] file File to append to * @return 0 if success or -1 if failure */ -int32_t UAVObjSave(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t instId) +int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId) { PIOS_Assert(obj_handle); @@ -754,7 +790,7 @@ int32_t UAVObjSave(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t ins * @param[in] instId The object instance * @return 0 if success or -1 if failure */ -int32_t UAVObjLoad(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t instId) +int32_t UAVObjLoad(UAVObjHandle obj_handle, uint16_t instId) { PIOS_Assert(obj_handle); @@ -794,7 +830,7 @@ int32_t UAVObjLoad(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t ins * @param[in] instId The object instance * @return 0 if success or -1 if failure */ -int32_t UAVObjDelete(UAVObjHandle obj_handle, __attribute__((unused)) uint16_t instId) +int32_t UAVObjDelete(UAVObjHandle obj_handle, uint16_t instId) { PIOS_Assert(obj_handle); PIOS_FLASHFS_ObjDelete(pios_uavo_settings_fs_id, UAVObjGetID(obj_handle), instId); From 6031200aea5481e8d0c91410dc1ffb8089149798 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 18:04:47 +0100 Subject: [PATCH 052/116] Some fixes in debuglog to compile and run on all firmware platforms --- flight/pios/common/pios_debuglog.c | 201 +++++++++++++++++++++++++++++ flight/pios/inc/pios_debuglog.h | 2 +- flight/pios/pios.h | 1 + flight/pios/posix/pios_debuglog.c | 73 ++++++----- make/apps-defs.mk | 1 + 5 files changed, 245 insertions(+), 33 deletions(-) create mode 100644 flight/pios/common/pios_debuglog.c diff --git a/flight/pios/common/pios_debuglog.c b/flight/pios/common/pios_debuglog.c new file mode 100644 index 000000000..6ef2112fb --- /dev/null +++ b/flight/pios/common/pios_debuglog.c @@ -0,0 +1,201 @@ +/** + ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @defgroup PIOS_DEBUGLOG Flash log debugging Functions + * @brief Debugging functionality + * @{ + * + * @file pios_debuglog.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. + * @brief Debugging Functions + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Project Includes */ +#include "pios.h" +#include "uavobjectmanager.h" +#include "debuglogentry.h" + +// global definitions + + +// Global variables +extern uintptr_t pios_user_fs_id; // flash filesystem for logging + +#if defined(PIOS_INCLUDE_FREERTOS) +static xSemaphoreHandle mutex = 0; +#define mutexlock() xSemaphoreTakeRecursive(mutex, portMAX_DELAY) +#define mutexunlock() xSemaphoreGiveRecursive(mutex) +#else +#define mutexlock() +#define mutexunlock() +#endif + +static bool logging_enabled = false; +static uint16_t flightnum = 0; +static uint16_t lognum = 0; +static DebugLogEntryData *buffer = 0; +#if !defined(PIOS_INCLUDE_FREERTOS) +static DebugLogEntryData staticbuffer; +#endif + +/* Private Function Prototypes */ + +/** + * @brief Initialize the log facility + */ +void PIOS_DEBUGLOG_Initialize() +{ +#if defined(PIOS_INCLUDE_FREERTOS) + if (!mutex) { + mutex = xSemaphoreCreateRecursiveMutex(); + buffer = pvPortMalloc(sizeof(DebugLogEntryData)); + } +#else + buffer = &staticbuffer; +#endif + if (!buffer) { + return; + } + mutexlock(); + lognum = 0; + flightnum = 0; + while (PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { + flightnum++; + } + mutexunlock(); +} + + +/** + * @brief Enables or Disables logging globally + * @param[in] enable or disable logging + */ +void PIOS_DEBUGLOG_Enable(uint8_t enabled) +{ + logging_enabled = enabled; +} + +/** + * @brief Write a debug log entry with a uavobject + * @param[in] objectid + * @param[in] instanceid + * @param[in] instanceid + * @param[in] size of object + * @param[in] data buffer + */ +void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8_t *data) +{ + if (!logging_enabled || !buffer) { + return; + } + mutexlock(); + buffer->Flight = flightnum; +#if defined(PIOS_INCLUDE_FREERTOS) + buffer->FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; +#else + buffer->FlightTime = 0; +#endif + buffer->Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; + buffer->ObjectID = objid; + buffer->InstanceID = instid; + if (size > sizeof(buffer->Data)) { + size = sizeof(buffer->Data); + } + buffer->Size = size; + memcpy(buffer->Data, data, size); + + if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { + lognum++; + } + mutexunlock(); +} +/** + * @brief Write a debug log entry with text + * @param[in] format - as in printf + * @param[in] variable arguments for printf + * @param... + */ +void PIOS_DEBUGLOG_Printf(char *format, ...) +{ + if (!logging_enabled || !buffer) { + return; + } + va_list args; + va_start(args, format); + mutexlock(); + vsnprintf((char *)buffer->Data, sizeof(buffer->Data), (char *)format, args); + buffer->Flight = flightnum; +#if defined(PIOS_INCLUDE_FREERTOS) + buffer->FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; +#else + buffer->FlightTime = 0; +#endif + buffer->Entry = lognum; + buffer->Type = DEBUGLOGENTRY_TYPE_TEXT; + buffer->ObjectID = 0; + buffer->InstanceID = 0; + buffer->Size = strlen((const char *)buffer->Data); + + if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { + lognum++; + } + mutexunlock(); +} + + +/** + * @brief Load one object instance from the filesystem + * @param[out] buffer where to store the uavobject + * @param[in] log entry from which flight + * @param[in] log entry sequence number + * @return 0 if success or error code + * @retval -1 if fs_id is not a valid filesystem instance + * @retval -2 if failed to start transaction + * @retval -3 if object not found in filesystem + * @retval -4 if object size in filesystem does not exactly match buffer size + * @retval -5 if reading the object data from flash fails + */ +int32_t PIOS_DEBUGLOG_Read(void *mybuffer, uint16_t flight, uint16_t inst) +{ + PIOS_Assert(mybuffer); + return PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flight * 256, inst, (uint8_t *)mybuffer, sizeof(DebugLogEntryData)); +} + +/** + * @brief Retrieve run time info of logging system + * @param[out] current flight number + * @param[out] next entry number + */ +void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry) +{ + if (flight) { + *flight = flightnum; + } + if (entry) { + *entry = lognum; + } +} + + +/** + * @} + * @} + */ diff --git a/flight/pios/inc/pios_debuglog.h b/flight/pios/inc/pios_debuglog.h index ba32631ee..e9d3e79a2 100644 --- a/flight/pios/inc/pios_debuglog.h +++ b/flight/pios/inc/pios_debuglog.h @@ -41,7 +41,7 @@ void PIOS_DEBUGLOG_Initialize(); * @brief Enables or Disables logging globally * @param[in] enable or disable logging */ -void PIOS_DEBUGLOG_Enable(bool enabled); +void PIOS_DEBUGLOG_Enable(uint8_t enabled); /** * @brief Write a debug log entry with a uavobject diff --git a/flight/pios/pios.h b/flight/pios/pios.h index 1a566627d..6ba15b104 100644 --- a/flight/pios/pios.h +++ b/flight/pios/pios.h @@ -69,6 +69,7 @@ /* #define DEBUG_LEVEL 0 */ /* #define PIOS_ENABLE_DEBUG_PINS */ #include +#include /* PIOS common functions */ #include diff --git a/flight/pios/posix/pios_debuglog.c b/flight/pios/posix/pios_debuglog.c index 369778137..6ef2112fb 100644 --- a/flight/pios/posix/pios_debuglog.c +++ b/flight/pios/posix/pios_debuglog.c @@ -51,7 +51,10 @@ static xSemaphoreHandle mutex = 0; static bool logging_enabled = false; static uint16_t flightnum = 0; static uint16_t lognum = 0; -static DebugLogEntryData buffer; +static DebugLogEntryData *buffer = 0; +#if !defined(PIOS_INCLUDE_FREERTOS) +static DebugLogEntryData staticbuffer; +#endif /* Private Function Prototypes */ @@ -62,13 +65,19 @@ void PIOS_DEBUGLOG_Initialize() { #if defined(PIOS_INCLUDE_FREERTOS) if (!mutex) { - mutex = xSemaphoreCreateRecursiveMutex(); + mutex = xSemaphoreCreateRecursiveMutex(); + buffer = pvPortMalloc(sizeof(DebugLogEntryData)); } +#else + buffer = &staticbuffer; #endif + if (!buffer) { + return; + } mutexlock(); lognum = 0; flightnum = 0; - while (PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)&buffer, sizeof(DebugLogEntryData)) == 0) { + while (PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { flightnum++; } mutexunlock(); @@ -79,7 +88,7 @@ void PIOS_DEBUGLOG_Initialize() * @brief Enables or Disables logging globally * @param[in] enable or disable logging */ -void PIOS_DEBUGLOG_Enable(bool enabled) +void PIOS_DEBUGLOG_Enable(uint8_t enabled) { logging_enabled = enabled; } @@ -94,26 +103,26 @@ void PIOS_DEBUGLOG_Enable(bool enabled) */ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8_t *data) { - if (!logging_enabled) { + if (!logging_enabled || !buffer) { return; } mutexlock(); - buffer.Flight = flightnum; + buffer->Flight = flightnum; #if defined(PIOS_INCLUDE_FREERTOS) - buffer.FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; + buffer->FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; #else - buffer.FlightTime = 0; + buffer->FlightTime = 0; #endif - buffer.Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; - buffer.ObjectID = objid; - buffer.InstanceID = instid; - buffer.Size = size; - uint16_t t = 0; - for (; t < size && t < sizeof(buffer.Data); t++) { - buffer.Data[t] = data[t]; + buffer->Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; + buffer->ObjectID = objid; + buffer->InstanceID = instid; + if (size > sizeof(buffer->Data)) { + size = sizeof(buffer->Data); } + buffer->Size = size; + memcpy(buffer->Data, data, size); - if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)&buffer, sizeof(DebugLogEntryData)) == 0) { + if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { lognum++; } mutexunlock(); @@ -126,26 +135,26 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 */ void PIOS_DEBUGLOG_Printf(char *format, ...) { - if (!logging_enabled) { + if (!logging_enabled || !buffer) { return; } va_list args; va_start(args, format); mutexlock(); - vsnprintf((char *)buffer.Data, sizeof(buffer.Data), (char *)format, args); - buffer.Flight = flightnum; + vsnprintf((char *)buffer->Data, sizeof(buffer->Data), (char *)format, args); + buffer->Flight = flightnum; #if defined(PIOS_INCLUDE_FREERTOS) - buffer.FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; + buffer->FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; #else - buffer.FlightTime = 0; + buffer->FlightTime = 0; #endif - buffer.Entry = lognum; - buffer.Type = DEBUGLOGENTRY_TYPE_TEXT; - buffer.ObjectID = 0; - buffer.InstanceID = 0; - buffer.Size = strlen((const char *)buffer.Data); + buffer->Entry = lognum; + buffer->Type = DEBUGLOGENTRY_TYPE_TEXT; + buffer->ObjectID = 0; + buffer->InstanceID = 0; + buffer->Size = strlen((const char *)buffer->Data); - if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)&buffer, sizeof(DebugLogEntryData)) == 0) { + if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { lognum++; } mutexunlock(); @@ -164,16 +173,16 @@ void PIOS_DEBUGLOG_Printf(char *format, ...) * @retval -4 if object size in filesystem does not exactly match buffer size * @retval -5 if reading the object data from flash fails */ -int32_t PIOS_DEBUGLOG_Read(void *buffer, uint16_t flight, uint16_t inst) +int32_t PIOS_DEBUGLOG_Read(void *mybuffer, uint16_t flight, uint16_t inst) { - PIOS_Assert(buffer); - return PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flight * 256, inst, (uint8_t *)buffer, sizeof(DebugLogEntryData)); + PIOS_Assert(mybuffer); + return PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flight * 256, inst, (uint8_t *)mybuffer, sizeof(DebugLogEntryData)); } /** * @brief Retrieve run time info of logging system - * @param[out] buffer where to store the uavobject - * @param[in] log entry from which flight + * @param[out] current flight number + * @param[out] next entry number */ void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry) { diff --git a/make/apps-defs.mk b/make/apps-defs.mk index 54e2e991e..801e75277 100644 --- a/make/apps-defs.mk +++ b/make/apps-defs.mk @@ -81,6 +81,7 @@ SRC += $(PIOSCOMMON)/pios_com_msg.c SRC += $(PIOSCOMMON)/pios_crc.c SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c SRC += $(PIOSCOMMON)/pios_flash_jedec.c +SRC += $(PIOSCOMMON)/pios_debuglog.c SRC += $(PIOSCOMMON)/pios_rcvr.c SRC += $(PIOSCOMMON)/pios_rfm22b.c SRC += $(PIOSCOMMON)/pios_rfm22b_com.c From 9dbac5d060f7a1f1e085f390c980ed0559cfcde7 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 18:49:50 +0100 Subject: [PATCH 053/116] Enabled printf-stdarg on all targets, implemented vsnprintf() (needed for logging) --- flight/libraries/printf-stdarg.c | 6 ++++++ flight/targets/boards/osd/firmware/Makefile | 2 +- make/apps-defs.mk | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/flight/libraries/printf-stdarg.c b/flight/libraries/printf-stdarg.c index 5f4f0c40b..c0bbd31f6 100644 --- a/flight/libraries/printf-stdarg.c +++ b/flight/libraries/printf-stdarg.c @@ -246,6 +246,12 @@ int snprintf(char *buf, size_t count, const char *format, ...) return print(count, &buf, format, args); } +// TK: added for alternative parameter passing +int vsnprintf(char *buf, size_t count, const char *format, va_list args) +{ + return print(count, &buf, format, args); +} + /** * @} */ diff --git a/flight/targets/boards/osd/firmware/Makefile b/flight/targets/boards/osd/firmware/Makefile index 70ec0624f..22f4f2928 100644 --- a/flight/targets/boards/osd/firmware/Makefile +++ b/flight/targets/boards/osd/firmware/Makefile @@ -68,7 +68,7 @@ ifndef TESTAPP #endif ## Misc library functions - SRC += $(FLIGHTLIB)/printf2.c + #SRC += $(FLIGHTLIB)/printf2.c SRC += $(FLIGHTLIB)/WorldMagModel.c ## UAVObjects diff --git a/make/apps-defs.mk b/make/apps-defs.mk index 801e75277..b326b218d 100644 --- a/make/apps-defs.mk +++ b/make/apps-defs.mk @@ -103,6 +103,7 @@ SRC += $(FLIGHTLIB)/sanitycheck.c SRC += $(FLIGHTLIB)/CoordinateConversions.c SRC += $(MATHLIB)/sin_lookup.c SRC += $(MATHLIB)/pid.c +SRC += $(FLIGHTLIB)/printf-stdarg.c ## Modules SRC += $(foreach mod, $(MODULES), $(sort $(wildcard $(OPMODULEDIR)/$(mod)/*.c))) From 3d8625abaf56ec861defc0681e8e75d16ed0ad85 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 18:50:51 +0100 Subject: [PATCH 054/116] Enabled logging on revolution (added module and uavobjects) --- flight/targets/boards/revolution/firmware/Makefile | 1 + flight/targets/boards/revolution/firmware/UAVObjects.inc | 3 +++ 2 files changed, 4 insertions(+) diff --git a/flight/targets/boards/revolution/firmware/Makefile b/flight/targets/boards/revolution/firmware/Makefile index 07aed3b52..3202b2e1e 100644 --- a/flight/targets/boards/revolution/firmware/Makefile +++ b/flight/targets/boards/revolution/firmware/Makefile @@ -47,6 +47,7 @@ MODULES += Radio MODULES += PathPlanner MODULES += FixedWingPathFollower MODULES += Osd/osdoutout +MODULES += Logging MODULES += Telemetry OPTMODULES += ComUsbBridge diff --git a/flight/targets/boards/revolution/firmware/UAVObjects.inc b/flight/targets/boards/revolution/firmware/UAVObjects.inc index 27563043b..ff08a773e 100644 --- a/flight/targets/boards/revolution/firmware/UAVObjects.inc +++ b/flight/targets/boards/revolution/firmware/UAVObjects.inc @@ -36,6 +36,9 @@ UAVOBJSRCFILENAMES += barosensor UAVOBJSRCFILENAMES += airspeedsensor UAVOBJSRCFILENAMES += airspeedsettings UAVOBJSRCFILENAMES += airspeedstate +UAVOBJSRCFILENAMES += debuglogsettings +UAVOBJSRCFILENAMES += debuglogcontrol +UAVOBJSRCFILENAMES += debuglogentry UAVOBJSRCFILENAMES += flightbatterysettings UAVOBJSRCFILENAMES += firmwareiapobj UAVOBJSRCFILENAMES += flightbatterystate From fcc479f5cb2f1b0c58f0fbb3b08a9ec8a709eebc Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 20:14:50 +0100 Subject: [PATCH 055/116] more intelligent log interfacing, including flash formatting option --- flight/modules/Logging/Logging.c | 49 ++++++++++++------- flight/pios/common/pios_debuglog.c | 25 +++++++++- flight/pios/inc/pios_debuglog.h | 13 +++-- flight/pios/posix/pios_debuglog.c | 25 +++++++++- .../boards/revolution/firmware/UAVObjects.inc | 1 + .../boards/simposix/firmware/UAVObjects.inc | 1 + .../src/plugins/uavobjects/uavobjects.pro | 2 + .../uavobjectdefinition/debuglogcontrol.xml | 1 + shared/uavobjectdefinition/debuglogstatus.xml | 13 +++++ 9 files changed, 108 insertions(+), 22 deletions(-) create mode 100644 shared/uavobjectdefinition/debuglogstatus.xml diff --git a/flight/modules/Logging/Logging.c b/flight/modules/Logging/Logging.c index 12441ffa4..3abb76477 100644 --- a/flight/modules/Logging/Logging.c +++ b/flight/modules/Logging/Logging.c @@ -33,22 +33,28 @@ #include "openpilot.h" #include "debuglogsettings.h" #include "debuglogcontrol.h" +#include "debuglogstatus.h" #include "debuglogentry.h" +#include "flightstatus.h" // private variables static DebugLogSettingsData settings; static DebugLogControlData control; +static DebugLogStatusData status; static DebugLogEntryData *entry; // would be better on stack but event dispatcher stack might be insufficient // private functions static void SettingsUpdatedCb(UAVObjEvent *ev); static void ControlUpdatedCb(UAVObjEvent *ev); +static void StatusUpdatedCb(UAVObjEvent *ev); int32_t LoggingInitialize(void) { DebugLogSettingsInitialize(); DebugLogControlInitialize(); + DebugLogStatusInitialize(); DebugLogEntryInitialize(); + FlightStatusInitialize(); PIOS_DEBUGLOG_Initialize(); entry = pvPortMalloc(sizeof(DebugLogEntryData)); if (!entry) { @@ -63,10 +69,21 @@ int32_t LoggingStart(void) DebugLogSettingsConnectCallback(SettingsUpdatedCb); DebugLogControlConnectCallback(ControlUpdatedCb); SettingsUpdatedCb(DebugLogSettingsHandle()); + + UAVObjEvent ev = { .obj = DebugLogSettingsHandle(), .instId = 0, .event = EV_UPDATED_PERIODIC }; + EventPeriodicCallbackCreate(&ev, StatusUpdatedCb, 1000); + // invoke a periodic dispatcher callback - the event struct is a dummy, it could be filled with anything! + StatusUpdatedCb(&ev); + return 0; } MODULE_INITCALL(LoggingInitialize, LoggingStart); +static void StatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) +{ + PIOS_DEBUGLOG_Info(&status.Flight, &status.Entry, &status.FreeSlots, &status.UsedSlots); + DebugLogStatusSet(&status); +} static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { @@ -77,26 +94,24 @@ static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { - static bool ignore = 0; // this little hack allows us to set our own uavobject in the callback - - if (ignore) { - ignore = 0; - return; - } - DebugLogControlGet(&control); - if (PIOS_DEBUGLOG_Read(entry, control.Flight, control.Entry) != 0) { - // reading from log failed, mark as non existent in output + if (control.Operation == DEBUGLOGCONTROL_OPERATION_RETRIEVE) { memset(entry, 0, sizeof(DebugLogEntryData)); - entry->Flight = control.Flight; - entry->Entry = control.Entry; - entry->Type = DEBUGLOGENTRY_TYPE_EMPTY; + if (PIOS_DEBUGLOG_Read(entry, control.Flight, control.Entry) != 0) { + // reading from log failed, mark as non existent in output + entry->Flight = control.Flight; + entry->Entry = control.Entry; + entry->Type = DEBUGLOGENTRY_TYPE_EMPTY; + } + DebugLogEntrySet(entry); + } else if (control.Operation == DEBUGLOGCONTROL_OPERATION_FORMATFLASH) { + uint8_t armed; + FlightStatusArmedGet(&armed); + if (armed == FLIGHTSTATUS_ARMED_DISARMED) { + PIOS_DEBUGLOG_Format(); + } } - PIOS_DEBUGLOG_Info(&control.Flight, &control.Entry); - - ignore = 1; // set ignore flag before setting object - creates loop otherwise!!! - DebugLogEntrySet(entry); - DebugLogControlSet(&control); + StatusUpdatedCb(ev); } diff --git a/flight/pios/common/pios_debuglog.c b/flight/pios/common/pios_debuglog.c index 6ef2112fb..79782e868 100644 --- a/flight/pios/common/pios_debuglog.c +++ b/flight/pios/common/pios_debuglog.c @@ -120,6 +120,7 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 size = sizeof(buffer->Data); } buffer->Size = size; + memset(buffer->Data, 0, sizeof(buffer->Data)); memcpy(buffer->Data, data, size); if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { @@ -141,6 +142,7 @@ void PIOS_DEBUGLOG_Printf(char *format, ...) va_list args; va_start(args, format); mutexlock(); + memset(buffer->Data, 0, sizeof(buffer->Data)); vsnprintf((char *)buffer->Data, sizeof(buffer->Data), (char *)format, args); buffer->Flight = flightnum; #if defined(PIOS_INCLUDE_FREERTOS) @@ -183,8 +185,10 @@ int32_t PIOS_DEBUGLOG_Read(void *mybuffer, uint16_t flight, uint16_t inst) * @brief Retrieve run time info of logging system * @param[out] current flight number * @param[out] next entry number + * @param[out] free slots in filesystem + * @param[out] used slots in filesystem */ -void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry) +void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry, uint16_t *free, uint16_t *used) { if (flight) { *flight = flightnum; @@ -192,8 +196,27 @@ void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry) if (entry) { *entry = lognum; } + struct PIOS_FLASHFS_Stats stats = { 0, 0 }; + PIOS_FLASHFS_GetStats(pios_user_fs_id, &stats); + if (free) { + *free = stats.num_free_slots; + } + if (used) { + *used = stats.num_active_slots; + } } +/** + * @brief Format entire flash memory!!! + */ +void PIOS_DEBUGLOG_Format(void) +{ + mutexlock(); + PIOS_FLASHFS_Format(pios_user_fs_id); + lognum = 0; + flightnum = 0; + mutexunlock(); +} /** * @} diff --git a/flight/pios/inc/pios_debuglog.h b/flight/pios/inc/pios_debuglog.h index e9d3e79a2..62023dc4d 100644 --- a/flight/pios/inc/pios_debuglog.h +++ b/flight/pios/inc/pios_debuglog.h @@ -77,10 +77,17 @@ int32_t PIOS_DEBUGLOG_Read(void *buffer, uint16_t flight, uint16_t inst); /** * @brief Retrieve run time info of logging system - * @param[out] buffer where to store the uavobject - * @param[in] log entry from which flight + * @param[out] current flight number + * @param[out] next entry number + * @param[out] free slots in filesystem + * @param[out] used slots in filesystem */ -void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry); +void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry, uint16_t *free, uint16_t *used); + +/** + * @brief Format entire flash memory!!! + */ +void PIOS_DEBUGLOG_Format(void); #endif // ifndef PIOS_DEBUGLOG_H diff --git a/flight/pios/posix/pios_debuglog.c b/flight/pios/posix/pios_debuglog.c index 6ef2112fb..79782e868 100644 --- a/flight/pios/posix/pios_debuglog.c +++ b/flight/pios/posix/pios_debuglog.c @@ -120,6 +120,7 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 size = sizeof(buffer->Data); } buffer->Size = size; + memset(buffer->Data, 0, sizeof(buffer->Data)); memcpy(buffer->Data, data, size); if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { @@ -141,6 +142,7 @@ void PIOS_DEBUGLOG_Printf(char *format, ...) va_list args; va_start(args, format); mutexlock(); + memset(buffer->Data, 0, sizeof(buffer->Data)); vsnprintf((char *)buffer->Data, sizeof(buffer->Data), (char *)format, args); buffer->Flight = flightnum; #if defined(PIOS_INCLUDE_FREERTOS) @@ -183,8 +185,10 @@ int32_t PIOS_DEBUGLOG_Read(void *mybuffer, uint16_t flight, uint16_t inst) * @brief Retrieve run time info of logging system * @param[out] current flight number * @param[out] next entry number + * @param[out] free slots in filesystem + * @param[out] used slots in filesystem */ -void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry) +void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry, uint16_t *free, uint16_t *used) { if (flight) { *flight = flightnum; @@ -192,8 +196,27 @@ void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry) if (entry) { *entry = lognum; } + struct PIOS_FLASHFS_Stats stats = { 0, 0 }; + PIOS_FLASHFS_GetStats(pios_user_fs_id, &stats); + if (free) { + *free = stats.num_free_slots; + } + if (used) { + *used = stats.num_active_slots; + } } +/** + * @brief Format entire flash memory!!! + */ +void PIOS_DEBUGLOG_Format(void) +{ + mutexlock(); + PIOS_FLASHFS_Format(pios_user_fs_id); + lognum = 0; + flightnum = 0; + mutexunlock(); +} /** * @} diff --git a/flight/targets/boards/revolution/firmware/UAVObjects.inc b/flight/targets/boards/revolution/firmware/UAVObjects.inc index ff08a773e..7a63dc9f2 100644 --- a/flight/targets/boards/revolution/firmware/UAVObjects.inc +++ b/flight/targets/boards/revolution/firmware/UAVObjects.inc @@ -38,6 +38,7 @@ UAVOBJSRCFILENAMES += airspeedsettings UAVOBJSRCFILENAMES += airspeedstate UAVOBJSRCFILENAMES += debuglogsettings UAVOBJSRCFILENAMES += debuglogcontrol +UAVOBJSRCFILENAMES += debuglogstatus UAVOBJSRCFILENAMES += debuglogentry UAVOBJSRCFILENAMES += flightbatterysettings UAVOBJSRCFILENAMES += firmwareiapobj diff --git a/flight/targets/boards/simposix/firmware/UAVObjects.inc b/flight/targets/boards/simposix/firmware/UAVObjects.inc index c404b272a..be99363d3 100644 --- a/flight/targets/boards/simposix/firmware/UAVObjects.inc +++ b/flight/targets/boards/simposix/firmware/UAVObjects.inc @@ -44,6 +44,7 @@ UAVOBJSRCFILENAMES += airspeedsettings UAVOBJSRCFILENAMES += airspeedstate UAVOBJSRCFILENAMES += debuglogsettings UAVOBJSRCFILENAMES += debuglogcontrol +UAVOBJSRCFILENAMES += debuglogstatus UAVOBJSRCFILENAMES += debuglogentry UAVOBJSRCFILENAMES += flightbatterysettings UAVOBJSRCFILENAMES += firmwareiapobj diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index 4051a027f..00cd3c29d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -36,6 +36,7 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ $$UAVOBJECT_SYNTHETICS/altitudefiltersettings.h \ $$UAVOBJECT_SYNTHETICS/debuglogsettings.h \ $$UAVOBJECT_SYNTHETICS/debuglogcontrol.h \ + $$UAVOBJECT_SYNTHETICS/debuglogstatus.h \ $$UAVOBJECT_SYNTHETICS/debuglogentry.h \ $$UAVOBJECT_SYNTHETICS/ekfconfiguration.h \ $$UAVOBJECT_SYNTHETICS/ekfstatevariance.h \ @@ -125,6 +126,7 @@ SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ $$UAVOBJECT_SYNTHETICS/altitudeholdsettings.cpp \ $$UAVOBJECT_SYNTHETICS/debuglogsettings.cpp \ $$UAVOBJECT_SYNTHETICS/debuglogcontrol.cpp \ + $$UAVOBJECT_SYNTHETICS/debuglogstatus.cpp \ $$UAVOBJECT_SYNTHETICS/debuglogentry.cpp \ $$UAVOBJECT_SYNTHETICS/altitudefiltersettings.cpp \ $$UAVOBJECT_SYNTHETICS/ekfconfiguration.cpp \ diff --git a/shared/uavobjectdefinition/debuglogcontrol.xml b/shared/uavobjectdefinition/debuglogcontrol.xml index 6af9106f9..1599fe6da 100644 --- a/shared/uavobjectdefinition/debuglogcontrol.xml +++ b/shared/uavobjectdefinition/debuglogcontrol.xml @@ -1,6 +1,7 @@ Log Control Object + diff --git a/shared/uavobjectdefinition/debuglogstatus.xml b/shared/uavobjectdefinition/debuglogstatus.xml new file mode 100644 index 000000000..a89c12562 --- /dev/null +++ b/shared/uavobjectdefinition/debuglogstatus.xml @@ -0,0 +1,13 @@ + + + Log Control Object + + + + + + + + + + From c7431623afe2918ad4db8c55554d4688048c6b31 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 20:43:53 +0100 Subject: [PATCH 056/116] changed hardware definition for revolution to have usr space in just one arena (no flash garbage collection since used primarily for logging where there are no deletes) --- flight/targets/boards/revolution/board_hw_defs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/targets/boards/revolution/board_hw_defs.c b/flight/targets/boards/revolution/board_hw_defs.c index 6ecec9522..02b8126e2 100644 --- a/flight/targets/boards/revolution/board_hw_defs.c +++ b/flight/targets/boards/revolution/board_hw_defs.c @@ -684,7 +684,7 @@ const struct pios_rfm22b_cfg *PIOS_BOARD_HW_DEFS_GetRfm22Cfg(uint32_t board_revi static const struct flashfs_logfs_cfg flashfs_external_user_cfg = { .fs_magic = 0x99abcdef, .total_fs_size = 0x001C0000, /* 2M bytes (32 sectors = entire chip) */ - .arena_size = 0x00010000, /* 256 * slot size */ + .arena_size = 0x001C0000, /* full size, no garbage collection in usr */ .slot_size = 0x00000100, /* 256 bytes */ .start_offset = 0x40000, /* start offset */ From 3f1ea5ed09ddced6efbbe42fb1cf809303b041b5 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 20:45:04 +0100 Subject: [PATCH 057/116] set all uavobjects logging mode to manual enable only at users discretion as needed to preserve log space --- shared/uavobjectdefinition/airspeedstate.xml | 2 +- shared/uavobjectdefinition/altitudeholddesired.xml | 2 +- shared/uavobjectdefinition/flighttelemetrystats.xml | 2 +- shared/uavobjectdefinition/gpspositionsensor.xml | 2 +- shared/uavobjectdefinition/gpssatellites.xml | 2 +- shared/uavobjectdefinition/gpstime.xml | 2 +- shared/uavobjectdefinition/gpsvelocitysensor.xml | 2 +- shared/uavobjectdefinition/i2cstats.xml | 2 +- shared/uavobjectdefinition/mixerstatus.xml | 2 +- shared/uavobjectdefinition/oplinkstatus.xml | 2 +- shared/uavobjectdefinition/overosyncsettings.xml | 2 +- shared/uavobjectdefinition/overosyncstats.xml | 2 +- shared/uavobjectdefinition/pathaction.xml | 2 +- shared/uavobjectdefinition/pathstatus.xml | 2 +- shared/uavobjectdefinition/poilocation.xml | 2 +- shared/uavobjectdefinition/positionstate.xml | 2 +- shared/uavobjectdefinition/ratedesired.xml | 2 +- shared/uavobjectdefinition/systemalarms.xml | 2 +- shared/uavobjectdefinition/systemstats.xml | 2 +- shared/uavobjectdefinition/taskinfo.xml | 2 +- shared/uavobjectdefinition/velocitydesired.xml | 2 +- shared/uavobjectdefinition/velocitystate.xml | 2 +- shared/uavobjectdefinition/watchdogstatus.xml | 2 +- shared/uavobjectdefinition/waypoint.xml | 2 +- shared/uavobjectdefinition/waypointactive.xml | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/shared/uavobjectdefinition/airspeedstate.xml b/shared/uavobjectdefinition/airspeedstate.xml index 3a7db51d9..f38473bae 100644 --- a/shared/uavobjectdefinition/airspeedstate.xml +++ b/shared/uavobjectdefinition/airspeedstate.xml @@ -6,6 +6,6 @@ - + diff --git a/shared/uavobjectdefinition/altitudeholddesired.xml b/shared/uavobjectdefinition/altitudeholddesired.xml index cf056cfa0..af2dafe94 100644 --- a/shared/uavobjectdefinition/altitudeholddesired.xml +++ b/shared/uavobjectdefinition/altitudeholddesired.xml @@ -8,6 +8,6 @@ - + diff --git a/shared/uavobjectdefinition/flighttelemetrystats.xml b/shared/uavobjectdefinition/flighttelemetrystats.xml index 352bb7de0..2e371b7de 100644 --- a/shared/uavobjectdefinition/flighttelemetrystats.xml +++ b/shared/uavobjectdefinition/flighttelemetrystats.xml @@ -10,6 +10,6 @@ - + diff --git a/shared/uavobjectdefinition/gpspositionsensor.xml b/shared/uavobjectdefinition/gpspositionsensor.xml index 8686a76ef..cfaba9db0 100644 --- a/shared/uavobjectdefinition/gpspositionsensor.xml +++ b/shared/uavobjectdefinition/gpspositionsensor.xml @@ -15,6 +15,6 @@ - + diff --git a/shared/uavobjectdefinition/gpssatellites.xml b/shared/uavobjectdefinition/gpssatellites.xml index 47c4c0f56..8d3ecb8e3 100644 --- a/shared/uavobjectdefinition/gpssatellites.xml +++ b/shared/uavobjectdefinition/gpssatellites.xml @@ -9,6 +9,6 @@ - + diff --git a/shared/uavobjectdefinition/gpstime.xml b/shared/uavobjectdefinition/gpstime.xml index ab93d4e9c..1408ba2d8 100644 --- a/shared/uavobjectdefinition/gpstime.xml +++ b/shared/uavobjectdefinition/gpstime.xml @@ -10,6 +10,6 @@ - + diff --git a/shared/uavobjectdefinition/gpsvelocitysensor.xml b/shared/uavobjectdefinition/gpsvelocitysensor.xml index c94474ca2..a9fa3ce2b 100644 --- a/shared/uavobjectdefinition/gpsvelocitysensor.xml +++ b/shared/uavobjectdefinition/gpsvelocitysensor.xml @@ -7,6 +7,6 @@ - + diff --git a/shared/uavobjectdefinition/i2cstats.xml b/shared/uavobjectdefinition/i2cstats.xml index 3e79d79ea..f5cc5318a 100644 --- a/shared/uavobjectdefinition/i2cstats.xml +++ b/shared/uavobjectdefinition/i2cstats.xml @@ -14,6 +14,6 @@ - + diff --git a/shared/uavobjectdefinition/mixerstatus.xml b/shared/uavobjectdefinition/mixerstatus.xml index c7491a92e..0c33d7f24 100644 --- a/shared/uavobjectdefinition/mixerstatus.xml +++ b/shared/uavobjectdefinition/mixerstatus.xml @@ -16,6 +16,6 @@ - + diff --git a/shared/uavobjectdefinition/oplinkstatus.xml b/shared/uavobjectdefinition/oplinkstatus.xml index a0d2fded5..bcceb3751 100644 --- a/shared/uavobjectdefinition/oplinkstatus.xml +++ b/shared/uavobjectdefinition/oplinkstatus.xml @@ -31,6 +31,6 @@ - + diff --git a/shared/uavobjectdefinition/overosyncsettings.xml b/shared/uavobjectdefinition/overosyncsettings.xml index 2d884bc1a..9c70d47bb 100644 --- a/shared/uavobjectdefinition/overosyncsettings.xml +++ b/shared/uavobjectdefinition/overosyncsettings.xml @@ -5,6 +5,6 @@ - + diff --git a/shared/uavobjectdefinition/overosyncstats.xml b/shared/uavobjectdefinition/overosyncstats.xml index de069e38c..ce87c306d 100644 --- a/shared/uavobjectdefinition/overosyncstats.xml +++ b/shared/uavobjectdefinition/overosyncstats.xml @@ -11,6 +11,6 @@ - + diff --git a/shared/uavobjectdefinition/pathaction.xml b/shared/uavobjectdefinition/pathaction.xml index 983863650..16ed7a569 100644 --- a/shared/uavobjectdefinition/pathaction.xml +++ b/shared/uavobjectdefinition/pathaction.xml @@ -25,6 +25,6 @@ - + diff --git a/shared/uavobjectdefinition/pathstatus.xml b/shared/uavobjectdefinition/pathstatus.xml index 746d15c47..52352dc4a 100644 --- a/shared/uavobjectdefinition/pathstatus.xml +++ b/shared/uavobjectdefinition/pathstatus.xml @@ -11,6 +11,6 @@ - + diff --git a/shared/uavobjectdefinition/poilocation.xml b/shared/uavobjectdefinition/poilocation.xml index 6ab6f0273..52298f017 100644 --- a/shared/uavobjectdefinition/poilocation.xml +++ b/shared/uavobjectdefinition/poilocation.xml @@ -7,6 +7,6 @@ - + diff --git a/shared/uavobjectdefinition/positionstate.xml b/shared/uavobjectdefinition/positionstate.xml index f6d689741..2a054a648 100644 --- a/shared/uavobjectdefinition/positionstate.xml +++ b/shared/uavobjectdefinition/positionstate.xml @@ -7,6 +7,6 @@ - + diff --git a/shared/uavobjectdefinition/ratedesired.xml b/shared/uavobjectdefinition/ratedesired.xml index 5d68597ee..6c297c3e5 100644 --- a/shared/uavobjectdefinition/ratedesired.xml +++ b/shared/uavobjectdefinition/ratedesired.xml @@ -7,6 +7,6 @@ - + diff --git a/shared/uavobjectdefinition/systemalarms.xml b/shared/uavobjectdefinition/systemalarms.xml index faa1cc9b1..34c353d64 100644 --- a/shared/uavobjectdefinition/systemalarms.xml +++ b/shared/uavobjectdefinition/systemalarms.xml @@ -43,6 +43,6 @@ - + diff --git a/shared/uavobjectdefinition/systemstats.xml b/shared/uavobjectdefinition/systemstats.xml index e09c817a4..4d305a471 100644 --- a/shared/uavobjectdefinition/systemstats.xml +++ b/shared/uavobjectdefinition/systemstats.xml @@ -16,6 +16,6 @@ - + diff --git a/shared/uavobjectdefinition/taskinfo.xml b/shared/uavobjectdefinition/taskinfo.xml index 1886967fc..7dc843c0a 100644 --- a/shared/uavobjectdefinition/taskinfo.xml +++ b/shared/uavobjectdefinition/taskinfo.xml @@ -113,6 +113,6 @@ - + diff --git a/shared/uavobjectdefinition/velocitydesired.xml b/shared/uavobjectdefinition/velocitydesired.xml index d20f43cb6..957c09b1a 100644 --- a/shared/uavobjectdefinition/velocitydesired.xml +++ b/shared/uavobjectdefinition/velocitydesired.xml @@ -7,6 +7,6 @@ - + diff --git a/shared/uavobjectdefinition/velocitystate.xml b/shared/uavobjectdefinition/velocitystate.xml index 90a89a4dd..9b922f6a9 100644 --- a/shared/uavobjectdefinition/velocitystate.xml +++ b/shared/uavobjectdefinition/velocitystate.xml @@ -7,6 +7,6 @@ - + diff --git a/shared/uavobjectdefinition/watchdogstatus.xml b/shared/uavobjectdefinition/watchdogstatus.xml index 2adef2c87..8bbc275e5 100644 --- a/shared/uavobjectdefinition/watchdogstatus.xml +++ b/shared/uavobjectdefinition/watchdogstatus.xml @@ -6,6 +6,6 @@ - + diff --git a/shared/uavobjectdefinition/waypoint.xml b/shared/uavobjectdefinition/waypoint.xml index 2a27f7fd5..e2c5b944a 100644 --- a/shared/uavobjectdefinition/waypoint.xml +++ b/shared/uavobjectdefinition/waypoint.xml @@ -7,6 +7,6 @@ - + diff --git a/shared/uavobjectdefinition/waypointactive.xml b/shared/uavobjectdefinition/waypointactive.xml index 3343715b5..d38b82713 100644 --- a/shared/uavobjectdefinition/waypointactive.xml +++ b/shared/uavobjectdefinition/waypointactive.xml @@ -5,6 +5,6 @@ - + From c6031ed9632f422b269eb40e648a787e61dd11da Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 21:03:08 +0100 Subject: [PATCH 058/116] fixed usr flash system definition --- flight/targets/boards/revolution/board_hw_defs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flight/targets/boards/revolution/board_hw_defs.c b/flight/targets/boards/revolution/board_hw_defs.c index 02b8126e2..78d106cbc 100644 --- a/flight/targets/boards/revolution/board_hw_defs.c +++ b/flight/targets/boards/revolution/board_hw_defs.c @@ -682,12 +682,12 @@ const struct pios_rfm22b_cfg *PIOS_BOARD_HW_DEFS_GetRfm22Cfg(uint32_t board_revi #include "pios_flash_internal_priv.h" static const struct flashfs_logfs_cfg flashfs_external_user_cfg = { - .fs_magic = 0x99abcdef, + .fs_magic = 0x99abceff, .total_fs_size = 0x001C0000, /* 2M bytes (32 sectors = entire chip) */ - .arena_size = 0x001C0000, /* full size, no garbage collection in usr */ + .arena_size = 0x000E0000, /* biggest possible arena size fssize/2 */ .slot_size = 0x00000100, /* 256 bytes */ - .start_offset = 0x40000, /* start offset */ + .start_offset = 0x00040000, /* start offset */ .sector_size = 0x00010000, /* 64K bytes */ .page_size = 0x00000100, /* 256 bytes */ }; From 0e502d373487463b8cfefbd892de34f861da316e Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 22:10:03 +0100 Subject: [PATCH 059/116] Modified queue creation for telemetry and logging event queues are now created for all uavobjects for both telemetry and logging, so later modifications from manual to periodic are possible --- flight/modules/Telemetry/telemetry.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 2749121a2..239aa33e1 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -191,9 +191,12 @@ static void registerObject(UAVObjHandle obj) UAVObjEvent ev = { .obj = obj, .instId = UAVOBJ_ALL_INSTANCES, - .event = (updateMode == UPDATEMODE_PERIODIC || updateMode == UPDATEMODE_THROTTLED) ? EV_UPDATED_PERIODIC : 0 | (loggingMode == UPDATEMODE_PERIODIC || loggingMode == UPDATEMODE_THROTTLED) ? EV_LOGGING_PERIODIC : 0, + .event = EV_UPDATED_PERIODIC, }; EventPeriodicQueueCreate(&ev, queue, 0); + ev.event = EV_LOGGING_PERIODIC; + EventPeriodicQueueCreate(&ev, queue, 0); + // Setup object for telemetry updates updateObject(obj, EV_NONE); From 951c7bfea042377ac189560540b8207021276db7 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 22:20:19 +0100 Subject: [PATCH 060/116] removed redundant code from Telemetry --- flight/modules/Telemetry/telemetry.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 239aa33e1..c43cddff7 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -181,12 +181,6 @@ static void registerObject(UAVObjHandle obj) UAVObjConnectQueue(obj, priorityQueue, EV_MASK_ALL_UPDATES); return; } else { - UAVObjMetadata metadata; - UAVObjUpdateMode updateMode, loggingMode; - UAVObjGetMetadata(obj, &metadata); - updateMode = UAVObjGetTelemetryUpdateMode(&metadata); - loggingMode = UAVObjGetLoggingUpdateMode(&metadata); - // Setup object for periodic updates UAVObjEvent ev = { .obj = obj, From 9414f3513f93b8c25266fd2b8e48e89a2ce4dc77 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 17 Nov 2013 22:39:39 +0100 Subject: [PATCH 061/116] adapted telemetry stack sizes for flight firmware to include more space needed for logging feature --- flight/targets/boards/coptercontrol/firmware/inc/pios_config.h | 2 +- flight/targets/boards/oplinkmini/firmware/inc/pios_config.h | 2 +- flight/targets/boards/osd/pios_board.h | 2 +- flight/targets/boards/revolution/pios_board.h | 2 +- flight/targets/boards/revoproto/pios_board.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h index 09f9b0b51..a8970239b 100644 --- a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h +++ b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h @@ -157,7 +157,7 @@ #define PIOS_MANUAL_STACK_SIZE 800 #define PIOS_SYSTEM_STACK_SIZE 660 #define PIOS_STABILIZATION_STACK_SIZE 524 -#define PIOS_TELEM_STACK_SIZE 500 +#define PIOS_TELEM_STACK_SIZE 800 #define PIOS_EVENTDISPATCHER_STACK_SIZE 130 /* This can't be too high to stop eventdispatcher thread overflowing */ diff --git a/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h b/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h index 97f307cb5..ef965b0af 100644 --- a/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h +++ b/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h @@ -157,7 +157,7 @@ #define PIOS_MANUAL_STACK_SIZE 724 #define PIOS_SYSTEM_STACK_SIZE 460 #define PIOS_STABILIZATION_STACK_SIZE 524 -#define PIOS_TELEM_STACK_SIZE 500 +#define PIOS_TELEM_STACK_SIZE 800 #define PIOS_EVENTDISPATCHER_STACK_SIZE 130 /* This can't be too high to stop eventdispatcher thread overflowing */ diff --git a/flight/targets/boards/osd/pios_board.h b/flight/targets/boards/osd/pios_board.h index 16dafb34f..9b88a5e3b 100644 --- a/flight/targets/boards/osd/pios_board.h +++ b/flight/targets/boards/osd/pios_board.h @@ -102,7 +102,7 @@ // TELEMETRY // ------------------------ #define TELEM_QUEUE_SIZE 20 -#define PIOS_TELEM_STACK_SIZE 624 +#define PIOS_TELEM_STACK_SIZE 800 // ***************************************************************** // Interrupt Priorities diff --git a/flight/targets/boards/revolution/pios_board.h b/flight/targets/boards/revolution/pios_board.h index d6843c7e6..de47db80a 100644 --- a/flight/targets/boards/revolution/pios_board.h +++ b/flight/targets/boards/revolution/pios_board.h @@ -177,7 +177,7 @@ extern uint32_t pios_packet_handler; // TELEMETRY // ------------------------ #define TELEM_QUEUE_SIZE 80 -#define PIOS_TELEM_STACK_SIZE 624 +#define PIOS_TELEM_STACK_SIZE 800 // ------------------------- // System Settings diff --git a/flight/targets/boards/revoproto/pios_board.h b/flight/targets/boards/revoproto/pios_board.h index 2c3dd65cb..6da2bbd9c 100644 --- a/flight/targets/boards/revoproto/pios_board.h +++ b/flight/targets/boards/revoproto/pios_board.h @@ -139,7 +139,7 @@ extern uint32_t pios_com_hkosd_id; // TELEMETRY // ------------------------ #define TELEM_QUEUE_SIZE 80 -#define PIOS_TELEM_STACK_SIZE 624 +#define PIOS_TELEM_STACK_SIZE 800 // ------------------------- // System Settings From d8772c55295fd2ec6313dd905aa4f28691b00cfb Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Mon, 18 Nov 2013 20:04:11 +1100 Subject: [PATCH 062/116] Clean this up, so debug DDLs don't hang around in a release and vice versa --- ground/openpilotgcs/copydata.pro | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 8212cc25b..41f0153b4 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -92,7 +92,23 @@ equals(copydata, 1) { data_copy.commands += $(COPY_DIR) $$targetPath(\"$$[QT_INSTALL_QML]/$$dir\") $$targetPath(\"$$GCS_APP_PATH/$$dir\") $$addNewline() } - # copy QtQuick plugin DLLs + # Remove the few unwanted DDLs after whole dir copy + QT_QUICK2_DELS = qtquick/controls/qtquickcontrolsplugin \ + qtquick/controls/private/qtquickcontrolsprivateplugin \ + qtquick/dialogs/dialogplugin + + CONFIG(debug, debug|release) { + for(delfile, QT_QUICK2_DELS) { + data_copy.commands += $(DEL_FILE) $$targetPath(\"$$GCS_APP_PATH/$${delfile}.dll\") $$addNewline() + } + } + CONFIG(release, debug|release) { + for(delfile, QT_QUICK2_DELS) { + data_copy.commands += $(DEL_FILE) $$targetPath(\"$$GCS_APP_PATH/$${delfile}d.dll\") $$addNewline() + } + } + + # Remianing QtQuick plugin DLLs QT_QUICK2_DLLS = QtQuick.2/qtquick2plugin$${DS}.dll \ QtQuick.2/plugins.qmltypes \ QtQuick.2/qmldir \ From 0afbed59952f2eb43d899723445b687c4b0ddf8b Mon Sep 17 00:00:00 2001 From: Fredrik Larrson Date: Mon, 18 Nov 2013 20:13:05 +1100 Subject: [PATCH 063/116] Doh, stupid type in comment, sorry. --- ground/openpilotgcs/copydata.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 41f0153b4..29721b02e 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -108,7 +108,7 @@ equals(copydata, 1) { } } - # Remianing QtQuick plugin DLLs + # Remaining QtQuick plugin DLLs QT_QUICK2_DLLS = QtQuick.2/qtquick2plugin$${DS}.dll \ QtQuick.2/plugins.qmltypes \ QtQuick.2/qmldir \ From 42ad9600446094d09d1a77c048381776d332aeb4 Mon Sep 17 00:00:00 2001 From: Patrick Huebner Date: Mon, 18 Nov 2013 22:43:14 +1100 Subject: [PATCH 064/116] OP-1109 Fix uninitialised use of m_container in welcomemode --- ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp b/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp index 838d28ff7..e2c21956f 100644 --- a/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp +++ b/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp @@ -74,6 +74,7 @@ WelcomeMode::WelcomeMode() : m_d->quickView->setResizeMode(QQuickView::SizeRootObjectToView); m_d->quickView->engine()->rootContext()->setContextProperty("welcomePlugin", this); m_d->quickView->setSource(QUrl("qrc:/welcome/qml/main.qml")); + m_container = NULL; } WelcomeMode::~WelcomeMode() From 8a064b27b9296af2a3309cba4c7407d6bd0c8404 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 18 Nov 2013 15:51:56 +0100 Subject: [PATCH 065/116] OP-1119 Initial commit of empty plugin with only menu item added to GCS. --- .../plugins/flightlog/FlightLog.pluginspec | 10 +++ .../src/plugins/flightlog/flightlog.pro | 10 +++ .../src/plugins/flightlog/flightlogplugin.cpp | 81 +++++++++++++++++++ .../src/plugins/flightlog/flightlogplugin.h | 49 +++++++++++ ground/openpilotgcs/src/plugins/plugins.pro | 5 ++ 5 files changed, 155 insertions(+) create mode 100644 ground/openpilotgcs/src/plugins/flightlog/FlightLog.pluginspec create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightlog.pro create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLog.pluginspec b/ground/openpilotgcs/src/plugins/flightlog/FlightLog.pluginspec new file mode 100644 index 000000000..8baef7f37 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLog.pluginspec @@ -0,0 +1,10 @@ + + The OpenPilot Project + (C) 2013 OpenPilot Project + The GNU Public License (GPL) Version 3 + A plugin to manage flight side logs, viewing and downloading. + http://www.openpilot.org + + + + diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro new file mode 100644 index 000000000..54662b041 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +TARGET = FlightLog + +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) + +HEADERS += flightlogplugin.h +SOURCES += flightlogplugin.cpp + +OTHER_FILES += Flightlog.pluginspec diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp new file mode 100644 index 000000000..ae700e2a5 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp @@ -0,0 +1,81 @@ +/** + ****************************************************************************** + * + * @file flightlogplugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @brief A plugin to view and download flight side logs. + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "flightlogplugin.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +FlightLogPlugin::FlightLogPlugin() +{ +} + +FlightLogPlugin::~FlightLogPlugin() +{ +} + +bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) +{ + Q_UNUSED(args); + Q_UNUSED(errMsg); + + // Add Menu entry + Core::ActionManager *am = Core::ICore::instance()->actionManager(); + Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_TOOLS); + + Core::Command *cmd = am->registerAction(new QAction(this), + "FlightLogPlugin.ShowLogManagementDialog", + QList() << + Core::Constants::C_GLOBAL_ID); + cmd->setDefaultKeySequence(QKeySequence("Ctrl+F")); + cmd->action()->setText(tr("Manage flight side logs")); + + Core::ModeManager::instance()->addAction(cmd, 1); + + ac->menu()->addSeparator(); + ac->appendGroup("Logs"); + ac->addAction(cmd, "Logs"); + + connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(ShowLogManagementDialog())); + return true; +} + +void FlightLogPlugin::ShowLogManagementDialog() +{ + +} + +void FlightLogPlugin::extensionsInitialized() +{ +} + +void FlightLogPlugin::shutdown() +{ +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h new file mode 100644 index 000000000..98d8c4a82 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h @@ -0,0 +1,49 @@ +/** + ****************************************************************************** + * + * @file flightlogplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @brief A plugin to view and download flight side logs. + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef FLIGHTLOGPLUGIN_H_ +#define FLIGHTLOGPLUGIN_H_ + +#include + +class FlightLogPlugin : public ExtensionSystem::IPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "OpenPilot.FlightLog") + +public: + FlightLogPlugin(); + ~FlightLogPlugin(); + + void extensionsInitialized(); + bool initialize(const QStringList & arguments, QString *errorString); + void shutdown(); + +private slots: + void ShowLogManagementDialog(); + +private: +}; + +#endif /* FLIGHTLOGPLUGIN_H_ */ diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro index 73bea8c59..867e7d16a 100644 --- a/ground/openpilotgcs/src/plugins/plugins.pro +++ b/ground/openpilotgcs/src/plugins/plugins.pro @@ -238,3 +238,8 @@ plugin_setupwizard.depends += plugin_config plugin_setupwizard.depends += plugin_uploader SUBDIRS += plugin_setupwizard +# Flight Logs plugin +plugin_flightlog.subdir = flightlog +plugin_setupwizard.depends = plugin_coreplugin +SUBDIRS += plugin_flightlog + From a2c4cb0454d59d0aba8f929fa91bad5e8f36ab8e Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 19 Nov 2013 00:26:38 +0100 Subject: [PATCH 066/116] OP-1119 Fixed .pro file dependency issue. --- ground/openpilotgcs/src/plugins/plugins.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro index 867e7d16a..09a8cb63b 100644 --- a/ground/openpilotgcs/src/plugins/plugins.pro +++ b/ground/openpilotgcs/src/plugins/plugins.pro @@ -240,6 +240,6 @@ SUBDIRS += plugin_setupwizard # Flight Logs plugin plugin_flightlog.subdir = flightlog -plugin_setupwizard.depends = plugin_coreplugin +plugin_flightlog.depends = plugin_coreplugin SUBDIRS += plugin_flightlog From a4d302bcc7307d40fdb58212314056eeb7f4278e Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 19 Nov 2013 07:39:52 +0100 Subject: [PATCH 067/116] OP-1119 Adding some more boilerplate code. --- .../src/plugins/flightlog/flightlog.pro | 6 ++- .../plugins/flightlog/flightlogmanager.cpp | 33 ++++++++++++++ .../src/plugins/flightlog/flightlogmanager.h | 45 +++++++++++++++++++ .../src/plugins/flightlog/flightlogplugin.cpp | 11 +++-- .../src/plugins/flightlog/flightlogplugin.h | 4 ++ .../src/plugins/logging/loggingplugin.cpp | 2 +- 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro index 54662b041..c50dbb091 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro @@ -4,7 +4,9 @@ TARGET = FlightLog include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) -HEADERS += flightlogplugin.h -SOURCES += flightlogplugin.cpp +HEADERS += flightlogplugin.h \ + flightlogmanager.h +SOURCES += flightlogplugin.cpp \ + flightlogmanager.cpp OTHER_FILES += Flightlog.pluginspec diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp new file mode 100644 index 000000000..e540467c9 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * + * @file flightlogmanager.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup [Group] + * @{ + * @addtogroup FlightLogManager + * @{ + * @brief [Brief] + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "flightlogmanager.h" + +FlightLogManager::FlightLogManager(QObject *parent) : + QObject(parent) +{ +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h new file mode 100644 index 000000000..0075acfdd --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -0,0 +1,45 @@ +/** + ****************************************************************************** + * + * @file flightlogmanager.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup [Group] + * @{ + * @addtogroup FlightLogManager + * @{ + * @brief [Brief] + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef FLIGHTLOGMANAGER_H +#define FLIGHTLOGMANAGER_H + +#include + +class FlightLogManager : public QObject +{ + Q_OBJECT +public: + explicit FlightLogManager(QObject *parent = 0); + +signals: + +public slots: + +}; + +#endif // FLIGHTLOGMANAGER_H diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp index ae700e2a5..74449fc2b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp @@ -35,10 +35,13 @@ FlightLogPlugin::FlightLogPlugin() { + m_manager = new FlightLogManager(); } FlightLogPlugin::~FlightLogPlugin() { + delete m_manager; + m_manager = 0; } bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) @@ -51,17 +54,17 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_TOOLS); Core::Command *cmd = am->registerAction(new QAction(this), - "FlightLogPlugin.ShowLogManagementDialog", + "FlightLogPlugin.ShowFlightLogDialog", QList() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+F")); - cmd->action()->setText(tr("Manage flight side logs")); + cmd->action()->setText(tr("Manage flight side logs...")); Core::ModeManager::instance()->addAction(cmd, 1); ac->menu()->addSeparator(); - ac->appendGroup("Logs"); - ac->addAction(cmd, "Logs"); + ac->appendGroup("FlightLogs"); + ac->addAction(cmd, "FlightLogs"); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(ShowLogManagementDialog())); return true; diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h index 98d8c4a82..5c08fda33 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h @@ -27,6 +27,7 @@ #define FLIGHTLOGPLUGIN_H_ #include +#include "flightlogmanager.h" class FlightLogPlugin : public ExtensionSystem::IPlugin { Q_OBJECT @@ -40,6 +41,9 @@ public: bool initialize(const QStringList & arguments, QString *errorString); void shutdown(); +private: + FlightLogManager* m_manager; + private slots: void ShowLogManagementDialog(); diff --git a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp index fc88cbe98..74239e5c6 100644 --- a/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp +++ b/ground/openpilotgcs/src/plugins/logging/loggingplugin.cpp @@ -323,7 +323,7 @@ bool LoggingPlugin::initialize(const QStringList & args, QString *errMsg) QList() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+L")); - cmd->action()->setText("Start logging..."); + cmd->action()->setText(tr("Start logging...")); ac->menu()->addSeparator(); ac->appendGroup("Logging"); From 3bfe74e73cfa7371dab4738a9d698dfb035d7923 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Tue, 19 Nov 2013 18:55:38 +0100 Subject: [PATCH 068/116] added some in uavobject definition comments --- shared/uavobjectdefinition/debuglogcontrol.xml | 10 +++++++++- shared/uavobjectdefinition/debuglogstatus.xml | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/shared/uavobjectdefinition/debuglogcontrol.xml b/shared/uavobjectdefinition/debuglogcontrol.xml index 1599fe6da..2a4b5a84a 100644 --- a/shared/uavobjectdefinition/debuglogcontrol.xml +++ b/shared/uavobjectdefinition/debuglogcontrol.xml @@ -1,6 +1,14 @@ - Log Control Object + Log Control Object - Used to issue commands to the on board logging system + diff --git a/shared/uavobjectdefinition/debuglogstatus.xml b/shared/uavobjectdefinition/debuglogstatus.xml index a89c12562..0d510a332 100644 --- a/shared/uavobjectdefinition/debuglogstatus.xml +++ b/shared/uavobjectdefinition/debuglogstatus.xml @@ -1,6 +1,6 @@ - Log Control Object + Log Status Object, contains log partition status information From 77b7ba3089bce90f0ac92ac3d3dab339c3722ee0 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Tue, 19 Nov 2013 19:29:24 +0100 Subject: [PATCH 069/116] Added new setting 'OnlyWhenArmed' to debuglogsettings --- flight/modules/Logging/Logging.c | 22 +++++++++++++++++-- .../uavobjectdefinition/debuglogsettings.xml | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/flight/modules/Logging/Logging.c b/flight/modules/Logging/Logging.c index 3abb76477..3cf7d2a78 100644 --- a/flight/modules/Logging/Logging.c +++ b/flight/modules/Logging/Logging.c @@ -41,12 +41,14 @@ static DebugLogSettingsData settings; static DebugLogControlData control; static DebugLogStatusData status; +static FlightStatusData flightstatus; static DebugLogEntryData *entry; // would be better on stack but event dispatcher stack might be insufficient // private functions static void SettingsUpdatedCb(UAVObjEvent *ev); static void ControlUpdatedCb(UAVObjEvent *ev); static void StatusUpdatedCb(UAVObjEvent *ev); +static void FlightStatusUpdatedCb(UAVObjEvent *ev); int32_t LoggingInitialize(void) { @@ -68,6 +70,7 @@ int32_t LoggingStart(void) { DebugLogSettingsConnectCallback(SettingsUpdatedCb); DebugLogControlConnectCallback(ControlUpdatedCb); + FlightStatusConnectCallback(FlightStatusUpdatedCb); SettingsUpdatedCb(DebugLogSettingsHandle()); UAVObjEvent ev = { .obj = DebugLogSettingsHandle(), .instId = 0, .event = EV_UPDATED_PERIODIC }; @@ -85,11 +88,26 @@ static void StatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) DebugLogStatusSet(&status); } +static void FlightStatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) +{ + FlightStatusGet(&flightstatus); + switch (settings.LoggingEnabled) { + case DEBUGLOGSETTINGS_LOGGINGENABLED_ALWAYS: + PIOS_DEBUGLOG_Enable(1); + break; + case DEBUGLOGSETTINGS_LOGGINGENABLED_ONLYWHENARMED: + PIOS_DEBUGLOG_Enable(flightstatus.Armed == FLIGHTSTATUS_ARMED_ARMED); + break; + default: + PIOS_DEBUGLOG_Enable(0); + } +} + static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { DebugLogSettingsGet(&settings); - PIOS_DEBUGLOG_Enable(settings.LoggingEnabled); - PIOS_DEBUGLOG_Printf("Logging enabled"); + FlightStatusUpdatedCb(NULL); + PIOS_DEBUGLOG_Printf("On board logging enabled."); } static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) diff --git a/shared/uavobjectdefinition/debuglogsettings.xml b/shared/uavobjectdefinition/debuglogsettings.xml index 05587dedc..cb5fef6ed 100644 --- a/shared/uavobjectdefinition/debuglogsettings.xml +++ b/shared/uavobjectdefinition/debuglogsettings.xml @@ -1,7 +1,7 @@ Configure On Board Logging Facilities - + From 04f4083d4d83e3307aea50685d8d884602ab437d Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 19 Nov 2013 22:00:16 +0100 Subject: [PATCH 070/116] OP-1119 Minor change --- .../openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp | 6 ++++++ .../openpilotgcs/src/plugins/flightlog/flightlogmanager.h | 1 + 2 files changed, 7 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index e540467c9..f07d5bd63 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -30,4 +30,10 @@ FlightLogManager::FlightLogManager(QObject *parent) : QObject(parent) { + +} + +FlightLogManager::~FlightLogManager() +{ + } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 0075acfdd..8852f1391 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -35,6 +35,7 @@ class FlightLogManager : public QObject Q_OBJECT public: explicit FlightLogManager(QObject *parent = 0); + ~FlightLogManager(); signals: From 1b33f48048211b4008872fa2bc71a546da67c540 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 20 Nov 2013 00:07:04 +0100 Subject: [PATCH 071/116] OP-1119 Some glue code between qml and c++ --- .../src/plugins/flightlog/flightlog.pro | 5 +- .../plugins/flightlog/flightlogmanager.cpp | 21 ++++- .../src/plugins/flightlog/flightlogmanager.h | 91 ++++++++++++++++++- ground/openpilotgcs/src/plugins/plugins.pro | 1 + 4 files changed, 111 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro index c50dbb091..d2210f6e6 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro @@ -1,8 +1,11 @@ TEMPLATE = lib TARGET = FlightLog +QT += qml quick + include(../../openpilotgcsplugin.pri) -include(../../plugins/coreplugin/coreplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(../../plugins/uavobjects/uavobjects.pri) HEADERS += flightlogplugin.h \ flightlogmanager.h diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index f07d5bd63..f99b3a53d 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -27,13 +27,30 @@ #include "flightlogmanager.h" -FlightLogManager::FlightLogManager(QObject *parent) : +FlightLogEntry::FlightLogEntry(QObject *parent) : QObject(parent) { } -FlightLogManager::~FlightLogManager() +FlightLogEntry::~FlightLogEntry() { } + +FlightLogManager::FlightLogManager(QObject *parent) : + QObject(parent) { + +} + +FlightLogManager::~FlightLogManager() { + +} + +void FlightLogManager::clearAllLogs() { + +} + +void FlightLogManager::retrieveLogs(int flight) { + +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 8852f1391..cbe8c9c27 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -29,18 +29,101 @@ #define FLIGHTLOGMANAGER_H #include +#include + +class FlightLogEntry : public QObject { + Q_OBJECT Q_PROPERTY(int flightTime READ getFlightTime NOTIFY FlightTimeChanged) + Q_PROPERTY(int flight READ getFlight NOTIFY FlightChanged) + Q_PROPERTY(int entry READ getEntry NOTIFY EntryChanged) + Q_PROPERTY(int type READ getType NOTIFY TypeChanged) + + int m_flightTime; + int m_flight; + int m_entry; + int m_type; + +public: + explicit FlightLogEntry(QObject *parent = 0); + ~FlightLogEntry(); + + int getFlightTime() const + { + return m_flightTime; + } + + int getFlight() const + { + return m_flight; + } + + int getEntry() const + { + return m_entry; + } + + int getType() const + { + return m_type; + } + +signals: + void FlightTimeChanged(int arg); + void FlightChanged(int arg); + void EntryChanged(int arg); + void TypeChanged(int arg); +}; + +class FlightLogManager : public QObject { + Q_OBJECT Q_PROPERTY(int flightsRecorded READ flightsRecorded NOTIFY flightsRecordedChanged) + Q_PROPERTY(int logsRecordedLastFlight READ logsRecordedLastFlight NOTIFY logsRecordedLastFlightChanged) + Q_PROPERTY(int totalLogsRecorded READ totalLogsRecorded NOTIFY totalLogsRecordedChanged) + Q_PROPERTY(int freeLogEntries READ freeLogEntries NOTIFY freeLogEntriesChanged) + Q_PROPERTY(QDeclarativeListProperty records READ records) + + int m_flightsRecorded; + int m_logsRecordedLastFlight; + int m_totalLogsRecorded; + int m_freeLogEntries; + QDeclarativeListProperty m_records; -class FlightLogManager : public QObject -{ - Q_OBJECT public: explicit FlightLogManager(QObject *parent = 0); ~FlightLogManager(); + int flightsRecorded() const + { + return m_flightsRecorded; + } + + int logsRecordedLastFlight() const + { + return m_logsRecordedLastFlight; + } + + int totalLogsRecorded() const + { + return m_totalLogsRecorded; + } + + int freeLogEntries() const + { + return m_freeLogEntries; + } + + QDeclarativeListProperty records() const + { + return m_records; + } + signals: + void flightsRecordedChanged(int arg); + void logsRecordedLastFlightChanged(int arg); + void totalLogsRecordedChanged(int arg); + void freeLogEntriesChanged(int arg); public slots: - + void clearAllLogs(); + void retrieveLogs(int flight = -1); }; #endif // FLIGHTLOGMANAGER_H diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro index 09a8cb63b..9020196e2 100644 --- a/ground/openpilotgcs/src/plugins/plugins.pro +++ b/ground/openpilotgcs/src/plugins/plugins.pro @@ -241,5 +241,6 @@ SUBDIRS += plugin_setupwizard # Flight Logs plugin plugin_flightlog.subdir = flightlog plugin_flightlog.depends = plugin_coreplugin +plugin_flightlog.depends += plugin_uavobjects SUBDIRS += plugin_flightlog From 2191acd22f38d9a446c2f13b8d01400210aa2c5d Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 20 Nov 2013 12:24:34 +0100 Subject: [PATCH 072/116] OP-1119 Adding dialog and qml --- .../src/plugins/flightlog/FlightLogDialog.qml | 15 ++++ .../src/plugins/flightlog/flightLog.qrc | 5 ++ .../src/plugins/flightlog/flightlog.pro | 14 ++- .../src/plugins/flightlog/flightlogdialog.cpp | 64 ++++++++++++++ .../src/plugins/flightlog/flightlogdialog.h | 17 ++++ .../plugins/flightlog/flightlogmanager.cpp | 19 ++-- .../src/plugins/flightlog/flightlogmanager.h | 88 +++---------------- .../src/plugins/flightlog/flightlogplugin.cpp | 18 +++- .../src/plugins/flightlog/flightlogplugin.h | 6 +- .../generators/gcs/uavobjectgeneratorgcs.cpp | 70 ++++++++------- 10 files changed, 188 insertions(+), 128 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp create mode 100644 ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml new file mode 100644 index 000000000..ddef743c0 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import QtQuick.Controls 1.0 + +Rectangle { + width: 100 + height: 62 + + Button { + id: button1 + x: 8 + y: 18 + text: qsTr("OK") + onClicked: dialog.close() + } +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc b/ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc new file mode 100644 index 000000000..c58558e22 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc @@ -0,0 +1,5 @@ + + + FlightLogDialog.qml + + diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro index d2210f6e6..71adb9647 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro @@ -8,8 +8,16 @@ include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/uavobjects/uavobjects.pri) HEADERS += flightlogplugin.h \ - flightlogmanager.h + flightlogmanager.h \ + flightlogdialog.h SOURCES += flightlogplugin.cpp \ - flightlogmanager.cpp + flightlogmanager.cpp \ + flightlogdialog.cpp -OTHER_FILES += Flightlog.pluginspec +OTHER_FILES += Flightlog.pluginspec \ + FlightLogDialog.qml + +FORMS += + +RESOURCES += \ + flightLog.qrc diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp new file mode 100644 index 000000000..8f522098d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -0,0 +1,64 @@ +/** + ****************************************************************************** + * + * @file flightlogdialog.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup [Group] + * @{ + * @addtogroup FlightLogDialog + * @{ + * @brief [Brief] + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "flightlogdialog.h" + +#include + +#include +#include +#include +#include + +FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) : + QDialog(parent) +{ + setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); + setWindowTitle(tr("Manage flight side logs")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + setMinimumSize(600, 400); + setMaximumSize(800, 600); + + QQuickView *view = new QQuickView(); + view->rootContext()->setContextProperty("dialog", this); + view->rootContext()->setContextProperty("logManager", flightLogManager); + view->setResizeMode(QQuickView::SizeRootObjectToView); + view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml")); + + QWidget * container = QWidget::createWindowContainer(view); + container->setMinimumSize(600, 400); + container->setMaximumSize(800, 600); + container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + QVBoxLayout *lay = new QVBoxLayout(); + lay->setContentsMargins(0,0,0,0); + setLayout(lay); + layout()->addWidget(container); +} + +FlightLogDialog::~FlightLogDialog() +{ +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h new file mode 100644 index 000000000..45649a13d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h @@ -0,0 +1,17 @@ +#ifndef FLIGHTLOGDIALOG_H +#define FLIGHTLOGDIALOG_H + +#include +#include"flightlogmanager.h" + +class FlightLogDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager); + ~FlightLogDialog(); + +}; + +#endif // FLIGHTLOGDIALOG_H diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index f99b3a53d..cb62d0c81 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -26,21 +26,20 @@ */ #include "flightlogmanager.h" +#include "extensionsystem/pluginmanager.h" -FlightLogEntry::FlightLogEntry(QObject *parent) : - QObject(parent) -{ - -} - -FlightLogEntry::~FlightLogEntry() -{ - -} +#include "debuglogcontrol.h" FlightLogManager::FlightLogManager(QObject *parent) : QObject(parent) { + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + m_objectManager = pm->getObject(); + Q_ASSERT(m_objectManager); + + m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager); + Q_ASSERT(m_flightLogStatus); + } FlightLogManager::~FlightLogManager() { diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index cbe8c9c27..01085a97a 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -31,99 +31,39 @@ #include #include -class FlightLogEntry : public QObject { - Q_OBJECT Q_PROPERTY(int flightTime READ getFlightTime NOTIFY FlightTimeChanged) - Q_PROPERTY(int flight READ getFlight NOTIFY FlightChanged) - Q_PROPERTY(int entry READ getEntry NOTIFY EntryChanged) - Q_PROPERTY(int type READ getType NOTIFY TypeChanged) - - int m_flightTime; - int m_flight; - int m_entry; - int m_type; - -public: - explicit FlightLogEntry(QObject *parent = 0); - ~FlightLogEntry(); - - int getFlightTime() const - { - return m_flightTime; - } - - int getFlight() const - { - return m_flight; - } - - int getEntry() const - { - return m_entry; - } - - int getType() const - { - return m_type; - } - -signals: - void FlightTimeChanged(int arg); - void FlightChanged(int arg); - void EntryChanged(int arg); - void TypeChanged(int arg); -}; +#include "uavobjectmanager.h" +#include "debuglogentry.h" +#include "debuglogstatus.h" class FlightLogManager : public QObject { - Q_OBJECT Q_PROPERTY(int flightsRecorded READ flightsRecorded NOTIFY flightsRecordedChanged) - Q_PROPERTY(int logsRecordedLastFlight READ logsRecordedLastFlight NOTIFY logsRecordedLastFlightChanged) - Q_PROPERTY(int totalLogsRecorded READ totalLogsRecorded NOTIFY totalLogsRecordedChanged) - Q_PROPERTY(int freeLogEntries READ freeLogEntries NOTIFY freeLogEntriesChanged) - Q_PROPERTY(QDeclarativeListProperty records READ records) - - int m_flightsRecorded; - int m_logsRecordedLastFlight; - int m_totalLogsRecorded; - int m_freeLogEntries; - QDeclarativeListProperty m_records; + Q_OBJECT + Q_PROPERTY(DebugLogStatus * flightLogStatus READ flightLogStatus) + Q_PROPERTY(QDeclarativeListProperty *logEntries READ logEntries) public: explicit FlightLogManager(QObject *parent = 0); ~FlightLogManager(); - int flightsRecorded() const + DebugLogStatus* flightLogStatus() const { - return m_flightsRecorded; + return m_flightLogStatus; } - int logsRecordedLastFlight() const - { - return m_logsRecordedLastFlight; - } - - int totalLogsRecorded() const - { - return m_totalLogsRecorded; - } - - int freeLogEntries() const - { - return m_freeLogEntries; - } - - QDeclarativeListProperty records() const + QDeclarativeListProperty* logEntries() const { return m_records; } signals: - void flightsRecordedChanged(int arg); - void logsRecordedLastFlightChanged(int arg); - void totalLogsRecordedChanged(int arg); - void freeLogEntriesChanged(int arg); public slots: void clearAllLogs(); void retrieveLogs(int flight = -1); + +private: + UAVObjectManager *m_objectManager; + DebugLogStatus *m_flightLogStatus; + QDeclarativeListProperty *m_records; }; #endif // FLIGHTLOGMANAGER_H diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp index 74449fc2b..656f8d191 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp @@ -33,15 +33,14 @@ #include #include -FlightLogPlugin::FlightLogPlugin() +#include "flightlogdialog.h" + +FlightLogPlugin::FlightLogPlugin() : m_logDialog(0) { - m_manager = new FlightLogManager(); } FlightLogPlugin::~FlightLogPlugin() { - delete m_manager; - m_manager = 0; } bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) @@ -72,7 +71,18 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) void FlightLogPlugin::ShowLogManagementDialog() { + if(!m_logDialog) { + m_logDialog = new FlightLogDialog(0, new FlightLogManager()); + connect(m_logDialog, SIGNAL(finished(int)), this, SLOT(LogManagementDialogClosed())); + m_logDialog->show(); + } +} +void FlightLogPlugin::LogManagementDialogClosed() +{ + if(m_logDialog) { + m_logDialog = 0; + } } void FlightLogPlugin::extensionsInitialized() diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h index 5c08fda33..6252e126d 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h @@ -28,6 +28,7 @@ #include #include "flightlogmanager.h" +#include "flightlogdialog.h" class FlightLogPlugin : public ExtensionSystem::IPlugin { Q_OBJECT @@ -41,13 +42,12 @@ public: bool initialize(const QStringList & arguments, QString *errorString); void shutdown(); -private: - FlightLogManager* m_manager; - private slots: void ShowLogManagementDialog(); + void LogManagementDialogClosed(); private: + FlightLogDialog* m_logDialog; }; #endif /* FLIGHTLOGPLUGIN_H_ */ diff --git a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp index 8821614dd..7579ce086 100644 --- a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp +++ b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp @@ -157,40 +157,42 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info) QString(" void %1Changed(quint32 index, %2 value);\n") .arg(field->name).arg(type); - for (int elementIndex = 0; elementIndex < field->numElements; elementIndex++) { - QString elementName = field->elementNames[elementIndex]; - properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n") - .arg(type).arg(field->name+"_"+elementName); - propertyGetters += - QString(" Q_INVOKABLE %1 get%2_%3() const;\n") - .arg(type).arg(field->name).arg(elementName); - propertiesImpl += - QString("%1 %2::get%3_%4() const\n" - "{\n" - " QMutexLocker locker(mutex);\n" - " return data.%3[%5];\n" - "}\n") - .arg(type).arg(info->name).arg(field->name).arg(elementName).arg(elementIndex); - propertySetters += - QString(" void set%1_%2(%3 value);\n") - .arg(field->name).arg(elementName).arg(type); - propertiesImpl += - QString("void %1::set%2_%3(%4 value)\n" - "{\n" - " mutex->lock();\n" - " bool changed = data.%2[%5] != value;\n" - " data.%2[%5] = value;\n" - " mutex->unlock();\n" - " if (changed) emit %2_%3Changed(value);\n" - "}\n\n") - .arg(info->name).arg(field->name).arg(elementName).arg(type).arg(elementIndex); - propertyNotifications += - QString(" void %1_%2Changed(%3 value);\n") - .arg(field->name).arg(elementName).arg(type); - propertyNotificationsImpl += - QString(" //if (data.%1[%2] != oldData.%1[%2])\n" - " emit %1_%3Changed(data.%1[%2]);\n") - .arg(field->name).arg(elementIndex).arg(elementName); + if(!field->defaultElementNames) { + for (int elementIndex = 0; elementIndex < field->numElements; elementIndex++) { + QString elementName = field->elementNames[elementIndex]; + properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n") + .arg(type).arg(field->name+"_"+elementName); + propertyGetters += + QString(" Q_INVOKABLE %1 get%2_%3() const;\n") + .arg(type).arg(field->name).arg(elementName); + propertiesImpl += + QString("%1 %2::get%3_%4() const\n" + "{\n" + " QMutexLocker locker(mutex);\n" + " return data.%3[%5];\n" + "}\n") + .arg(type).arg(info->name).arg(field->name).arg(elementName).arg(elementIndex); + propertySetters += + QString(" void set%1_%2(%3 value);\n") + .arg(field->name).arg(elementName).arg(type); + propertiesImpl += + QString("void %1::set%2_%3(%4 value)\n" + "{\n" + " mutex->lock();\n" + " bool changed = data.%2[%5] != value;\n" + " data.%2[%5] = value;\n" + " mutex->unlock();\n" + " if (changed) emit %2_%3Changed(value);\n" + "}\n\n") + .arg(info->name).arg(field->name).arg(elementName).arg(type).arg(elementIndex); + propertyNotifications += + QString(" void %1_%2Changed(%3 value);\n") + .arg(field->name).arg(elementName).arg(type); + propertyNotificationsImpl += + QString(" //if (data.%1[%2] != oldData.%1[%2])\n" + " emit %1_%3Changed(data.%1[%2]);\n") + .arg(field->name).arg(elementIndex).arg(elementName); + } } } else { properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n") From e42c53de742929abcb52b223a81e1480b940d162 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 20 Nov 2013 16:24:57 +0100 Subject: [PATCH 073/116] OP-1119 Added QmlProperty to handle list of log events downloaded from board. --- .../src/plugins/flightlog/FlightLogDialog.qml | 54 ++++++++++++++++--- .../src/plugins/flightlog/flightlogdialog.cpp | 5 ++ .../plugins/flightlog/flightlogmanager.cpp | 53 +++++++++++++++++- .../src/plugins/flightlog/flightlogmanager.h | 17 +++--- .../src/plugins/flightlog/flightlogplugin.cpp | 6 +++ 5 files changed, 117 insertions(+), 18 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index ddef743c0..ed073d9fd 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -1,15 +1,53 @@ import QtQuick 2.0 import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 + +import org.openpilot 1.0 Rectangle { - width: 100 - height: 62 + width: 600 + height: 400 - Button { - id: button1 - x: 8 - y: 18 - text: qsTr("OK") - onClicked: dialog.close() + ColumnLayout { + anchors.fill: parent + spacing: 10 + + Text { + id:flights + height: 40 + text: logStatus.Flight + } + + ScrollView { + Layout.fillWidth: true + Layout.fillHeight: true + frameVisible: true + ListView { + id: authorsView + anchors.fill: parent + + spacing: 3 + model: logManager.logEntries + delegate: Text { + font.pixelSize: 12 + text: Flight + } + clip: true + } + } + + Rectangle { + Layout.fillWidth: true + height: 40 + Button { + id: button1 + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + anchors.right: parent.right + anchors.rightMargin: 10 + text: qsTr("OK") + onClicked: dialog.close() + } + } } } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp index 8f522098d..be00fc68b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -34,9 +34,13 @@ #include #include +#include "debuglogentry.h" + FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) : QDialog(parent) { + qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry"); + setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png")); setWindowTitle(tr("Manage flight side logs")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -45,6 +49,7 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan QQuickView *view = new QQuickView(); view->rootContext()->setContextProperty("dialog", this); + view->rootContext()->setContextProperty("logStatus", flightLogManager->flightLogStatus()); view->rootContext()->setContextProperty("logManager", flightLogManager); view->setResizeMode(QQuickView::SizeRootObjectToView); view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml")); diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index cb62d0c81..eea99b90e 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -40,16 +40,67 @@ FlightLogManager::FlightLogManager(QObject *parent) : m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager); Q_ASSERT(m_flightLogStatus); + DebugLogEntry *entry = new DebugLogEntry(); + entry->setFlight(1); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(2); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(3); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(4); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(5); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(6); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(7); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(8); + m_logEntries.append(entry); + entry = new DebugLogEntry(); + entry->setFlight(9); + m_logEntries.append(entry); + } FlightLogManager::~FlightLogManager() { } +void addEntries(QQmlListProperty *list, DebugLogEntry *entry) { + Q_UNUSED(list); + Q_UNUSED(entry); +} + +int countEntries(QQmlListProperty *list) { + return static_cast< QList *>(list->data)->size(); +} + +DebugLogEntry* entryAt(QQmlListProperty *list, int index) { + return static_cast< QList *>(list->data)->at(index); +} + +void clearEntries(QQmlListProperty *list) { + return static_cast< QList *>(list->data)->clear(); +} + +QQmlListProperty FlightLogManager::logEntries() { + return QQmlListProperty(this, &m_logEntries, &addEntries, &countEntries, &entryAt, &clearEntries); +} + void FlightLogManager::clearAllLogs() { + //Clear on flight side + m_logEntries.clear(); } void FlightLogManager::retrieveLogs(int flight) { - + //Get logs from flight side } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 01085a97a..e19b228cc 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -29,7 +29,8 @@ #define FLIGHTLOGMANAGER_H #include -#include +#include +#include #include "uavobjectmanager.h" #include "debuglogentry.h" @@ -37,23 +38,20 @@ class FlightLogManager : public QObject { Q_OBJECT - Q_PROPERTY(DebugLogStatus * flightLogStatus READ flightLogStatus) - Q_PROPERTY(QDeclarativeListProperty *logEntries READ logEntries) + Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) + Q_PROPERTY(QQmlListProperty logEntries READ logEntries CONSTANT) public: explicit FlightLogManager(QObject *parent = 0); ~FlightLogManager(); + QQmlListProperty logEntries(); + DebugLogStatus* flightLogStatus() const { return m_flightLogStatus; } - QDeclarativeListProperty* logEntries() const - { - return m_records; - } - signals: public slots: @@ -63,7 +61,8 @@ public slots: private: UAVObjectManager *m_objectManager; DebugLogStatus *m_flightLogStatus; - QDeclarativeListProperty *m_records; + QList m_logEntries; + }; #endif // FLIGHTLOGMANAGER_H diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp index 656f8d191..47d6da6f7 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp @@ -41,6 +41,7 @@ FlightLogPlugin::FlightLogPlugin() : m_logDialog(0) FlightLogPlugin::~FlightLogPlugin() { + shutdown(); } bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) @@ -81,6 +82,7 @@ void FlightLogPlugin::ShowLogManagementDialog() void FlightLogPlugin::LogManagementDialogClosed() { if(m_logDialog) { + m_logDialog->deleteLater(); m_logDialog = 0; } } @@ -91,4 +93,8 @@ void FlightLogPlugin::extensionsInitialized() void FlightLogPlugin::shutdown() { + if(m_logDialog) { + m_logDialog->close(); + LogManagementDialogClosed(); + } } From ed18e372dbc329c371c14251d150b1df84caee8b Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 20 Nov 2013 16:56:43 +0100 Subject: [PATCH 074/116] OP-1119 Some more gui work --- .../src/plugins/flightlog/FlightLogDialog.qml | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index ed073d9fd..d33e4ead0 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -11,11 +11,26 @@ Rectangle { ColumnLayout { anchors.fill: parent spacing: 10 - - Text { - id:flights - height: 40 - text: logStatus.Flight + RowLayout { + Layout.fillWidth: true + spacing: 10 + ColumnLayout { + Layout.fillWidth: true + spacing: 10 + height: 40 + Text { + id: totalFlights + text: "" + qsTr("Flights recorded: ") + "" + logStatus.Flight + } + Text { + id: totalEntries + text: "" + qsTr("Logs recorded: ") + "" + logStatus.UsedSlots + } + Text { + id: freeEntries + text: "" + qsTr("Logs left: ") + "" + logStatus.FreeSlots + } + } } ScrollView { @@ -25,7 +40,6 @@ Rectangle { ListView { id: authorsView anchors.fill: parent - spacing: 3 model: logManager.logEntries delegate: Text { From 72d1744676297e6899623189bc71863123dc60fa Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 20 Nov 2013 21:08:26 +0100 Subject: [PATCH 075/116] OP-1119 More gui --- .../src/plugins/flightlog/FlightLogDialog.qml | 28 +++++++++++++------ .../src/plugins/flightlog/flightlogdialog.h | 1 - .../plugins/flightlog/flightlogmanager.cpp | 5 ++++ .../src/plugins/flightlog/flightlogmanager.h | 1 + 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index d33e4ead0..8da2fd5ee 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -10,6 +10,7 @@ Rectangle { ColumnLayout { anchors.fill: parent + anchors.margins: 10 spacing: 10 RowLayout { Layout.fillWidth: true @@ -20,15 +21,18 @@ Rectangle { height: 40 Text { id: totalFlights + font.pixelSize: 12 text: "" + qsTr("Flights recorded: ") + "" + logStatus.Flight } Text { id: totalEntries - text: "" + qsTr("Logs recorded: ") + "" + logStatus.UsedSlots + font.pixelSize: 12 + text: "" + qsTr("Logs slots used: ") + "" + logStatus.UsedSlots } Text { id: freeEntries - text: "" + qsTr("Logs left: ") + "" + logStatus.FreeSlots + font.pixelSize: 12 + text: "" + qsTr("Logs slots left: ") + "" + logStatus.FreeSlots } } } @@ -50,16 +54,24 @@ Rectangle { } } - Rectangle { + RowLayout { Layout.fillWidth: true height: 40 Button { - id: button1 - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - anchors.right: parent.right - anchors.rightMargin: 10 + id: exportButton + text: qsTr("Export...") + activeFocusOnPress: true + onClicked: logManager.exportLogs() + } + + Rectangle { + Layout.fillWidth: true + } + + Button { + id: okButton text: qsTr("OK") + activeFocusOnPress: true onClicked: dialog.close() } } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h index 45649a13d..64cfbdd3b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h @@ -11,7 +11,6 @@ class FlightLogDialog : public QDialog public: explicit FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager); ~FlightLogDialog(); - }; #endif // FLIGHTLOGDIALOG_H diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index eea99b90e..e1a30bc0f 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -104,3 +104,8 @@ void FlightLogManager::clearAllLogs() { void FlightLogManager::retrieveLogs(int flight) { //Get logs from flight side } + +void FlightLogManager::exportLogs() +{ + +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index e19b228cc..d6e7df31b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -57,6 +57,7 @@ signals: public slots: void clearAllLogs(); void retrieveLogs(int flight = -1); + void exportLogs(); private: UAVObjectManager *m_objectManager; From e693d94637a55245633cd1abe9d2e03a7423dad5 Mon Sep 17 00:00:00 2001 From: m_thread Date: Thu, 21 Nov 2013 12:10:06 +0100 Subject: [PATCH 076/116] OP-1119 Added more gui elements. Fixed layouts and alignments. --- .../src/plugins/flightlog/FlightLogDialog.qml | 101 +++++++++++++----- 1 file changed, 74 insertions(+), 27 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 8da2fd5ee..78431c9a0 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 @@ -12,30 +12,6 @@ Rectangle { anchors.fill: parent anchors.margins: 10 spacing: 10 - RowLayout { - Layout.fillWidth: true - spacing: 10 - ColumnLayout { - Layout.fillWidth: true - spacing: 10 - height: 40 - Text { - id: totalFlights - font.pixelSize: 12 - text: "" + qsTr("Flights recorded: ") + "" + logStatus.Flight - } - Text { - id: totalEntries - font.pixelSize: 12 - text: "" + qsTr("Logs slots used: ") + "" + logStatus.UsedSlots - } - Text { - id: freeEntries - font.pixelSize: 12 - text: "" + qsTr("Logs slots left: ") + "" + logStatus.FreeSlots - } - } - } ScrollView { Layout.fillWidth: true @@ -54,6 +30,79 @@ Rectangle { } } + RowLayout { + Layout.fillWidth: true + spacing: 10 + ColumnLayout { + spacing: 10 + height: 40 + Text { + id: totalFlights + font.pixelSize: 12 + text: "" + qsTr("Flights recorded: ") + "" + (logStatus.Flight + 1) + } + Text { + id: totalEntries + font.pixelSize: 12 + text: "" + qsTr("Logs slots used: ") + "" + logStatus.UsedSlots + } + Text { + id: freeEntries + font.pixelSize: 12 + text: "" + qsTr("Logs slots left: ") + "" + logStatus.FreeSlots + } + } + Rectangle { + Layout.fillWidth: true + } + ColumnLayout { + spacing: 10 + height: 40 + RowLayout { + Rectangle { + Layout.fillWidth: true + } + Text { + font.pixelSize: 12 + text: "" + qsTr("Flight to download:") + "" + } + + ComboBox { + id: flightCombo + property ListModel dataModel: ListModel {} + model: dataModel + Component.onCompleted: { + dataModel.append({"value": "All"}) + for (var a = 0; a <= logStatus.Flight ; a++) { + dataModel.append({"value": (a + 1).toString()}) + } + } + } + } + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + Rectangle { + Layout.fillWidth: true + } + Button { + text: qsTr("Download logs") + activeFocusOnPress: true + onClicked: logManager.retrieveLogs(flightCombo.currentIndex - 1) + } + } + } + } + + Rectangle { + border.width: 1 + height: 2 + width: parent.width + anchors.margins: 20 + anchors.horizontalCenter: parent.horizontalCenter + border.color: "#adadad" + } + RowLayout { Layout.fillWidth: true height: 40 @@ -63,11 +112,9 @@ Rectangle { activeFocusOnPress: true onClicked: logManager.exportLogs() } - Rectangle { Layout.fillWidth: true } - Button { id: okButton text: qsTr("OK") From 077c2b092148c61f976f20dc4ea6efabaf161c28 Mon Sep 17 00:00:00 2001 From: m_thread Date: Thu, 21 Nov 2013 18:07:48 +0100 Subject: [PATCH 077/116] OP-1119 Changed from ListView to TableView. Starting to implement the log entry population and retrieveng code. --- .../src/plugins/flightlog/FlightLogDialog.qml | 137 +++++++++--------- .../src/plugins/flightlog/flightlogdialog.cpp | 2 - .../plugins/flightlog/flightlogmanager.cpp | 2 - 3 files changed, 65 insertions(+), 76 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 78431c9a0..0167f8459 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -13,96 +13,89 @@ Rectangle { anchors.margins: 10 spacing: 10 - ScrollView { + Rectangle { Layout.fillWidth: true Layout.fillHeight: true - frameVisible: true - ListView { - id: authorsView + border.width: 1 + radius: 4 + ColumnLayout { + anchors.margins: 10 anchors.fill: parent - spacing: 3 - model: logManager.logEntries - delegate: Text { + Text { + Layout.fillWidth: true + text: "" + qsTr("Log entries") + "" font.pixelSize: 12 - text: Flight } - clip: true - } - } + TableView { + Layout.fillWidth: true + Layout.fillHeight: true + model: logManager.logEntries + TableViewColumn { role: "Flight"; title: "Flight"; width: 50; horizontalAlignment: Text.AlignRight} + TableViewColumn { role: "FlightTime"; title: "Time";width: 50; horizontalAlignment: Text.AlignRight} + TableViewColumn { role: "Entry"; title: "#"; width: 50; horizontalAlignment: Text.AlignRight} + TableViewColumn { role: "Type"; title: "Contents"; width: 100} + } - RowLayout { - Layout.fillWidth: true - spacing: 10 - ColumnLayout { - spacing: 10 - height: 40 - Text { - id: totalFlights - font.pixelSize: 12 - text: "" + qsTr("Flights recorded: ") + "" + (logStatus.Flight + 1) - } - Text { - id: totalEntries - font.pixelSize: 12 - text: "" + qsTr("Logs slots used: ") + "" + logStatus.UsedSlots - } - Text { - id: freeEntries - font.pixelSize: 12 - text: "" + qsTr("Logs slots left: ") + "" + logStatus.FreeSlots - } - } - Rectangle { - Layout.fillWidth: true - } - ColumnLayout { - spacing: 10 - height: 40 RowLayout { + anchors.margins: 10 + spacing: 10 + ColumnLayout { + spacing: 10 + Text { + id: totalFlights + font.pixelSize: 12 + text: "" + qsTr("Flights recorded: ") + "" + (logStatus.Flight + 1) + } + Text { + id: totalEntries + font.pixelSize: 12 + text: "" + qsTr("Entries logged (free): ") + "" + + logStatus.UsedSlots + " (" + logStatus.FreeSlots + ")" + } + } Rectangle { Layout.fillWidth: true } - Text { - font.pixelSize: 12 - text: "" + qsTr("Flight to download:") + "" - } + ColumnLayout { + spacing: 10 + RowLayout { + Rectangle { + Layout.fillWidth: true + } + Text { + font.pixelSize: 12 + text: "" + qsTr("Flight to download:") + "" + } - ComboBox { - id: flightCombo - property ListModel dataModel: ListModel {} - model: dataModel - Component.onCompleted: { - dataModel.append({"value": "All"}) - for (var a = 0; a <= logStatus.Flight ; a++) { - dataModel.append({"value": (a + 1).toString()}) + ComboBox { + id: flightCombo + property ListModel dataModel: ListModel {} + model: dataModel + Component.onCompleted: { + dataModel.append({"value": "All"}) + for (var a = 0; a <= logStatus.Flight ; a++) { + dataModel.append({"value": (a + 1).toString()}) + } + } + } + } + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + Rectangle { + Layout.fillWidth: true + } + Button { + text: qsTr("Download logs") + activeFocusOnPress: true + onClicked: logManager.retrieveLogs(flightCombo.currentIndex - 1) } } } } - RowLayout { - Layout.fillWidth: true - Layout.fillHeight: true - Rectangle { - Layout.fillWidth: true - } - Button { - text: qsTr("Download logs") - activeFocusOnPress: true - onClicked: logManager.retrieveLogs(flightCombo.currentIndex - 1) - } - } } } - Rectangle { - border.width: 1 - height: 2 - width: parent.width - anchors.margins: 20 - anchors.horizontalCenter: parent.horizontalCenter - border.color: "#adadad" - } - RowLayout { Layout.fillWidth: true height: 40 diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp index be00fc68b..269ad4bf7 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -45,7 +45,6 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan setWindowTitle(tr("Manage flight side logs")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setMinimumSize(600, 400); - setMaximumSize(800, 600); QQuickView *view = new QQuickView(); view->rootContext()->setContextProperty("dialog", this); @@ -56,7 +55,6 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan QWidget * container = QWidget::createWindowContainer(view); container->setMinimumSize(600, 400); - container->setMaximumSize(800, 600); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QVBoxLayout *lay = new QVBoxLayout(); lay->setContentsMargins(0,0,0,0); diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index e1a30bc0f..82c25dc73 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -75,8 +75,6 @@ FlightLogManager::~FlightLogManager() { } void addEntries(QQmlListProperty *list, DebugLogEntry *entry) { - Q_UNUSED(list); - Q_UNUSED(entry); } int countEntries(QQmlListProperty *list) { From 2ed6c021663a76fe4f2ff86991c9ebb4a9ad46a9 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 23 Nov 2013 23:36:23 +0100 Subject: [PATCH 078/116] OP-1119 Fix in pios function for debuglogging uavo. --- flight/pios/common/pios_debuglog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/flight/pios/common/pios_debuglog.c b/flight/pios/common/pios_debuglog.c index 79782e868..48967b1eb 100644 --- a/flight/pios/common/pios_debuglog.c +++ b/flight/pios/common/pios_debuglog.c @@ -113,6 +113,7 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 #else buffer->FlightTime = 0; #endif + buffer->Entry = lognum; buffer->Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; buffer->ObjectID = objid; buffer->InstanceID = instid; From 32b5ff22cf7e188f1ff1b33a8b39410fe78b6742 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 24 Nov 2013 15:27:33 +0100 Subject: [PATCH 079/116] cleanup defect in OP-Review-586 --- flight/targets/boards/osd/firmware/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/flight/targets/boards/osd/firmware/Makefile b/flight/targets/boards/osd/firmware/Makefile index 22f4f2928..90bc9618e 100644 --- a/flight/targets/boards/osd/firmware/Makefile +++ b/flight/targets/boards/osd/firmware/Makefile @@ -68,7 +68,6 @@ ifndef TESTAPP #endif ## Misc library functions - #SRC += $(FLIGHTLIB)/printf2.c SRC += $(FLIGHTLIB)/WorldMagModel.c ## UAVObjects From 89afbde58ad169624485e416aa7c3d19d8d8614c Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 24 Nov 2013 15:36:26 +0100 Subject: [PATCH 080/116] initialized log packages with 0xff instead of 0x0 to reduce flash wear --- flight/pios/common/pios_debuglog.c | 4 ++-- flight/pios/posix/pios_debuglog.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/pios/common/pios_debuglog.c b/flight/pios/common/pios_debuglog.c index 79782e868..d87b655af 100644 --- a/flight/pios/common/pios_debuglog.c +++ b/flight/pios/common/pios_debuglog.c @@ -120,7 +120,7 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 size = sizeof(buffer->Data); } buffer->Size = size; - memset(buffer->Data, 0, sizeof(buffer->Data)); + memset(buffer->Data, 0xff, sizeof(buffer->Data)); memcpy(buffer->Data, data, size); if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { @@ -142,7 +142,7 @@ void PIOS_DEBUGLOG_Printf(char *format, ...) va_list args; va_start(args, format); mutexlock(); - memset(buffer->Data, 0, sizeof(buffer->Data)); + memset(buffer->Data, 0xff, sizeof(buffer->Data)); vsnprintf((char *)buffer->Data, sizeof(buffer->Data), (char *)format, args); buffer->Flight = flightnum; #if defined(PIOS_INCLUDE_FREERTOS) diff --git a/flight/pios/posix/pios_debuglog.c b/flight/pios/posix/pios_debuglog.c index 79782e868..d87b655af 100644 --- a/flight/pios/posix/pios_debuglog.c +++ b/flight/pios/posix/pios_debuglog.c @@ -120,7 +120,7 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 size = sizeof(buffer->Data); } buffer->Size = size; - memset(buffer->Data, 0, sizeof(buffer->Data)); + memset(buffer->Data, 0xff, sizeof(buffer->Data)); memcpy(buffer->Data, data, size); if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { @@ -142,7 +142,7 @@ void PIOS_DEBUGLOG_Printf(char *format, ...) va_list args; va_start(args, format); mutexlock(); - memset(buffer->Data, 0, sizeof(buffer->Data)); + memset(buffer->Data, 0xff, sizeof(buffer->Data)); vsnprintf((char *)buffer->Data, sizeof(buffer->Data), (char *)format, args); buffer->Flight = flightnum; #if defined(PIOS_INCLUDE_FREERTOS) From 18ad56d4ed5d80be1e02b39e46d9772e2f1edd82 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 24 Nov 2013 15:40:32 +0100 Subject: [PATCH 081/116] removed identical files from pios/posix (use files from common instead) --- flight/pios/posix/pios_debuglog.c | 224 --------------- flight/pios/posix/pios_dosfs_logfs.c | 261 ------------------ .../targets/boards/simposix/firmware/Makefile | 2 + 3 files changed, 2 insertions(+), 485 deletions(-) delete mode 100644 flight/pios/posix/pios_debuglog.c delete mode 100644 flight/pios/posix/pios_dosfs_logfs.c diff --git a/flight/pios/posix/pios_debuglog.c b/flight/pios/posix/pios_debuglog.c deleted file mode 100644 index d87b655af..000000000 --- a/flight/pios/posix/pios_debuglog.c +++ /dev/null @@ -1,224 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @defgroup PIOS_DEBUGLOG Flash log debugging Functions - * @brief Debugging functionality - * @{ - * - * @file pios_debuglog.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. - * @brief Debugging Functions - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* Project Includes */ -#include "pios.h" -#include "uavobjectmanager.h" -#include "debuglogentry.h" - -// global definitions - - -// Global variables -extern uintptr_t pios_user_fs_id; // flash filesystem for logging - -#if defined(PIOS_INCLUDE_FREERTOS) -static xSemaphoreHandle mutex = 0; -#define mutexlock() xSemaphoreTakeRecursive(mutex, portMAX_DELAY) -#define mutexunlock() xSemaphoreGiveRecursive(mutex) -#else -#define mutexlock() -#define mutexunlock() -#endif - -static bool logging_enabled = false; -static uint16_t flightnum = 0; -static uint16_t lognum = 0; -static DebugLogEntryData *buffer = 0; -#if !defined(PIOS_INCLUDE_FREERTOS) -static DebugLogEntryData staticbuffer; -#endif - -/* Private Function Prototypes */ - -/** - * @brief Initialize the log facility - */ -void PIOS_DEBUGLOG_Initialize() -{ -#if defined(PIOS_INCLUDE_FREERTOS) - if (!mutex) { - mutex = xSemaphoreCreateRecursiveMutex(); - buffer = pvPortMalloc(sizeof(DebugLogEntryData)); - } -#else - buffer = &staticbuffer; -#endif - if (!buffer) { - return; - } - mutexlock(); - lognum = 0; - flightnum = 0; - while (PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { - flightnum++; - } - mutexunlock(); -} - - -/** - * @brief Enables or Disables logging globally - * @param[in] enable or disable logging - */ -void PIOS_DEBUGLOG_Enable(uint8_t enabled) -{ - logging_enabled = enabled; -} - -/** - * @brief Write a debug log entry with a uavobject - * @param[in] objectid - * @param[in] instanceid - * @param[in] instanceid - * @param[in] size of object - * @param[in] data buffer - */ -void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8_t *data) -{ - if (!logging_enabled || !buffer) { - return; - } - mutexlock(); - buffer->Flight = flightnum; -#if defined(PIOS_INCLUDE_FREERTOS) - buffer->FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; -#else - buffer->FlightTime = 0; -#endif - buffer->Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; - buffer->ObjectID = objid; - buffer->InstanceID = instid; - if (size > sizeof(buffer->Data)) { - size = sizeof(buffer->Data); - } - buffer->Size = size; - memset(buffer->Data, 0xff, sizeof(buffer->Data)); - memcpy(buffer->Data, data, size); - - if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { - lognum++; - } - mutexunlock(); -} -/** - * @brief Write a debug log entry with text - * @param[in] format - as in printf - * @param[in] variable arguments for printf - * @param... - */ -void PIOS_DEBUGLOG_Printf(char *format, ...) -{ - if (!logging_enabled || !buffer) { - return; - } - va_list args; - va_start(args, format); - mutexlock(); - memset(buffer->Data, 0xff, sizeof(buffer->Data)); - vsnprintf((char *)buffer->Data, sizeof(buffer->Data), (char *)format, args); - buffer->Flight = flightnum; -#if defined(PIOS_INCLUDE_FREERTOS) - buffer->FlightTime = xTaskGetTickCount() * portTICK_RATE_MS; -#else - buffer->FlightTime = 0; -#endif - buffer->Entry = lognum; - buffer->Type = DEBUGLOGENTRY_TYPE_TEXT; - buffer->ObjectID = 0; - buffer->InstanceID = 0; - buffer->Size = strlen((const char *)buffer->Data); - - if (PIOS_FLASHFS_ObjSave(pios_user_fs_id, flightnum * 256, lognum, (uint8_t *)buffer, sizeof(DebugLogEntryData)) == 0) { - lognum++; - } - mutexunlock(); -} - - -/** - * @brief Load one object instance from the filesystem - * @param[out] buffer where to store the uavobject - * @param[in] log entry from which flight - * @param[in] log entry sequence number - * @return 0 if success or error code - * @retval -1 if fs_id is not a valid filesystem instance - * @retval -2 if failed to start transaction - * @retval -3 if object not found in filesystem - * @retval -4 if object size in filesystem does not exactly match buffer size - * @retval -5 if reading the object data from flash fails - */ -int32_t PIOS_DEBUGLOG_Read(void *mybuffer, uint16_t flight, uint16_t inst) -{ - PIOS_Assert(mybuffer); - return PIOS_FLASHFS_ObjLoad(pios_user_fs_id, flight * 256, inst, (uint8_t *)mybuffer, sizeof(DebugLogEntryData)); -} - -/** - * @brief Retrieve run time info of logging system - * @param[out] current flight number - * @param[out] next entry number - * @param[out] free slots in filesystem - * @param[out] used slots in filesystem - */ -void PIOS_DEBUGLOG_Info(uint16_t *flight, uint16_t *entry, uint16_t *free, uint16_t *used) -{ - if (flight) { - *flight = flightnum; - } - if (entry) { - *entry = lognum; - } - struct PIOS_FLASHFS_Stats stats = { 0, 0 }; - PIOS_FLASHFS_GetStats(pios_user_fs_id, &stats); - if (free) { - *free = stats.num_free_slots; - } - if (used) { - *used = stats.num_active_slots; - } -} - -/** - * @brief Format entire flash memory!!! - */ -void PIOS_DEBUGLOG_Format(void) -{ - mutexlock(); - PIOS_FLASHFS_Format(pios_user_fs_id); - lognum = 0; - flightnum = 0; - mutexunlock(); -} - -/** - * @} - * @} - */ diff --git a/flight/pios/posix/pios_dosfs_logfs.c b/flight/pios/posix/pios_dosfs_logfs.c deleted file mode 100644 index 0b627e542..000000000 --- a/flight/pios/posix/pios_dosfs_logfs.c +++ /dev/null @@ -1,261 +0,0 @@ -/** - ****************************************************************************** - * @file pios_dosfs_logfs.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @brief Log Structured Filesystem wrapper implemented using dosfs - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "pios.h" - -#ifdef PIOS_USE_SETTINGS_ON_SDCARD - -#include - -#if defined(PIOS_INCLUDE_FREERTOS) -static xSemaphoreHandle mutex = 0; -#endif - -struct flashfs_logfs_cfg; - - -/** - * Get an 8 character (plus extension) filename for the object. - * @param[in] obj The object handle. - * @param[in] instId The instance ID - * @param[in] file Filename string pointer -- must be 14 bytes long and allocated - */ -static void objectFilename(uint32_t obj_id, uint16_t obj_inst_id, uint8_t *filename) -{ - uint32_t prefix = obj_id + (obj_inst_id / 256) * 16; // put upper 8 bit of instance id into object id modification, - // skip least sig nibble since that is used for meta object id - uint8_t suffix = obj_inst_id & 0xff; - - snprintf((char *)filename, 13, "%08X.o%02X", prefix, suffix); -} - - -/** - * @brief Initialize the flash object setting FS - * @return 0 if success, -1 if failure - */ -int32_t PIOS_FLASHFS_Logfs_Init(__attribute__((unused)) uintptr_t *fs_id, __attribute__((unused)) const struct flashfs_logfs_cfg *cfg, __attribute__((unused)) const struct pios_flash_driver *driver, __attribute__((unused)) uintptr_t flash_id) -{ -#if defined(PIOS_INCLUDE_FREERTOS) - if (!mutex) { - mutex = xSemaphoreCreateRecursiveMutex(); - } -#endif - return 0; -} - -int32_t PIOS_FLASHFS_Logfs_Destroy(__attribute__((unused)) uintptr_t fs_id) -{ - // stub, only wrapper for dosfs, does not need destroying - return 0; -} - -/********************************** - * - * Provide a PIOS_FLASHFS_* driver - * - *********************************/ -#include "pios_flashfs.h" /* API for flash filesystem */ - -/** - * @brief Saves one object instance to the filesystem - * @param[in] fs_id The filesystem to use for this action - * @param[in] obj UAVObject ID of the object to save - * @param[in] obj_inst_id The instance number of the object being saved - * @param[in] obj_data Contents of the object being saved - * @param[in] obj_size Size of the object being saved - * @return 0 if success or error code - * @retval -1 if fs_id is not a valid filesystem instance - * @retval -2 if failed to start transaction - * @retval -3 if failure to delete any previous versions of the object - * @retval -4 if filesystem is entirely full and garbage collection won't help - * @retval -5 if garbage collection failed - * @retval -6 if filesystem is full even after garbage collection should have freed space - * @retval -7 if writing the new object to the filesystem failed - */ -int32_t PIOS_FLASHFS_ObjSave(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) -{ - FILEINFO file; - uint8_t filename[14]; - - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - - // Lock - -#if defined(PIOS_INCLUDE_FREERTOS) - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); -#endif - - // Get filename - objectFilename(obj_id, obj_inst_id, filename); - - // Open file - if (PIOS_FOPEN_WRITE(filename, file)) { -#if defined(PIOS_INCLUDE_FREERTOS) - xSemaphoreGiveRecursive(mutex); -#endif - return -2; - } - // Append object - uint32_t bytes_written = 0; - PIOS_FWRITE(&file, obj_data, obj_size, &bytes_written); - - // Done, close file and unlock - PIOS_FCLOSE(file); -#if defined(PIOS_INCLUDE_FREERTOS) - xSemaphoreGiveRecursive(mutex); -#endif - - if (bytes_written != obj_size) { - return -7; - } - - return 0; -} - -/** - * @brief Load one object instance from the filesystem - * @param[in] fs_id The filesystem to use for this action - * @param[in] obj UAVObject ID of the object to load - * @param[in] obj_inst_id The instance of the object to load - * @param[in] obj_data Buffer to hold the contents of the loaded object - * @param[in] obj_size Size of the object to be loaded - * @return 0 if success or error code - * @retval -1 if fs_id is not a valid filesystem instance - * @retval -2 if failed to start transaction - * @retval -3 if object not found in filesystem - * @retval -4 if object size in filesystem does not exactly match buffer size - * @retval -5 if reading the object data from flash fails - */ -int32_t PIOS_FLASHFS_ObjLoad(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) -{ - FILEINFO file; - uint8_t filename[14]; - - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - -#if defined(PIOS_INCLUDE_FREERTOS) - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); -#endif - // Get filename - objectFilename(obj_id, obj_inst_id, filename); - - // Open file - if (PIOS_FOPEN_READ(filename, file)) { -#if defined(PIOS_INCLUDE_FREERTOS) - xSemaphoreGiveRecursive(mutex); -#endif - return -1; - } - // Load object - uint32_t bytes_read = 0; - uint32_t result = PIOS_FREAD(&file, obj_data, obj_size, &bytes_read); - - // Done, close file and unlock - PIOS_FCLOSE(file); -#if defined(PIOS_INCLUDE_FREERTOS) - xSemaphoreGiveRecursive(mutex); -#endif - if (result != 0) { - return -1; - } - return 0; -} - -/** - * @brief Delete one instance of an object from the filesystem - * @param[in] fs_id The filesystem to use for this action - * @param[in] obj UAVObject ID of the object to delete - * @param[in] obj_inst_id The instance of the object to delete - * @return 0 if success or error code - * @retval -1 if fs_id is not a valid filesystem instance - * @retval -2 if failed to start transaction - * @retval -3 if failed to delete the object from the filesystem - */ -int32_t PIOS_FLASHFS_ObjDelete(__attribute__((unused)) uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id) -{ - uint8_t filename[14]; - - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } -#if defined(PIOS_INCLUDE_FREERTOS) - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); -#endif - // Get filename - objectFilename(obj_id, obj_inst_id, filename); - - // Delete file - PIOS_FUNLINK(filename); - - // Done -#if defined(PIOS_INCLUDE_FREERTOS) - xSemaphoreGiveRecursive(mutex); -#endif - return 0; -} - -/** - * @brief Erases all filesystem arenas and activate the first arena - * @param[in] fs_id The filesystem to use for this action - * @return 0 if success or error code - * @retval -1 if fs_id is not a valid filesystem instance - * @retval -2 if failed to start transaction - * @retval -3 if failed to erase all arenas - * @retval -4 if failed to activate arena 0 - * @retval -5 if failed to mount arena 0 - */ -int32_t PIOS_FLASHFS_Format(__attribute__((unused)) uintptr_t fs_id) -{ - /* stub - not implemented */ - return -1; -} - -/** - * @brief Returs stats for the filesystems - * @param[in] fs_id The filesystem to use for this action - * @return 0 if success or error code - * @retval -1 if fs_id is not a valid filesystem instance - */ -int32_t PIOS_FLASHFS_GetStats(__attribute__((unused)) uintptr_t fs_id, __attribute__((unused)) struct PIOS_FLASHFS_Stats *stats) -{ - /* stub - not implemented */ - return 0; -} - -#endif /* PIOS_USE_SETTINGS_ON_SDCARD */ - -/** - * @} - * @} - */ diff --git a/flight/targets/boards/simposix/firmware/Makefile b/flight/targets/boards/simposix/firmware/Makefile index ed04e470f..c9d719334 100644 --- a/flight/targets/boards/simposix/firmware/Makefile +++ b/flight/targets/boards/simposix/firmware/Makefile @@ -98,6 +98,8 @@ SRC += $(MATHLIB)/sin_lookup.c SRC += $(MATHLIB)/pid.c SRC += $(PIOSCORECOMMON)/pios_task_monitor.c +SRC += $(PIOSCORECOMMON)/pios_dosfs_logfs.c +SRC += $(PIOSCORECOMMON)/pios_debuglog.c ## PIOS Hardware include $(PIOS)/posix/library.mk From 71ec5a9a64a60ac4de624a55733297a407e34239 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sun, 24 Nov 2013 17:50:07 +0100 Subject: [PATCH 082/116] OP-1119 Added helper class for synchronous uavo stuff. Added code for retrieval of flight side logs. --- .../plugins/flightlog/flightlogmanager.cpp | 60 +++++++++- .../src/plugins/flightlog/flightlogmanager.h | 8 +- .../plugins/uavobjects/uavobjecthelper.cpp | 103 ++++++++++++++++++ .../src/plugins/uavobjects/uavobjecthelper.h | 81 ++++++++++++++ .../src/plugins/uavobjects/uavobjects.pro | 6 +- 5 files changed, 254 insertions(+), 4 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp create mode 100644 ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 82c25dc73..4c3505c11 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -29,6 +29,7 @@ #include "extensionsystem/pluginmanager.h" #include "debuglogcontrol.h" +#include "uavobjecthelper.h" FlightLogManager::FlightLogManager(QObject *parent) : QObject(parent) { @@ -37,9 +38,15 @@ FlightLogManager::FlightLogManager(QObject *parent) : m_objectManager = pm->getObject(); Q_ASSERT(m_objectManager); + m_flightLogControl = DebugLogControl::GetInstance(m_objectManager); + Q_ASSERT(m_flightLogControl); + m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager); Q_ASSERT(m_flightLogStatus); + m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); + Q_ASSERT(m_flightLogEntry); + DebugLogEntry *entry = new DebugLogEntry(); entry->setFlight(1); m_logEntries.append(entry); @@ -99,8 +106,59 @@ void FlightLogManager::clearAllLogs() { m_logEntries.clear(); } -void FlightLogManager::retrieveLogs(int flight) { +void FlightLogManager::retrieveLogs(int flightToRetrieve) { + + UAVObjectUpdaterHelper updateHelper; + UAVObjectRequestHelper requestHelper; + //Get logs from flight side + m_logEntries.clear(); + + // Set up what to retrieve + bool timedOut = false; + int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve; + int endFlight = (flightToRetrieve == -1 ) ? m_flightLogStatus->getFlight() : flightToRetrieve; + + // Prepare to send request for event retrieval + m_flightLogControl->setOperation(DebugLogControl::OPERATION_RETRIEVE); + for(int flight = startFlight; flight < endFlight; flight++) { + m_flightLogControl->setFlight(flight); + bool gotLast = false; + int entry = 0; + while(!gotLast) { + + // Send request for loading flight entry on flight side and wait for ack/nack + m_flightLogControl->setEntry(entry); + + UAVObjectUpdaterHelper::Result result = updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT); + if(result == UAVObjectUpdaterHelper::SUCCESS) { + result = requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT); + if(result == UAVObjectUpdaterHelper::TIMEOUT) { + timedOut = true; + break; + } else { + if(!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY && + m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) { + + //Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list + m_logEntries.append((DebugLogEntry*) m_flightLogEntry->clone(0)); + + // Increment to get next entry from flight side + entry++; + } else { + // We are done, not more entries on this flight + break; + } + } + } else { + break; + } + } + if(timedOut) { + // We timed out, do something smart here to alert the user + break; + } + } } void FlightLogManager::exportLogs() diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index d6e7df31b..f5d1eb5bb 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -31,10 +31,12 @@ #include #include #include +#include #include "uavobjectmanager.h" #include "debuglogentry.h" #include "debuglogstatus.h" +#include "debuglogcontrol.h" class FlightLogManager : public QObject { Q_OBJECT @@ -56,14 +58,18 @@ signals: public slots: void clearAllLogs(); - void retrieveLogs(int flight = -1); + void retrieveLogs(int flightToRetrieve = -1); void exportLogs(); private: UAVObjectManager *m_objectManager; + DebugLogControl *m_flightLogControl; DebugLogStatus *m_flightLogStatus; + DebugLogEntry *m_flightLogEntry; QList m_logEntries; + const int UAVTALK_TIMEOUT = 4000; + }; #endif // FLIGHTLOGMANAGER_H diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp new file mode 100644 index 000000000..3007843ed --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp @@ -0,0 +1,103 @@ +/** + ****************************************************************************** + * + * @file uavobjecthelper.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup [Group] + * @{ + * @addtogroup UAVObjectHelper + * @{ + * @brief [Brief] + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "uavobjecthelper.h" +#include + +AbstractUAVObjectHelper::AbstractUAVObjectHelper(QObject *parent) : + QObject(parent), m_transactionResult(false), m_transactionCompleted(false) +{ +} + +AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObject *object, int timeout) +{ + // Lock, we can't call this twice from different threads + QMutexLocker locker(&m_mutex); + + m_object = object; + + // Reset variables + m_transactionResult = false; + m_transactionCompleted = false; + + // Create timer and connect it, connect object tx completed to local slot + QTimer timeoutTimer; + timeoutTimer.setSingleShot(true); + connect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit())); + connect(object, SIGNAL(transactionCompleted(UAVObject*, bool)), this, SLOT(transactionCompleted(UAVObject*, bool))); + + // Start timeout timer + timeoutTimer.start(timeout); + + // Call the actual implementation in concrete subclass + doObjectAndWaitImpl(); + + // Wait if not completed + if (!m_transactionCompleted) { + m_eventLoop.exec(); + } + timeoutTimer.stop(); + + // Disconnect + disconnect(object, SIGNAL(transactionCompleted(UAVObject*, bool)), this, SLOT(transactionCompleted(UAVObject*, bool))); + disconnect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit())); + + // Return result + if (!m_transactionCompleted) { + return TIMEOUT; + } else { + return (m_transactionResult != true) ? SUCCESS : FAIL; + } +} + +void AbstractUAVObjectHelper::transactionCompleted(UAVObject *object, bool success) +{ + Q_UNUSED(object) + + // Set variables and quit event loop + m_transactionResult = success; + m_transactionCompleted = true; + m_eventLoop.quit(); +} + +UAVObjectUpdaterHelper::UAVObjectUpdaterHelper(QObject *parent) : AbstractUAVObjectHelper(parent) +{ +} + +void UAVObjectUpdaterHelper::doObjectAndWaitImpl() +{ + m_object->updated(); +} + +UAVObjectRequestHelper::UAVObjectRequestHelper(QObject *parent) : AbstractUAVObjectHelper(parent) +{ +} + +void UAVObjectRequestHelper::doObjectAndWaitImpl() +{ + m_object->requestUpdate(); +} diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h new file mode 100644 index 000000000..97a790fca --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h @@ -0,0 +1,81 @@ +/** + ****************************************************************************** + * + * @file uavobjecthelper.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup [Group] + * @{ + * @addtogroup UAVObjectHelper + * @{ + * @brief [Brief] + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef UAVOBJECTHELPER_H +#define UAVOBJECTHELPER_H + +#include +#include +#include +#include + +#include "uavobject.h" + +class UAVOBJECTS_EXPORT AbstractUAVObjectHelper : public QObject +{ + Q_OBJECT +public: + explicit AbstractUAVObjectHelper(QObject *parent = 0); + + enum Result {SUCCESS, FAIL, TIMEOUT}; + Result doObjectAndWait(UAVObject* object, int timeout); + +protected: + virtual void doObjectAndWaitImpl() = 0; + UAVObject *m_object; + +private slots: + void transactionCompleted(UAVObject *object, bool success); + +private: + QMutex m_mutex; + QEventLoop m_eventLoop; + bool m_transactionResult; + bool m_transactionCompleted; +}; + +class UAVOBJECTS_EXPORT UAVObjectUpdaterHelper : public AbstractUAVObjectHelper +{ + Q_OBJECT +public: + explicit UAVObjectUpdaterHelper(QObject *parent = 0); + +protected: + virtual void doObjectAndWaitImpl(); +}; + +class UAVOBJECTS_EXPORT UAVObjectRequestHelper : public AbstractUAVObjectHelper +{ + Q_OBJECT +public: + explicit UAVObjectRequestHelper(QObject *parent = 0); + +protected: + virtual void doObjectAndWaitImpl(); +}; + +#endif // UAVOBJECTHELPER_H diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index 00cd3c29d..d1b002994 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -11,14 +11,16 @@ HEADERS += uavobjects_global.h \ uavdataobject.h \ uavobjectfield.h \ uavobjectsinit.h \ - uavobjectsplugin.h + uavobjectsplugin.h \ + uavobjecthelper.h SOURCES += uavobject.cpp \ uavmetaobject.cpp \ uavobjectmanager.cpp \ uavdataobject.cpp \ uavobjectfield.cpp \ - uavobjectsplugin.cpp + uavobjectsplugin.cpp \ + uavobjecthelper.cpp OTHER_FILES += UAVObjects.pluginspec From 1c83d3ee280f9f835d4bea861d46071a5d8053f8 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 24 Nov 2013 21:24:55 +0100 Subject: [PATCH 083/116] BUGFIX to OpLinkMini: oplinkmod needs to initialize the Callback Scheduler OPLMini does not use Systemmod but its own system module called oplinkmod - which did not initialize the callback scheduler. Making the event dispatcher a callback caused it to no longer run due to the missing callback scheduler initialization --- flight/modules/OPLink/oplinkmod.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flight/modules/OPLink/oplinkmod.c b/flight/modules/OPLink/oplinkmod.c index a1a4a3442..994e0d5d9 100644 --- a/flight/modules/OPLink/oplinkmod.c +++ b/flight/modules/OPLink/oplinkmod.c @@ -118,6 +118,9 @@ static void systemTask(__attribute__((unused)) void *parameters) /* create all modules thread */ MODULE_TASKCREATE_ALL; + /* start the delayed callback scheduler */ + CallbackSchedulerStart(); + if (mallocFailed) { /* We failed to malloc during task creation, * system behaviour is undefined. Reset and let From d41f99aca863a27e54f66aca508c6881e4b16e1e Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sun, 24 Nov 2013 21:47:57 +0100 Subject: [PATCH 084/116] OP-1119 Bug fixin --- ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp | 2 +- ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 4c3505c11..40df5ffdd 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -121,7 +121,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { // Prepare to send request for event retrieval m_flightLogControl->setOperation(DebugLogControl::OPERATION_RETRIEVE); - for(int flight = startFlight; flight < endFlight; flight++) { + for(int flight = startFlight; flight <= endFlight; flight++) { m_flightLogControl->setFlight(flight); bool gotLast = false; int entry = 0; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp index 3007843ed..8c3de3b64 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp @@ -70,7 +70,7 @@ AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObje if (!m_transactionCompleted) { return TIMEOUT; } else { - return (m_transactionResult != true) ? SUCCESS : FAIL; + return m_transactionResult ? SUCCESS : FAIL; } } From 0a085ce106437f8b61028a389eb289b63163d017 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 25 Nov 2013 14:58:08 +0100 Subject: [PATCH 085/116] OP-1119 Added logging event for disabling logging. --- flight/modules/Logging/Logging.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/flight/modules/Logging/Logging.c b/flight/modules/Logging/Logging.c index 3abb76477..48fe4b5f6 100644 --- a/flight/modules/Logging/Logging.c +++ b/flight/modules/Logging/Logging.c @@ -88,8 +88,13 @@ static void StatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { DebugLogSettingsGet(&settings); - PIOS_DEBUGLOG_Enable(settings.LoggingEnabled); - PIOS_DEBUGLOG_Printf("Logging enabled"); + if (settings.LoggingEnabled) { + PIOS_DEBUGLOG_Enable(settings.LoggingEnabled); + PIOS_DEBUGLOG_Printf("Logging enabled"); + } else { + PIOS_DEBUGLOG_Printf("Logging disabled"); + PIOS_DEBUGLOG_Enable(settings.LoggingEnabled); + } } static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) From 00d710a324efd0487b8ac2465449c77ef5124d87 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 25 Nov 2013 14:59:23 +0100 Subject: [PATCH 086/116] OP-1119 Downloading from firmware now works. Added columns for log data and some table formatting quirks. --- .../src/plugins/flightlog/FlightLogDialog.qml | 41 +++++++++++-- .../src/plugins/flightlog/flightlogdialog.cpp | 4 +- .../plugins/flightlog/flightlogmanager.cpp | 59 +++++++------------ .../src/plugins/flightlog/flightlogmanager.h | 30 ++++++++-- .../generators/gcs/uavobjectgeneratorgcs.cpp | 1 + 5 files changed, 84 insertions(+), 51 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 0167f8459..94dc4e884 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -30,10 +30,43 @@ Rectangle { Layout.fillWidth: true Layout.fillHeight: true model: logManager.logEntries - TableViewColumn { role: "Flight"; title: "Flight"; width: 50; horizontalAlignment: Text.AlignRight} - TableViewColumn { role: "FlightTime"; title: "Time";width: 50; horizontalAlignment: Text.AlignRight} - TableViewColumn { role: "Entry"; title: "#"; width: 50; horizontalAlignment: Text.AlignRight} - TableViewColumn { role: "Type"; title: "Contents"; width: 100} + + itemDelegate: Text { + anchors.margins: 3 + font.pixelSize: 12 + text: styleData.value + } + + TableViewColumn { + role: "Flight"; title: qsTr("Flight"); width: 50; + delegate: + Text { + anchors.margins: 3 + font.pixelSize: 12 + text: styleData.value + 1 + } + + } + TableViewColumn { role: "FlightTime"; title: qsTr("Time"); width: 50} + TableViewColumn { role: "Entry"; title: qsTr("#"); width: 50} + TableViewColumn { + role: "Type"; title: "Type"; width: 100; + delegate: + Text { + anchors.margins: 3 + font.pixelSize: 12 + text: { + switch(styleData.value) { + case 0 : text: qsTr("Empty"); break; + case 1 : text: qsTr("Text"); break; + case 2 : text: qsTr("UAVO"); break; + default: text: qsTr("Unknown"); break; + } + } + } + + } + TableViewColumn { role: "LogString"; title: qsTr("Data"); width: 280} } RowLayout { diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp index 269ad4bf7..145b3b13a 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -34,12 +34,12 @@ #include #include -#include "debuglogentry.h" +#include "flightlogmanager.h" FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) : QDialog(parent) { - qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry"); + qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry"); 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 40df5ffdd..b7909414d 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -46,58 +46,31 @@ FlightLogManager::FlightLogManager(QObject *parent) : m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); Q_ASSERT(m_flightLogEntry); - - DebugLogEntry *entry = new DebugLogEntry(); - entry->setFlight(1); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(2); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(3); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(4); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(5); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(6); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(7); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(8); - m_logEntries.append(entry); - entry = new DebugLogEntry(); - entry->setFlight(9); - m_logEntries.append(entry); - } FlightLogManager::~FlightLogManager() { } -void addEntries(QQmlListProperty *list, DebugLogEntry *entry) { +void addEntries(QQmlListProperty *list, ExtendedDebugLogEntry *entry) { + Q_UNUSED(list); + Q_UNUSED(entry); } -int countEntries(QQmlListProperty *list) { - return static_cast< QList *>(list->data)->size(); +int countEntries(QQmlListProperty *list) { + return static_cast< QList *>(list->data)->size(); } -DebugLogEntry* entryAt(QQmlListProperty *list, int index) { - return static_cast< QList *>(list->data)->at(index); +ExtendedDebugLogEntry* entryAt(QQmlListProperty *list, int index) { + return static_cast< QList *>(list->data)->at(index); } -void clearEntries(QQmlListProperty *list) { - return static_cast< QList *>(list->data)->clear(); +void clearEntries(QQmlListProperty *list) { + return static_cast< QList *>(list->data)->clear(); } -QQmlListProperty FlightLogManager::logEntries() { - return QQmlListProperty(this, &m_logEntries, &addEntries, &countEntries, &entryAt, &clearEntries); +QQmlListProperty FlightLogManager::logEntries() { + return QQmlListProperty(this, &m_logEntries, &addEntries, &countEntries, &entryAt, &clearEntries); } void FlightLogManager::clearAllLogs() { @@ -141,7 +114,10 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) { //Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list - m_logEntries.append((DebugLogEntry*) m_flightLogEntry->clone(0)); + + ExtendedDebugLogEntry* logEntry = new ExtendedDebugLogEntry(); + logEntry->setData(m_flightLogEntry->getData()); + m_logEntries.append(logEntry); // Increment to get next entry from flight side entry++; @@ -159,9 +135,14 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { break; } } + emit logEntriesChanged(); } void FlightLogManager::exportLogs() { } + +ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry() +{ +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index f5d1eb5bb..571d22935 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -38,23 +38,41 @@ #include "debuglogstatus.h" #include "debuglogcontrol.h" -class FlightLogManager : public QObject { +class ExtendedDebugLogEntry : public DebugLogEntry { Q_OBJECT + Q_PROPERTY(QString LogString READ LogString) + +public: + explicit ExtendedDebugLogEntry(); + + QString LogString() + { + if(getType() == DebugLogEntry::TYPE_TEXT) { + return QString((const char*)getData().Data); + } else { + return "Object"; + } + } +}; + +class FlightLogManager : public QObject { + Q_OBJECT Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) - Q_PROPERTY(QQmlListProperty logEntries READ logEntries CONSTANT) + Q_PROPERTY(QQmlListProperty logEntries READ logEntries NOTIFY logEntriesChanged) public: explicit FlightLogManager(QObject *parent = 0); ~FlightLogManager(); - QQmlListProperty logEntries(); + QQmlListProperty logEntries(); DebugLogStatus* flightLogStatus() const { return m_flightLogStatus; } -signals: +signals: + void logEntriesChanged(); public slots: void clearAllLogs(); @@ -66,9 +84,9 @@ private: DebugLogControl *m_flightLogControl; DebugLogStatus *m_flightLogStatus; DebugLogEntry *m_flightLogEntry; - QList m_logEntries; + QList m_logEntries; - const int UAVTALK_TIMEOUT = 4000; + static const int UAVTALK_TIMEOUT = 4000; }; diff --git a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp index 7579ce086..576c30576 100644 --- a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp +++ b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp @@ -244,6 +244,7 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info) // Setup element names QString varElemName = info->fields[n]->name + "ElemNames"; finit.append(QString(" QStringList %1;\n").arg(varElemName)); + QStringList elemNames = info->fields[n]->elementNames; for (int m = 0; m < elemNames.length(); ++m) { finit.append(QString(" %1.append(\"%2\");\n") From daf589d9cebd7f651665dc4dd674b0910c80cb26 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 25 Nov 2013 17:58:29 +0100 Subject: [PATCH 087/116] OP-1119 Added Functions.js to host functions needed in qml. Added de-serialization of UAVDataObjects in table. Started to clean up memory management tasks in code. --- .../src/plugins/flightlog/FlightLogDialog.qml | 29 ++++++++++++---- .../src/plugins/flightlog/flightLog.qrc | 1 + .../src/plugins/flightlog/flightlog.pro | 3 +- .../plugins/flightlog/flightlogmanager.cpp | 33 +++++++++++++++++-- .../src/plugins/flightlog/flightlogmanager.h | 24 +++++++++----- .../src/plugins/flightlog/functions.js | 20 +++++++++++ 6 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/flightlog/functions.js diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 94dc4e884..4b36b2bc8 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -4,6 +4,8 @@ import QtQuick.Layouts 1.0 import org.openpilot 1.0 +import "functions.js" as Functions + Rectangle { width: 600 height: 400 @@ -32,7 +34,9 @@ Rectangle { model: logManager.logEntries itemDelegate: Text { - anchors.margins: 3 + anchors.fill: parent + anchors.margins: 2 + anchors.leftMargin: 5 font.pixelSize: 12 text: styleData.value } @@ -41,19 +45,32 @@ Rectangle { role: "Flight"; title: qsTr("Flight"); width: 50; delegate: Text { - anchors.margins: 3 + anchors.fill: parent + anchors.margins: 2 + anchors.leftMargin: 5 font.pixelSize: 12 text: styleData.value + 1 } } - TableViewColumn { role: "FlightTime"; title: qsTr("Time"); width: 50} - TableViewColumn { role: "Entry"; title: qsTr("#"); width: 50} TableViewColumn { - role: "Type"; title: "Type"; width: 100; + role: "FlightTime"; title: qsTr("Time"); width: 80; delegate: Text { - anchors.margins: 3 + anchors.fill: parent + anchors.margins: 2 + anchors.leftMargin: 5 + font.pixelSize: 12 + text: Functions.millisToTime(styleData.value) + } + } + TableViewColumn { + role: "Type"; title: "Type"; width: 50; + delegate: + Text { + anchors.fill: parent + anchors.margins: 2 + anchors.leftMargin: 5 font.pixelSize: 12 text: { switch(styleData.value) { diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc b/ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc index c58558e22..4283127f5 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc +++ b/ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc @@ -1,5 +1,6 @@ FlightLogDialog.qml + functions.js diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro index 71adb9647..1aa79b004 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro @@ -15,7 +15,8 @@ SOURCES += flightlogplugin.cpp \ flightlogdialog.cpp OTHER_FILES += Flightlog.pluginspec \ - FlightLogDialog.qml + FlightLogDialog.qml \ + functions.js FORMS += diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index b7909414d..2060ad4cc 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -116,6 +116,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { //Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list ExtendedDebugLogEntry* logEntry = new ExtendedDebugLogEntry(); + logEntry->setObjectManager(m_objectManager); logEntry->setData(m_flightLogEntry->getData()); m_logEntries.append(logEntry); @@ -140,9 +141,37 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { void FlightLogManager::exportLogs() { - } -ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry() +ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(), + m_objectManager(0), m_object(0) { } + +ExtendedDebugLogEntry::~ExtendedDebugLogEntry() +{ + if(m_object) { + delete m_object; + m_object = 0; + } +} + +QString ExtendedDebugLogEntry::getLogString() +{ + if(getType() == DebugLogEntry::TYPE_TEXT) { + return QString((const char*)getData().Data); + } else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) { + UAVDataObject *object = (UAVDataObject*)m_objectManager->getObject(getObjectID(), getInstanceID()); + object = object->clone(getInstanceID()); + object->unpack(getData().Data); + m_object = object; + return object->toString().replace("\n", " ").replace("\t", " "); + } else { + return ""; + } +} + +void ExtendedDebugLogEntry::setObjectManager(UAVObjectManager *objectManager) +{ + m_objectManager = objectManager; +} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 571d22935..d77e9ac1f 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -40,19 +40,25 @@ class ExtendedDebugLogEntry : public DebugLogEntry { Q_OBJECT - Q_PROPERTY(QString LogString READ LogString) + Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated) public: explicit ExtendedDebugLogEntry(); + ~ExtendedDebugLogEntry(); - QString LogString() - { - if(getType() == DebugLogEntry::TYPE_TEXT) { - return QString((const char*)getData().Data); - } else { - return "Object"; - } - } + QString getLogString(); + UAVDataObject* uavObject() { return m_object; } + void setObjectManager(UAVObjectManager *objectManager); + +public slots: + void setLogString(QString arg){ Q_UNUSED(arg); } + +signals: + void LogStringUpdated(QString arg); + +private: + UAVObjectManager *m_objectManager; + UAVDataObject *m_object; }; class FlightLogManager : public QObject { diff --git a/ground/openpilotgcs/src/plugins/flightlog/functions.js b/ground/openpilotgcs/src/plugins/flightlog/functions.js new file mode 100644 index 000000000..47884432b --- /dev/null +++ b/ground/openpilotgcs/src/plugins/flightlog/functions.js @@ -0,0 +1,20 @@ +.pragma library + +function millisToTime(ms) { + var secs = Math.floor(ms / 1000); + var msleft = ms % 1000; + var hours = Math.floor(secs / (60 * 60)); + var divisor_for_minutes = secs % (60 * 60); + var minutes = Math.floor(divisor_for_minutes / 60); + var divisor_for_seconds = divisor_for_minutes % 60; + var seconds = Math.ceil(divisor_for_seconds); + return pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + ":" + pad(msleft, 3); +} + +function pad(number, length) { + var str = '' + number; + while (str.length < length) { + str = '0' + str; + } + return str; +} From 2fc34910e0ad599f9492e965d4c82501266ff1f9 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 23 Nov 2013 23:36:23 +0100 Subject: [PATCH 088/116] OP-1119 Fix in pios function for debuglogging uavo. --- flight/pios/common/pios_debuglog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/flight/pios/common/pios_debuglog.c b/flight/pios/common/pios_debuglog.c index d87b655af..1c7a4e191 100644 --- a/flight/pios/common/pios_debuglog.c +++ b/flight/pios/common/pios_debuglog.c @@ -113,6 +113,7 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 #else buffer->FlightTime = 0; #endif + buffer->Entry = lognum; buffer->Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; buffer->ObjectID = objid; buffer->InstanceID = instid; From 25fd3d5740f2e564133599c93a469db3391f4778 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Tue, 26 Nov 2013 00:43:02 +0100 Subject: [PATCH 089/116] Just uncrustification --- flight/pios/common/pios_debuglog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flight/pios/common/pios_debuglog.c b/flight/pios/common/pios_debuglog.c index 1c7a4e191..167e33329 100644 --- a/flight/pios/common/pios_debuglog.c +++ b/flight/pios/common/pios_debuglog.c @@ -113,8 +113,8 @@ void PIOS_DEBUGLOG_UAVObject(uint32_t objid, uint16_t instid, size_t size, uint8 #else buffer->FlightTime = 0; #endif - buffer->Entry = lognum; - buffer->Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; + buffer->Entry = lognum; + buffer->Type = DEBUGLOGENTRY_TYPE_UAVOBJECT; buffer->ObjectID = objid; buffer->InstanceID = instid; if (size > sizeof(buffer->Data)) { From 3f3245b749e495ba136d13e9c7bea1f54dacdf69 Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 26 Nov 2013 15:25:27 +0100 Subject: [PATCH 090/116] OP-1119 Added some mem management improvements --- .../src/plugins/flightlog/flightlogmanager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 2060ad4cc..5ef1f14d1 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -49,7 +49,9 @@ FlightLogManager::FlightLogManager(QObject *parent) : } FlightLogManager::~FlightLogManager() { - + while (!m_logEntries.isEmpty()) { + delete m_logEntries.takeFirst(); + } } void addEntries(QQmlListProperty *list, ExtendedDebugLogEntry *entry) { @@ -76,7 +78,11 @@ QQmlListProperty FlightLogManager::logEntries() { void FlightLogManager::clearAllLogs() { //Clear on flight side - m_logEntries.clear(); + + //Then delete locally + while (!m_logEntries.isEmpty()) { + delete m_logEntries.takeFirst(); + } } void FlightLogManager::retrieveLogs(int flightToRetrieve) { @@ -85,7 +91,10 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { UAVObjectRequestHelper requestHelper; //Get logs from flight side - m_logEntries.clear(); + while (!m_logEntries.isEmpty()) { + delete m_logEntries.takeFirst(); + } + emit logEntriesChanged(); // Set up what to retrieve bool timedOut = false; @@ -114,7 +123,6 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) { //Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list - ExtendedDebugLogEntry* logEntry = new ExtendedDebugLogEntry(); logEntry->setObjectManager(m_objectManager); logEntry->setData(m_flightLogEntry->getData()); From a11d98aa0d01afb87f3483df81e592065824a37a Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 26 Nov 2013 15:42:49 +0100 Subject: [PATCH 091/116] OP-1119 Uncrustify --- .../src/plugins/flightlog/flightlogdialog.cpp | 9 +- .../src/plugins/flightlog/flightlogdialog.h | 5 +- .../plugins/flightlog/flightlogmanager.cpp | 87 ++++++++++--------- .../src/plugins/flightlog/flightlogmanager.h | 21 +++-- .../src/plugins/flightlog/flightlogplugin.cpp | 14 ++- .../src/plugins/flightlog/flightlogplugin.h | 2 +- 6 files changed, 70 insertions(+), 68 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp index 145b3b13a..65f04f575 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp @@ -53,15 +53,14 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan view->setResizeMode(QQuickView::SizeRootObjectToView); view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml")); - QWidget * container = QWidget::createWindowContainer(view); + QWidget *container = QWidget::createWindowContainer(view); container->setMinimumSize(600, 400); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - QVBoxLayout *lay = new QVBoxLayout(); - lay->setContentsMargins(0,0,0,0); + QVBoxLayout *lay = new QVBoxLayout(); + lay->setContentsMargins(0, 0, 0, 0); setLayout(lay); layout()->addWidget(container); } FlightLogDialog::~FlightLogDialog() -{ -} +{} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h index 64cfbdd3b..d1b2fd18e 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h @@ -2,10 +2,9 @@ #define FLIGHTLOGDIALOG_H #include -#include"flightlogmanager.h" +#include "flightlogmanager.h" -class FlightLogDialog : public QDialog -{ +class FlightLogDialog : public QDialog { Q_OBJECT public: diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 5ef1f14d1..37be5e682 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -32,101 +32,106 @@ #include "uavobjecthelper.h" FlightLogManager::FlightLogManager(QObject *parent) : - QObject(parent) { - + QObject(parent) +{ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - m_objectManager = pm->getObject(); + + m_objectManager = pm->getObject(); Q_ASSERT(m_objectManager); m_flightLogControl = DebugLogControl::GetInstance(m_objectManager); Q_ASSERT(m_flightLogControl); - m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager); + m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager); Q_ASSERT(m_flightLogStatus); - m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); + m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); Q_ASSERT(m_flightLogEntry); } -FlightLogManager::~FlightLogManager() { +FlightLogManager::~FlightLogManager() +{ while (!m_logEntries.isEmpty()) { delete m_logEntries.takeFirst(); } } -void addEntries(QQmlListProperty *list, ExtendedDebugLogEntry *entry) { +void addEntries(QQmlListProperty *list, ExtendedDebugLogEntry *entry) +{ Q_UNUSED(list); Q_UNUSED(entry); } -int countEntries(QQmlListProperty *list) { +int countEntries(QQmlListProperty *list) +{ return static_cast< QList *>(list->data)->size(); } -ExtendedDebugLogEntry* entryAt(QQmlListProperty *list, int index) { +ExtendedDebugLogEntry *entryAt(QQmlListProperty *list, int index) +{ return static_cast< QList *>(list->data)->at(index); } -void clearEntries(QQmlListProperty *list) { +void clearEntries(QQmlListProperty *list) +{ return static_cast< QList *>(list->data)->clear(); } -QQmlListProperty FlightLogManager::logEntries() { +QQmlListProperty FlightLogManager::logEntries() +{ return QQmlListProperty(this, &m_logEntries, &addEntries, &countEntries, &entryAt, &clearEntries); } -void FlightLogManager::clearAllLogs() { +void FlightLogManager::clearAllLogs() +{ + // Clear on flight side - //Clear on flight side - - //Then delete locally + // Then delete locally while (!m_logEntries.isEmpty()) { delete m_logEntries.takeFirst(); } } -void FlightLogManager::retrieveLogs(int flightToRetrieve) { - +void FlightLogManager::retrieveLogs(int flightToRetrieve) +{ UAVObjectUpdaterHelper updateHelper; UAVObjectRequestHelper requestHelper; - //Get logs from flight side + // Get logs from flight side while (!m_logEntries.isEmpty()) { delete m_logEntries.takeFirst(); } emit logEntriesChanged(); // Set up what to retrieve - bool timedOut = false; + bool timedOut = false; int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve; - int endFlight = (flightToRetrieve == -1 ) ? m_flightLogStatus->getFlight() : flightToRetrieve; + int endFlight = (flightToRetrieve == -1) ? m_flightLogStatus->getFlight() : flightToRetrieve; // Prepare to send request for event retrieval m_flightLogControl->setOperation(DebugLogControl::OPERATION_RETRIEVE); - for(int flight = startFlight; flight <= endFlight; flight++) { + for (int flight = startFlight; flight <= endFlight; flight++) { m_flightLogControl->setFlight(flight); bool gotLast = false; - int entry = 0; - while(!gotLast) { - + int entry = 0; + while (!gotLast) { // Send request for loading flight entry on flight side and wait for ack/nack m_flightLogControl->setEntry(entry); UAVObjectUpdaterHelper::Result result = updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT); - if(result == UAVObjectUpdaterHelper::SUCCESS) { + if (result == UAVObjectUpdaterHelper::SUCCESS) { result = requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT); - if(result == UAVObjectUpdaterHelper::TIMEOUT) { + if (result == UAVObjectUpdaterHelper::TIMEOUT) { timedOut = true; break; } else { - if(!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY && - m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) { - - //Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list - ExtendedDebugLogEntry* logEntry = new ExtendedDebugLogEntry(); + if (!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY && + m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) { + // Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list + ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry(); logEntry->setObjectManager(m_objectManager); logEntry->setData(m_flightLogEntry->getData()); - m_logEntries.append(logEntry); + m_logEntries << logEntry; // Increment to get next entry from flight side entry++; @@ -139,7 +144,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { break; } } - if(timedOut) { + if (timedOut) { // We timed out, do something smart here to alert the user break; } @@ -148,17 +153,15 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { } void FlightLogManager::exportLogs() -{ -} +{} ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(), m_objectManager(0), m_object(0) -{ -} +{} ExtendedDebugLogEntry::~ExtendedDebugLogEntry() { - if(m_object) { + if (m_object) { delete m_object; m_object = 0; } @@ -166,11 +169,11 @@ ExtendedDebugLogEntry::~ExtendedDebugLogEntry() QString ExtendedDebugLogEntry::getLogString() { - if(getType() == DebugLogEntry::TYPE_TEXT) { - return QString((const char*)getData().Data); + if (getType() == DebugLogEntry::TYPE_TEXT) { + return QString((const char *)getData().Data); } else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) { - UAVDataObject *object = (UAVDataObject*)m_objectManager->getObject(getObjectID(), getInstanceID()); - object = object->clone(getInstanceID()); + UAVDataObject *object = (UAVDataObject *)m_objectManager->getObject(getObjectID(), getInstanceID()); + object = object->clone(getInstanceID()); object->unpack(getData().Data); m_object = object; return object->toString().replace("\n", " ").replace("\t", " "); diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index d77e9ac1f..498d87e56 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -39,19 +39,24 @@ #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(); ~ExtendedDebugLogEntry(); QString getLogString(); - UAVDataObject* uavObject() { return m_object; } + UAVDataObject *uavObject() + { + return m_object; + } void setObjectManager(UAVObjectManager *objectManager); public slots: - void setLogString(QString arg){ Q_UNUSED(arg); } + void setLogString(QString arg) + { + Q_UNUSED(arg); + } signals: void LogStringUpdated(QString arg); @@ -62,8 +67,7 @@ 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) public: @@ -72,12 +76,12 @@ public: QQmlListProperty logEntries(); - DebugLogStatus* flightLogStatus() const + DebugLogStatus *flightLogStatus() const { return m_flightLogStatus; } -signals: +signals: void logEntriesChanged(); public slots: @@ -93,7 +97,6 @@ private: QList m_logEntries; static const int UAVTALK_TIMEOUT = 4000; - }; #endif // FLIGHTLOGMANAGER_H diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp index 47d6da6f7..5b8e9def6 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.cpp @@ -36,8 +36,7 @@ #include "flightlogdialog.h" FlightLogPlugin::FlightLogPlugin() : m_logDialog(0) -{ -} +{} FlightLogPlugin::~FlightLogPlugin() { @@ -48,7 +47,7 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); - + // Add Menu entry Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_TOOLS); @@ -72,7 +71,7 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg) void FlightLogPlugin::ShowLogManagementDialog() { - if(!m_logDialog) { + if (!m_logDialog) { m_logDialog = new FlightLogDialog(0, new FlightLogManager()); connect(m_logDialog, SIGNAL(finished(int)), this, SLOT(LogManagementDialogClosed())); m_logDialog->show(); @@ -81,19 +80,18 @@ void FlightLogPlugin::ShowLogManagementDialog() void FlightLogPlugin::LogManagementDialogClosed() { - if(m_logDialog) { + if (m_logDialog) { m_logDialog->deleteLater(); m_logDialog = 0; } } void FlightLogPlugin::extensionsInitialized() -{ -} +{} void FlightLogPlugin::shutdown() { - if(m_logDialog) { + if (m_logDialog) { m_logDialog->close(); LogManagementDialogClosed(); } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h index 6252e126d..81194272c 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h @@ -47,7 +47,7 @@ private slots: void LogManagementDialogClosed(); private: - FlightLogDialog* m_logDialog; + FlightLogDialog *m_logDialog; }; #endif /* FLIGHTLOGPLUGIN_H_ */ From 8054cd5296b49f678e2330836bd4f8910051b890 Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 26 Nov 2013 16:06:12 +0100 Subject: [PATCH 092/116] OP-1119 Code cleanup and more uncrustification --- .../plugins/flightlog/flightlogmanager.cpp | 44 ++++++++----------- .../plugins/uavobjects/uavobjecthelper.cpp | 17 +++---- .../src/plugins/uavobjects/uavobjecthelper.h | 13 +++--- 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 37be5e682..2ba232a34 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -28,6 +28,8 @@ #include "flightlogmanager.h" #include "extensionsystem/pluginmanager.h" +#include + #include "debuglogcontrol.h" #include "uavobjecthelper.h" @@ -94,6 +96,8 @@ void FlightLogManager::clearAllLogs() void FlightLogManager::retrieveLogs(int flightToRetrieve) { + QApplication::setOverrideCursor(Qt::WaitCursor); + UAVObjectUpdaterHelper updateHelper; UAVObjectRequestHelper requestHelper; @@ -104,7 +108,6 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) emit logEntriesChanged(); // Set up what to retrieve - bool timedOut = false; int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve; int endFlight = (flightToRetrieve == -1) ? m_flightLogStatus->getFlight() : flightToRetrieve; @@ -118,38 +121,29 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) // Send request for loading flight entry on flight side and wait for ack/nack m_flightLogControl->setEntry(entry); - UAVObjectUpdaterHelper::Result result = updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT); - if (result == UAVObjectUpdaterHelper::SUCCESS) { - result = requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT); - if (result == UAVObjectUpdaterHelper::TIMEOUT) { - timedOut = true; - break; - } else { - if (!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY && - m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) { - // Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list - ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry(); - logEntry->setObjectManager(m_objectManager); - logEntry->setData(m_flightLogEntry->getData()); - m_logEntries << logEntry; + if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS && + requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) { + if (m_flightLogEntry->getType() != DebugLogEntry::TYPE_EMPTY) { + // Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list + ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry(); + logEntry->setObjectManager(m_objectManager); + logEntry->setData(m_flightLogEntry->getData()); + m_logEntries << logEntry; - // Increment to get next entry from flight side - entry++; - } else { - // We are done, not more entries on this flight - break; - } + // Increment to get next entry from flight side + entry++; + } else { + // We are done, not more entries on this flight + gotLast = true; } } else { + // We failed for some reason break; } } - if (timedOut) { - // We timed out, do something smart here to alert the user - break; - } } emit logEntriesChanged(); + QApplication::restoreOverrideCursor(); } void FlightLogManager::exportLogs() diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp index 8c3de3b64..25ff5f805 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.cpp @@ -30,8 +30,7 @@ AbstractUAVObjectHelper::AbstractUAVObjectHelper(QObject *parent) : QObject(parent), m_transactionResult(false), m_transactionCompleted(false) -{ -} +{} AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObject *object, int timeout) { @@ -41,14 +40,14 @@ AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObje m_object = object; // Reset variables - m_transactionResult = false; + m_transactionResult = false; m_transactionCompleted = false; // Create timer and connect it, connect object tx completed to local slot QTimer timeoutTimer; timeoutTimer.setSingleShot(true); connect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit())); - connect(object, SIGNAL(transactionCompleted(UAVObject*, bool)), this, SLOT(transactionCompleted(UAVObject*, bool))); + connect(object, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(transactionCompleted(UAVObject *, bool))); // Start timeout timer timeoutTimer.start(timeout); @@ -63,7 +62,7 @@ AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObje timeoutTimer.stop(); // Disconnect - disconnect(object, SIGNAL(transactionCompleted(UAVObject*, bool)), this, SLOT(transactionCompleted(UAVObject*, bool))); + disconnect(object, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(transactionCompleted(UAVObject *, bool))); disconnect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit())); // Return result @@ -79,14 +78,13 @@ void AbstractUAVObjectHelper::transactionCompleted(UAVObject *object, bool succe Q_UNUSED(object) // Set variables and quit event loop - m_transactionResult = success; + m_transactionResult = success; m_transactionCompleted = true; m_eventLoop.quit(); } UAVObjectUpdaterHelper::UAVObjectUpdaterHelper(QObject *parent) : AbstractUAVObjectHelper(parent) -{ -} +{} void UAVObjectUpdaterHelper::doObjectAndWaitImpl() { @@ -94,8 +92,7 @@ void UAVObjectUpdaterHelper::doObjectAndWaitImpl() } UAVObjectRequestHelper::UAVObjectRequestHelper(QObject *parent) : AbstractUAVObjectHelper(parent) -{ -} +{} void UAVObjectRequestHelper::doObjectAndWaitImpl() { diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h index 97a790fca..bf2739e09 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecthelper.h @@ -35,14 +35,13 @@ #include "uavobject.h" -class UAVOBJECTS_EXPORT AbstractUAVObjectHelper : public QObject -{ +class UAVOBJECTS_EXPORT AbstractUAVObjectHelper : public QObject { Q_OBJECT public: explicit AbstractUAVObjectHelper(QObject *parent = 0); - enum Result {SUCCESS, FAIL, TIMEOUT}; - Result doObjectAndWait(UAVObject* object, int timeout); + enum Result { SUCCESS, FAIL, TIMEOUT }; + Result doObjectAndWait(UAVObject *object, int timeout); protected: virtual void doObjectAndWaitImpl() = 0; @@ -58,8 +57,7 @@ private: bool m_transactionCompleted; }; -class UAVOBJECTS_EXPORT UAVObjectUpdaterHelper : public AbstractUAVObjectHelper -{ +class UAVOBJECTS_EXPORT UAVObjectUpdaterHelper : public AbstractUAVObjectHelper { Q_OBJECT public: explicit UAVObjectUpdaterHelper(QObject *parent = 0); @@ -68,8 +66,7 @@ protected: virtual void doObjectAndWaitImpl(); }; -class UAVOBJECTS_EXPORT UAVObjectRequestHelper : public AbstractUAVObjectHelper -{ +class UAVOBJECTS_EXPORT UAVObjectRequestHelper : public AbstractUAVObjectHelper { Q_OBJECT public: explicit UAVObjectRequestHelper(QObject *parent = 0); From 5738a871416d889d4fa5d570e5845ed414b87c6e Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 26 Nov 2013 16:22:44 +0100 Subject: [PATCH 093/116] OP-1119 Added code to format log flash on flight controller --- .../src/plugins/flightlog/flightlogmanager.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 2ba232a34..3262f5737 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -87,10 +87,17 @@ QQmlListProperty FlightLogManager::logEntries() void FlightLogManager::clearAllLogs() { // Clear on flight side + UAVObjectUpdaterHelper updateHelper; - // Then delete locally - while (!m_logEntries.isEmpty()) { - delete m_logEntries.takeFirst(); + m_flightLogControl->setFlight(0); + m_flightLogControl->setEntry(0); + m_flightLogControl->setOperation(DebugLogControl::OPERATION_FORMATFLASH); + if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) { + // Then delete locally + while (!m_logEntries.isEmpty()) { + delete m_logEntries.takeFirst(); + } + emit logEntriesChanged(); } } From 7bb127445d17b8c2a6e7192c34d186d15a7b68b6 Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 26 Nov 2013 17:00:01 +0100 Subject: [PATCH 094/116] OP-1119 Added some progress indication with cursors and disabling of controls during operation. --- .../src/plugins/flightlog/FlightLogDialog.qml | 4 ++++ .../src/plugins/flightlog/flightlogmanager.cpp | 10 +++++++++- .../src/plugins/flightlog/flightlogmanager.h | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 4b36b2bc8..5b38a2113 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -119,6 +119,7 @@ Rectangle { ComboBox { id: flightCombo + enabled: !logManager.disableControls property ListModel dataModel: ListModel {} model: dataModel Component.onCompleted: { @@ -137,6 +138,7 @@ Rectangle { } Button { text: qsTr("Download logs") + enabled: !logManager.disableControls activeFocusOnPress: true onClicked: logManager.retrieveLogs(flightCombo.currentIndex - 1) } @@ -151,6 +153,7 @@ Rectangle { height: 40 Button { id: exportButton + enabled: !logManager.disableControls text: qsTr("Export...") activeFocusOnPress: true onClicked: logManager.exportLogs() @@ -160,6 +163,7 @@ Rectangle { } Button { id: okButton + enabled: !logManager.disableControls text: qsTr("OK") activeFocusOnPress: true onClicked: dialog.close() diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 3262f5737..ec12b324b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -34,7 +34,7 @@ #include "uavobjecthelper.h" FlightLogManager::FlightLogManager(QObject *parent) : - QObject(parent) + QObject(parent), m_disableControls(false) { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -86,6 +86,9 @@ QQmlListProperty FlightLogManager::logEntries() void FlightLogManager::clearAllLogs() { + setDisableControls(true); + QApplication::setOverrideCursor(Qt::WaitCursor); + // Clear on flight side UAVObjectUpdaterHelper updateHelper; @@ -99,10 +102,14 @@ void FlightLogManager::clearAllLogs() } emit logEntriesChanged(); } + + QApplication::restoreOverrideCursor(); + setDisableControls(false); } void FlightLogManager::retrieveLogs(int flightToRetrieve) { + setDisableControls(true); QApplication::setOverrideCursor(Qt::WaitCursor); UAVObjectUpdaterHelper updateHelper; @@ -151,6 +158,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) } emit logEntriesChanged(); QApplication::restoreOverrideCursor(); + setDisableControls(false); } void FlightLogManager::exportLogs() diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 498d87e56..0ce83bf33 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -69,6 +69,7 @@ private: class FlightLogManager : public QObject { Q_OBJECT Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus) Q_PROPERTY(QQmlListProperty logEntries READ logEntries NOTIFY logEntriesChanged) + Q_PROPERTY(bool disableControls READ disableControls WRITE setDisableControls NOTIFY disableControlsChanged) public: explicit FlightLogManager(QObject *parent = 0); @@ -81,14 +82,29 @@ public: return m_flightLogStatus; } + bool disableControls() const + { + return m_disableControls; + } + signals: void logEntriesChanged(); + void disableControlsChanged(bool arg); + public slots: void clearAllLogs(); void retrieveLogs(int flightToRetrieve = -1); void exportLogs(); + void setDisableControls(bool arg) + { + if (m_disableControls != arg) { + m_disableControls = arg; + emit disableControlsChanged(arg); + } + } + private: UAVObjectManager *m_objectManager; DebugLogControl *m_flightLogControl; @@ -97,6 +113,7 @@ private: QList m_logEntries; static const int UAVTALK_TIMEOUT = 4000; + bool m_disableControls; }; #endif // FLIGHTLOGMANAGER_H From 144b2c587de9c2f54db71851c879d3c7a539ac98 Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 26 Nov 2013 22:52:24 +0100 Subject: [PATCH 095/116] OP-1119 Added real-time updates of the flights combobox. Added some cleanup code. --- .../src/plugins/flightlog/FlightLogDialog.qml | 16 ++--- .../plugins/flightlog/flightlogmanager.cpp | 60 ++++++++++++++----- .../src/plugins/flightlog/flightlogmanager.h | 11 +++- 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 5b38a2113..f9c3f8dc6 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -120,14 +120,7 @@ Rectangle { ComboBox { id: flightCombo enabled: !logManager.disableControls - property ListModel dataModel: ListModel {} - model: dataModel - Component.onCompleted: { - dataModel.append({"value": "All"}) - for (var a = 0; a <= logStatus.Flight ; a++) { - dataModel.append({"value": (a + 1).toString()}) - } - } + model: logManager.flightEntries } } RowLayout { @@ -158,6 +151,13 @@ Rectangle { activeFocusOnPress: true onClicked: logManager.exportLogs() } + Button { + id: clearButton + enabled: !logManager.disableControls + text: qsTr("Clear all logs") + activeFocusOnPress: true + onClicked: logManager.clearAllLogs() + } Rectangle { Layout.fillWidth: true } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index ec12b324b..f96b51eac 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -46,9 +46,12 @@ FlightLogManager::FlightLogManager(QObject *parent) : m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager); Q_ASSERT(m_flightLogStatus); + connect(m_flightLogStatus, SIGNAL(FlightChanged(quint16)), this, SLOT(updateFlightEntries(quint16))); m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager); Q_ASSERT(m_flightLogEntry); + + updateFlightEntries(m_flightLogStatus->getFlight()); } FlightLogManager::~FlightLogManager() @@ -58,30 +61,35 @@ FlightLogManager::~FlightLogManager() } } -void addEntries(QQmlListProperty *list, ExtendedDebugLogEntry *entry) +void addLogEntries(QQmlListProperty *list, ExtendedDebugLogEntry *entry) { Q_UNUSED(list); Q_UNUSED(entry); } -int countEntries(QQmlListProperty *list) +int countLogEntries(QQmlListProperty *list) { return static_cast< QList *>(list->data)->size(); } -ExtendedDebugLogEntry *entryAt(QQmlListProperty *list, int index) +ExtendedDebugLogEntry *logEntryAt(QQmlListProperty *list, int index) { return static_cast< QList *>(list->data)->at(index); } -void clearEntries(QQmlListProperty *list) +void clearLogEntries(QQmlListProperty *list) { return static_cast< QList *>(list->data)->clear(); } QQmlListProperty FlightLogManager::logEntries() { - return QQmlListProperty(this, &m_logEntries, &addEntries, &countEntries, &entryAt, &clearEntries); + return QQmlListProperty(this, &m_logEntries, &addLogEntries, &countLogEntries, &logEntryAt, &clearLogEntries); +} + +QStringList FlightLogManager::flightEntries() +{ + return m_flightEntries; } void FlightLogManager::clearAllLogs() @@ -96,17 +104,26 @@ void FlightLogManager::clearAllLogs() m_flightLogControl->setEntry(0); m_flightLogControl->setOperation(DebugLogControl::OPERATION_FORMATFLASH); if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) { - // Then delete locally - while (!m_logEntries.isEmpty()) { - delete m_logEntries.takeFirst(); - } - emit logEntriesChanged(); + // Then empty locally + clearLogList(); } QApplication::restoreOverrideCursor(); setDisableControls(false); } +void FlightLogManager::clearLogList() +{ + QList tmpList(m_logEntries); + m_logEntries.clear(); + + emit logEntriesChanged(); + + while (!tmpList.isEmpty()) { + delete tmpList.takeFirst(); + } +} + void FlightLogManager::retrieveLogs(int flightToRetrieve) { setDisableControls(true); @@ -115,11 +132,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) UAVObjectUpdaterHelper updateHelper; UAVObjectRequestHelper requestHelper; - // Get logs from flight side - while (!m_logEntries.isEmpty()) { - delete m_logEntries.takeFirst(); - } - emit logEntriesChanged(); + clearLogList(); // Set up what to retrieve int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve; @@ -164,6 +177,23 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) void FlightLogManager::exportLogs() {} +void FlightLogManager::updateFlightEntries(quint16 currentFlight) +{ + Q_UNUSED(currentFlight); + + int flights = m_flightLogStatus->getFlight(); + if (m_flightEntries.count() == 0 || (m_flightEntries.count() - 1 != flights)) { + m_flightEntries.clear(); + + m_flightEntries << tr("All"); + for(int i = 0; i <= flights; i++) { + m_flightEntries << QString::number(i + 1); + } + + emit flightEntriesChanged(); + } +} + ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(), m_objectManager(0), m_object(0) {} diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 0ce83bf33..1f105008b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -69,6 +69,7 @@ private: class FlightLogManager : public QObject { 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) public: @@ -76,6 +77,7 @@ public: ~FlightLogManager(); QQmlListProperty logEntries(); + QStringList flightEntries(); DebugLogStatus *flightLogStatus() const { @@ -87,11 +89,14 @@ public: return m_disableControls; } + void clearLogList(); + signals: void logEntriesChanged(); - + void flightEntriesChanged(); void disableControlsChanged(bool arg); + public slots: void clearAllLogs(); void retrieveLogs(int flightToRetrieve = -1); @@ -105,12 +110,16 @@ public slots: } } +private slots: + void updateFlightEntries(quint16 currentFlight); + private: UAVObjectManager *m_objectManager; DebugLogControl *m_flightLogControl; DebugLogStatus *m_flightLogStatus; DebugLogEntry *m_flightLogEntry; QList m_logEntries; + QStringList m_flightEntries; static const int UAVTALK_TIMEOUT = 4000; bool m_disableControls; From bc9bbebfdf9ec6f9e0555ff670b050ebaca01d34 Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 26 Nov 2013 23:45:38 +0100 Subject: [PATCH 096/116] OP-1119 Starting to implement the export functionality. Aiming to do it so it is compatible with the standard .opl file format and replayable in the logging plugin. --- .../src/plugins/flightlog/flightlog.pro | 1 + .../plugins/flightlog/flightlogmanager.cpp | 20 ++++++++++++++++++- .../src/plugins/logging/logfile.h | 3 +-- ground/openpilotgcs/src/plugins/plugins.pro | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro index 1aa79b004..dfae3248b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlog.pro @@ -6,6 +6,7 @@ QT += qml quick include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/uavobjects/uavobjects.pri) +include(../../plugins/uavtalk/uavtalk.pri) HEADERS += flightlogplugin.h \ flightlogmanager.h \ diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index f96b51eac..3b70289e9 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -29,9 +29,11 @@ #include "extensionsystem/pluginmanager.h" #include +#include #include "debuglogcontrol.h" #include "uavobjecthelper.h" +#include "uavtalk/uavtalk.h" FlightLogManager::FlightLogManager(QObject *parent) : QObject(parent), m_disableControls(false) @@ -175,7 +177,23 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) } void FlightLogManager::exportLogs() -{} +{ + setDisableControls(true); + QApplication::setOverrideCursor(Qt::WaitCursor); + + QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save Log"), + tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")), + tr("OpenPilot Log (*.opl)")); + /* + if (!fileName.isEmpty()) { + logFile.setFileName(fileName); + logFile.open(QIODevice::WriteOnly); + UAVTalk uavTalk(file, m_objectManager); + } + */ + QApplication::restoreOverrideCursor(); + setDisableControls(false); +} void FlightLogManager::updateFlightEntries(quint16 currentFlight) { diff --git a/ground/openpilotgcs/src/plugins/logging/logfile.h b/ground/openpilotgcs/src/plugins/logging/logfile.h index ae936a7c4..9fbe94f00 100644 --- a/ground/openpilotgcs/src/plugins/logging/logfile.h +++ b/ground/openpilotgcs/src/plugins/logging/logfile.h @@ -7,8 +7,7 @@ #include #include #include -#include "uavobjectmanager.h" -#include +#include class LogFile : public QIODevice { Q_OBJECT diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro index 9020196e2..827acc49e 100644 --- a/ground/openpilotgcs/src/plugins/plugins.pro +++ b/ground/openpilotgcs/src/plugins/plugins.pro @@ -242,5 +242,6 @@ SUBDIRS += plugin_setupwizard plugin_flightlog.subdir = flightlog plugin_flightlog.depends = plugin_coreplugin plugin_flightlog.depends += plugin_uavobjects +plugin_flightlog.depends += plugin_uavtalk SUBDIRS += plugin_flightlog From 81443570ab13ae1b6e3c31e39e5eeefcb26b3094 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 27 Nov 2013 16:07:15 +0100 Subject: [PATCH 097/116] OP-1119 Moved class LogFile from Logging plugin to libs/utils --- .../logging => libs/utils}/logfile.cpp | 104 +++++++++--------- .../{plugins/logging => libs/utils}/logfile.h | 42 ++++--- ground/openpilotgcs/src/libs/utils/utils.pro | 6 +- .../src/plugins/logging/logging.pro | 13 +-- .../src/plugins/logging/loggingplugin.h | 2 +- 5 files changed, 92 insertions(+), 75 deletions(-) rename ground/openpilotgcs/src/{plugins/logging => libs/utils}/logfile.cpp (51%) rename ground/openpilotgcs/src/{plugins/logging => libs/utils}/logfile.h (52%) diff --git a/ground/openpilotgcs/src/plugins/logging/logfile.cpp b/ground/openpilotgcs/src/libs/utils/logfile.cpp similarity index 51% rename from ground/openpilotgcs/src/plugins/logging/logfile.cpp rename to ground/openpilotgcs/src/libs/utils/logfile.cpp index 2b1647139..4c20b413f 100644 --- a/ground/openpilotgcs/src/plugins/logging/logfile.cpp +++ b/ground/openpilotgcs/src/libs/utils/logfile.cpp @@ -4,12 +4,14 @@ LogFile::LogFile(QObject *parent) : QIODevice(parent), - lastTimeStamp(0), - lastPlayed(0), - timeOffset(0), - playbackSpeed(1.0) + m_lastTimeStamp(0), + m_lastPlayed(0), + m_timeOffset(0), + m_playbackSpeed(1.0), + m_nextTimeStamp(0), + m_useProvidedTimeStamp(false) { - connect(&timer, SIGNAL(timeout()), this, SLOT(timerFired())); + connect(&m_timer, SIGNAL(timeout()), this, SLOT(timerFired())); } /** @@ -20,8 +22,8 @@ LogFile::LogFile(QObject *parent) : bool LogFile::open(OpenMode mode) { // start a timer for playback - myTime.restart(); - if (file.isOpen()) { + m_myTime.restart(); + if (m_file.isOpen()) { // We end up here when doing a replay, because the connection // manager will also try to open the QIODevice, even though we just // opened it after selecting the file, which happens before the @@ -29,8 +31,8 @@ bool LogFile::open(OpenMode mode) return true; } - if (file.open(mode) == false) { - qDebug() << "Unable to open " << file.fileName() << " for logging"; + if (m_file.open(mode) == false) { + qDebug() << "Unable to open " << m_file.fileName() << " for logging"; return false; } @@ -49,25 +51,27 @@ void LogFile::close() { emit aboutToClose(); - if (timer.isActive()) { - timer.stop(); + if (m_timer.isActive()) { + m_timer.stop(); } - file.close(); + m_file.close(); QIODevice::close(); } qint64 LogFile::writeData(const char *data, qint64 dataSize) { - if (!file.isWritable()) { + if (!m_file.isWritable()) { return dataSize; } - quint32 timeStamp = myTime.elapsed(); + // If m_nextTimeStamp != -1 then use this timestamp instead of the timer + // This is used when saving logs from on-board logging + quint32 timeStamp = m_useProvidedTimeStamp ? m_nextTimeStamp : m_myTime.elapsed(); - file.write((char *)&timeStamp, sizeof(timeStamp)); - file.write((char *)&dataSize, sizeof(dataSize)); + m_file.write((char *)&timeStamp, sizeof(timeStamp)); + m_file.write((char *)&dataSize, sizeof(dataSize)); - qint64 written = file.write(data, dataSize); + qint64 written = m_file.write(data, dataSize); if (written != -1) { emit bytesWritten(written); } @@ -77,36 +81,36 @@ qint64 LogFile::writeData(const char *data, qint64 dataSize) qint64 LogFile::readData(char *data, qint64 maxSize) { - QMutexLocker locker(&mutex); - qint64 toRead = qMin(maxSize, (qint64)dataBuffer.size()); + QMutexLocker locker(&m_mutex); + qint64 toRead = qMin(maxSize, (qint64)m_dataBuffer.size()); - memcpy(data, dataBuffer.data(), toRead); - dataBuffer.remove(0, toRead); + memcpy(data, m_dataBuffer.data(), toRead); + m_dataBuffer.remove(0, toRead); return toRead; } qint64 LogFile::bytesAvailable() const { - return dataBuffer.size(); + return m_dataBuffer.size(); } void LogFile::timerFired() { qint64 dataSize; - if (file.bytesAvailable() > 4) { + if (m_file.bytesAvailable() > 4) { int time; - time = myTime.elapsed(); + time = m_myTime.elapsed(); // TODO: going back in time will be a problem - while ((lastPlayed + ((time - timeOffset) * playbackSpeed) > lastTimeStamp)) { - lastPlayed += ((time - timeOffset) * playbackSpeed); - if (file.bytesAvailable() < sizeof(dataSize)) { + while ((m_lastPlayed + ((time - m_timeOffset) * m_playbackSpeed) > m_lastTimeStamp)) { + m_lastPlayed += ((time - m_timeOffset) * m_playbackSpeed); + if (m_file.bytesAvailable() < sizeof(dataSize)) { stopReplay(); return; } - file.read((char *)&dataSize, sizeof(dataSize)); + m_file.read((char *)&dataSize, sizeof(dataSize)); if (dataSize < 1 || dataSize > (1024 * 1024)) { qDebug() << "Error: Logfile corrupted! Unlikely packet size: " << dataSize << "\n"; @@ -114,34 +118,34 @@ void LogFile::timerFired() return; } - if (file.bytesAvailable() < dataSize) { + if (m_file.bytesAvailable() < dataSize) { stopReplay(); return; } - mutex.lock(); - dataBuffer.append(file.read(dataSize)); - mutex.unlock(); + m_mutex.lock(); + m_dataBuffer.append(m_file.read(dataSize)); + m_mutex.unlock(); emit readyRead(); - if (file.bytesAvailable() < sizeof(lastTimeStamp)) { + if (m_file.bytesAvailable() < sizeof(m_lastTimeStamp)) { stopReplay(); return; } - int save = lastTimeStamp; - file.read((char *)&lastTimeStamp, sizeof(lastTimeStamp)); + int save = m_lastTimeStamp; + m_file.read((char *)&m_lastTimeStamp, sizeof(m_lastTimeStamp)); // some validity checks - if (lastTimeStamp < save // logfile goes back in time - || (lastTimeStamp - save) > (60 * 60 * 1000)) { // gap of more than 60 minutes) - qDebug() << "Error: Logfile corrupted! Unlikely timestamp " << lastTimeStamp << " after " << save << "\n"; + if (m_lastTimeStamp < save // logfile goes back in time + || (m_lastTimeStamp - save) > (60 * 60 * 1000)) { // gap of more than 60 minutes) + qDebug() << "Error: Logfile corrupted! Unlikely timestamp " << m_lastTimeStamp << " after " << save << "\n"; stopReplay(); return; } - timeOffset = time; - time = myTime.elapsed(); + m_timeOffset = time; + time = m_myTime.elapsed(); } } else { stopReplay(); @@ -150,13 +154,13 @@ void LogFile::timerFired() bool LogFile::startReplay() { - dataBuffer.clear(); - myTime.restart(); - timeOffset = 0; - lastPlayed = 0; - file.read((char *)&lastTimeStamp, sizeof(lastTimeStamp)); - timer.setInterval(10); - timer.start(); + m_dataBuffer.clear(); + m_myTime.restart(); + m_timeOffset = 0; + m_lastPlayed = 0; + m_file.read((char *)&m_lastTimeStamp, sizeof(m_lastTimeStamp)); + m_timer.setInterval(10); + m_timer.start(); emit replayStarted(); return true; } @@ -170,11 +174,11 @@ bool LogFile::stopReplay() void LogFile::pauseReplay() { - timer.stop(); + m_timer.stop(); } void LogFile::resumeReplay() { - timeOffset = myTime.elapsed(); - timer.start(); + m_timeOffset = m_myTime.elapsed(); + m_timer.start(); } diff --git a/ground/openpilotgcs/src/plugins/logging/logfile.h b/ground/openpilotgcs/src/libs/utils/logfile.h similarity index 52% rename from ground/openpilotgcs/src/plugins/logging/logfile.h rename to ground/openpilotgcs/src/libs/utils/logfile.h index 9fbe94f00..26e0f86ca 100644 --- a/ground/openpilotgcs/src/plugins/logging/logfile.h +++ b/ground/openpilotgcs/src/libs/utils/logfile.h @@ -8,20 +8,21 @@ #include #include #include +#include "utils_global.h" -class LogFile : public QIODevice { +class QTCREATOR_UTILS_EXPORT LogFile : public QIODevice { Q_OBJECT public: explicit LogFile(QObject *parent = 0); qint64 bytesAvailable() const; qint64 bytesToWrite() { - return file.bytesToWrite(); + return m_file.bytesToWrite(); }; bool open(OpenMode mode); void setFileName(QString name) { - file.setFileName(name); + m_file.setFileName(name); }; void close(); qint64 writeData(const char *data, qint64 dataSize); @@ -29,12 +30,21 @@ public: bool startReplay(); bool stopReplay(); + void useProvidedTimeStamp(bool useProvidedTimeStamp) + { + m_useProvidedTimeStamp = useProvidedTimeStamp; + } + + void setNextTimeStamp(quint32 nextTimestamp) + { + m_nextTimeStamp = nextTimestamp; + } public slots: void setReplaySpeed(double val) { - playbackSpeed = val; - qDebug() << "Playback speed is now" << playbackSpeed; + m_playbackSpeed = val; + qDebug() << "Playback speed is now" << m_playbackSpeed; }; void pauseReplay(); void resumeReplay(); @@ -48,17 +58,21 @@ signals: void replayFinished(); protected: - QByteArray dataBuffer; - QTimer timer; - QTime myTime; - QFile file; - qint32 lastTimeStamp; - qint32 lastPlayed; - QMutex mutex; + QByteArray m_dataBuffer; + QTimer m_timer; + QTime m_myTime; + QFile m_file; + qint32 m_lastTimeStamp; + qint32 m_lastPlayed; + QMutex m_mutex; - int timeOffset; - double playbackSpeed; + int m_timeOffset; + double m_playbackSpeed; + +private: + quint32 m_nextTimeStamp; + bool m_useProvidedTimeStamp; }; #endif // LOGFILE_H diff --git a/ground/openpilotgcs/src/libs/utils/utils.pro b/ground/openpilotgcs/src/libs/utils/utils.pro index 202751020..311212891 100644 --- a/ground/openpilotgcs/src/libs/utils/utils.pro +++ b/ground/openpilotgcs/src/libs/utils/utils.pro @@ -54,7 +54,8 @@ SOURCES += reloadpromptutils.cpp \ mytabwidget.cpp \ cachedsvgitem.cpp \ svgimageprovider.cpp \ - hostosinfo.cpp + hostosinfo.cpp \ + logfile.cpp SOURCES += xmlconfig.cpp @@ -111,7 +112,8 @@ HEADERS += utils_global.h \ mytabwidget.h \ cachedsvgitem.h \ svgimageprovider.h \ - hostosinfo.h + hostosinfo.h \ + logfile.h HEADERS += xmlconfig.h diff --git a/ground/openpilotgcs/src/plugins/logging/logging.pro b/ground/openpilotgcs/src/plugins/logging/logging.pro index 8d10d54a3..5514f4034 100644 --- a/ground/openpilotgcs/src/plugins/logging/logging.pro +++ b/ground/openpilotgcs/src/plugins/logging/logging.pro @@ -1,25 +1,22 @@ TEMPLATE = lib + TARGET = LoggingGadget DEFINES += LOGGING_LIBRARY QT += svg + include(../../openpilotgcsplugin.pri) include(logging_dependencies.pri) HEADERS += loggingplugin.h \ - logfile.h \ logginggadgetwidget.h \ logginggadget.h \ logginggadgetfactory.h -# logginggadgetconfiguration.h -# logginggadgetoptionspage.h SOURCES += loggingplugin.cpp \ - logfile.cpp \ logginggadgetwidget.cpp \ logginggadget.cpp \ logginggadgetfactory.cpp -# logginggadgetconfiguration.cpp \ -# logginggadgetoptionspage.cpp + OTHER_FILES += LoggingGadget.pluginspec + FORMS += logging.ui -# logginggadgetwidget.ui \ -# loggingdialog.ui + diff --git a/ground/openpilotgcs/src/plugins/logging/loggingplugin.h b/ground/openpilotgcs/src/plugins/logging/loggingplugin.h index ed697714e..7c2ed7406 100644 --- a/ground/openpilotgcs/src/plugins/logging/loggingplugin.h +++ b/ground/openpilotgcs/src/plugins/logging/loggingplugin.h @@ -35,7 +35,7 @@ #include "uavobjectmanager.h" #include "gcstelemetrystats.h" #include -#include +#include #include #include From d14044431ef9a85ce75ff4d3222547b73d518ba2 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 27 Nov 2013 16:07:34 +0100 Subject: [PATCH 098/116] OP-1119 WIP export of logs to .opl file --- .../plugins/flightlog/flightlogmanager.cpp | 38 ++++++++++++------- .../src/plugins/flightlog/flightlogmanager.h | 4 +- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 3b70289e9..89adae3ca 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -34,6 +34,7 @@ #include "debuglogcontrol.h" #include "uavobjecthelper.h" #include "uavtalk/uavtalk.h" +#include "utils/logfile.h" FlightLogManager::FlightLogManager(QObject *parent) : QObject(parent), m_disableControls(false) @@ -155,8 +156,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) if (m_flightLogEntry->getType() != DebugLogEntry::TYPE_EMPTY) { // Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry(); - logEntry->setObjectManager(m_objectManager); - logEntry->setData(m_flightLogEntry->getData()); + logEntry->setData(m_flightLogEntry->getData(), m_objectManager); m_logEntries << logEntry; // Increment to get next entry from flight side @@ -184,13 +184,23 @@ void FlightLogManager::exportLogs() QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save Log"), tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")), tr("OpenPilot Log (*.opl)")); - /* if (!fileName.isEmpty()) { + LogFile logFile; + logFile.useProvidedTimeStamp(true); logFile.setFileName(fileName); logFile.open(QIODevice::WriteOnly); - UAVTalk uavTalk(file, m_objectManager); + UAVTalk uavTalk(&logFile, m_objectManager); + + foreach (ExtendedDebugLogEntry* entry, m_logEntries) { + if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT) { + logFile.setNextTimeStamp(entry->getFlightTime()); + uavTalk.sendObject(entry->uavObject(), false, false); + } + } + + logFile.close(); } - */ + QApplication::restoreOverrideCursor(); setDisableControls(false); } @@ -213,7 +223,7 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight) } ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(), - m_objectManager(0), m_object(0) + m_object(0) {} ExtendedDebugLogEntry::~ExtendedDebugLogEntry() @@ -229,17 +239,19 @@ QString ExtendedDebugLogEntry::getLogString() if (getType() == DebugLogEntry::TYPE_TEXT) { return QString((const char *)getData().Data); } else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) { - UAVDataObject *object = (UAVDataObject *)m_objectManager->getObject(getObjectID(), getInstanceID()); - object = object->clone(getInstanceID()); - object->unpack(getData().Data); - m_object = object; - return object->toString().replace("\n", " ").replace("\t", " "); + return m_object->toString().replace("\n", " ").replace("\t", " "); } else { return ""; } } -void ExtendedDebugLogEntry::setObjectManager(UAVObjectManager *objectManager) +void ExtendedDebugLogEntry::setData(const DebugLogEntry::DataFields &data, UAVObjectManager *objectManager) { - m_objectManager = objectManager; + DebugLogEntry::setData(data); + if (getType() == DebugLogEntry::TYPE_UAVOBJECT) { + UAVDataObject *object = (UAVDataObject *)objectManager->getObject(getObjectID(), getInstanceID()); + Q_ASSERT(object); + m_object = object->clone(getInstanceID()); + m_object->unpack(getData().Data); + } } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 1f105008b..27412fd4b 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -50,7 +50,8 @@ public: { return m_object; } - void setObjectManager(UAVObjectManager *objectManager); + + void setData(const DataFields& data, UAVObjectManager *objectManager); public slots: void setLogString(QString arg) @@ -62,7 +63,6 @@ signals: void LogStringUpdated(QString arg); private: - UAVObjectManager *m_objectManager; UAVDataObject *m_object; }; From a3c555f8bb87a6b4af1c0fc1333d5638fdb2db21 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 30 Nov 2013 11:44:55 +0100 Subject: [PATCH 099/116] OP-1119 Fixed support for saving multiple flights when saving logs to .opl format. --- .../plugins/flightlog/flightlogmanager.cpp | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 89adae3ca..45b58725a 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -178,27 +178,53 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) void FlightLogManager::exportLogs() { + if(m_flightEntries.isEmpty()) { + return; + } + setDisableControls(true); QApplication::setOverrideCursor(Qt::WaitCursor); QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save Log"), tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")), - tr("OpenPilot Log (*.opl)")); + tr("OpenPilot Log (*.opl)")); if (!fileName.isEmpty()) { - LogFile logFile; - logFile.useProvidedTimeStamp(true); - logFile.setFileName(fileName); - logFile.open(QIODevice::WriteOnly); - UAVTalk uavTalk(&logFile, m_objectManager); + // Loop and create a new file for each flight. + fileName = fileName.replace(QString(".opl"), QString("%1.opl")); + int currentEntry = 0; + int currentFlight = 0; + // Continue until all entries are exported + while(currentEntry < m_logEntries.count()) { - foreach (ExtendedDebugLogEntry* entry, m_logEntries) { - if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT) { - logFile.setNextTimeStamp(entry->getFlightTime()); - uavTalk.sendObject(entry->uavObject(), false, false); + // Get current flight + currentFlight = m_logEntries[currentEntry]->getFlight(); + + LogFile logFile; + logFile.useProvidedTimeStamp(true); + + // Set the file name to contain flight number + logFile.setFileName(fileName.arg(tr("_flight-%1").arg(currentFlight + 1))); + logFile.open(QIODevice::WriteOnly); + UAVTalk uavTalk(&logFile, m_objectManager); + + // Export entries until no more available or flight changes + while(currentEntry < m_logEntries.count() && m_logEntries[currentEntry]->getFlight() == currentFlight) { + ExtendedDebugLogEntry* entry = m_logEntries[currentEntry]; + + // Only log uavobjects + if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT) { + // Set timestamp that should be logged for this entry + logFile.setNextTimeStamp(entry->getFlightTime()); + + // Use UAVTalk to log complete message to file + uavTalk.sendObject(entry->uavObject(), false, false); + } + currentEntry++; } + + logFile.close(); } - logFile.close(); } QApplication::restoreOverrideCursor(); From 74ad0fd40a2bd2c8b2d816fdb887e3c3066aaa6a Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 30 Nov 2013 13:02:52 +0100 Subject: [PATCH 100/116] OP-1119 Added cancel functionality on download. Added soem more gui update logic. --- .../src/plugins/flightlog/FlightLogDialog.qml | 10 ++++++- .../plugins/flightlog/flightlogmanager.cpp | 26 ++++++++++++++++--- .../src/plugins/flightlog/flightlogmanager.h | 19 +++++++++++++- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index f9c3f8dc6..18debefc0 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -146,7 +146,7 @@ Rectangle { height: 40 Button { id: exportButton - enabled: !logManager.disableControls + enabled: !logManager.disableControls && !logManager.disableExport text: qsTr("Export...") activeFocusOnPress: true onClicked: logManager.exportLogs() @@ -161,10 +161,18 @@ Rectangle { Rectangle { Layout.fillWidth: true } + Button { + id: cancelButton + enabled: logManager.disableControls + text: qsTr("Cancel") + activeFocusOnPress: true + onClicked: logManager.cancelExportLogs() + } Button { id: okButton enabled: !logManager.disableControls text: qsTr("OK") + isDefault: true activeFocusOnPress: true onClicked: dialog.close() } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 45b58725a..48aec397f 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -37,7 +37,7 @@ #include "utils/logfile.h" FlightLogManager::FlightLogManager(QObject *parent) : - QObject(parent), m_disableControls(false) + QObject(parent), m_disableControls(false), m_cancelDownload(false) { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -121,6 +121,7 @@ void FlightLogManager::clearLogList() m_logEntries.clear(); emit logEntriesChanged(); + setDisableExport(true); while (!tmpList.isEmpty()) { delete tmpList.takeFirst(); @@ -131,7 +132,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) { setDisableControls(true); QApplication::setOverrideCursor(Qt::WaitCursor); - + m_cancelDownload = false; UAVObjectUpdaterHelper updateHelper; UAVObjectRequestHelper requestHelper; @@ -169,16 +170,30 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) // We failed for some reason break; } + if (m_cancelDownload) { + break; + } + } + if (m_cancelDownload) { + break; } } + + if (m_cancelDownload) { + clearLogList(); + m_cancelDownload = false; + } + emit logEntriesChanged(); + setDisableExport(m_logEntries.count() == 0); + QApplication::restoreOverrideCursor(); setDisableControls(false); } void FlightLogManager::exportLogs() { - if(m_flightEntries.isEmpty()) { + if(m_logEntries.isEmpty()) { return; } @@ -231,6 +246,11 @@ void FlightLogManager::exportLogs() setDisableControls(false); } +void FlightLogManager::cancelExportLogs() +{ + m_cancelDownload = true; +} + void FlightLogManager::updateFlightEntries(quint16 currentFlight) { Q_UNUSED(currentFlight); diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index 27412fd4b..2b53c3982 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -71,6 +71,7 @@ class FlightLogManager : public QObject { 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) public: explicit FlightLogManager(QObject *parent = 0); @@ -89,18 +90,24 @@ public: return m_disableControls; } + bool disableExport() const + { + return m_disableExport; + } + void clearLogList(); signals: void logEntriesChanged(); void flightEntriesChanged(); void disableControlsChanged(bool arg); - + void disableExportChanged(bool arg); public slots: void clearAllLogs(); void retrieveLogs(int flightToRetrieve = -1); void exportLogs(); + void cancelExportLogs(); void setDisableControls(bool arg) { @@ -110,6 +117,14 @@ public slots: } } + void setDisableExport(bool arg) + { + if (m_disableExport != arg) { + m_disableExport = arg; + emit disableExportChanged(arg); + } + } + private slots: void updateFlightEntries(quint16 currentFlight); @@ -123,6 +138,8 @@ private: static const int UAVTALK_TIMEOUT = 4000; bool m_disableControls; + bool m_disableExport; + bool m_cancelDownload; }; #endif // FLIGHTLOGMANAGER_H From 38f7d9b28e437277de8eb5431a21f4453e8c3602 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 30 Nov 2013 16:54:18 +0100 Subject: [PATCH 101/116] OP-1119 Minor fixes --- ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml | 1 - ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml index 18debefc0..33f917b18 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml +++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml @@ -14,7 +14,6 @@ Rectangle { anchors.fill: parent anchors.margins: 10 spacing: 10 - Rectangle { Layout.fillWidth: true Layout.fillHeight: true diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 48aec397f..764e5ef47 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -37,7 +37,7 @@ #include "utils/logfile.h" FlightLogManager::FlightLogManager(QObject *parent) : - QObject(parent), m_disableControls(false), m_cancelDownload(false) + QObject(parent), m_disableControls(false), m_cancelDownload(false), m_disableExport(true) { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); From 9c6abef89ba88ae7bea22cbaade4669451b7c2bb Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 1 Dec 2013 00:03:24 +0100 Subject: [PATCH 102/116] fixed enabled and disabled messages for logging in all cases --- flight/modules/Logging/Logging.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/flight/modules/Logging/Logging.c b/flight/modules/Logging/Logging.c index 3cf7d2a78..504b58abf 100644 --- a/flight/modules/Logging/Logging.c +++ b/flight/modules/Logging/Logging.c @@ -91,23 +91,29 @@ static void StatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) static void FlightStatusUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { FlightStatusGet(&flightstatus); - switch (settings.LoggingEnabled) { - case DEBUGLOGSETTINGS_LOGGINGENABLED_ALWAYS: - PIOS_DEBUGLOG_Enable(1); - break; - case DEBUGLOGSETTINGS_LOGGINGENABLED_ONLYWHENARMED: - PIOS_DEBUGLOG_Enable(flightstatus.Armed == FLIGHTSTATUS_ARMED_ARMED); - break; - default: - PIOS_DEBUGLOG_Enable(0); + if (settings.LoggingEnabled == DEBUGLOGSETTINGS_LOGGINGENABLED_ONLYWHENARMED) { + if (flightstatus.Armed != FLIGHTSTATUS_ARMED_ARMED) { + PIOS_DEBUGLOG_Printf("FlightStatus Disarmed: On board Logging disabled."); + PIOS_DEBUGLOG_Enable(0); + } else { + PIOS_DEBUGLOG_Enable(1); + PIOS_DEBUGLOG_Printf("FlightStatus Armed: On board logging enabled."); + } } } static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { DebugLogSettingsGet(&settings); - FlightStatusUpdatedCb(NULL); - PIOS_DEBUGLOG_Printf("On board logging enabled."); + if (settings.LoggingEnabled == DEBUGLOGSETTINGS_LOGGINGENABLED_ALWAYS) { + PIOS_DEBUGLOG_Enable(1); + PIOS_DEBUGLOG_Printf("On board logging enabled."); + } else if (settings.LoggingEnabled == DEBUGLOGSETTINGS_LOGGINGENABLED_DISABLED) { + PIOS_DEBUGLOG_Printf("On board logging disabled."); + PIOS_DEBUGLOG_Enable(0); + } else { + FlightStatusUpdatedCb(NULL); + } } static void ControlUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) From 2d3683d511e2ca2af1b92e0de25723ec28535b99 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sun, 1 Dec 2013 21:22:58 +0100 Subject: [PATCH 103/116] 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 From 56c404e778bf0e7fc2fcd2d525dbd30f2c74106d Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 1 Dec 2013 23:17:48 +0100 Subject: [PATCH 104/116] OP-1132 added new openssl-install that downloads and install the required SSL libraries for Windows the missing SSLEAY32.DLL and LIBEAY32.DLL are copied to GCS bin dir OpenSSL version 1.0.1e was downloaded from http://slproweb.com/products/Win32OpenSSL.html --- Makefile | 1 + ground/openpilotgcs/copydata.pro | 8 ++++++++ make/tools.mk | 28 ++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 32cdb2da3..667aeb622 100644 --- a/Makefile +++ b/Makefile @@ -865,6 +865,7 @@ help: @$(ECHO) " mingw_install - Install the MinGW toolchain (Windows only)" @$(ECHO) " python_install - Install the Python interpreter (Windows only)" @$(ECHO) " nsis_install - Install the NSIS Unicode (Windows only)" + @$(ECHO) " openssl_install - Install the OpenSSL libraries (Windows only)" @$(ECHO) " uncrustify_install - Install the Uncrustify source code beautifier" @$(ECHO) " doxygen_install - Install the Doxygen documentation generator" @$(ECHO) " gtest_install - Install the GoogleTest framework" diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 0f30ae9fc..2962e7956 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -73,6 +73,14 @@ equals(copydata, 1) { data_copy.commands += $(COPY_FILE) $$targetPath(\"$$(QTMINGW)/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() } + # copy OpenSSL DLLs + OPENSSL_DLLS = \ + ssleay32.dll \ + libeay32.dll + for(dll, OPENSSL_DLLS) { + data_copy.commands += $(COPY_FILE) $$targetPath(\"$$(OPENSSL)/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + } + data_copy.target = FORCE QMAKE_EXTRA_TARGETS += data_copy } diff --git a/make/tools.mk b/make/tools.mk index 806365e9b..addc6ef61 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -12,6 +12,7 @@ # mingw_install (Windows only - NOT USED for Qt-5.1.x) # python_install (Windows only - NOT USED for Qt-5.1.x) # nsis_install (Windows only) +# openssl_install (Windows only) # uncrustify_install # doxygen_install # gtest_install @@ -77,6 +78,7 @@ else ifeq ($(UNAME), Windows) ARM_SDK_URL := http://wiki.openpilot.org/download/attachments/18612236/gcc-arm-none-eabi-4_7-2013q1-20130313-windows.tar.bz2 QT_SDK_URL := http://wiki.openpilot.org/download/attachments/18612236/qt-5.1.1-windows.tar.bz2 NSIS_URL := http://wiki.openpilot.org/download/attachments/18612236/nsis-2.46-unicode.tar.bz2 + OPENSSL_URL := http://wiki.openpilot.org/download/attachments/18612236/openssl-1.0.1e-win32.tar.bz2 UNCRUSTIFY_URL := http://wiki.openpilot.org/download/attachments/18612236/uncrustify-0.60-windows.tar.bz2 DOXYGEN_URL := http://wiki.openpilot.org/download/attachments/18612236/doxygen-1.8.3.1-windows.tar.bz2 endif @@ -89,11 +91,13 @@ QT_SDK_DIR := $(TOOLS_DIR)/qt-5.1.1 MINGW_DIR := $(QT_SDK_DIR)/Tools/mingw48_32 PYTHON_DIR := $(QT_SDK_DIR)/Tools/mingw48_32/opt/bin NSIS_DIR := $(TOOLS_DIR)/nsis-2.46-unicode +OPENSSL_DIR := $(TOOLS_DIR)/openssl-1.0.1e-win32 UNCRUSTIFY_DIR := $(TOOLS_DIR)/uncrustify-0.60 DOXYGEN_DIR := $(TOOLS_DIR)/doxygen-1.8.3.1 GTEST_DIR := $(TOOLS_DIR)/gtest-1.6.0 QT_SDK_PREFIX := $(QT_SDK_DIR) + ############################## # # Build only and all toolchains available for the platform @@ -102,7 +106,7 @@ QT_SDK_PREFIX := $(QT_SDK_DIR) BUILD_SDK_TARGETS := arm_sdk qt_sdk ifeq ($(UNAME), Windows) - BUILD_SDK_TARGETS += mingw python nsis + BUILD_SDK_TARGETS += mingw python nsis openssl endif ALL_SDK_TARGETS := $(BUILD_SDK_TARGETS) gtest uncrustify doxygen @@ -223,6 +227,7 @@ endif # $(2) = string compare operator, e.g. = or != # ############################## + define MD5_CHECK_TEMPLATE "`test -f \"$(1)\" && $(OPENSSL) dgst -md5 \"$(1)\" | $(CUT) -f2 -d' '`" $(2) "`$(CUT) -f1 -d' ' < \"$(1).md5\"`" endef @@ -526,7 +531,7 @@ python_version: ############################## # -# NSIS Unicode +# NSIS Unicode (Windows only) # ############################## @@ -548,6 +553,25 @@ nsis_version: endif +############################## +# +# OpenSSL (Windows only) +# +############################## + +ifeq ($(UNAME), Windows) + +$(eval $(call TOOL_INSTALL_TEMPLATE,openssl,$(OPENSSL_DIR),$(OPENSSL_URL),$(notdir $(OPENSSL_URL)))) + +ifeq ($(shell [ -d "$(OPENSSL_DIR)" ] && $(ECHO) "exists"), exists) + export OPENSSL := $(OPENSSL_DIR) +else + # not installed, hope it's in the path... + # $(info $(EMPTY) WARNING $(call toprel, $(OPENSSL_DIR)) not found (make openssl_install), using system PATH) +endif + +endif + ############################## # # Uncrustify From b627b71d0ec3a826531463f4537fa00b2897b80f Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 2 Dec 2013 23:47:27 +0100 Subject: [PATCH 105/116] uncrustification --- .../plugins/coreplugin/connectionmanager.cpp | 4 +- .../plugins/coreplugin/connectionmanager.h | 1 - .../plugins/coreplugin/workspacesettings.cpp | 8 +- .../src/plugins/telemetry/monitorgadget.cpp | 17 +- .../src/plugins/telemetry/monitorgadget.h | 8 +- .../telemetry/monitorgadgetconfiguration.cpp | 9 +- .../telemetry/monitorgadgetfactory.cpp | 8 +- .../plugins/telemetry/monitorgadgetfactory.h | 8 +- .../telemetry/monitorgadgetoptionspage.cpp | 95 +++---- .../src/plugins/telemetry/monitorwidget.cpp | 173 ++++++------ .../src/plugins/telemetry/monitorwidget.h | 8 +- .../src/plugins/telemetry/telemetryplugin.cpp | 263 +++++++++--------- .../src/plugins/telemetry/telemetryplugin.h | 2 +- .../plugins/uavobjectbrowser/fieldtreeitem.h | 3 +- .../src/plugins/uavtalk/telemetrymanager.cpp | 9 +- .../src/plugins/uavtalk/telemetrymonitor.cpp | 2 +- 16 files changed, 303 insertions(+), 315 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index 02e3a3302..b8f2714c6 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -40,7 +40,6 @@ #include namespace Core { - ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow) : QWidget(mainWindow), m_availableDevList(0), @@ -97,7 +96,8 @@ void ConnectionManager::init() // TODO needs documentation? void ConnectionManager::addWidget(QWidget *widget) { - QHBoxLayout *l = (QHBoxLayout *) layout(); + QHBoxLayout *l = (QHBoxLayout *)layout(); + l->insertWidget(0, widget, 0, Qt::AlignVCenter); } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h index 0d9a3b24b..0d72cb71d 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h @@ -43,7 +43,6 @@ #include namespace Core { - class IConnection; namespace Internal { diff --git a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp index 345d53039..6ffaa4a0b 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp @@ -39,13 +39,11 @@ using namespace Core::Internal; const int WorkspaceSettings::MAX_WORKSPACES = 10; WorkspaceSettings::WorkspaceSettings(QObject *parent) : - IOptionsPage(parent) -{ -} + IOptionsPage(parent) +{} WorkspaceSettings::~WorkspaceSettings() -{ -} +{} // IOptionsPage diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp index b8adfba17..e23591da2 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.cpp @@ -30,9 +30,8 @@ #include "monitorwidget.h" MonitorGadget::MonitorGadget(QString classId, MonitorWidget *widget, QWidget *parent) : - IUAVGadget(classId, parent), m_widget(widget) -{ -} + IUAVGadget(classId, parent), m_widget(widget) +{} MonitorGadget::~MonitorGadget() { @@ -40,14 +39,14 @@ MonitorGadget::~MonitorGadget() } /* - This is called when a configuration is loaded, and updates the plugin's settings. - Careful: the plugin is already drawn before the loadConfiguration method is called the - first time, so you have to be careful not to assume all the plugin values are initialized - the first time you use them + This is called when a configuration is loaded, and updates the plugin's settings. + Careful: the plugin is already drawn before the loadConfiguration method is called the + first time, so you have to be careful not to assume all the plugin values are initialized + the first time you use them */ void MonitorGadget::loadConfiguration(IUAVGadgetConfiguration *config) { - //MonitorGadgetConfiguration *m = qobject_cast(config); + // MonitorGadgetConfiguration *m = qobject_cast(config); - //m_widget->setSystemFile(m->getSystemFile()); // Triggers widget repaint + // m_widget->setSystemFile(m->getSystemFile()); // Triggers widget repaint } diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h index 90f9dcb74..e85c15ade 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadget.h @@ -31,14 +31,14 @@ #include #include "monitorwidget.h" -//class IUAVGadget; -//class QWidget; -//class QString; +// class IUAVGadget; +// class QWidget; +// class QString; // class NotifyPluginGadgetWidget; using namespace Core; -class MonitorGadget: public IUAVGadget { +class MonitorGadget : public IUAVGadget { Q_OBJECT public: MonitorGadget(QString classId, MonitorWidget *widget, QWidget *parent = 0); diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp index 9c15744a8..6a69905af 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetconfiguration.cpp @@ -31,8 +31,7 @@ MonitorGadgetConfiguration::MonitorGadgetConfiguration(QString classId, QSetting IUAVGadgetConfiguration(classId, parent) { // if a saved configuration exists load it - if (qSettings != 0) { - } + if (qSettings != 0) {} } IUAVGadgetConfiguration *MonitorGadgetConfiguration::clone() @@ -48,7 +47,7 @@ IUAVGadgetConfiguration *MonitorGadgetConfiguration::clone() */ void MonitorGadgetConfiguration::saveConfig(QSettings *qSettings) const { -// qSettings->setValue("acFilename", Utils::PathUtils().RemoveDataPath(m_acFilename)); -// qSettings->setValue("bgFilename", Utils::PathUtils().RemoveDataPath(m_bgFilename)); -// qSettings->setValue("enableVbo", m_enableVbo); +// qSettings->setValue("acFilename", Utils::PathUtils().RemoveDataPath(m_acFilename)); +// qSettings->setValue("bgFilename", Utils::PathUtils().RemoveDataPath(m_bgFilename)); +// qSettings->setValue("enableVbo", m_enableVbo); } diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp index 6506ce521..94faf597a 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.cpp @@ -35,13 +35,11 @@ #include MonitorGadgetFactory::MonitorGadgetFactory(QObject *parent) : - IUAVGadgetFactory(QString("TelemetryMonitorGadget"), tr("Telemetry Monitor"), parent) -{ -} + IUAVGadgetFactory(QString("TelemetryMonitorGadget"), tr("Telemetry Monitor"), parent) +{} MonitorGadgetFactory::~MonitorGadgetFactory() -{ -} +{} Core::IUAVGadget *MonitorGadgetFactory::createGadget(QWidget *parent) { diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h index f1663156b..0b44e8b53 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetfactory.h @@ -33,14 +33,14 @@ namespace Core { - class IUAVGadget; - class IUAVGadgetFactory; +class IUAVGadget; +class IUAVGadgetFactory; } using namespace Core; -class MonitorGadgetFactory: public IUAVGadgetFactory { -Q_OBJECT +class MonitorGadgetFactory : public IUAVGadgetFactory { + Q_OBJECT public: MonitorGadgetFactory(QObject *parent = 0); ~MonitorGadgetFactory(); diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp index fcd4bd37f..6601efd54 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorgadgetoptionspage.cpp @@ -27,81 +27,78 @@ #include "monitorgadgetoptionspage.h" #include -//#include "ui_telemetrypluginoptionspage.h" +// #include "ui_telemetrypluginoptionspage.h" #include "extensionsystem/pluginmanager.h" MonitorGadgetOptionsPage::MonitorGadgetOptionsPage(MonitorGadgetConfiguration *config, QObject *parent) : IOptionsPage(parent) -{ -} +{} MonitorGadgetOptionsPage::~MonitorGadgetOptionsPage() -{ -} +{} QWidget *MonitorGadgetOptionsPage::createPage(QWidget * /* parent */) { -// _optionsPage.reset(new Ui::TelemetryPluginOptionsPage()); -// // main widget -// QWidget *optionsPageWidget = new QWidget; -// _dynamicFieldWidget = NULL; -// _dynamicFieldCondition = NULL; -// resetFieldType(); -// // save ref to form, needed for binding dynamic fields in future -// _form = optionsPageWidget; -// // main layout -// _optionsPage->setupUi(optionsPageWidget); +// _optionsPage.reset(new Ui::TelemetryPluginOptionsPage()); +//// main widget +// QWidget *optionsPageWidget = new QWidget; +// _dynamicFieldWidget = NULL; +// _dynamicFieldCondition = NULL; +// resetFieldType(); +//// save ref to form, needed for binding dynamic fields in future +// _form = optionsPageWidget; +//// main layout +// _optionsPage->setupUi(optionsPageWidget); // -// _optionsPage->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory); -// _optionsPage->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory")); +// _optionsPage->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory); +// _optionsPage->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory")); // -// connect(_optionsPage->SoundDirectoryPathChooser, SIGNAL(changed(const QString &)), -// this, SLOT(on_clicked_buttonSoundFolder(const QString &))); -// connect(_optionsPage->SoundCollectionList, SIGNAL(currentIndexChanged(int)), -// this, SLOT(on_changedIndex_soundLanguage(int))); +// connect(_optionsPage->SoundDirectoryPathChooser, SIGNAL(changed(const QString &)), +// this, SLOT(on_clicked_buttonSoundFolder(const QString &))); +// connect(_optionsPage->SoundCollectionList, SIGNAL(currentIndexChanged(int)), +// this, SLOT(on_changedIndex_soundLanguage(int))); // -// connect(this, SIGNAL(updateNotifications(QList)), -// _owner, SLOT(updateNotificationList(QList))); -// // connect(this, SIGNAL(resetNotification()),owner, SLOT(resetNotification())); +// connect(this, SIGNAL(updateNotifications(QList)), +// _owner, SLOT(updateNotificationList(QList))); +//// connect(this, SIGNAL(resetNotification()),owner, SLOT(resetNotification())); // -// _privListNotifications = _owner->getListNotifications(); +// _privListNotifications = _owner->getListNotifications(); // // -// // [1] -// setSelectedNotification(_owner->getCurrentNotification()); -// addDynamicFieldLayout(); -// // [2] -// updateConfigView(_selectedNotification); +//// [1] +// setSelectedNotification(_owner->getCurrentNotification()); +// addDynamicFieldLayout(); +//// [2] +// updateConfigView(_selectedNotification); // -// initRulesTable(); -// initButtons(); -// initPhononPlayer(); +// initRulesTable(); +// initButtons(); +// initPhononPlayer(); // -// int curr_row = _privListNotifications.indexOf(_selectedNotification); -// _telemetryRulesSelection->setCurrentIndex(_telemetryRulesModel->index(curr_row, 0, QModelIndex()), -// QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); +// int curr_row = _privListNotifications.indexOf(_selectedNotification); +// _telemetryRulesSelection->setCurrentIndex(_telemetryRulesModel->index(curr_row, 0, QModelIndex()), +// QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); // -// return optionsPageWidget; +// return optionsPageWidget; return NULL; } void MonitorGadgetOptionsPage::apply() { -// getOptionsPageValues(_owner->getCurrentNotification()); -// _owner->setEnableSound(_optionsPage->chkEnableSound->isChecked()); -// emit updateNotifications(_privListNotifications); +// getOptionsPageValues(_owner->getCurrentNotification()); +// _owner->setEnableSound(_optionsPage->chkEnableSound->isChecked()); +// emit updateNotifications(_privListNotifications); } void MonitorGadgetOptionsPage::finish() { -// disconnect(_optionsPage->UAVObjectField, SIGNAL(currentIndexChanged(QString)), -// this, SLOT(on_changedIndex_UAVField(QString))); +// disconnect(_optionsPage->UAVObjectField, SIGNAL(currentIndexChanged(QString)), +// this, SLOT(on_changedIndex_UAVField(QString))); // -// disconnect(_testSound.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), -// this, SLOT(on_changed_playButtonText(Phonon::State, Phonon::State))); -// if (_testSound) { -// _testSound->stop(); -// _testSound->clear(); -// } +// disconnect(_testSound.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), +// this, SLOT(on_changed_playButtonText(Phonon::State, Phonon::State))); +// if (_testSound) { +// _testSound->stop(); +// _testSound->clear(); +// } } - diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp index c75e301c2..722869652 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.cpp @@ -7,102 +7,101 @@ #include namespace { +/** + * Create an SVG item and connect it to an element of the SVG file previously loaded into the parent item. + * This then allows to show, hide, move, scale and rotate the element. + * Opacity can also be changed. + * Other characteristics (color, ...) of the element cannot be modified. + */ +// TODO move to some utility class that can be reused by other SVG manipulating code +QGraphicsSvgItem *createSvgItem(QGraphicsSvgItem *parent, QString elementId) +{ + QGraphicsSvgItem *item = new QGraphicsSvgItem(parent); - /** - * Create an SVG item and connect it to an element of the SVG file previously loaded into the parent item. - * This then allows to show, hide, move, scale and rotate the element. - * Opacity can also be changed. - * Other characteristics (color, ...) of the element cannot be modified. - */ - // TODO move to some utility class that can be reused by other SVG manipulating code - QGraphicsSvgItem *createSvgItem(QGraphicsSvgItem *parent, QString elementId) - { - QGraphicsSvgItem *item = new QGraphicsSvgItem(parent); + QSvgRenderer *renderer = parent->renderer(); - QSvgRenderer *renderer = parent->renderer(); + // connect item to its corresponding element + item->setSharedRenderer(renderer); + item->setElementId(elementId); - // connect item to its corresponding element - item->setSharedRenderer(renderer); - item->setElementId(elementId); + // move item to its location + QMatrix elementMatrix = renderer->matrixForElement(elementId); + QRectF elementRect = elementMatrix.mapRect(renderer->boundsOnElement(elementId)); + item->setPos(elementRect.x(), elementRect.y()); - // move item to its location - QMatrix elementMatrix = renderer->matrixForElement(elementId); - QRectF elementRect = elementMatrix.mapRect(renderer->boundsOnElement(elementId)); - item->setPos(elementRect.x(), elementRect.y()); + return item; +} - return item; +/** + * Create a text item based on a svg rectangle. + * The rectangle must be in the correct location (hint: use a "text" layer on top of the "background layer") + * The font size will be set to match as well as possible the rectangle height but it is not guaranteed. + * + * It is possible to show the text rectangle to help understand layout issues. + * + */ +// TODO move to some utility class that can be reused by other SVG manipulating code +QGraphicsTextItem *createTextItem(QGraphicsSvgItem *parent, QString elementId, QString fontName, + bool showRect = false) +{ + if (showRect) { + // create and display the text rectangle + // needs to be done first otherwise the rectangle will blank out the text. + createSvgItem(parent, elementId); } - /** - * Create a text item based on a svg rectangle. - * The rectangle must be in the correct location (hint: use a "text" layer on top of the "background layer") - * The font size will be set to match as well as possible the rectangle height but it is not guaranteed. - * - * It is possible to show the text rectangle to help understand layout issues. - * - */ - // TODO move to some utility class that can be reused by other SVG manipulating code - QGraphicsTextItem *createTextItem(QGraphicsSvgItem *parent, QString elementId, QString fontName, - bool showRect = false) - { - if (showRect) { - // create and display the text rectangle - // needs to be done first otherwise the rectangle will blank out the text. - createSvgItem(parent, elementId); - } + QGraphicsTextItem *item = new QGraphicsTextItem(); - QGraphicsTextItem *item = new QGraphicsTextItem(); + QSvgRenderer *renderer = parent->renderer(); - QSvgRenderer *renderer = parent->renderer(); + // move new text item to location of rectangle element + QMatrix elementMatrix = renderer->matrixForElement(elementId); + QRectF elementRect = elementMatrix.mapRect(renderer->boundsOnElement(elementId)); - // move new text item to location of rectangle element - QMatrix elementMatrix = renderer->matrixForElement(elementId); - QRectF elementRect = elementMatrix.mapRect(renderer->boundsOnElement(elementId)); + qreal fontPointSizeF = elementRect.height(); - qreal fontPointSizeF = elementRect.height(); + QTransform matrix; + matrix.translate(elementRect.x(), elementRect.y() - (fontPointSizeF / 2.0)); - QTransform matrix; - matrix.translate(elementRect.x(), elementRect.y() - (fontPointSizeF / 2.0)); + item->setParentItem(parent); + item->setTransform(matrix, false); + // to right align or center text we must provide a text width + // item->setTextWidth(elementRect.width()); - item->setParentItem(parent); - item->setTransform(matrix, false); - // to right align or center text we must provide a text width - //item->setTextWidth(elementRect.width()); + // create font to match the rectangle height + // there is not guaranteed that all fonts will play well... + QFont font(fontName); + // not sure if PreferMatch helps to get the correct font size (i.e. that fits the text rectangle nicely) + font.setStyleStrategy(QFont::PreferMatch); + font.setPointSizeF(fontPointSizeF); - // create font to match the rectangle height - // there is not guaranteed that all fonts will play well... - QFont font(fontName); - // not sure if PreferMatch helps to get the correct font size (i.e. that fits the text rectangle nicely) - font.setStyleStrategy(QFont::PreferMatch); - font.setPointSizeF(fontPointSizeF); - - item->setFont(font); + item->setFont(font); #ifdef DEBUG_FONT - // just in case - qDebug() << "Font point size: " << fontPointSizeF; - qDebug() << "Font pixel size: " << font.pixelSize(); - qDebug() << "Font point size: " << font.pointSize(); - qDebug() << "Font point size F: " << font.pointSizeF(); - qDebug() << "Font exact match: " << font.exactMatch(); + // just in case + qDebug() << "Font point size: " << fontPointSizeF; + qDebug() << "Font pixel size: " << font.pixelSize(); + qDebug() << "Font point size: " << font.pointSize(); + qDebug() << "Font point size F: " << font.pointSizeF(); + qDebug() << "Font exact match: " << font.exactMatch(); - QFontInfo fontInfo(font); - qDebug() << "Font info pixel size: " << fontInfo.pixelSize(); - qDebug() << "Font info point size: " << fontInfo.pointSize(); - qDebug() << "Font info point size F: " << fontInfo.pointSizeF(); - qDebug() << "Font info exact match: " << fontInfo.exactMatch(); + QFontInfo fontInfo(font); + qDebug() << "Font info pixel size: " << fontInfo.pixelSize(); + qDebug() << "Font info point size: " << fontInfo.pointSize(); + qDebug() << "Font info point size F: " << fontInfo.pointSizeF(); + qDebug() << "Font info exact match: " << fontInfo.exactMatch(); #endif - return item; - } - + return item; +} } // anonymous namespace MonitorWidget::MonitorWidget(QWidget *parent) : - QGraphicsView(parent), aspectRatioMode(Qt::KeepAspectRatio) + QGraphicsView(parent), aspectRatioMode(Qt::KeepAspectRatio) { - //setMinimumWidth(180); + // setMinimumWidth(180); QGraphicsScene *scene = new QGraphicsScene(); + setScene(scene); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); @@ -132,7 +131,7 @@ MonitorWidget::MonitorWidget(QWidget *parent) : // create tx nodes i = 0; while (true) { - QString id = QString("tx%0").arg(i); + QString id = QString("tx%0").arg(i); QString bgId = QString("tx_bg%0").arg(i); if (!renderer->elementExists(id) || !renderer->elementExists(bgId)) { break; @@ -146,7 +145,7 @@ MonitorWidget::MonitorWidget(QWidget *parent) : // create rx nodes i = 0; while (true) { - QString id = QString("rx%0").arg(i); + QString id = QString("rx%0").arg(i); QString bgId = QString("rx_bg%0").arg(i); if (!renderer->elementExists(id) || !renderer->elementExists(bgId)) { break; @@ -170,7 +169,7 @@ MonitorWidget::MonitorWidget(QWidget *parent) : } else { rxSpeed = NULL; } - //scene->setSceneRect(graph->boundingRect()); + // scene->setSceneRect(graph->boundingRect()); } connected = false; @@ -200,14 +199,14 @@ MonitorWidget::~MonitorWidget() /*! \brief Enables/Disables OpenGL */ -//void LineardialGadgetWidget::enableOpenGL(bool flag) -//{ -// if (flag) { -// setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); -// } else { -// setViewport(new QWidget); -// } -//} +// void LineardialGadgetWidget::enableOpenGL(bool flag) +// { +// if (flag) { +// setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); +// } else { +// setViewport(new QWidget); +// } +// } void MonitorWidget::telemetryConnected() { @@ -236,9 +235,9 @@ void MonitorWidget::telemetryDisconnected() } /*! - \brief Called by the UAVObject which got updated + \brief Called by the UAVObject which got updated - Updates the numeric value and/or the icon if the dial wants this. + Updates the numeric value and/or the icon if the dial wants this. */ void MonitorWidget::telemetryUpdated(double txRate, double rxRate) { @@ -251,7 +250,7 @@ void MonitorWidget::telemetryUpdated(double txRate, double rxRate) for (int i = 0; i < txNodes.count(); i++) { QGraphicsItem *node = txNodes.at(i); - bool visible = (/*connected &&*/ (i < txIndex)); + bool visible = ( /*connected &&*/ (i < txIndex)); if (visible != node->isVisible()) { node->setVisible(visible); node->update(); @@ -260,7 +259,7 @@ void MonitorWidget::telemetryUpdated(double txRate, double rxRate) for (int i = 0; i < rxNodes.count(); i++) { QGraphicsItem *node = rxNodes.at(i); - bool visible = (/*connected &&*/ (i < rxIndex)); + bool visible = ( /*connected &&*/ (i < rxIndex)); if (visible != node->isVisible()) { node->setVisible(visible); node->update(); diff --git a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h index 380cd3b00..729d25775 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h +++ b/ground/openpilotgcs/src/plugins/telemetry/monitorwidget.h @@ -8,8 +8,8 @@ #include #include -class MonitorWidget: public QGraphicsView { -Q_OBJECT +class MonitorWidget : public QGraphicsView { + Q_OBJECT public: explicit MonitorWidget(QWidget *parent = 0); ~MonitorWidget(); @@ -54,8 +54,8 @@ private: QPointer txSpeed; QPointer rxSpeed; - QList txNodes; - QList rxNodes; + QList txNodes; + QList rxNodes; Qt::AspectRatioMode aspectRatioMode; }; diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp index 8a4991e95..4a68a2734 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.cpp @@ -43,12 +43,11 @@ #include TelemetryPlugin::TelemetryPlugin() -{ -} +{} TelemetryPlugin::~TelemetryPlugin() { -// Core::ICore::instance()->saveSettings(this); +// Core::ICore::instance()->saveSettings(this); } bool TelemetryPlugin::initialize(const QStringList & args, QString *errMsg) @@ -59,15 +58,15 @@ bool TelemetryPlugin::initialize(const QStringList & args, QString *errMsg) MonitorGadgetFactory *mf = new MonitorGadgetFactory(this); addAutoReleasedObject(mf); - // mop = new TelemetryPluginOptionsPage(this); - //addAutoReleasedObject(mop); + // mop = new TelemetryPluginOptionsPage(this); + // addAutoReleasedObject(mop); // TODO not so good... g is probalby leaked... MonitorWidget *w = mf->createMonitorWidget(NULL); w->setMaximumWidth(180); // - //setAlignment(Qt::AlignCenter); + // setAlignment(Qt::AlignCenter); // no border w->setFrameStyle(QFrame::NoFrame); @@ -82,8 +81,8 @@ bool TelemetryPlugin::initialize(const QStringList & args, QString *errMsg) // add monitor widget to connection manager Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); -// connect(cm, SIGNAL(deviceConnected(QIODevice *)), w, SLOT(telemetryConnected())); -// connect(cm, SIGNAL(deviceDisconnected()), w, SLOT(telemetryDisconnected())); +// connect(cm, SIGNAL(deviceConnected(QIODevice *)), w, SLOT(telemetryConnected())); +// connect(cm, SIGNAL(deviceDisconnected()), w, SLOT(telemetryDisconnected())); cm->addWidget(w); @@ -92,156 +91,156 @@ bool TelemetryPlugin::initialize(const QStringList & args, QString *errMsg) void TelemetryPlugin::extensionsInitialized() { -// Core::ICore::instance()->readSettings(this); +// Core::ICore::instance()->readSettings(this); - //ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + // ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); -// connect(pm, SIGNAL(objectAdded(QObject *)), this, SLOT(onTelemetryManagerAdded(QObject *))); -// _toRemoveNotifications.clear(); -// connectNotifications(); +// connect(pm, SIGNAL(objectAdded(QObject *)), this, SLOT(onTelemetryManagerAdded(QObject *))); +// _toRemoveNotifications.clear(); +// connectNotifications(); } -//void TelemetryPlugin::saveConfig(QSettings *settings, UAVConfigInfo *configInfo) -//{ -// configInfo->setVersion(VERSION); +// void TelemetryPlugin::saveConfig(QSettings *settings, UAVConfigInfo *configInfo) +// { +// configInfo->setVersion(VERSION); // -// settings->beginWriteArray("Current"); -// settings->setArrayIndex(0); -// currentNotification.saveState(settings); -// settings->endArray(); +// settings->beginWriteArray("Current"); +// settings->setArrayIndex(0); +// currentNotification.saveState(settings); +// settings->endArray(); // -// settings->beginGroup("listNotifies"); -// settings->remove(""); -// settings->endGroup(); +// settings->beginGroup("listNotifies"); +// settings->remove(""); +// settings->endGroup(); // -// settings->beginWriteArray("listNotifies"); -// for (int i = 0; i < _notificationList.size(); i++) { -// settings->setArrayIndex(i); -// _notificationList.at(i)->saveState(settings); -// } -// settings->endArray(); -// settings->setValue(QLatin1String("Enable"), enable); -//} +// settings->beginWriteArray("listNotifies"); +// for (int i = 0; i < _notificationList.size(); i++) { +// settings->setArrayIndex(i); +// _notificationList.at(i)->saveState(settings); +// } +// settings->endArray(); +// settings->setValue(QLatin1String("Enable"), enable); +// } -//void TelemetryPlugin::readConfig(QSettings *settings, UAVConfigInfo * /* configInfo */) -//{ -// // Just for migration to the new format. -// // Q_ASSERT(configInfo->version() == UAVConfigVersion()); +// void TelemetryPlugin::readConfig(QSettings *settings, UAVConfigInfo * /* configInfo */) +// { +//// Just for migration to the new format. +//// Q_ASSERT(configInfo->version() == UAVConfigVersion()); // -// settings->beginReadArray("Current"); -// settings->setArrayIndex(0); -// currentNotification.restoreState(settings); -// settings->endArray(); +// settings->beginReadArray("Current"); +// settings->setArrayIndex(0); +// currentNotification.restoreState(settings); +// settings->endArray(); // -// // read list of notifications from settings -// int size = settings->beginReadArray("listNotifies"); -// for (int i = 0; i < size; ++i) { -// settings->setArrayIndex(i); -// NotificationItem *notification = new NotificationItem; -// notification->restoreState(settings); -// _notificationList.append(notification); -// } -// settings->endArray(); -// setEnable(settings->value(QLatin1String("Enable"), 0).toBool()); -//} +//// read list of notifications from settings +// int size = settings->beginReadArray("listNotifies"); +// for (int i = 0; i < size; ++i) { +// settings->setArrayIndex(i); +// NotificationItem *notification = new NotificationItem; +// notification->restoreState(settings); +// _notificationList.append(notification); +// } +// settings->endArray(); +// setEnable(settings->value(QLatin1String("Enable"), 0).toBool()); +// } -//void TelemetryPlugin::onTelemetryManagerAdded(QObject *obj) -//{ -// telMngr = qobject_cast(obj); -// if (telMngr) { -// connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); -// } -//} +// void TelemetryPlugin::onTelemetryManagerAdded(QObject *obj) +// { +// telMngr = qobject_cast(obj); +// if (telMngr) { +// connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); +// } +// } void TelemetryPlugin::shutdown() { // Do nothing } -//void TelemetryPlugin::onAutopilotDisconnect() -//{ -// connectNotifications(); -//} +// void TelemetryPlugin::onAutopilotDisconnect() +// { +// connectNotifications(); +// } ///*! -// clear any telemetry timers from previous flight; -// reset will be perform on start of option page +// clear any telemetry timers from previous flight; +// reset will be perform on start of option page // */ -//void TelemetryPlugin::resetNotification(void) -//{ -// // first, reject empty args and unknown fields. -// foreach(NotificationItem * ntf, _notificationList) { -// ntf->disposeTimer(); -// disconnect(ntf->getTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification())); -// ntf->disposeExpireTimer(); -// disconnect(ntf->getExpireTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification())); -// } -//} +// void TelemetryPlugin::resetNotification(void) +// { +//// first, reject empty args and unknown fields. +// foreach(NotificationItem * ntf, _notificationList) { +// ntf->disposeTimer(); +// disconnect(ntf->getTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification())); +// ntf->disposeExpireTimer(); +// disconnect(ntf->getExpireTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification())); +// } +// } -//void TelemetryPlugin::connectNotifications() -//{ -// foreach(UAVDataObject * obj, lstNotifiedUAVObjects) { -// if (obj != NULL) { -// disconnect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(on_arrived_Notification(UAVObject *))); -// } -// } -// if (phonon.mo != NULL) { -// delete phonon.mo; -// phonon.mo = NULL; -// } +// void TelemetryPlugin::connectNotifications() +// { +// foreach(UAVDataObject * obj, lstNotifiedUAVObjects) { +// if (obj != NULL) { +// disconnect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(on_arrived_Notification(UAVObject *))); +// } +// } +// if (phonon.mo != NULL) { +// delete phonon.mo; +// phonon.mo = NULL; +// } // -// if (!enable) { -// return; -// } +// if (!enable) { +// return; +// } // -// ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); -// UAVObjectManager *objManager = pm->getObject(); +// ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); +// UAVObjectManager *objManager = pm->getObject(); // -// lstNotifiedUAVObjects.clear(); -// _pendingNotifications.clear(); -// _notificationList.append(_toRemoveNotifications); -// _toRemoveNotifications.clear(); +// lstNotifiedUAVObjects.clear(); +// _pendingNotifications.clear(); +// _notificationList.append(_toRemoveNotifications); +// _toRemoveNotifications.clear(); // -// // first, reject empty args and unknown fields. -// foreach(NotificationItem * telemetry, _notificationList) { -// telemetry->_isPlayed = false; -// telemetry->isNowPlaying = false; +//// first, reject empty args and unknown fields. +// foreach(NotificationItem * telemetry, _notificationList) { +// telemetry->_isPlayed = false; +// telemetry->isNowPlaying = false; // -// if (telemetry->mute()) { -// continue; -// } -// // check is all sounds presented for notification, -// // if not - we must not subscribe to it at all -// if (telemetry->toList().isEmpty()) { -// continue; -// } +// if (telemetry->mute()) { +// continue; +// } +//// check is all sounds presented for notification, +//// if not - we must not subscribe to it at all +// if (telemetry->toList().isEmpty()) { +// continue; +// } // -// UAVDataObject *obj = dynamic_cast(objManager->getObject(telemetry->getDataObject())); -// if (obj != NULL) { -// if (!lstNotifiedUAVObjects.contains(obj)) { -// lstNotifiedUAVObjects.append(obj); +// UAVDataObject *obj = dynamic_cast(objManager->getObject(telemetry->getDataObject())); +// if (obj != NULL) { +// if (!lstNotifiedUAVObjects.contains(obj)) { +// lstNotifiedUAVObjects.append(obj); // -// connect(obj, SIGNAL(objectUpdated(UAVObject *)), -// this, SLOT(on_arrived_Notification(UAVObject *)), -// Qt::QueuedConnection); -// } -// } else { -// qTelemetryDebug() << "Error: Object is unknown (" << telemetry->getDataObject() << ")."; -// } -// } +// connect(obj, SIGNAL(objectUpdated(UAVObject *)), +// this, SLOT(on_arrived_Notification(UAVObject *)), +// Qt::QueuedConnection); +// } +// } else { +// qTelemetryDebug() << "Error: Object is unknown (" << telemetry->getDataObject() << ")."; +// } +// } // -// if (_notificationList.isEmpty()) { -// return; -// } -// // set notification message to current event -// phonon.mo = Phonon::createPlayer(Phonon::NotificationCategory); -// phonon.mo->clearQueue(); -// phonon.firstPlay = true; -// QList audioOutputDevices = -// Phonon::BackendCapabilities::availableAudioOutputDevices(); -// foreach(Phonon::AudioOutputDevice dev, audioOutputDevices) { -// qTelemetryDebug() << "Telemetry: Audio Output device: " << dev.name() << " - " << dev.description(); -// } -// connect(phonon.mo, SIGNAL(stateChanged(Phonon::State, Phonon::State)), -// this, SLOT(stateChanged(Phonon::State, Phonon::State))); -//} +// if (_notificationList.isEmpty()) { +// return; +// } +//// set notification message to current event +// phonon.mo = Phonon::createPlayer(Phonon::NotificationCategory); +// phonon.mo->clearQueue(); +// phonon.firstPlay = true; +// QList audioOutputDevices = +// Phonon::BackendCapabilities::availableAudioOutputDevices(); +// foreach(Phonon::AudioOutputDevice dev, audioOutputDevices) { +// qTelemetryDebug() << "Telemetry: Audio Output device: " << dev.name() << " - " << dev.description(); +// } +// connect(phonon.mo, SIGNAL(stateChanged(Phonon::State, Phonon::State)), +// this, SLOT(stateChanged(Phonon::State, Phonon::State))); +// } diff --git a/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h index 86cffe320..300c08ad7 100644 --- a/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h +++ b/ground/openpilotgcs/src/plugins/telemetry/telemetryplugin.h @@ -33,7 +33,7 @@ class MonitorGadgetFactory; class TelemetryPlugin : public ExtensionSystem::IPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "OpenPilot.Telemetry") + Q_PLUGIN_METADATA(IID "OpenPilot.Telemetry") public: diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h index 2876c6f0f..31cf9ecb3 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h @@ -114,7 +114,8 @@ public: QWidget *createEditor(QWidget *parent) { QComboBox *editor = new QComboBox(parent); - // Setting ClickFocus lets the ComboBox stay open on Mac OSX. + + // Setting ClickFocus lets the ComboBox stay open on Mac OSX. editor->setFocusPolicy(Qt::ClickFocus); foreach(QString option, m_enumOptions) editor->addItem(option); diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp index c38566db8..3eeb7e5a8 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymanager.cpp @@ -31,7 +31,7 @@ #include TelemetryManager::TelemetryManager() : - autopilotConnected(false) + autopilotConnected(false) { moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread()); // Get UAVObjectManager instance @@ -44,8 +44,7 @@ TelemetryManager::TelemetryManager() : } TelemetryManager::~TelemetryManager() -{ -} +{} bool TelemetryManager::isConnected() { @@ -60,8 +59,8 @@ void TelemetryManager::start(QIODevice *dev) void TelemetryManager::onStart() { - utalk = new UAVTalk(device, objMngr); - telemetry = new Telemetry(utalk, objMngr); + utalk = new UAVTalk(device, objMngr); + telemetry = new Telemetry(utalk, objMngr); telemetryMon = new TelemetryMonitor(objMngr, telemetry); connect(telemetryMon, SIGNAL(connected()), this, SLOT(onConnect())); connect(telemetryMon, SIGNAL(disconnected()), this, SLOT(onDisconnect())); diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp index 0c8f94a38..8342d5001 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.cpp @@ -232,7 +232,7 @@ void TelemetryMonitor::processStatsUpdates() } } - emit telemetryUpdated((double) gcsStats.TxDataRate, (double) gcsStats.RxDataRate); + emit telemetryUpdated((double)gcsStats.TxDataRate, (double)gcsStats.RxDataRate); // Set data gcsStatsObj->setData(gcsStats); From 035c8afcba96513ac4cc0691069c7a1feeb3a6ff Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 2 Dec 2013 23:51:01 +0100 Subject: [PATCH 106/116] OP-963 minor UI tweak to the status bar icon tray margins --- .../openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index b8f2714c6..8de9e66e0 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -61,7 +61,8 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow) : // put everything together QHBoxLayout *layout = new QHBoxLayout; layout->setSpacing(5); - layout->setContentsMargins(5, 2, 5, 2); + // cheat a bit with the margin to "nicely" center things vertically + layout->setContentsMargins(5, 0, 5, 4); setLayout(layout); layout->addWidget(new QLabel(tr("Connections:")), 0, Qt::AlignVCenter); From 336510c3e6588ff0d209ad32b2825f93baaae3e4 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 3 Dec 2013 20:48:40 +0100 Subject: [PATCH 107/116] OP-771 Added some descriptive text. OP-1059 Fixed typos. --- .../src/plugins/setupwizard/pages/outputcalibrationpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui index 6699ad531..0f0dd1707 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui @@ -66,7 +66,7 @@ p, li { white-space: pre-wrap; } - <html><head/><body><p>In this step we will set the neutral rate for the motor highlighted in the illustration to the right. <br/>Plase pay attention to the details and in particular the motors position and its rotation direction.</p><p>To find the neutral rate for this engine, press the Start button below and slide the slider to the right until the engine just starts to spin stably. <br/><br/>When done press button again to stop.</p></body></html> + <html><head/><body><p>In this step we will set the neutral rate for the motor highlighted in the illustration to the right. <br/>Please pay attention to the details and in particular the motors position and its rotation direction. Ensure the motors are spinning in the correct direction as shown in the diagram. Swap any 2 motor wires to change the direction of a motor. </p><p>To find the neutral rate for this engine, press the Start button below and slide the slider to the right until the engine just starts to spin stable. <br/><br/>When done press button again to stop.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop From fbea95e8170d39250135995b753991c4a650a93d Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 3 Dec 2013 22:03:32 +0100 Subject: [PATCH 108/116] OP-1063 Fixed text --- ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui index b4da7c0a7..0883ec4d5 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui @@ -21,7 +21,7 @@ <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot multirotor configuration</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot Multirotor Configuration</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">This part of the wizard will set up the OpenPilot controller for use with a flying platform utilizing multiple rotors. The wizard supports the most common types of multirotors. Other variants of multirotors can be configured by using custom configuration options in the Configuration plugin in the GCS.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> From a68c4da62d463ef23dad8710d8a74e4a782980f4 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Fri, 6 Dec 2013 18:46:58 +0100 Subject: [PATCH 109/116] Disable dragging of icons in the configuration plugin. --- ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp index 1a521c10d..ed094d16f 100644 --- a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp +++ b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp @@ -78,6 +78,7 @@ void MyTabbedStackWidget::insertTab(const int index, QWidget *tab, const QIcon & tab->setContentsMargins(0, 0, 0, 0); m_stackWidget->insertWidget(index, tab); QListWidgetItem *item = new QListWidgetItem(icon, label); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom); item->setToolTip(label); m_listWidget->insertItem(index, item); From 2f2cff3dc601fa41e90784a250fdb42b89b15898 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sat, 7 Dec 2013 15:25:15 +0100 Subject: [PATCH 110/116] uncrustification --- .../src/plugins/coreplugin/aboutdialog.cpp | 9 ++- .../src/plugins/coreplugin/aboutdialog.h | 4 +- .../src/plugins/pfdqml/pfdqmlgadget.cpp | 2 +- .../src/plugins/pfdqml/pfdqmlgadget.h | 2 +- .../src/plugins/pfdqml/pfdqmlgadgetwidget.cpp | 2 +- .../src/plugins/qmlview/qmlviewgadget.cpp | 2 +- .../src/plugins/qmlview/qmlviewgadget.h | 2 +- .../plugins/uavobjectbrowser/fieldtreeitem.h | 3 +- .../src/plugins/welcome/welcomemode.cpp | 2 +- .../generators/gcs/uavobjectgeneratorgcs.cpp | 62 +++++++++---------- 10 files changed, 44 insertions(+), 46 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp index e47015051..d72c7c412 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.cpp @@ -58,7 +58,7 @@ AboutDialog::AboutDialog(QWidget *parent) : "Built on %4 at %5
" "Based on Qt %6 (%7 bit)
" "
" - "© %8, 2010-%9. All rights reserved.
" + "© %8, 2010-%9. All rights reserved.
" ).arg( VersionInfo::revision().left(60), // %1 VersionInfo::uavoHash().left(8), // %2 @@ -77,12 +77,12 @@ AboutDialog::AboutDialog(QWidget *parent) : view->setResizeMode(QQuickView::SizeRootObjectToView); view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml")); - QWidget * container = QWidget::createWindowContainer(view); + QWidget *container = QWidget::createWindowContainer(view); container->setMinimumSize(600, 400); container->setMaximumSize(800, 600); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QVBoxLayout *lay = new QVBoxLayout(); - lay->setContentsMargins(0,0,0,0); + lay->setContentsMargins(0, 0, 0, 0); setLayout(lay); layout()->addWidget(container); } @@ -93,5 +93,4 @@ void AboutDialog::openUrl(const QString &url) } AboutDialog::~AboutDialog() -{ -} +{} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h index 6bce8d24b..a023354d5 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/aboutdialog.h @@ -26,8 +26,7 @@ #include -class AboutDialog : public QDialog -{ +class AboutDialog : public QDialog { Q_OBJECT public: @@ -36,7 +35,6 @@ public: public slots: void openUrl(const QString &url); - }; #endif // ABOUTDIALOG_H diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp index 30e803f33..e28257ff5 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp @@ -23,7 +23,7 @@ PfdQmlGadget::PfdQmlGadget(QString classId, PfdQmlGadgetWidget *widget, QWidget m_widget(widget) { m_container = NULL; - m_parent = parent; + m_parent = parent; } PfdQmlGadget::~PfdQmlGadget() diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h index 131ab9b31..f36bbb6fe 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h @@ -35,7 +35,7 @@ public: QWidget *widget() { - if(!m_container){ + if (!m_container) { m_container = QWidget::createWindowContainer(m_widget, m_parent); m_container->setMinimumSize(64, 64); m_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp index 7f0262ad3..96fa900a4 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp @@ -162,7 +162,7 @@ void PfdQmlGadgetWidget::setAltitudeFactor(double factor) void PfdQmlGadgetWidget::setOpenGLEnabled(bool arg) { - setTerrainEnabled(m_terrainEnabled); + setTerrainEnabled(m_terrainEnabled); } // Switch between PositionState UAVObject position diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp index aa071e893..0bc9eca42 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp @@ -35,7 +35,7 @@ QmlViewGadget::QmlViewGadget(QString classId, QmlViewGadgetWidget *widget, QWidg m_widget(widget) { m_container = NULL; - m_parent = parent; + m_parent = parent; } QmlViewGadget::~QmlViewGadget() diff --git a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h index fe7fac302..076cd8d99 100644 --- a/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h +++ b/ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h @@ -46,7 +46,7 @@ public: QWidget *widget() { - if(!m_container){ + if (!m_container) { m_container = QWidget::createWindowContainer(m_widget, m_parent); m_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_container->setMinimumSize(64, 64); diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h index 2876c6f0f..31cf9ecb3 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h @@ -114,7 +114,8 @@ public: QWidget *createEditor(QWidget *parent) { QComboBox *editor = new QComboBox(parent); - // Setting ClickFocus lets the ComboBox stay open on Mac OSX. + + // Setting ClickFocus lets the ComboBox stay open on Mac OSX. editor->setFocusPolicy(Qt::ClickFocus); foreach(QString option, m_enumOptions) editor->addItem(option); diff --git a/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp b/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp index e2c21956f..381fd226a 100644 --- a/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp +++ b/ground/openpilotgcs/src/plugins/welcome/welcomemode.cpp @@ -100,7 +100,7 @@ int WelcomeMode::priority() const QWidget *WelcomeMode::widget() { - if(!m_container){ + if (!m_container) { m_container = QWidget::createWindowContainer(m_d->quickView); m_container->setMinimumSize(64, 64); m_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); diff --git a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp index 8821614dd..7265d411a 100644 --- a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp +++ b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp @@ -127,9 +127,9 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info) type = fieldTypeStrCPP[field->type]; // Append field if (field->numElements > 1) { - //add both field(elementIndex)/setField(elemntIndex,value) and field_element properties - //field_element is more convenient if only certain element is used - //and much easier to use from the qml side + // add both field(elementIndex)/setField(elemntIndex,value) and field_element properties + // field_element is more convenient if only certain element is used + // and much easier to use from the qml side propertyGetters += QString(" Q_INVOKABLE %1 get%2(quint32 index) const;\n") .arg(type).arg(field->name); @@ -160,37 +160,37 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info) for (int elementIndex = 0; elementIndex < field->numElements; elementIndex++) { QString elementName = field->elementNames[elementIndex]; properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n") - .arg(type).arg(field->name+"_"+elementName); + .arg(type).arg(field->name + "_" + elementName); propertyGetters += - QString(" Q_INVOKABLE %1 get%2_%3() const;\n") - .arg(type).arg(field->name).arg(elementName); - propertiesImpl += - QString("%1 %2::get%3_%4() const\n" - "{\n" - " QMutexLocker locker(mutex);\n" - " return data.%3[%5];\n" - "}\n") - .arg(type).arg(info->name).arg(field->name).arg(elementName).arg(elementIndex); + QString(" Q_INVOKABLE %1 get%2_%3() const;\n") + .arg(type).arg(field->name).arg(elementName); + propertiesImpl += + QString("%1 %2::get%3_%4() const\n" + "{\n" + " QMutexLocker locker(mutex);\n" + " return data.%3[%5];\n" + "}\n") + .arg(type).arg(info->name).arg(field->name).arg(elementName).arg(elementIndex); propertySetters += - QString(" void set%1_%2(%3 value);\n") - .arg(field->name).arg(elementName).arg(type); - propertiesImpl += - QString("void %1::set%2_%3(%4 value)\n" - "{\n" - " mutex->lock();\n" - " bool changed = data.%2[%5] != value;\n" - " data.%2[%5] = value;\n" - " mutex->unlock();\n" - " if (changed) emit %2_%3Changed(value);\n" - "}\n\n") - .arg(info->name).arg(field->name).arg(elementName).arg(type).arg(elementIndex); - propertyNotifications += - QString(" void %1_%2Changed(%3 value);\n") - .arg(field->name).arg(elementName).arg(type); + QString(" void set%1_%2(%3 value);\n") + .arg(field->name).arg(elementName).arg(type); + propertiesImpl += + QString("void %1::set%2_%3(%4 value)\n" + "{\n" + " mutex->lock();\n" + " bool changed = data.%2[%5] != value;\n" + " data.%2[%5] = value;\n" + " mutex->unlock();\n" + " if (changed) emit %2_%3Changed(value);\n" + "}\n\n") + .arg(info->name).arg(field->name).arg(elementName).arg(type).arg(elementIndex); + propertyNotifications += + QString(" void %1_%2Changed(%3 value);\n") + .arg(field->name).arg(elementName).arg(type); propertyNotificationsImpl += - QString(" //if (data.%1[%2] != oldData.%1[%2])\n" - " emit %1_%3Changed(data.%1[%2]);\n") - .arg(field->name).arg(elementIndex).arg(elementName); + QString(" //if (data.%1[%2] != oldData.%1[%2])\n" + " emit %1_%3Changed(data.%1[%2]);\n") + .arg(field->name).arg(elementIndex).arg(elementName); } } else { properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n") From 8fadcd85d251318897ad090654e3bd83fc9afa62 Mon Sep 17 00:00:00 2001 From: Fredrik Larsson Date: Sun, 8 Dec 2013 03:28:32 +1100 Subject: [PATCH 111/116] Rename GCS Configuration, check it to be removed by default --- package/winx86/openpilotgcs.nsi | 4 ++-- package/winx86/translations/strings_en.nsh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/winx86/openpilotgcs.nsi b/package/winx86/openpilotgcs.nsi index db6fcf7eb..c0ffdb797 100644 --- a/package/winx86/openpilotgcs.nsi +++ b/package/winx86/openpilotgcs.nsi @@ -368,8 +368,8 @@ Section "un.Maps cache" UnSecCache RMDir /r /rebootok "$APPDATA\OpenPilot\mapscache" SectionEnd -Section /o "un.Configuration" UnSecConfig - ; Remove configuration +Section "un.GCS Layout" UnSecConfig + ; Remove GCS configuration files SetShellVarContext current Delete /rebootok "$APPDATA\OpenPilot\OpenPilotGCS*.db" Delete /rebootok "$APPDATA\OpenPilot\OpenPilotGCS*.xml" diff --git a/package/winx86/translations/strings_en.nsh b/package/winx86/translations/strings_en.nsh index e8aa794b0..efa553d3e 100644 --- a/package/winx86/translations/strings_en.nsh +++ b/package/winx86/translations/strings_en.nsh @@ -42,4 +42,4 @@ LangString DESC_UnSecProgram ${LANG_ENGLISH} "OpenPilot GCS application and all components." LangString DESC_UnSecCache ${LANG_ENGLISH} "OpenPilot GCS cached maps data." - LangString DESC_UnSecConfig ${LANG_ENGLISH} "OpenPilot GCS configuration files." + LangString DESC_UnSecConfig ${LANG_ENGLISH} "OpenPilot GCS layout files." From 853174b4cadd704e62ebb86dc46c957d3ddb035b Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 7 Dec 2013 17:36:14 +0100 Subject: [PATCH 112/116] OP-963 fixed bad merge --- ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 4ba2264c3..40fb468ea 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -70,8 +70,7 @@ SOURCES += mainwindow.cpp \ uavgadgetdecorator.cpp \ workspacesettings.cpp \ uavconfiginfo.cpp \ - authorsdialog.cpp \ - telemetrymonitorwidget.cpp + aboutdialog.cpp \ HEADERS += mainwindow.h \ tabpositionindicator.h \ @@ -132,7 +131,7 @@ HEADERS += mainwindow.h \ uavconfiginfo.h \ authorsdialog.h \ iconfigurableplugin.h \ - telemetrymonitorwidget.h + aboutdialog.h FORMS += dialogs/settingsdialog.ui \ dialogs/shortcutsettings.ui \ From 30e0c9f6c182da41044045c93ae43493d3e0e8ca Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sat, 7 Dec 2013 23:28:25 +0100 Subject: [PATCH 113/116] somone forgot uncrustification again --- .../plugins/flightlog/flightlogmanager.cpp | 23 +++++++++---------- .../src/plugins/flightlog/flightlogmanager.h | 2 +- .../src/plugins/flightlog/flightlogplugin.h | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp index 04bd822a4..60578532a 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp @@ -53,7 +53,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); updateFlightEntries(m_flightLogStatus->getFlight()); @@ -119,7 +119,7 @@ void FlightLogManager::clearAllLogs() void FlightLogManager::clearLogList() { - QList tmpList(m_logEntries); + QList tmpList(m_logEntries); m_logEntries.clear(); emit logEntriesChanged(); @@ -195,7 +195,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) void FlightLogManager::exportLogs() { - if(m_logEntries.isEmpty()) { + if (m_logEntries.isEmpty()) { return; } @@ -204,16 +204,15 @@ void FlightLogManager::exportLogs() QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save Log"), tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")), - tr("OpenPilot Log (*.opl)")); + tr("OpenPilot Log (*.opl)")); if (!fileName.isEmpty()) { // Loop and create a new file for each flight. fileName = fileName.replace(QString(".opl"), QString("%1.opl")); - int currentEntry = 0; + int currentEntry = 0; int currentFlight = 0; quint32 adjustedBaseTime = 0; // Continue until all entries are exported - while(currentEntry < m_logEntries.count()) { - + while (currentEntry < m_logEntries.count()) { if (m_adjustExportedTimestamps) { adjustedBaseTime = m_logEntries[currentEntry]->getFlightTime(); } @@ -230,8 +229,8 @@ void FlightLogManager::exportLogs() UAVTalk uavTalk(&logFile, m_objectManager); // Export entries until no more available or flight changes - while(currentEntry < m_logEntries.count() && m_logEntries[currentEntry]->getFlight() == currentFlight) { - ExtendedDebugLogEntry* entry = m_logEntries[currentEntry]; + while (currentEntry < m_logEntries.count() && m_logEntries[currentEntry]->getFlight() == currentFlight) { + ExtendedDebugLogEntry *entry = m_logEntries[currentEntry]; // Only log uavobjects if (entry->getType() == ExtendedDebugLogEntry::TYPE_UAVOBJECT) { @@ -247,7 +246,6 @@ void FlightLogManager::exportLogs() logFile.close(); } - } QApplication::restoreOverrideCursor(); @@ -268,7 +266,7 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight) m_flightEntries.clear(); m_flightEntries << tr("All"); - for(int i = 0; i <= flights; i++) { + for (int i = 0; i <= flights; i++) { m_flightEntries << QString::number(i + 1); } @@ -302,10 +300,11 @@ QString ExtendedDebugLogEntry::getLogString() void ExtendedDebugLogEntry::setData(const DebugLogEntry::DataFields &data, UAVObjectManager *objectManager) { DebugLogEntry::setData(data); + if (getType() == DebugLogEntry::TYPE_UAVOBJECT) { UAVDataObject *object = (UAVDataObject *)objectManager->getObject(getObjectID(), getInstanceID()); Q_ASSERT(object); - m_object = object->clone(getInstanceID()); + m_object = object->clone(getInstanceID()); m_object->unpack(getData().Data); } } diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h index eb5915d07..af01dd7e7 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h @@ -51,7 +51,7 @@ public: return m_object; } - void setData(const DataFields& data, UAVObjectManager *objectManager); + void setData(const DataFields & data, UAVObjectManager *objectManager); public slots: void setLogString(QString arg) diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h index 81194272c..b78c58836 100644 --- a/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h +++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogplugin.h @@ -32,7 +32,7 @@ class FlightLogPlugin : public ExtensionSystem::IPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "OpenPilot.FlightLog") + Q_PLUGIN_METADATA(IID "OpenPilot.FlightLog") public: FlightLogPlugin(); From c4f4916590fda7599baf487cda650e4c4ea3b747 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Fri, 13 Dec 2013 18:40:05 +0100 Subject: [PATCH 114/116] OP-1143: add missing ids to udev rules +review OPReview --- package/linux/45-openpilot-permissions.rules | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package/linux/45-openpilot-permissions.rules b/package/linux/45-openpilot-permissions.rules index 74e415c39..9015612a6 100644 --- a/package/linux/45-openpilot-permissions.rules +++ b/package/linux/45-openpilot-permissions.rules @@ -5,6 +5,15 @@ SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415b", MODE="0664", GROUP="plugdev" # OpenPilot OPLink Mini radio modem board SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415c", MODE="0664", GROUP="plugdev" + # OpenPilot Revolution board + SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415e", MODE="0664", GROUP="plugdev" + + # Other OpenPilot reserved pids + SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415d", MODE="0664", GROUP="plugdev" + SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="4194", MODE="0664", GROUP="plugdev" + SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="4195", MODE="0664", GROUP="plugdev" + + # unprogrammed openpilot flight control board SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5750", MODE="0664", GROUP="plugdev" # FTDI FT2232C Dual USB-UART/FIFO IC From 117c2fb97f0102aba5ed49e974b6ebca89ab3aea Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 12 Nov 2013 22:43:54 +0100 Subject: [PATCH 115/116] Fix for issue OP-1108: Mutex not correctly released in GCS --- .../src/plugins/ophid/src/ophid.cpp | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp b/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp index afcc28446..447fa2f98 100644 --- a/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp +++ b/ground/openpilotgcs/src/plugins/ophid/src/ophid.cpp @@ -205,6 +205,8 @@ qint64 RawHIDReadThread::getBytesAvailable() return m_readBuffer.size(); } +// ********************************************************************************* + RawHIDWriteThread::RawHIDWriteThread(RawHID *hid) : m_hid(hid), hiddev(&hid->dev), @@ -212,8 +214,6 @@ RawHIDWriteThread::RawHIDWriteThread(RawHID *hid) m_running(true) {} -// ********************************************************************************* - RawHIDWriteThread::~RawHIDWriteThread() { m_running = false; @@ -227,29 +227,31 @@ void RawHIDWriteThread::run() { while (m_running) { char buffer[WRITE_SIZE] = { 0 }; + int size; - m_writeBufMtx.lock(); - int size = qMin(WRITE_SIZE - 2, m_writeBuffer.size()); - while (size <= 0) { - // wait on new data to write condition, the timeout - // enable the thread to shutdown properly - m_newDataToWrite.wait(&m_writeBufMtx, 200); - if (!m_running) { - return; + { + QMutexLocker lock(&m_writeBufMtx); + size = qMin(WRITE_SIZE - 2, m_writeBuffer.size()); + while (size <= 0) { + // wait on new data to write condition, the timeout + // enable the thread to shutdown properly + m_newDataToWrite.wait(&m_writeBufMtx, 200); + if (!m_running) { + return; + } + + size = m_writeBuffer.size(); } - size = m_writeBuffer.size(); + // NOTE: data size is limited to 2 bytes less than the + // usb packet size (64 bytes for interrupt) to make room + // for the reportID and valid data length + size = qMin(WRITE_SIZE - 2, m_writeBuffer.size()); + memcpy(&buffer[2], m_writeBuffer.constData(), size); + buffer[1] = size; // valid data length + buffer[0] = 2; // reportID } - // NOTE: data size is limited to 2 bytes less than the - // usb packet size (64 bytes for interrupt) to make room - // for the reportID and valid data length - size = qMin(WRITE_SIZE - 2, m_writeBuffer.size()); - memcpy(&buffer[2], m_writeBuffer.constData(), size); - buffer[1] = size; // valid data length - buffer[0] = 2; // reportID - m_writeBufMtx.unlock(); - // must hold lock through the send to know how much was sent int ret = hiddev->send(hidno, buffer, WRITE_SIZE, WRITE_TIMEOUT); From e472b167e47d121e8b30d82b0c76eab834b46cf4 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sat, 14 Dec 2013 17:58:27 +0100 Subject: [PATCH 116/116] Uncrustification --- ground/openpilotgcs/src/plugins/config/twostep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/twostep.cpp b/ground/openpilotgcs/src/plugins/config/twostep.cpp index d6534d7cc..014fb18ae 100644 --- a/ground/openpilotgcs/src/plugins/config/twostep.cpp +++ b/ground/openpilotgcs/src/plugins/config/twostep.cpp @@ -126,7 +126,7 @@ Vector3f twostep_bias_only(const Vector3f samples[], const float noise) { // \tilde{H} - Vector3f* centeredSamples = new Vector3f[n_samples]; + Vector3f *centeredSamples = new Vector3f[n_samples]; // z_k float sampleDeltaMag[n_samples]; // eq 7 and 8 applied to samples