Commit a298165f authored by Don Gagne's avatar Don Gagne

New FirmwarePlugin support

- FirmwarePlugin is the new place for code which is specific to
firmware flight stack
- FirmwarePlugin currently supports flight mode apis
- Modify code to use new FirmwarePlugin support
parent 13cc2cfb
......@@ -554,14 +554,19 @@ SOURCES += \
} # MobileBuild
#
# AutoPilot Plugin Support
# Firmware Plugin Support
#
INCLUDEPATH += \
src/FirmwarePlugin \
src/VehicleSetup \
src/AutoPilotPlugins/PX4 \
HEADERS+= \
src/FirmwarePlugin/FirmwarePluginManager.h \
src/FirmwarePlugin/FirmwarePlugin.h \
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.h \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h \
src/AutoPilotPlugins/AutoPilotPlugin.h \
src/AutoPilotPlugins/AutoPilotPluginManager.h \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \
......@@ -594,6 +599,9 @@ HEADERS += \
}
SOURCES += \
src/FirmwarePlugin/FirmwarePluginManager.cc \
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.cc \
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc \
src/AutoPilotPlugins/AutoPilotPlugin.cc \
src/AutoPilotPlugins/AutoPilotPluginManager.cc \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \
......
......@@ -117,39 +117,6 @@ QSharedPointer<AutoPilotPlugin> AutoPilotPluginManager::getInstanceForAutoPilotP
return _pluginMap[autopilotType][uasId];
}
QList<AutoPilotPluginManager::FullMode_t> AutoPilotPluginManager::getModes(int autopilotType) const
{
switch (autopilotType) {
case MAV_AUTOPILOT_PX4:
return PX4AutoPilotPlugin::getModes();
case MAV_AUTOPILOT_GENERIC:
default:
return GenericAutoPilotPlugin::getModes();
}
}
QString AutoPilotPluginManager::getAudioModeText(uint8_t baseMode, uint32_t customMode, int autopilotType) const
{
switch (autopilotType) {
case MAV_AUTOPILOT_PX4:
return PX4AutoPilotPlugin::getAudioModeText(baseMode, customMode);
case MAV_AUTOPILOT_GENERIC:
default:
return GenericAutoPilotPlugin::getAudioModeText(baseMode, customMode);
}
}
QString AutoPilotPluginManager::getShortModeText(uint8_t baseMode, uint32_t customMode, int autopilotType) const
{
switch (autopilotType) {
case MAV_AUTOPILOT_PX4:
return PX4AutoPilotPlugin::getShortModeText(baseMode, customMode);
case MAV_AUTOPILOT_GENERIC:
default:
return GenericAutoPilotPlugin::getShortModeText(baseMode, customMode);
}
}
/// If autopilot is not an installed plugin, returns MAV_AUTOPILOT_GENERIC
MAV_AUTOPILOT AutoPilotPluginManager::_installedAutopilotType(MAV_AUTOPILOT autopilot)
{
......
......@@ -51,20 +51,6 @@ public:
/// to prevent shutdown ordering problems with Qml destruction happening after Facts are destroyed.
/// @param uas Uas to get plugin for
QSharedPointer<AutoPilotPlugin> getInstanceForAutoPilotPlugin(UASInterface* uas);
typedef struct {
uint8_t baseMode;
uint32_t customMode;
} FullMode_t;
/// Returns the list of modes which are available for the specified autopilot type.
QList<FullMode_t> getModes(int autopilotType) const;
/// @brief Returns a human readable short description for the specified mode.
QString getShortModeText(uint8_t baseMode, uint32_t customMode, int autopilotType) const;
/// @brief Returns a human hearable short description for the specified mode.
QString getAudioModeText(uint8_t baseMode, uint32_t customMode, int autopilotType) const;
private slots:
void _uasCreated(UASInterface* uas);
......
......@@ -38,61 +38,6 @@ GenericAutoPilotPlugin::GenericAutoPilotPlugin(UASInterface* uas, QObject* paren
connect(_parameterFacts, &GenericParameterFacts::parameterListProgress, this, &GenericAutoPilotPlugin::parameterListProgress);
}
QList<AutoPilotPluginManager::FullMode_t> GenericAutoPilotPlugin::getModes(void)
{
AutoPilotPluginManager::FullMode_t fullMode;
QList<AutoPilotPluginManager::FullMode_t> modeList;
fullMode.customMode = 0;
fullMode.baseMode = MAV_MODE_FLAG_MANUAL_INPUT_ENABLED;
modeList << fullMode;
fullMode.baseMode = MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED;
modeList << fullMode;
fullMode.baseMode = MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
modeList << fullMode;
fullMode.baseMode = MAV_MODE_FLAG_AUTO_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
modeList << fullMode;
return modeList;
}
QString GenericAutoPilotPlugin::getAudioModeText(uint8_t baseMode, uint32_t customMode)
{
Q_UNUSED(baseMode);
Q_UNUSED(customMode);
QString mode = "";
return mode;
}
QString GenericAutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t customMode)
{
Q_UNUSED(customMode);
QString mode;
// use base_mode - not autopilot-specific
if (baseMode == 0) {
mode = "|PREFLIGHT";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_AUTO) {
mode = "|AUTO";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_MANUAL) {
mode = "|MANUAL";
if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_GUIDED) {
mode += "|GUIDED";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_STABILIZE) {
mode += "|STABILIZED";
}
}
return mode;
}
void GenericAutoPilotPlugin::clearStaticData(void)
{
// No Static data yet
......
......@@ -43,9 +43,6 @@ public:
// Overrides from AutoPilotPlugin
virtual const QVariantList& vehicleComponents(void);
static QList<AutoPilotPluginManager::FullMode_t> getModes(void);
static QString getAudioModeText(uint8_t baseMode, uint32_t customMode);
static QString getShortModeText(uint8_t baseMode, uint32_t customMode);
static void clearStaticData(void);
private slots:
......
......@@ -96,172 +96,6 @@ PX4AutoPilotPlugin::~PX4AutoPilotPlugin()
delete _airframeFacts;
}
QList<AutoPilotPluginManager::FullMode_t> PX4AutoPilotPlugin::getModes(void)
{
union px4_custom_mode px4_cm;
AutoPilotPluginManager::FullMode_t fullMode;
QList<AutoPilotPluginManager::FullMode_t> modeList;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_MANUAL;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_ACRO;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_STABILIZED;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_ALTCTL;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_POSCTL;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_AUTO;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_AUTO_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_OFFBOARD;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_AUTO_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
return modeList;
}
QString PX4AutoPilotPlugin::getAudioModeText(uint8_t baseMode, uint32_t customMode)
{
QString mode;
Q_ASSERT(baseMode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED);
if (baseMode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) {
union px4_custom_mode px4_mode;
px4_mode.data = customMode;
if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_MANUAL) {
mode = "manual";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_ACRO) {
mode = "caro";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_STABILIZED) {
mode = "stabilized";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_ALTCTL) {
mode = "altitude control";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_POSCTL) {
mode = "position control";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_AUTO) {
mode = "auto and ";
if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_READY) {
mode += "ready";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF) {
mode += "taking off";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_LOITER) {
mode += "loitering";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_MISSION) {
mode += "following waypoints";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_RTL) {
mode += "returning to land";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_LAND) {
mode += "landing";
}
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_OFFBOARD) {
mode = "offboard controlled";
}
if (baseMode != 0)
{
mode += " mode";
}
// ARMED STATE DECODING
if (baseMode & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_SAFETY)
{
mode.append(" and armed");
}
} else {
mode = "";
}
return mode;
}
QString PX4AutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t customMode)
{
QString mode;
Q_ASSERT(baseMode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED);
if (baseMode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) {
union px4_custom_mode px4_mode;
px4_mode.data = customMode;
if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_MANUAL) {
mode = "|MANUAL";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_ACRO) {
mode = "|ACRO";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_STABILIZED) {
mode = "|STAB";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_ALTCTL) {
mode = "|ALTCTL";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_POSCTL) {
mode = "|POSCTL";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_AUTO) {
mode = "|AUTO";
if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_READY) {
mode += "|READY";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF) {
mode += "|TAKEOFF";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_LOITER) {
mode += "|LOITER";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_MISSION) {
mode += "|MISSION";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_RTL) {
mode += "|RTL";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_LAND) {
mode += "|LAND";
}
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_OFFBOARD) {
mode = "|OFFBOARD";
}
} else {
// use base_mode - not autopilot-specific
if (baseMode == 0) {
mode = "|PREFLIGHT";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_AUTO) {
mode = "|AUTO";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_MANUAL) {
mode = "|MANUAL";
if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_GUIDED) {
mode += "|GUIDED";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_STABILIZE) {
mode += "|STABILIZED";
}
}
}
return mode;
}
void PX4AutoPilotPlugin::clearStaticData(void)
{
PX4ParameterLoader::clearStaticData();
......
......@@ -53,9 +53,6 @@ public:
// Overrides from AutoPilotPlugin
virtual const QVariantList& vehicleComponents(void);
static QList<AutoPilotPluginManager::FullMode_t> getModes(void);
static QString getAudioModeText(uint8_t baseMode, uint32_t customMode);
static QString getShortModeText(uint8_t baseMode, uint32_t customMode);
static void clearStaticData(void);
// These methods should only be used by objects within the plugin
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef FirmwarePlugin_H
#define FirmwarePlugin_H
#include "QGCSingleton.h"
#include "QGCMAVlink.h"
#include "VehicleComponent.h"
#include "AutoPilotPlugin.h"
#include <QList>
#include <QString>
/// This is the base class for Firmware specific plugins
///
/// The FirmwarePlugin class is the abstract base class which represents the methods and objects
/// which are specific to a certain Firmware flight stack. This is the only place where
/// flight stack specific code should reside in QGroundControl. The remainder of the
/// QGroundControl source is generic to a common mavlink implementation. The implementation
/// in the base class supports mavlink generic firmware. Override the base clase virtuals
/// to create you firmware specific plugin.
class FirmwarePlugin : public QGCSingleton
{
Q_OBJECT
public:
/// Set of optional capabilites which firmware may support
typedef enum {
SetFlightModeCapability,
} FirmwareCapabilities;
/// @return true: Firmware supports all specified capabilites
virtual bool isCapable(FirmwareCapabilities capabilities) = 0;
/// Returns VehicleComponents for specified Vehicle
/// @param vehicle Vehicle to associate with components
/// @return List of VehicleComponents for the specified vehicle. Caller owns returned objects and must
/// free when no longer needed.
virtual QList<VehicleComponent*> componentsForVehicle(AutoPilotPlugin* vehicle) = 0;
/// Returns the list of available flight modes
virtual QStringList flightModes(void) = 0;
/// Returns the name for this flight mode. Flight mode names must be human readable as well as audio speakable.
/// @param base_mode Base mode from mavlink HEARTBEAT message
/// @param custom_mode Custom mode from mavlink HEARTBEAT message
virtual QString flightMode(uint8_t base_mode, uint32_t custom_mode) = 0;
/// Sets base_mode and custom_mode to specified flight mode.
/// @param[out] base_mode Base mode for SET_MODE mavlink message
/// @param[out] custom_mode Custom mode for SET_MODE mavlink message
virtual bool setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode) = 0;
protected:
FirmwarePlugin(QObject* parent = NULL) : QGCSingleton(parent) { }
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "FirmwarePluginManager.h"
#include "Generic/GenericFirmwarePlugin.h"
#include "PX4/PX4FirmwarePlugin.h"
IMPLEMENT_QGC_SINGLETON(FirmwarePluginManager, FirmwarePluginManager)
FirmwarePluginManager::FirmwarePluginManager(QObject* parent) :
QGCSingleton(parent)
{
}
FirmwarePluginManager::~FirmwarePluginManager()
{
}
FirmwarePlugin* FirmwarePluginManager::firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType)
{
if (autopilotType == MAV_AUTOPILOT_PX4) {
return PX4FirmwarePlugin::instance();
} else {
return GenericFirmwarePlugin::instance();
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef FirmwarePluginManager_H
#define FirmwarePluginManager_H
#include <QObject>
#include "QGCSingleton.h"
#include "FirmwarePlugin.h"
#include "QGCMAVLink.h"
/// FirmwarePluginManager is a singleton which is used to return the correct FirmwarePlugin for a MAV_AUTOPILOT type.
class FirmwarePluginManager : public QGCSingleton
{
Q_OBJECT
DECLARE_QGC_SINGLETON(FirmwarePluginManager, FirmwarePluginManager)
public:
/// Returns appropriate plugin for autopilot type.
/// @param autopilotType Type of autopilot to return plugin for.
/// @return Singleton FirmwarePlugin instance for the specified MAV_AUTOPILOT.
FirmwarePlugin* firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType);
private:
/// All access to singleton is through FirmwarePluginManager::instance
FirmwarePluginManager(QObject* parent = NULL);
~FirmwarePluginManager();
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "GenericFirmwarePlugin.h"
#include <QDebug>
IMPLEMENT_QGC_SINGLETON(GenericFirmwarePlugin, FirmwarePlugin)
GenericFirmwarePlugin::GenericFirmwarePlugin(QObject* parent) :
FirmwarePlugin(parent)
{
}
GenericFirmwarePlugin::GenericFirmwarePlugin()
{
}
QList<VehicleComponent*> GenericFirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle)
{
Q_UNUSED(vehicle);
return QList<VehicleComponent*>();
}
QString GenericFirmwarePlugin::flightMode(uint8_t base_mode, uint32_t custom_mode)
{
QString flightMode;
struct Bit2Name {
uint8_t baseModeBit;
const char* name;
};
static const struct Bit2Name rgBit2Name[] = {
{ MAV_MODE_FLAG_MANUAL_INPUT_ENABLED, "Manual" },
{ MAV_MODE_FLAG_STABILIZE_ENABLED, "Stabilize" },
{ MAV_MODE_FLAG_GUIDED_ENABLED, "Guided" },
{ MAV_MODE_FLAG_AUTO_ENABLED, "Auto" },
{ MAV_MODE_FLAG_TEST_ENABLED, "Test" },
};
Q_UNUSED(custom_mode);
if (base_mode == 0) {
flightMode = "PreFlight";
} else if (base_mode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) {
flightMode = QString("Custom:0x%1").arg(custom_mode, 0, 16);
} else {
for (size_t i=0; i<sizeof(rgBit2Name)/sizeof(rgBit2Name[0]); i++) {
if (base_mode & rgBit2Name[i].baseModeBit) {
if (i != 0) {
flightMode += " ";
}
flightMode += rgBit2Name[i].name;
}
}
}
return flightMode;
}
bool GenericFirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode)
{
Q_UNUSED(flightMode);
Q_UNUSED(base_mode);
Q_UNUSED(custom_mode);
qWarning() << "GenericFirmwarePlugin::setFlightMode called on base class, not supported";
return false;
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef GenericFirmwarePlugin_H
#define GenericFirmwarePlugin_H
#include "FirmwarePlugin.h"
class GenericFirmwarePlugin : public FirmwarePlugin
{
Q_OBJECT
DECLARE_QGC_SINGLETON(GenericFirmwarePlugin, FirmwarePlugin)
public:
// Overrides from FirmwarePlugin
virtual bool isCapable(FirmwareCapabilities capabilities) { Q_UNUSED(capabilities); return false; }
virtual QList<VehicleComponent*> componentsForVehicle(AutoPilotPlugin* vehicle);
virtual QStringList flightModes(void) { return QStringList(); }
virtual QString flightMode(uint8_t base_mode, uint32_t custom_mode);
virtual bool setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode);
private:
/// All access to singleton is through AutoPilotPluginManager::instance
GenericFirmwarePlugin(QObject* parent = NULL);
GenericFirmwarePlugin();
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,