Commit 360bfab5 authored by Don Gagne's avatar Don Gagne

parent 74a0e0de
......@@ -33,22 +33,23 @@ const char* PlanMasterController::kJsonGeoFenceObjectKey = "geoFence";
const char* PlanMasterController::kJsonRallyPointsObjectKey = "rallyPoints";
PlanMasterController::PlanMasterController(QObject* parent)
: QObject (parent)
, _multiVehicleMgr (qgcApp()->toolbox()->multiVehicleManager())
, _controllerVehicle (new Vehicle(
: QObject (parent)
, _multiVehicleMgr (qgcApp()->toolbox()->multiVehicleManager())
, _controllerVehicle (new Vehicle(
static_cast<MAV_AUTOPILOT>(qgcApp()->toolbox()->settingsManager()->appSettings()->offlineEditingFirmwareType()->rawValue().toInt()),
static_cast<MAV_TYPE>(qgcApp()->toolbox()->settingsManager()->appSettings()->offlineEditingVehicleType()->rawValue().toInt()),
qgcApp()->toolbox()->firmwarePluginManager()))
, _managerVehicle (_controllerVehicle)
, _flyView (true)
, _offline (true)
, _missionController (this)
, _geoFenceController (this)
, _rallyPointController (this)
, _loadGeoFence (false)
, _loadRallyPoints (false)
, _sendGeoFence (false)
, _sendRallyPoints (false)
, _managerVehicle (_controllerVehicle)
, _flyView (true)
, _offline (true)
, _missionController (this)
, _geoFenceController (this)
, _rallyPointController (this)
, _loadGeoFence (false)
, _loadRallyPoints (false)
, _sendGeoFence (false)
, _sendRallyPoints (false)
, _deleteWhenSendCompleted (false)
{
connect(&_missionController, &MissionController::dirtyChanged, this, &PlanMasterController::dirtyChanged);
connect(&_geoFenceController, &GeoFenceController::dirtyChanged, this, &PlanMasterController::dirtyChanged);
......@@ -86,9 +87,10 @@ void PlanMasterController::start(bool flyView)
#endif
}
void PlanMasterController::startStaticActiveVehicle(Vehicle* vehicle)
void PlanMasterController::startStaticActiveVehicle(Vehicle* vehicle, bool deleteWhenSendCompleted)
{
_flyView = true;
_deleteWhenSendCompleted = deleteWhenSendCompleted;
_missionController.start(_flyView);
_geoFenceController.start(_flyView);
_rallyPointController.start(_flyView);
......@@ -264,6 +266,9 @@ void PlanMasterController::_sendGeoFenceComplete(void)
void PlanMasterController::_sendRallyPointsComplete(void)
{
qCDebug(PlanMasterControllerLog) << "PlanMasterController::sendToVehicle Rally Point send complete";
if (_deleteWhenSendCompleted) {
this->deleteLater();
}
}
void PlanMasterController::sendToVehicle(void)
......@@ -535,10 +540,9 @@ void PlanMasterController::sendPlanToVehicle(Vehicle* vehicle, const QString& fi
{
// Use a transient PlanMasterController to accomplish this
PlanMasterController* controller = new PlanMasterController();
controller->startStaticActiveVehicle(vehicle);
controller->startStaticActiveVehicle(vehicle, true /* deleteWhenSendCompleted */);
controller->loadFromFile(filename);
controller->sendToVehicle();
delete controller;
}
void PlanMasterController::_showPlanFromManagerVehicle(void)
......
......@@ -49,7 +49,8 @@ public:
Q_INVOKABLE void start(bool flyView);
/// Starts the controller using a single static active vehicle. Will not track global active vehicle changes.
Q_INVOKABLE void startStaticActiveVehicle(Vehicle* vehicle);
/// @param deleteWhenSendCmplete The PlanMasterController object should be deleted after the first send is completed.
Q_INVOKABLE void startStaticActiveVehicle(Vehicle* vehicle, bool deleteWhenSendCompleted = false);
/// Determines if the plan has all data needed to be saved or sent to the vehicle. Currently the only case where this
/// would return false is when it is still waiting on terrain data to determine correct altitudes.
......@@ -127,5 +128,6 @@ private:
bool _sendGeoFence;
bool _sendRallyPoints;
QString _currentPlanFile;
bool _deleteWhenSendCompleted;
};
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