APMAirframeComponent.cc 2.5 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 12 13 14

/// @file
///     @author Don Gagne <don@thegagnes.com>

#include "APMAirframeComponent.h"
15
#include "ArduCopterFirmwarePlugin.h"
16

17
APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
18
    : VehicleComponent(vehicle, autopilot, parent)
19
    , _requiresFrameSetup(false)
20
    , _name("Airframe")
21
{
22 23 24 25 26 27 28
    if (qobject_cast<ArduCopterFirmwarePlugin*>(_vehicle->firmwarePlugin()) != NULL) {
        _requiresFrameSetup = true;
        MAV_TYPE vehicleType = vehicle->vehicleType();
        if (vehicleType == MAV_TYPE_TRICOPTER || vehicleType == MAV_TYPE_HELICOPTER) {
            _requiresFrameSetup = false;
        }
    }
29 30 31 32 33 34 35 36 37 38
}

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

QString APMAirframeComponent::description(void) const
{
    return tr("The Airframe Component is used to select the airframe which matches your vehicle. "
nopeppermint's avatar
nopeppermint committed
39
              "This will in turn set up the various tuning values for flight parameters.");
40 41 42 43
}

QString APMAirframeComponent::iconResource(void) const
{
44
    return QStringLiteral("/qmlimages/AirframeComponentIcon.png");
45 46 47 48
}

bool APMAirframeComponent::requiresSetup(void) const
{
49
    return _requiresFrameSetup;
50 51 52 53
}

bool APMAirframeComponent::setupComplete(void) const
{
54
    if (_requiresFrameSetup) {
55
        return _autopilot->getParameterFact(FactSystem::defaultComponentId, QStringLiteral("FRAME"))->rawValue().toInt() >= 0;
56 57 58
    } else {
        return true;
    }
59 60 61 62
}

QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const
{
63 64
    QStringList list;

65
    if (_requiresFrameSetup) {
66
        list << QStringLiteral("FRAME");
67 68 69
    }

    return list;
70 71 72 73
}

QUrl APMAirframeComponent::setupSource(void) const
{
74
    if (_requiresFrameSetup) {
75
        return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMAirframeComponent.qml"));
76 77 78
    } else {
        return QUrl();
    }
79 80 81 82
}

QUrl APMAirframeComponent::summaryQmlSource(void) const
{
83
    if (_requiresFrameSetup) {
84
        return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMAirframeComponentSummary.qml"));
85 86 87
    } else {
        return QUrl();
    }
88 89 90 91 92 93
}

QString APMAirframeComponent::prerequisiteSetup(void) const
{
    return QString();
}