ViewWidgetController.cc 1.28 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 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.
 *
 ****************************************************************************/

10 11

#include "ViewWidgetController.h"
12
#include "MultiVehicleManager.h"
13
#include "UAS.h"
14
#include "QGCApplication.h"
15 16

ViewWidgetController::ViewWidgetController(void) :
Don Gagne's avatar
Don Gagne committed
17 18
	_autopilot(NULL),
	_uas(NULL)
19
{
20
    connect(qgcApp()->toolbox()->multiVehicleManager(), &MultiVehicleManager::parameterReadyVehicleAvailableChanged, this, &ViewWidgetController::_vehicleAvailable);
21 22
}

23
void ViewWidgetController::_vehicleAvailable(bool available)
24
{
25 26 27 28 29 30 31
    if (_uas) {
        _uas = NULL;
        _autopilot = NULL;
        emit pluginDisconnected();
    }
    
    if (available) {
32
        Vehicle* vehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle();
33 34 35 36 37
        
        _uas = vehicle->uas();
        _autopilot = vehicle->autopilotPlugin();
        emit pluginConnected(QVariant::fromValue(_autopilot));
    }
38
}
DonLakeFlyer's avatar
DonLakeFlyer committed
39 40

void ViewWidgetController::checkForVehicle(void)
41
{
42
    _vehicleAvailable(qgcApp()->toolbox()->multiVehicleManager()->activeVehicle());
43
}