APMAirframeComponent.cc 2.4 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
#include "APMAirframeComponent.h"
11
#include "ArduCopterFirmwarePlugin.h"
12
#include "ParameterManager.h"
13

14
const char* APMAirframeComponent::_frameClassParam = "FRAME_CLASS";
15

16
APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
17 18
    : VehicleComponent      (vehicle, autopilot, parent)
    , _requiresFrameSetup   (false)
19
    , _name                 (tr("Frame"))
20
{
21 22 23 24 25 26
    ParameterManager* paramMgr = vehicle->parameterManager();

    if (paramMgr->parameterExists(FactSystem::defaultComponentId, _frameClassParam)) {
        _frameClassFact = paramMgr->getParameter(FactSystem::defaultComponentId, _frameClassParam);
        if (vehicle->vehicleType() != MAV_TYPE_HELICOPTER) {
            _requiresFrameSetup = true;
27
        }
28 29
    } else {
        _frameClassFact = nullptr;
30
    }
31 32 33 34 35 36 37 38 39
}

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

QString APMAirframeComponent::description(void) const
{
40
    return tr("Frame Setup is used to select the airframe which matches your vehicle.");
41 42 43 44
}

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

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

bool APMAirframeComponent::setupComplete(void) const
{
55
    if (_requiresFrameSetup) {
56
        return _frameClassFact->rawValue().toInt() != 0;
57 58 59
    } else {
        return true;
    }
60 61 62 63
}

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

66
    if (_requiresFrameSetup) {
67
        list << _frameClassParam;
68 69 70
    }

    return list;
71 72 73 74
}

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

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