AirspaceVehicleManager.cc 1.34 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
#include "AirspaceManager.h"
12
#include "AirspaceVehicleManager.h"
Gus Grubba's avatar
Gus Grubba committed
13 14
#include "Vehicle.h"
#include "MissionItem.h"
15

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

23
void AirspaceVehicleManager::_vehicleArmedChanged(bool armed)
24 25 26 27 28 29 30 31 32 33 34 35 36 37
{
    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();
        }
    }
}