diff --git a/src/MissionManager/RallyPointController.cc b/src/MissionManager/RallyPointController.cc index bc88fdce93efa183f0aa5fa6cf744dc5c18f419e..24c0cde56687e227e832bf48edd6f1c5dbfc038e 100644 --- a/src/MissionManager/RallyPointController.cc +++ b/src/MissionManager/RallyPointController.cc @@ -300,10 +300,8 @@ bool RallyPointController::showPlanFromManagerVehicle (void) qCDebug(RallyPointControllerLog) << "showPlanFromManagerVehicle: syncInProgress wait for signal"; return true; } else { - // Fake a _loadComplete with the current items - qCDebug(RallyPointControllerLog) << "showPlanFromManagerVehicle: sync complete simulate signal"; + qCDebug(RallyPointControllerLog) << "showPlanFromManagerVehicle: sync complete"; _itemsRequested = true; - _managerLoadComplete(_rallyPointManager->points()); return false; } } diff --git a/src/MissionManager/RallyPointManager.cc b/src/MissionManager/RallyPointManager.cc index 072ac4ae0d8d96157b507197d815e224be5d843d..4e2956953bdf79362477e9407ffabcc9c6da1137 100644 --- a/src/MissionManager/RallyPointManager.cc +++ b/src/MissionManager/RallyPointManager.cc @@ -8,6 +8,7 @@ ****************************************************************************/ #include "RallyPointManager.h" +#include "ParameterManager.h" #include "Vehicle.h" QGC_LOGGING_CATEGORY(RallyPointManagerLog, "RallyPointManagerLog") @@ -15,10 +16,17 @@ QGC_LOGGING_CATEGORY(RallyPointManagerLog, "RallyPointManagerLog") RallyPointManager::RallyPointManager(Vehicle* vehicle) : QObject(vehicle) , _vehicle(vehicle) + , _planManager (vehicle, MAV_MISSION_TYPE_RALLY) +// , _firstParamLoadComplete (false) { - + connect(&_planManager, &PlanManager::inProgressChanged, this, &RallyPointManager::inProgressChanged); + connect(&_planManager, &PlanManager::error, this, &RallyPointManager::error); + connect(&_planManager, &PlanManager::removeAllComplete, this, &RallyPointManager::removeAllComplete); + connect(&_planManager, &PlanManager::sendComplete, this, &RallyPointManager::sendComplete); + connect(&_planManager, &PlanManager::newMissionItemsAvailable, this, &RallyPointManager::_planManagerLoadComplete); } + RallyPointManager::~RallyPointManager() { @@ -33,24 +41,65 @@ void RallyPointManager::_sendError(ErrorCode_t errorCode, const QString& errorMs void RallyPointManager::loadFromVehicle(void) { - // No support in generic vehicle - emit loadComplete(QList()); + _planManager.loadFromVehicle(); } void RallyPointManager::sendToVehicle(const QList& rgPoints) { - // No support in generic vehicle - Q_UNUSED(rgPoints); - emit sendComplete(false /* error */); + QList rallyItems; + + for (int i=0; icapabilityBits() & MAV_PROTOCOL_CAPABILITY_MISSION_RALLY) && (_vehicle->maxProtoVersion() >= 200); } + +void RallyPointManager::_planManagerLoadComplete(bool removeAllRequested) +{ + _rgPoints.clear(); + + Q_UNUSED(removeAllRequested); + + const QList& rallyItems = _planManager.missionItems(); + + for (int i=0; icommand(); + + if (command == MAV_CMD_NAV_RALLY_POINT) { + _rgPoints.append(QGeoCoordinate(item->param5(), item->param6(), item->param7())); + + + } else { + qCDebug(RallyPointManagerLog) << "RallyPointManager load: Unsupported command %1" << item->command(); + break; + } + } + + + emit loadComplete(_rgPoints); +} diff --git a/src/MissionManager/RallyPointManager.h b/src/MissionManager/RallyPointManager.h index cf9e1747d502c331912383aa726f74fd84743884..dc49edb82549b42049cc12b0c852d4eab46231a9 100644 --- a/src/MissionManager/RallyPointManager.h +++ b/src/MissionManager/RallyPointManager.h @@ -14,8 +14,10 @@ #include #include "QGCLoggingCategory.h" +#include "PlanManager.h" class Vehicle; +class PlanManager; Q_DECLARE_LOGGING_CATEGORY(RallyPointManagerLog) @@ -66,10 +68,14 @@ signals: void removeAllComplete (bool error); void sendComplete (bool error); +private slots: + void _planManagerLoadComplete (bool removeAllRequested); + protected: void _sendError(ErrorCode_t errorCode, const QString& errorMsg); Vehicle* _vehicle; + PlanManager _planManager; QList _rgPoints; };