Commit c1a14c56 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5035 from DonLakeFlyer/MissinProgress

Progress bar for mission upload/download
parents 97ac36f9 2157ba2a
...@@ -57,6 +57,7 @@ MissionController::MissionController(QObject *parent) ...@@ -57,6 +57,7 @@ MissionController::MissionController(QObject *parent)
, _surveyMissionItemName(tr("Survey")) , _surveyMissionItemName(tr("Survey"))
, _fwLandingMissionItemName(tr("Fixed Wing Landing")) , _fwLandingMissionItemName(tr("Fixed Wing Landing"))
, _appSettings(qgcApp()->toolbox()->settingsManager()->appSettings()) , _appSettings(qgcApp()->toolbox()->settingsManager()->appSettings())
, _progressPct(0)
{ {
_resetMissionFlightStatus(); _resetMissionFlightStatus();
} }
...@@ -1307,6 +1308,7 @@ void MissionController::activeVehicleBeingRemoved(void) ...@@ -1307,6 +1308,7 @@ void MissionController::activeVehicleBeingRemoved(void)
disconnect(missionManager, &MissionManager::newMissionItemsAvailable, this, &MissionController::_newMissionItemsAvailableFromVehicle); disconnect(missionManager, &MissionManager::newMissionItemsAvailable, this, &MissionController::_newMissionItemsAvailableFromVehicle);
disconnect(missionManager, &MissionManager::inProgressChanged, this, &MissionController::_inProgressChanged); disconnect(missionManager, &MissionManager::inProgressChanged, this, &MissionController::_inProgressChanged);
disconnect(missionManager, &MissionManager::progressPct, this, &MissionController::_progressPctChanged);
disconnect(missionManager, &MissionManager::currentIndexChanged, this, &MissionController::_currentMissionIndexChanged); disconnect(missionManager, &MissionManager::currentIndexChanged, this, &MissionController::_currentMissionIndexChanged);
disconnect(missionManager, &MissionManager::lastCurrentIndexChanged, this, &MissionController::resumeMissionIndexChanged); disconnect(missionManager, &MissionManager::lastCurrentIndexChanged, this, &MissionController::resumeMissionIndexChanged);
disconnect(missionManager, &MissionManager::resumeMissionReady, this, &MissionController::resumeMissionReady); disconnect(missionManager, &MissionManager::resumeMissionReady, this, &MissionController::resumeMissionReady);
...@@ -1334,6 +1336,7 @@ void MissionController::activeVehicleSet(Vehicle* activeVehicle) ...@@ -1334,6 +1336,7 @@ void MissionController::activeVehicleSet(Vehicle* activeVehicle)
connect(missionManager, &MissionManager::newMissionItemsAvailable, this, &MissionController::_newMissionItemsAvailableFromVehicle); connect(missionManager, &MissionManager::newMissionItemsAvailable, this, &MissionController::_newMissionItemsAvailableFromVehicle);
connect(missionManager, &MissionManager::inProgressChanged, this, &MissionController::_inProgressChanged); connect(missionManager, &MissionManager::inProgressChanged, this, &MissionController::_inProgressChanged);
connect(missionManager, &MissionManager::progressPct, this, &MissionController::_progressPctChanged);
connect(missionManager, &MissionManager::currentIndexChanged, this, &MissionController::_currentMissionIndexChanged); connect(missionManager, &MissionManager::currentIndexChanged, this, &MissionController::_currentMissionIndexChanged);
connect(missionManager, &MissionManager::lastCurrentIndexChanged, this, &MissionController::resumeMissionIndexChanged); connect(missionManager, &MissionManager::lastCurrentIndexChanged, this, &MissionController::resumeMissionIndexChanged);
connect(missionManager, &MissionManager::resumeMissionReady, this, &MissionController::resumeMissionReady); connect(missionManager, &MissionManager::resumeMissionReady, this, &MissionController::resumeMissionReady);
...@@ -1610,3 +1613,11 @@ void MissionController::clearCameraPoints(void) ...@@ -1610,3 +1613,11 @@ void MissionController::clearCameraPoints(void)
{ {
_cameraPoints.clearAndDeleteContents(); _cameraPoints.clearAndDeleteContents();
} }
void MissionController::_progressPctChanged(double progressPct)
{
if (!qFuzzyCompare(progressPct, _progressPct)) {
_progressPct = progressPct;
emit progressPctChanged(progressPct);
}
}
...@@ -66,6 +66,8 @@ public: ...@@ -66,6 +66,8 @@ public:
Q_PROPERTY(QStringList complexMissionItemNames READ complexMissionItemNames NOTIFY complexMissionItemNamesChanged) Q_PROPERTY(QStringList complexMissionItemNames READ complexMissionItemNames NOTIFY complexMissionItemNamesChanged)
Q_PROPERTY(QGeoCoordinate plannedHomePosition READ plannedHomePosition NOTIFY plannedHomePositionChanged) Q_PROPERTY(QGeoCoordinate plannedHomePosition READ plannedHomePosition NOTIFY plannedHomePositionChanged)
Q_PROPERTY(double progressPct READ progressPct NOTIFY progressPctChanged)
Q_PROPERTY(int resumeMissionIndex READ resumeMissionIndex NOTIFY resumeMissionIndexChanged) Q_PROPERTY(int resumeMissionIndex READ resumeMissionIndex NOTIFY resumeMissionIndexChanged)
Q_PROPERTY(double missionDistance READ missionDistance NOTIFY missionDistanceChanged) Q_PROPERTY(double missionDistance READ missionDistance NOTIFY missionDistanceChanged)
...@@ -129,6 +131,7 @@ public: ...@@ -129,6 +131,7 @@ public:
QmlObjectListModel* cameraPoints (void) { return &_cameraPoints; } QmlObjectListModel* cameraPoints (void) { return &_cameraPoints; }
QStringList complexMissionItemNames (void) const; QStringList complexMissionItemNames (void) const;
QGeoCoordinate plannedHomePosition (void) const; QGeoCoordinate plannedHomePosition (void) const;
double progressPct (void) const { return _progressPct; }
/// Returns the item index two which a mission should be resumed. -1 indicates resume mission not available. /// Returns the item index two which a mission should be resumed. -1 indicates resume mission not available.
int resumeMissionIndex(void) const; int resumeMissionIndex(void) const;
...@@ -161,6 +164,7 @@ signals: ...@@ -161,6 +164,7 @@ signals:
void batteryChangePointChanged(int batteryChangePoint); void batteryChangePointChanged(int batteryChangePoint);
void batteriesRequiredChanged(int batteriesRequired); void batteriesRequiredChanged(int batteriesRequired);
void plannedHomePositionChanged(QGeoCoordinate plannedHomePosition); void plannedHomePositionChanged(QGeoCoordinate plannedHomePosition);
void progressPctChanged(double progressPct);
private slots: private slots:
void _newMissionItemsAvailableFromVehicle(bool removeAllRequested); void _newMissionItemsAvailableFromVehicle(bool removeAllRequested);
...@@ -172,6 +176,7 @@ private slots: ...@@ -172,6 +176,7 @@ private slots:
void _recalcMissionFlightStatus(void); void _recalcMissionFlightStatus(void);
void _updateContainsItems(void); void _updateContainsItems(void);
void _cameraFeedback(QGeoCoordinate imageCoordinate, int index); void _cameraFeedback(QGeoCoordinate imageCoordinate, int index);
void _progressPctChanged(double progressPct);
private: private:
void _init(void); void _init(void);
...@@ -216,6 +221,7 @@ private: ...@@ -216,6 +221,7 @@ private:
QString _surveyMissionItemName; QString _surveyMissionItemName;
QString _fwLandingMissionItemName; QString _fwLandingMissionItemName;
AppSettings* _appSettings; AppSettings* _appSettings;
double _progressPct;
static const char* _settingsGroup; static const char* _settingsGroup;
......
...@@ -49,6 +49,7 @@ void MissionManager::_writeMissionItemsWorker(void) ...@@ -49,6 +49,7 @@ void MissionManager::_writeMissionItemsWorker(void)
_lastMissionRequest = -1; _lastMissionRequest = -1;
emit newMissionItemsAvailable(_missionItems.count() == 0); emit newMissionItemsAvailable(_missionItems.count() == 0);
emit progressPct(0);
qCDebug(MissionManagerLog) << "writeMissionItems count:" << _missionItems.count(); qCDebug(MissionManagerLog) << "writeMissionItems count:" << _missionItems.count();
...@@ -500,6 +501,8 @@ void MissionManager::_handleMissionItem(const mavlink_message_t& message, bool m ...@@ -500,6 +501,8 @@ void MissionManager::_handleMissionItem(const mavlink_message_t& message, bool m
_startAckTimeout(AckMissionItem); _startAckTimeout(AckMissionItem);
return; return;
} }
emit progressPct((double)seq / (double)_missionItems.count());
_retryCount = 0; _retryCount = 0;
if (_itemIndicesToRead.count() == 0) { if (_itemIndicesToRead.count() == 0) {
...@@ -532,6 +535,8 @@ void MissionManager::_handleMissionRequest(const mavlink_message_t& message, boo ...@@ -532,6 +535,8 @@ void MissionManager::_handleMissionRequest(const mavlink_message_t& message, boo
return; return;
} }
emit progressPct((double)missionRequest.seq / (double)_missionItems.count());
_lastMissionRequest = missionRequest.seq; _lastMissionRequest = missionRequest.seq;
if (!_itemIndicesToWrite.contains(missionRequest.seq)) { if (!_itemIndicesToWrite.contains(missionRequest.seq)) {
qCDebug(MissionManagerLog) << "_handleMissionRequest sequence number requested which has already been sent, sending again:" << missionRequest.seq; qCDebug(MissionManagerLog) << "_handleMissionRequest sequence number requested which has already been sent, sending again:" << missionRequest.seq;
...@@ -857,6 +862,8 @@ QString MissionManager::_missionResultToString(MAV_MISSION_RESULT result) ...@@ -857,6 +862,8 @@ QString MissionManager::_missionResultToString(MAV_MISSION_RESULT result)
void MissionManager::_finishTransaction(bool success) void MissionManager::_finishTransaction(bool success)
{ {
emit progressPct(1);
if (!success && _transactionInProgress == TransactionRead) { if (!success && _transactionInProgress == TransactionRead) {
// Read from vehicle failed, clear partial list // Read from vehicle failed, clear partial list
_clearAndDeleteMissionItems(); _clearAndDeleteMissionItems();
...@@ -907,6 +914,8 @@ void MissionManager::_removeAllWorker(void) ...@@ -907,6 +914,8 @@ void MissionManager::_removeAllWorker(void)
qCDebug(MissionManagerLog) << "_removeAllWorker"; qCDebug(MissionManagerLog) << "_removeAllWorker";
emit progressPct(0);
_dedicatedLink = _vehicle->priorityLink(); _dedicatedLink = _vehicle->priorityLink();
mavlink_msg_mission_clear_all_pack_chan(qgcApp()->toolbox()->mavlinkProtocol()->getSystemId(), mavlink_msg_mission_clear_all_pack_chan(qgcApp()->toolbox()->mavlinkProtocol()->getSystemId(),
qgcApp()->toolbox()->mavlinkProtocol()->getComponentId(), qgcApp()->toolbox()->mavlinkProtocol()->getComponentId(),
......
...@@ -85,6 +85,7 @@ signals: ...@@ -85,6 +85,7 @@ signals:
void lastCurrentIndexChanged(int lastCurrentIndex); void lastCurrentIndexChanged(int lastCurrentIndex);
void resumeMissionReady(void); void resumeMissionReady(void);
void cameraFeedback(QGeoCoordinate imageCoordinate, int index); void cameraFeedback(QGeoCoordinate imageCoordinate, int index);
void progressPct(double progressPercentPct);
private slots: private slots:
void _mavlinkMessageReceived(const mavlink_message_t& message); void _mavlinkMessageReceived(const mavlink_message_t& message);
......
...@@ -57,6 +57,8 @@ Rectangle { ...@@ -57,6 +57,8 @@ Rectangle {
property real _missionTime: _missionValid ? missionTime : NaN property real _missionTime: _missionValid ? missionTime : NaN
property int _batteryChangePoint: _controllerValid ? planMasterController.missionController.batteryChangePoint : -1 property int _batteryChangePoint: _controllerValid ? planMasterController.missionController.batteryChangePoint : -1
property int _batteriesRequired: _controllerValid ? planMasterController.missionController.batteriesRequired : -1 property int _batteriesRequired: _controllerValid ? planMasterController.missionController.batteriesRequired : -1
property real _controllerProgressPct: _controllerValid ? planMasterController.missionController.progressPct : 0
property bool _syncInProgress: _controllerValid ? planMasterController.missionController.syncInProgress : false
property string _distanceText: isNaN(_distance) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_distance).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString property string _distanceText: isNaN(_distance) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_distance).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString
property string _altDifferenceText: isNaN(_altDifference) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_altDifference).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString property string _altDifferenceText: isNaN(_altDifference) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_altDifference).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString
...@@ -110,6 +112,32 @@ Rectangle { ...@@ -110,6 +112,32 @@ Rectangle {
} }
} }
// Progress bar
on_ControllerProgressPctChanged: {
if (_controllerProgressPct === 1) {
resetProgressTimer.start()
} else if (_controllerProgressPct > 0) {
progressBar.visible = true
}
}
Timer {
id: resetProgressTimer
interval: 1000
onTriggered: progressBar.visible = false
}
Rectangle {
id: progressBar
anchors.left: parent.left
anchors.bottom: parent.bottom
height: 2
width: _controllerProgressPct * parent.width
color: qgcPal.colorGreen
visible: false
}
RowLayout { RowLayout {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
......
...@@ -211,5 +211,4 @@ Rectangle { ...@@ -211,5 +211,4 @@ Rectangle {
width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0 width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0
color: qgcPal.colorGreen color: qgcPal.colorGreen
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment