From fbd8d66b7d113823c44b752cb41e159884f2f16e Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 7 Apr 2015 18:36:45 -0700 Subject: [PATCH] Progress bar for parameter load --- src/uas/QGCUASParamManager.cc | 2 + src/uas/QGCUASParamManager.h | 1 + src/uas/QGCUASParamManagerInterface.h | 1 + src/uas/UASParameterCommsMgr.cc | 10 ++++ src/uas/UASParameterCommsMgr.h | 2 + src/ui/toolbar/MainToolBar.cc | 13 +++++ src/ui/toolbar/MainToolBar.h | 72 ++++++++++----------------- src/ui/toolbar/MainToolBar.qml | 10 ++++ 8 files changed, 66 insertions(+), 45 deletions(-) diff --git a/src/uas/QGCUASParamManager.cc b/src/uas/QGCUASParamManager.cc index 36e9fb481..008512085 100644 --- a/src/uas/QGCUASParamManager.cc +++ b/src/uas/QGCUASParamManager.cc @@ -39,6 +39,8 @@ void QGCUASParamManager::connectToModelAndComms() this, SIGNAL(parameterStatusMsgUpdated(QString,int))); connect(¶mCommsMgr, SIGNAL(parameterListUpToDate()), this, SLOT(_parameterListUpToDate())); + + connect(¶mCommsMgr, SIGNAL(parameterListProgress(float)), this, SIGNAL(parameterListProgress(float))); // Pass along data model updates connect(¶mDataModel, SIGNAL(parameterUpdated(int, QString , QVariant )), diff --git a/src/uas/QGCUASParamManager.h b/src/uas/QGCUASParamManager.h index d10d2d79e..27853dd49 100644 --- a/src/uas/QGCUASParamManager.h +++ b/src/uas/QGCUASParamManager.h @@ -78,6 +78,7 @@ signals: void parameterStatusMsgUpdated(QString msg, int level); /** @brief We have received a complete list of all parameters onboard the MAV */ void parameterListUpToDate(); + void parameterListProgress(float percentComplete); /** @brief We've received an update of a parameter's value */ void parameterUpdated(int compId, QString paramName, QVariant value); diff --git a/src/uas/QGCUASParamManagerInterface.h b/src/uas/QGCUASParamManagerInterface.h index 2b1c41b74..a704fe6af 100644 --- a/src/uas/QGCUASParamManagerInterface.h +++ b/src/uas/QGCUASParamManagerInterface.h @@ -52,6 +52,7 @@ public slots: signals: void parameterStatusMsgUpdated(QString msg, int level); void parameterListUpToDate(); + void parameterListProgress(float percentComplete); void parameterUpdated(int compId, QString paramName, QVariant value); void pendingParamUpdate(int compId, const QString& paramName, QVariant value, bool isPending); }; diff --git a/src/uas/UASParameterCommsMgr.cc b/src/uas/UASParameterCommsMgr.cc index 94f06ec98..6f9256da6 100644 --- a/src/uas/UASParameterCommsMgr.cc +++ b/src/uas/UASParameterCommsMgr.cc @@ -447,6 +447,16 @@ void UASParameterCommsMgr::receivedParameterUpdate(int uas, int compId, int para compMissingReads->insert(i); } } + + int progDiv = paramCount / 100; + if ((paramId % progDiv) == 0) { + qDebug() << paramId << paramCount; + emit parameterListProgress((float)paramId / (float)paramCount); + } + if (paramId == paramCount) { + qDebug() << "List complete"; + emit parameterListProgress(0.0f); + } } diff --git a/src/uas/UASParameterCommsMgr.h b/src/uas/UASParameterCommsMgr.h index bb68ebebd..8721f51e3 100644 --- a/src/uas/UASParameterCommsMgr.h +++ b/src/uas/UASParameterCommsMgr.h @@ -63,6 +63,8 @@ signals: /** @brief We have received a complete list of all parameters onboard the MAV */ void parameterListUpToDate(); + + void parameterListProgress(float percentComplete); void parameterUpdateRequested(int component, const QString& parameter); void parameterUpdateRequestedById(int componentId, int paramId); diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc index c4951b5b4..f5409e93e 100644 --- a/src/ui/toolbar/MainToolBar.cc +++ b/src/ui/toolbar/MainToolBar.cc @@ -60,6 +60,7 @@ MainToolBar::MainToolBar(QWidget* parent) , _showMav(true) , _showMessages(true) , _showBattery(true) + , _progressBarValue(0.0f) , _rollDownMessages(0) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -312,6 +313,9 @@ void MainToolBar::_setActiveUAS(UASInterface* active) if(pUas) { disconnect(pUas, &UAS::satelliteCountChanged, this, &MainToolBar::_setSatelliteCount); } + QGCUASParamManagerInterface* paramMgr = _mav->getParamManager(); + Q_ASSERT(paramMgr); + disconnect(paramMgr, SIGNAL(parameterListProgress(float)), this, SLOT(_setProgressBarValue(float))); } // Connect new system _mav = active; @@ -338,6 +342,9 @@ void MainToolBar::_setActiveUAS(UASInterface* active) _setSatelliteCount(pUas->getSatelliteCount(), QString("")); connect(pUas, &UAS::satelliteCountChanged, this, &MainToolBar::_setSatelliteCount); } + QGCUASParamManagerInterface* paramMgr = _mav->getParamManager(); + Q_ASSERT(paramMgr); + connect(paramMgr, SIGNAL(parameterListProgress(float)), this, SLOT(_setProgressBarValue(float))); } // Let toolbar know about it emit mavPresentChanged(_mav != NULL); @@ -645,3 +652,9 @@ void MainToolBar::_setSatLoc(UASInterface*, int fix) emit satelliteLockChanged(_satelliteLock); } } + +void MainToolBar::_setProgressBarValue(float value) +{ + _progressBarValue = value; + emit progressBarValueChanged(value); +} diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h index 0a7ff584d..263e5763f 100644 --- a/src/ui/toolbar/MainToolBar.h +++ b/src/ui/toolbar/MainToolBar.h @@ -75,51 +75,31 @@ public: Q_INVOKABLE void onEnterMessageArea(int x, int y); Q_INVOKABLE QString getMavIconColor(); - Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged) - Q_PROPERTY(double batteryVoltage READ batteryVoltage NOTIFY batteryVoltageChanged) - Q_PROPERTY(double batteryPercent READ batteryPercent NOTIFY batteryPercentChanged) - Q_PROPERTY(ViewType_t currentView READ currentView NOTIFY currentViewChanged) - Q_PROPERTY(QStringList configList READ configList NOTIFY configListChanged) - Q_PROPERTY(bool systemArmed READ systemArmed NOTIFY systemArmedChanged) - Q_PROPERTY(unsigned int heartbeatTimeout READ heartbeatTimeout NOTIFY heartbeatTimeoutChanged) - Q_PROPERTY(QString currentMode READ currentMode NOTIFY currentModeChanged) - Q_PROPERTY(MessageType_t messageType READ messageType NOTIFY messageTypeChanged) - Q_PROPERTY(int newMessageCount READ newMessageCount NOTIFY newMessageCountChanged) - Q_PROPERTY(int messageCount READ messageCount NOTIFY messageCountChanged) - Q_PROPERTY(QString currentConfig READ currentConfig NOTIFY currentConfigChanged) - Q_PROPERTY(QString systemPixmap READ systemPixmap NOTIFY systemPixmapChanged) - Q_PROPERTY(int satelliteCount READ satelliteCount NOTIFY satelliteCountChanged) - Q_PROPERTY(QStringList connectedList READ connectedList NOTIFY connectedListChanged) - Q_PROPERTY(bool mavPresent READ mavPresent NOTIFY mavPresentChanged) - Q_PROPERTY(QString currentState READ currentState NOTIFY currentStateChanged) - Q_PROPERTY(int satelliteLock READ satelliteLock NOTIFY satelliteLockChanged) - Q_PROPERTY(bool showGPS READ showGPS NOTIFY showGPSChanged) - Q_PROPERTY(bool showMav READ showMav NOTIFY showMavChanged) - Q_PROPERTY(bool showMessages READ showMessages NOTIFY showMessagesChanged) - Q_PROPERTY(bool showBattery READ showBattery NOTIFY showBatteryChanged) - - int connectionCount () { return _connectionCount; } - double batteryVoltage () { return _batteryVoltage; } - double batteryPercent () { return _batteryPercent; } - ViewType_t currentView () { return _currentView; } - QStringList configList () { return _linkConfigurations; } - bool systemArmed () { return _systemArmed; } - unsigned int heartbeatTimeout () { return _currentHeartbeatTimeout; } - QString currentMode () { return _currentMode; } - MessageType_t messageType () { return _currentMessageType; } - int newMessageCount () { return _currentMessageCount; } - int messageCount () { return _messageCount; } - QString currentConfig () { return _currentConfig; } - QString systemPixmap () { return _systemPixmap; } - int satelliteCount () { return _satelliteCount; } - QStringList connectedList () { return _connectedList; } + Q_PROPERTY(int connectionCount MEMBER _connectionCount NOTIFY connectionCountChanged) + Q_PROPERTY(double batteryVoltage MEMBER _batteryVoltage NOTIFY batteryVoltageChanged) + Q_PROPERTY(double batteryPercent MEMBER _batteryPercent NOTIFY batteryPercentChanged) + Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged) + Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged) + Q_PROPERTY(bool systemArmed MEMBER _systemArmed NOTIFY systemArmedChanged) + Q_PROPERTY(unsigned int heartbeatTimeout MEMBER _currentHeartbeatTimeout NOTIFY heartbeatTimeoutChanged) + Q_PROPERTY(QString currentMode MEMBER _currentMode NOTIFY currentModeChanged) + Q_PROPERTY(MessageType_t messageType MEMBER _currentMessageType NOTIFY messageTypeChanged) + Q_PROPERTY(int newMessageCount MEMBER _currentMessageCount NOTIFY newMessageCountChanged) + Q_PROPERTY(int messageCount MEMBER _messageCount NOTIFY messageCountChanged) + Q_PROPERTY(QString currentConfig MEMBER _currentConfig NOTIFY currentConfigChanged) + Q_PROPERTY(QString systemPixmap MEMBER _systemPixmap NOTIFY systemPixmapChanged) + Q_PROPERTY(int satelliteCount MEMBER _satelliteCount NOTIFY satelliteCountChanged) + Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged) + Q_PROPERTY(bool mavPresent READ mavPresent NOTIFY mavPresentChanged) + Q_PROPERTY(QString currentState MEMBER _currentState NOTIFY currentStateChanged) + Q_PROPERTY(int satelliteLock MEMBER _satelliteLock NOTIFY satelliteLockChanged) + Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged) + Q_PROPERTY(bool showMav MEMBER _showMav NOTIFY showMavChanged) + Q_PROPERTY(bool showMessages MEMBER _showMessages NOTIFY showMessagesChanged) + Q_PROPERTY(bool showBattery MEMBER _showBattery NOTIFY showBatteryChanged) + Q_PROPERTY(float progressBarValue MEMBER _progressBarValue NOTIFY progressBarValueChanged) + bool mavPresent () { return _mav != NULL; } - QString currentState () { return _currentState; } - int satelliteLock () { return _satelliteLock; } - bool showGPS () { return _showGPS; } - bool showMav () { return _showMav; } - bool showMessages () { return _showMessages; } - bool showBattery () { return _showBattery; } void setCurrentView (int currentView); void viewStateChanged (const QString& key, bool value); @@ -147,6 +127,7 @@ signals: void showMavChanged (bool value); void showMessagesChanged (bool value); void showBatteryChanged (bool value); + void progressBarValueChanged (float value); private slots: void _setActiveUAS (UASInterface* active); @@ -166,7 +147,7 @@ private slots: void _setSatelliteCount (double val, QString name); void _leaveMessageView (); void _setSatLoc (UASInterface* uas, int fix); - + void _setProgressBarValue (float value); private: void _updateConnection (LinkInterface *disconnectedLink = NULL); @@ -203,6 +184,7 @@ private: bool _showMav; bool _showMessages; bool _showBattery; + float _progressBarValue; UASMessageViewRollDown* _rollDownMessages; }; diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 07095ae07..003eeabb7 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -526,5 +526,15 @@ Rectangle { } } + + // Progress bar + Rectangle { + readonly property int progressBarHeight: 3 + + y: parent.height - progressBarHeight + height: progressBarHeight + width: parent.width * mainToolBar.progressBarValue + color: qgcPal.text + } } -- 2.22.0