AirspaceVehicleManager.cc 1.55 KB
Newer Older
1 2
/****************************************************************************
 *
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10
 *
 * 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)
{
19
    qCDebug(AirspaceManagementLog) << "Instatiating AirspaceVehicleManager";
Gus Grubba's avatar
Gus Grubba committed
20
    connect(&_vehicle, &Vehicle::armedChanged,           this, &AirspaceVehicleManager::_vehicleArmedChanged);
21
    connect(&_vehicle, &Vehicle::mavlinkMessageReceived, this, &AirspaceVehicleManager::vehicleMavlinkMessageReceived);
22 23
}

24
void AirspaceVehicleManager::_vehicleArmedChanged(bool armed)
25 26
{
    if (armed) {
27
        qCDebug(AirspaceManagementLog) << "Starting telemetry";
28 29 30
        startTelemetryStream();
        _vehicleWasInMissionMode = _vehicle.flightMode() == _vehicle.missionFlightMode();
    } else {
31
        qCDebug(AirspaceManagementLog) << "Stopping telemetry";
32 33 34 35 36 37 38 39 40
        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();
        }
    }
}