APMTuningComponent.cc 2.03 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9 10 11 12


#include "APMTuningComponent.h"
#include "APMAutoPilotPlugin.h"
13
#include "APMAirframeComponent.h"
14
#include "ParameterManager.h"
Don Gagne's avatar
Don Gagne committed
15 16

APMTuningComponent::APMTuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
17
    : VehicleComponent(vehicle, autopilot, parent)
Don Gagne's avatar
Don Gagne committed
18 19 20 21 22 23 24 25 26 27 28
    , _name("Tuning")
{
}

QString APMTuningComponent::name(void) const
{
    return _name;
}

QString APMTuningComponent::description(void) const
{
29
    return tr("Tuning Setup is used to tune the flight characteristics of the Vehicle.");
Don Gagne's avatar
Don Gagne committed
30 31 32 33
}

QString APMTuningComponent::iconResource(void) const
{
34
    return QStringLiteral("/qmlimages/TuningComponentIcon.png");
Don Gagne's avatar
Don Gagne committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
}

bool APMTuningComponent::requiresSetup(void) const
{
    return false;
}

bool APMTuningComponent::setupComplete(void) const
{
    return true;
}

QStringList APMTuningComponent::setupCompleteChangedTriggerList(void) const
{
    return QStringList();
}

QUrl APMTuningComponent::setupSource(void) const
{
    QString qmlFile;

    switch (_vehicle->vehicleType()) {
        case MAV_TYPE_QUADROTOR:
        case MAV_TYPE_COAXIAL:
        case MAV_TYPE_HELICOPTER:
        case MAV_TYPE_HEXAROTOR:
        case MAV_TYPE_OCTOROTOR:
        case MAV_TYPE_TRICOPTER:
Don Gagne's avatar
Don Gagne committed
63
            // Older firmwares do not have CH9_OPT, we don't support Tuning on older firmwares
64
            if (_vehicle->parameterManager()->parameterExists(-1, QStringLiteral("CH9_OPT"))) {
65
                qmlFile = QStringLiteral("qrc:/qml/APMTuningComponentCopter.qml");
Don Gagne's avatar
Don Gagne committed
66
            }
Don Gagne's avatar
Don Gagne committed
67 68
            break;
        default:
Don Gagne's avatar
Don Gagne committed
69
            // No tuning panel
Don Gagne's avatar
Don Gagne committed
70 71 72 73 74 75 76 77 78 79
            break;
    }

    return QUrl::fromUserInput(qmlFile);
}

QUrl APMTuningComponent::summaryQmlSource(void) const
{
    return QUrl();
}