AirspaceVehicleManager.cc 1.31 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/****************************************************************************
 *
 *   (c) 2017 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/


Gus Grubba's avatar
Gus Grubba committed
11 12 13
#include "AirspaceManager.h"
#include "Vehicle.h"
#include "MissionItem.h"
14

15
AirspaceVehicleManager::AirspaceVehicleManager(const Vehicle& vehicle)
16 17
    : _vehicle(vehicle)
{
Gus Grubba's avatar
Gus Grubba committed
18
    connect(&_vehicle, &Vehicle::armedChanged,           this, &AirspaceVehicleManager::_vehicleArmedChanged);
19
    connect(&_vehicle, &Vehicle::mavlinkMessageReceived, this, &AirspaceVehicleManager::vehicleMavlinkMessageReceived);
20 21
}

22
void AirspaceVehicleManager::_vehicleArmedChanged(bool armed)
23 24 25 26 27 28 29 30 31 32 33 34 35 36
{
    if (armed) {
        startTelemetryStream();
        _vehicleWasInMissionMode = _vehicle.flightMode() == _vehicle.missionFlightMode();
    } else {
        stopTelemetryStream();
        // end the flight if we were in mission mode during arming or disarming
        // TODO: needs to be improved. for instance if we do RTL and then want to continue the mission...
        if (_vehicleWasInMissionMode || _vehicle.flightMode() == _vehicle.missionFlightMode()) {
            endFlight();
        }
    }
}