Skip to content
SafetyComponent.cc 1.8 KiB
Newer Older
/****************************************************************************
 *
 *   (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

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

#include "SafetyComponent.h"
Don Gagne's avatar
Don Gagne committed
#include "PX4AutoPilotPlugin.h"
SafetyComponent::SafetyComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
    VehicleComponent(vehicle, autopilot, parent),
Don Gagne's avatar
Don Gagne committed
    _name(tr("Safety"))
{
}

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

QString SafetyComponent::description(void) const
{
    return tr("Safety Setup is used to setup triggers for Return to Land as well as the settings for Return to Land itself.");
QString SafetyComponent::iconResource(void) const
    return "/qmlimages/SafetyComponentIcon.png";
Don Gagne's avatar
Don Gagne committed
}

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

bool SafetyComponent::setupComplete(void) const
{
    // FIXME: What aboout invalid settings?
    return true;
}

Don Gagne's avatar
Don Gagne committed
QStringList SafetyComponent::setupCompleteChangedTriggerList(void) const
Don Gagne's avatar
Don Gagne committed
    return QStringList();
QUrl SafetyComponent::setupSource(void) const
    return QUrl::fromUserInput("qrc:/qml/SafetyComponent.qml");
QUrl SafetyComponent::summaryQmlSource(void) const
    return QUrl::fromUserInput("qrc:/qml/SafetyComponentSummary.qml");
Don Gagne's avatar
Don Gagne committed

QString SafetyComponent::prerequisiteSetup(void) const
{
    PX4AutoPilotPlugin* plugin = dynamic_cast<PX4AutoPilotPlugin*>(_autopilot);
    Q_ASSERT(plugin);
Don Gagne's avatar
Don Gagne committed
    if (!plugin->airframeComponent()->setupComplete()) {
        return plugin->airframeComponent()->name();
    }
Don Gagne's avatar
Don Gagne committed
    return QString();
}