From da4dc0e935b290d3cadfbe83a4f84d639a7edb72 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 5 Apr 2015 00:37:20 +0200 Subject: [PATCH] OP-1814 Reset consumed energy from PFD --- ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml | 7 +++++++ ground/openpilotgcs/share/openpilotgcs/pfd/default/Panels.qml | 7 +++++++ ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp | 11 +++++++++++ ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml index 712fb3656..9c0990530 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml @@ -355,6 +355,13 @@ Item { Rectangle { anchors.fill: parent + MouseArea { + id: reset_consumed_energy_mouseArea; + anchors.fill: parent; + cursorShape: Qt.PointingHandCursor; + onClicked: qmlWidget.resetConsumedEnergy(); + } + // Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" : (FlightBatteryState.EstimatedFlightTime <= 60 ? "red": info.batColors[SystemAlarms.Alarm_Battery])) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Panels.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Panels.qml index f8173c9ad..b150b8807 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Panels.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Panels.qml @@ -480,6 +480,13 @@ Item { Rectangle { anchors.fill: parent + MouseArea { + id: reset_panel_consumed_energy_mouseArea; + anchors.fill: parent; + cursorShape: Qt.PointingHandCursor; + onClicked: qmlWidget.resetConsumedEnergy(); + } + // Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" : (FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[SystemAlarms.Alarm_Battery])) diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp index 6a0c650ea..616328091 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp @@ -18,6 +18,7 @@ #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" +#include "flightbatterysettings.h" #include "utils/svgimageprovider.h" #ifdef USE_OSG #include "osgearth.h" @@ -81,6 +82,8 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWindow *parent) : ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); + m_uavoManager = pm->getObject(); + Q_ASSERT(m_uavoManager); foreach(const QString &objectName, objectsToExport) { UAVObject *object = objManager->getObject(objectName); @@ -124,6 +127,14 @@ void PfdQmlGadgetWidget::setQmlFile(QString fn) } } +void PfdQmlGadgetWidget::resetConsumedEnergy() +{ + FlightBatterySettings *mBatterySettings = FlightBatterySettings::GetInstance(m_uavoManager); + + mBatterySettings->setResetConsumedEnergy(true); + mBatterySettings->setData(mBatterySettings->getData()); +} + void PfdQmlGadgetWidget::setEarthFile(QString arg) { if (m_earthFile != arg) { diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h index 222fb8ce4..b971942e0 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h @@ -18,6 +18,7 @@ #define PFDQMLGADGETWIDGET_H_ #include "pfdqmlgadgetconfiguration.h" +#include "uavobjectmanager.h" #include class PfdQmlGadgetWidget : public QQuickView { @@ -84,6 +85,8 @@ public: return m_altitude; } + Q_INVOKABLE void resetConsumedEnergy(); + public slots: void setEarthFile(QString arg); void setTerrainEnabled(bool arg); @@ -119,6 +122,7 @@ protected: void mouseReleaseEvent(QMouseEvent *event); private: + UAVObjectManager *m_uavoManager; QString m_qmlFileName; QString m_earthFile; bool m_openGLEnabled; -- 2.11.4.GIT