Skip to content
Snippets Groups Projects
AutoPilotPlugin.h 2.11 KiB
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

#ifndef AUTOPILOTPLUGIN_H
#define AUTOPILOTPLUGIN_H

#include <QObject>
#include <QList>
#include <QString>
#include <QQmlContext>

#include "VehicleComponent.h"
#include "FactSystem.h"
#include "Vehicle.h"

class ParameterManager;
class Vehicle;
class FirmwarePlugin;

/// This is the base class for AutoPilot plugins
///
/// The AutoPilotPlugin class is an abstract base class which represent the methods and objects
/// which are specific to a certain AutoPilot. This is the only place where AutoPilot specific
/// code should reside in QGroundControl. The remainder of the QGroundControl source is
/// generic to a common mavlink implementation.

class AutoPilotPlugin : public QObject
{
    Q_OBJECT

public:
    AutoPilotPlugin(Vehicle* vehicle, QObject* parent);
    ~AutoPilotPlugin();

    /// List of VehicleComponent objects
    Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT)

    /// false: One or more vehicle components require setup
    Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged)

    /// Called when parameters are ready for the first time. Note that parameters may still be missing.
    /// Overrides must call base class.
    virtual void parametersReadyPreChecks(void);

    // Must be implemented by derived class
    virtual const QVariantList& vehicleComponents(void) = 0;

    // Property accessors
    bool setupComplete(void);

signals:
    void setupCompleteChanged(bool setupComplete);

protected:
    /// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
    AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { }

    Vehicle*        _vehicle;
    FirmwarePlugin* _firmwarePlugin;
    bool            _setupComplete;

private:
    void _recalcSetupComplete(void);
};

#endif