APMTuningComponent.cc 2.28 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"
Don Gagne's avatar
Don Gagne committed
14 15

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

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

QString APMTuningComponent::description(void) const
{
    return tr("The Tuning Component is used to tune the flight characteristics of the Vehicle.");
}

QString APMTuningComponent::iconResource(void) const
{
33
    return QStringLiteral("/qmlimages/TuningComponentIcon.png");
Don Gagne's avatar
Don Gagne committed
34 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
}

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
62
            // Older firmwares do not have CH9_OPT, we don't support Tuning on older firmwares
63
            if (_autopilot->parameterExists(-1, QStringLiteral("CH9_OPT"))) {
64
                qmlFile = QStringLiteral("qrc:/qml/APMTuningComponentCopter.qml");
Don Gagne's avatar
Don Gagne committed
65
            }
Don Gagne's avatar
Don Gagne committed
66 67
            break;
        default:
Don Gagne's avatar
Don Gagne committed
68
            // No tuning panel
Don Gagne's avatar
Don Gagne committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
            break;
    }

    return QUrl::fromUserInput(qmlFile);
}

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

QString APMTuningComponent::prerequisiteSetup(void) const
{
    APMAutoPilotPlugin* plugin = dynamic_cast<APMAutoPilotPlugin*>(_autopilot);
    Q_ASSERT(plugin);

    if (!plugin->airframeComponent()->setupComplete()) {
        return plugin->airframeComponent()->name();
    }

    return QString();
}