Unverified Commit 74fb1dae authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8924 from DonLakeFlyer/FirmwareVehicleClass

Support for Vehicle and Firmware classes
parents 2a361a8b 2debdad3
......@@ -752,23 +752,23 @@ QList<MAV_CMD> APMFirmwarePlugin::supportedMissionCommands(void)
};
}
QString APMFirmwarePlugin::missionCommandOverrides(MAV_TYPE vehicleType) const
QString APMFirmwarePlugin::missionCommandOverrides(QGCMAVLink::VehicleClass_t vehicleClass) const
{
switch (vehicleType) {
case MAV_TYPE_GENERIC:
switch (vehicleClass) {
case QGCMAVLink::VehicleClassGeneric:
return QStringLiteral(":/json/APM-MavCmdInfoCommon.json");
case MAV_TYPE_FIXED_WING:
case QGCMAVLink::VehicleClassFixedWing:
return QStringLiteral(":/json/APM-MavCmdInfoFixedWing.json");
case MAV_TYPE_QUADROTOR:
case QGCMAVLink::VehicleClassMultiRotor:
return QStringLiteral(":/json/APM-MavCmdInfoMultiRotor.json");
case MAV_TYPE_VTOL_QUADROTOR:
case QGCMAVLink::VehicleClassVTOL:
return QStringLiteral(":/json/APM-MavCmdInfoVTOL.json");
case MAV_TYPE_SUBMARINE:
case QGCMAVLink::VehicleClassSub:
return QStringLiteral(":/json/APM-MavCmdInfoSub.json");
case MAV_TYPE_GROUND_ROVER:
case QGCMAVLink::VehicleClassRoverBoat:
return QStringLiteral(":/json/APM-MavCmdInfoRover.json");
default:
qWarning() << "APMFirmwarePlugin::missionCommandOverrides called with bad MAV_TYPE:" << vehicleType;
qWarning() << "APMFirmwarePlugin::missionCommandOverrides called with bad VehicleClass_t:" << vehicleClass;
return QString();
}
}
......
......@@ -97,7 +97,7 @@ public:
virtual void initializeStreamRates (Vehicle* vehicle);
void initializeVehicle (Vehicle* vehicle) override;
bool sendHomePositionToVehicle (void) override;
QString missionCommandOverrides (MAV_TYPE vehicleType) const override;
QString missionCommandOverrides (QGCMAVLink::VehicleClass_t vehicleClass) const override;
QString getVersionParam (void) override { return QStringLiteral("SYSID_SW_MREV"); }
QString _internalParameterMetaDataFile (Vehicle* vehicle) override;
FactMetaData* _getMetaDataForFact (QObject* parameterMetaData, const QString& name, FactMetaData::ValueType_t type, MAV_TYPE vehicleType) override;
......
......@@ -24,11 +24,11 @@ APMFirmwarePluginFactory::APMFirmwarePluginFactory(void)
}
QList<MAV_AUTOPILOT> APMFirmwarePluginFactory::supportedFirmwareTypes(void) const
QList<QGCMAVLink::FirmwareClass_t> APMFirmwarePluginFactory::supportedFirmwareClasses(void) const
{
QList<MAV_AUTOPILOT> list;
QList<QGCMAVLink::FirmwareClass_t> list;
list.append(MAV_AUTOPILOT_ARDUPILOTMEGA);
list.append(QGCMAVLink::FirmwareClassArduPilot);
return list;
}
......
......@@ -7,8 +7,7 @@
*
****************************************************************************/
#ifndef APMFirmwarePluginFactory_H
#define APMFirmwarePluginFactory_H
#pragma once
#include "FirmwarePlugin.h"
......@@ -24,7 +23,7 @@ class APMFirmwarePluginFactory : public FirmwarePluginFactory
public:
APMFirmwarePluginFactory(void);
QList<MAV_AUTOPILOT> supportedFirmwareTypes (void) const final;
QList<QGCMAVLink::FirmwareClass_t> supportedFirmwareClasses(void) const final;
FirmwarePlugin* firmwarePluginForAutopilot (MAV_AUTOPILOT autopilotType, MAV_TYPE vehicleType) final;
private:
......@@ -33,5 +32,3 @@ private:
ArduRoverFirmwarePlugin* _arduRoverPluginInstance;
ArduSubFirmwarePlugin* _arduSubPluginInstance;
};
#endif
......@@ -34,11 +34,9 @@ FirmwarePluginFactory::FirmwarePluginFactory(void)
FirmwarePluginFactoryRegister::instance()->registerPluginFactory(this);
}
QList<MAV_TYPE> FirmwarePluginFactory::supportedVehicleTypes(void) const
QList<QGCMAVLink::VehicleClass_t> FirmwarePluginFactory::supportedVehicleClasses(void) const
{
QList<MAV_TYPE> vehicleTypes;
vehicleTypes << MAV_TYPE_FIXED_WING << MAV_TYPE_QUADROTOR << MAV_TYPE_VTOL_QUADROTOR << MAV_TYPE_GROUND_ROVER << MAV_TYPE_SUBMARINE;
return vehicleTypes;
return QGCMAVLink::allVehicleClasses();
}
FirmwarePluginFactoryRegister* FirmwarePluginFactoryRegister::instance(void)
......@@ -182,23 +180,23 @@ QList<MAV_CMD> FirmwarePlugin::supportedMissionCommands(void)
return QList<MAV_CMD>();
}
QString FirmwarePlugin::missionCommandOverrides(MAV_TYPE vehicleType) const
QString FirmwarePlugin::missionCommandOverrides(QGCMAVLink::VehicleClass_t vehicleClass) const
{
switch (vehicleType) {
case MAV_TYPE_GENERIC:
switch (vehicleClass) {
case QGCMAVLink::VehicleClassGeneric:
return QStringLiteral(":/json/MavCmdInfoCommon.json");
case MAV_TYPE_FIXED_WING:
case QGCMAVLink::VehicleClassFixedWing:
return QStringLiteral(":/json/MavCmdInfoFixedWing.json");
case MAV_TYPE_QUADROTOR:
case QGCMAVLink::VehicleClassMultiRotor:
return QStringLiteral(":/json/MavCmdInfoMultiRotor.json");
case MAV_TYPE_VTOL_QUADROTOR:
case QGCMAVLink::VehicleClassVTOL:
return QStringLiteral(":/json/MavCmdInfoVTOL.json");
case MAV_TYPE_SUBMARINE:
case QGCMAVLink::VehicleClassSub:
return QStringLiteral(":/json/MavCmdInfoSub.json");
case MAV_TYPE_GROUND_ROVER:
case QGCMAVLink::VehicleClassRoverBoat:
return QStringLiteral(":/json/MavCmdInfoRover.json");
default:
qWarning() << "FirmwarePlugin::missionCommandOverrides called with bad MAV_TYPE:" << vehicleType;
qWarning() << "FirmwarePlugin::missionCommandOverrides called with bad VehicleClass_t:" << vehicleClass;
return QString();
}
}
......@@ -787,22 +785,6 @@ bool FirmwarePlugin::hasGimbal(Vehicle* vehicle, bool& rollSupported, bool& pitc
return false;
}
bool FirmwarePlugin::isVtol(const Vehicle* vehicle) const
{
switch (vehicle->vehicleType()) {
case MAV_TYPE_VTOL_DUOROTOR:
case MAV_TYPE_VTOL_QUADROTOR:
case MAV_TYPE_VTOL_TILTROTOR:
case MAV_TYPE_VTOL_RESERVED2:
case MAV_TYPE_VTOL_RESERVED3:
case MAV_TYPE_VTOL_RESERVED4:
case MAV_TYPE_VTOL_RESERVED5:
return true;
default:
return false;
}
}
QGCCameraManager* FirmwarePlugin::createCameraManager(Vehicle* vehicle)
{
return new QGCCameraManager(vehicle);
......
......@@ -241,8 +241,8 @@ public:
virtual QList<MAV_CMD> supportedMissionCommands(void);
/// Returns the name of the mission command json override file for the specified vehicle type.
/// @param vehicleType Vehicle type to return file for, MAV_TYPE_GENERIC is a request for overrides for all vehicle types
virtual QString missionCommandOverrides(MAV_TYPE vehicleType) const;
/// @param vehicleClass Vehicle class to return file for, VehicleClassGeneric is a request for overrides for all vehicle types
virtual QString missionCommandOverrides(QGCMAVLink::VehicleClass_t vehicleClass) const;
/// Returns the mapping structure which is used to map from one parameter name to another based on firmware version.
virtual const remapParamNameMajorVersionMap_t& paramNameRemapMajorVersionMap(void) const;
......@@ -316,9 +316,6 @@ public:
/// @return true: vehicle has gimbal, false: gimbal support unknown
virtual bool hasGimbal(Vehicle* vehicle, bool& rollSupported, bool& pitchSupported, bool& yawSupported);
/// Returns true if the vehicle is a VTOL
virtual bool isVtol(const Vehicle* vehicle) const;
/// Convert from HIGH_LATENCY2.custom_mode value to correct 32 bit value.
virtual uint32_t highLatencyCustomModeTo32Bits(uint16_t hlCustomMode);
......@@ -383,11 +380,11 @@ public:
/// @return Singleton FirmwarePlugin instance for the specified MAV_AUTOPILOT.
virtual FirmwarePlugin* firmwarePluginForAutopilot(MAV_AUTOPILOT autopilotType, MAV_TYPE vehicleType) = 0;
/// @return List of firmware types this plugin supports.
virtual QList<MAV_AUTOPILOT> supportedFirmwareTypes(void) const = 0;
/// @return List of firmware classes this plugin supports.
virtual QList<QGCMAVLink::FirmwareClass_t> supportedFirmwareClasses(void) const = 0;
/// @return List of vehicle types this plugin supports.
virtual QList<MAV_TYPE> supportedVehicleTypes(void) const;
/// @return List of vehicle classes this plugin supports.
virtual QList<QGCMAVLink::VehicleClass_t> supportedVehicleClasses(void) const;
};
class FirmwarePluginFactoryRegister : public QObject
......
......@@ -26,33 +26,35 @@ FirmwarePluginManager::~FirmwarePluginManager()
delete _genericFirmwarePlugin;
}
QList<MAV_AUTOPILOT> FirmwarePluginManager::supportedFirmwareTypes(void)
QList<QGCMAVLink::FirmwareClass_t> FirmwarePluginManager::supportedFirmwareClasses(void)
{
if (_supportedFirmwareTypes.isEmpty()) {
if (_supportedFirmwareClasses.isEmpty()) {
QList<FirmwarePluginFactory*> factoryList = FirmwarePluginFactoryRegister::instance()->pluginFactories();
for (int i = 0; i < factoryList.count(); i++) {
_supportedFirmwareTypes.append(factoryList[i]->supportedFirmwareTypes());
_supportedFirmwareClasses.append(factoryList[i]->supportedFirmwareClasses());
}
_supportedFirmwareTypes.append(MAV_AUTOPILOT_GENERIC);
_supportedFirmwareClasses.append(QGCMAVLink::FirmwareClassGeneric);
}
return _supportedFirmwareTypes;
return _supportedFirmwareClasses;
}
QList<MAV_TYPE> FirmwarePluginManager::supportedVehicleTypes(MAV_AUTOPILOT firmwareType)
QList<QGCMAVLink::VehicleClass_t> FirmwarePluginManager::supportedVehicleClasses(QGCMAVLink::FirmwareClass_t firmwareClass)
{
QList<MAV_TYPE> vehicleTypes;
QList<QGCMAVLink::VehicleClass_t> vehicleClasses;
FirmwarePluginFactory* factory = _findPluginFactory(firmwareType);
FirmwarePluginFactory* factory = _findPluginFactory(firmwareClass);
if (factory) {
vehicleTypes = factory->supportedVehicleTypes();
} else if (firmwareType == MAV_AUTOPILOT_GENERIC) {
vehicleTypes << MAV_TYPE_FIXED_WING << MAV_TYPE_QUADROTOR << MAV_TYPE_VTOL_QUADROTOR << MAV_TYPE_GROUND_ROVER << MAV_TYPE_SUBMARINE;
vehicleClasses = factory->supportedVehicleClasses();
} else if (firmwareClass == QGCMAVLink::FirmwareClassGeneric) {
// Generic supports all specific vehicle class
vehicleClasses = QGCMAVLink::allVehicleClasses();
vehicleClasses.removeOne(QGCMAVLink::VehicleClassGeneric);
} else {
qWarning() << "Request for unknown firmware plugin factory" << firmwareType;
qWarning() << "Request for unknown firmware plugin factory" << firmwareClass;
}
return vehicleTypes;
return vehicleClasses;
}
FirmwarePlugin* FirmwarePluginManager::firmwarePluginForAutopilot(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType)
......@@ -62,8 +64,6 @@ FirmwarePlugin* FirmwarePluginManager::firmwarePluginForAutopilot(MAV_AUTOPILOT
if (factory) {
plugin = factory->firmwarePluginForAutopilot(firmwareType, vehicleType);
} else if (firmwareType != MAV_AUTOPILOT_GENERIC) {
qWarning() << "Request for unknown firmware plugin factory" << firmwareType;
}
if (!plugin) {
......@@ -77,14 +77,14 @@ FirmwarePlugin* FirmwarePluginManager::firmwarePluginForAutopilot(MAV_AUTOPILOT
return plugin;
}
FirmwarePluginFactory* FirmwarePluginManager::_findPluginFactory(MAV_AUTOPILOT firmwareType)
FirmwarePluginFactory* FirmwarePluginManager::_findPluginFactory(QGCMAVLink::FirmwareClass_t firmwareClass)
{
QList<FirmwarePluginFactory*> factoryList = FirmwarePluginFactoryRegister::instance()->pluginFactories();
// Find the plugin which supports this vehicle
for (int i=0; i<factoryList.count(); i++) {
FirmwarePluginFactory* factory = factoryList[i];
if (factory->supportedFirmwareTypes().contains(firmwareType)) {
if (factory->supportedFirmwareClasses().contains(firmwareClass)) {
return factory;
}
}
......
......@@ -7,12 +7,7 @@
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef FirmwarePluginManager_H
#define FirmwarePluginManager_H
#pragma once
#include <QObject>
......@@ -33,10 +28,10 @@ public:
~FirmwarePluginManager();
/// Returns list of firmwares which are supported by the system
QList<MAV_AUTOPILOT> supportedFirmwareTypes(void);
QList<QGCMAVLink::FirmwareClass_t> supportedFirmwareClasses(void);
/// Returns the list of supported vehicle types for the specified firmware
QList<MAV_TYPE> supportedVehicleTypes(MAV_AUTOPILOT firmwareType);
QList<QGCMAVLink::VehicleClass_t> supportedVehicleClasses(QGCMAVLink::FirmwareClass_t firmwareClass);
/// Returns appropriate plugin for autopilot type.
/// @param firmwareType Type of firmwware to return plugin for.
......@@ -45,10 +40,8 @@ public:
FirmwarePlugin* firmwarePluginForAutopilot(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType);
private:
FirmwarePluginFactory* _findPluginFactory(MAV_AUTOPILOT firmwareType);
FirmwarePluginFactory* _findPluginFactory(QGCMAVLink::FirmwareClass_t firmwareClass);
FirmwarePlugin* _genericFirmwarePlugin;
QList<MAV_AUTOPILOT> _supportedFirmwareTypes;
QList<QGCMAVLink::FirmwareClass_t> _supportedFirmwareClasses;
};
#endif
......@@ -297,23 +297,23 @@ QList<MAV_CMD> PX4FirmwarePlugin::supportedMissionCommands(void)
return cmds;
}
QString PX4FirmwarePlugin::missionCommandOverrides(MAV_TYPE vehicleType) const
QString PX4FirmwarePlugin::missionCommandOverrides(QGCMAVLink::VehicleClass_t vehicleClass) const
{
switch (vehicleType) {
case MAV_TYPE_GENERIC:
switch (vehicleClass) {
case QGCMAVLink::VehicleClassGeneric:
return QStringLiteral(":/json/PX4-MavCmdInfoCommon.json");
case MAV_TYPE_FIXED_WING:
case QGCMAVLink::VehicleClassFixedWing:
return QStringLiteral(":/json/PX4-MavCmdInfoFixedWing.json");
case MAV_TYPE_QUADROTOR:
case QGCMAVLink::VehicleClassMultiRotor:
return QStringLiteral(":/json/PX4-MavCmdInfoMultiRotor.json");
case MAV_TYPE_VTOL_QUADROTOR:
case QGCMAVLink::VehicleClassVTOL:
return QStringLiteral(":/json/PX4-MavCmdInfoVTOL.json");
case MAV_TYPE_SUBMARINE:
case QGCMAVLink::VehicleClassSub:
return QStringLiteral(":/json/PX4-MavCmdInfoSub.json");
case MAV_TYPE_GROUND_ROVER:
case QGCMAVLink::VehicleClassRoverBoat:
return QStringLiteral(":/json/PX4-MavCmdInfoRover.json");
default:
qWarning() << "PX4FirmwarePlugin::missionCommandOverrides called with bad MAV_TYPE:" << vehicleType;
qWarning() << "PX4FirmwarePlugin::missionCommandOverrides called with bad VehicleClass_t:" << vehicleClass;
return QString();
}
}
......
......@@ -55,7 +55,7 @@ public:
bool isGuidedMode (const Vehicle* vehicle) const override;
void initializeVehicle (Vehicle* vehicle) override;
bool sendHomePositionToVehicle (void) override;
QString missionCommandOverrides (MAV_TYPE vehicleType) const override;
QString missionCommandOverrides (QGCMAVLink::VehicleClass_t vehicleClass) const override;
QString getVersionParam (void) override { return QString("SYS_PARAM_VER"); }
FactMetaData* _getMetaDataForFact (QObject* parameterMetaData, const QString& name, FactMetaData::ValueType_t type, MAV_TYPE vehicleType) override;
QString _internalParameterMetaDataFile (Vehicle* vehicle) override { Q_UNUSED(vehicle); return QString(":/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml"); }
......
......@@ -7,10 +7,6 @@
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "PX4FirmwarePluginFactory.h"
#include "PX4/PX4FirmwarePlugin.h"
......@@ -22,10 +18,10 @@ PX4FirmwarePluginFactory::PX4FirmwarePluginFactory(void)
}
QList<MAV_AUTOPILOT> PX4FirmwarePluginFactory::supportedFirmwareTypes(void) const
QList<QGCMAVLink::FirmwareClass_t> PX4FirmwarePluginFactory::supportedFirmwareClasses(void) const
{
QList<MAV_AUTOPILOT> list;
list.append(MAV_AUTOPILOT_PX4);
QList<QGCMAVLink::FirmwareClass_t> list;
list.append(QGCMAVLink::FirmwareClassPX4);
return list;
}
......
......@@ -7,8 +7,7 @@
*
****************************************************************************/
#ifndef PX4FirmwarePluginFactory_H
#define PX4FirmwarePluginFactory_H
#pragma once
#include "FirmwarePlugin.h"
......@@ -21,11 +20,9 @@ class PX4FirmwarePluginFactory : public FirmwarePluginFactory
public:
PX4FirmwarePluginFactory(void);
QList<MAV_AUTOPILOT> supportedFirmwareTypes (void) const final;
QList<QGCMAVLink::FirmwareClass_t> supportedFirmwareClasses(void) const final;
FirmwarePlugin* firmwarePluginForAutopilot (MAV_AUTOPILOT autopilotType, MAV_TYPE vehicleType) final;
private:
PX4FirmwarePlugin* _pluginInstance;
};
#endif
......@@ -26,8 +26,8 @@ FirstRunPrompt {
property var _offlineVehicle: QGroundControl.multiVehicleManager.offlineEditingVehicle
property bool _showCruiseSpeed: !_offlineVehicle.multiRotor
property bool _showHoverSpeed: _offlineVehicle.multiRotor || _offlineVehicle.vtol
property bool _multipleFirmware: QGroundControl.supportedFirmwareCount > 2
property bool _multipleVehicleTypes: QGroundControl.supportedVehicleCount > 1
property bool _multipleFirmware: !QGroundControl.singleFirmwareSupport
property bool _multipleVehicleTypes: !QGroundControl.singleVehicleSupport
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 16
ColumnLayout {
......@@ -61,7 +61,7 @@ FirstRunPrompt {
}
FactComboBox {
Layout.preferredWidth: _fieldWidth
fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareType
fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
indexModel: false
visible: _multipleFirmware
}
......@@ -73,7 +73,7 @@ FirstRunPrompt {
}
FactComboBox {
Layout.preferredWidth: _fieldWidth
fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleType
fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
indexModel: false
visible: _multipleVehicleTypes
}
......
......@@ -27,8 +27,7 @@ class MissionCommandList : public QObject
Q_OBJECT
public:
/// @param jsonFilename Json file which contains commands
/// @param baseCommandList true: bottomost level of mission command hierarchy (partial not allowed), false: mid-level of command hierarchy
/// @param baseCommandList true: bottomost level of mission command hierarchy (partial spec allowed), false: override level of hierarchy
MissionCommandList(const QString& jsonFilename, bool baseCommandList, QObject* parent = nullptr);
/// Returns list of categories in this list
......
This diff is collapsed.
......@@ -7,8 +7,7 @@
*
****************************************************************************/
#ifndef MissionCommandTree_H
#define MissionCommandTree_H
#pragma once
#include "QGCToolbox.h"
#include "QGCMAVLink.h"
......@@ -26,9 +25,9 @@ class MissionCommandTreeTest;
/// Manages a hierarchy of MissionCommandUIInfo.
///
/// The static hierarchy allows for overriding mission command ui info based on MAV_AUTOPILOT and MAV_TYPE. The hierarchy of the tree is:
/// Any Firmware, Any Vehicle - Base set of all command definitions for any firmware, any vehicle, essentially ui defined to mavlink spec
/// Any Firmware, Fixed Wing
/// The static hierarchy allows for overriding mission command ui info based on firmware and vehicle class. The hierarchy of the tree is:
/// FirmwareClassGeneric - VehicleClassGeneric - Base set of all command definitions for any firmware, any vehicle, ui defined by mavlink spec
/// FirmwareClassGeneric - VehicleClassFixedWing
/// Known Firmware, Fixed Wing
/// Any Firmware, Multi Rotor (all types)
/// Known Firmware, Multi Rotor (all types)
......@@ -62,19 +61,17 @@ public:
const MissionCommandUIInfo* getUIInfo(Vehicle* vehicle, MAV_CMD command);
/// @param showFlyThroughCommands - true: al commands shows, false: filter out commands which the vehicle flies through (specifiedCoordinate=true, standaloneCoordinate=false)
/// @param showFlyThroughCommands - true: all commands shows, false: filter out commands which the vehicle flies through (specifiedCoordinate=true, standaloneCoordinate=false)
Q_INVOKABLE QVariantList getCommandsForCategory(Vehicle* vehicle, const QString& category, bool showFlyThroughCommands);
// Overrides from QGCTool
virtual void setToolbox(QGCToolbox* toolbox);
private:
void _collapseHierarchy(Vehicle* vehicle, const MissionCommandList* cmdList, QMap<MAV_CMD, MissionCommandUIInfo*>& collapsedTree);
MAV_TYPE _baseVehicleType(MAV_TYPE mavType) const;
MAV_AUTOPILOT _baseFirmwareType(MAV_AUTOPILOT firmwareType) const;
void _buildAllCommands(Vehicle* vehicle);
QStringList _availableCategoriesForVehicle(Vehicle* vehicle);
void _baseVehicleInfo(Vehicle* vehicle, MAV_AUTOPILOT& baseFirmwareType, MAV_TYPE& baseVehicleType) const;
void _collapseHierarchy (const MissionCommandList* cmdList, QMap<MAV_CMD, MissionCommandUIInfo*>& collapsedTree);
void _buildAllCommands (Vehicle* vehicle);
QStringList _availableCategoriesForVehicle (Vehicle* vehicle);
void _firmwareAndVehicleClassInfo (Vehicle* vehicle, QGCMAVLink::FirmwareClass_t& firmwareClass, QGCMAVLink::VehicleClass_t& vehicleClass) const;
private:
QString _allCommandsCategory; ///< Category which contains all available commands
......@@ -83,18 +80,16 @@ private:
bool _unitTest; ///< true: running in unit test mode
/// Full hierarchy
QMap<MAV_AUTOPILOT, QMap<MAV_TYPE, MissionCommandList*>> _staticCommandTree;
QMap<QGCMAVLink::FirmwareClass_t, QMap<QGCMAVLink::VehicleClass_t, MissionCommandList*>> _staticCommandTree;
/// Collapsed hierarchy for specific vehicle type
QMap<MAV_AUTOPILOT, QMap<MAV_TYPE, QMap<MAV_CMD, MissionCommandUIInfo*>>> _allCommands;
QMap<QGCMAVLink::FirmwareClass_t, QMap<QGCMAVLink::VehicleClass_t, QMap<MAV_CMD, MissionCommandUIInfo*>>> _allCommands;
/// Collapsed hierarchy for specific vehicle type
QMap<MAV_AUTOPILOT, QMap<MAV_TYPE, QStringList /* category */>> _supportedCategories;
QMap<QGCMAVLink::FirmwareClass_t, QMap<QGCMAVLink::VehicleClass_t, QStringList /* category */>> _supportedCategories;
#ifdef UNITTEST_BUILD
friend class MissionCommandTreeTest;
#endif
};
#endif
......@@ -728,16 +728,16 @@ bool MissionController::_loadJsonMissionFileV2(const QJsonObject& json, QmlObjec
// Get the firmware/vehicle type from the plan file
MAV_AUTOPILOT planFileFirmwareType = static_cast<MAV_AUTOPILOT>(json[_jsonFirmwareTypeKey].toInt());
MAV_TYPE planFileVehicleType = static_cast<MAV_TYPE> (appSettings->offlineEditingVehicleType()->rawValue().toInt());
MAV_TYPE planFileVehicleType = static_cast<MAV_TYPE> (QGCMAVLink::vehicleClassToMavType(appSettings->offlineEditingVehicleClass()->rawValue().toInt()));
if (json.contains(_jsonVehicleTypeKey)) {
planFileVehicleType = static_cast<MAV_TYPE>(json[_jsonVehicleTypeKey].toInt());
}
// Update firmware/vehicle offline settings if we aren't connect to a vehicle
if (_masterController->offline()) {
appSettings->offlineEditingFirmwareType()->setRawValue(AppSettings::offlineEditingFirmwareTypeFromFirmwareType(static_cast<MAV_AUTOPILOT>(json[_jsonFirmwareTypeKey].toInt())));
appSettings->offlineEditingFirmwareClass()->setRawValue(QGCMAVLink::firmwareClass(static_cast<MAV_AUTOPILOT>(json[_jsonFirmwareTypeKey].toInt())));
if (json.contains(_jsonVehicleTypeKey)) {
appSettings->offlineEditingVehicleType()->setRawValue(AppSettings::offlineEditingVehicleTypeFromVehicleType(static_cast<MAV_TYPE>(json[_jsonVehicleTypeKey].toInt())));
appSettings->offlineEditingVehicleClass()->setRawValue(QGCMAVLink::vehicleClass(planFileVehicleType));
}
}
......
......@@ -50,7 +50,7 @@ void MissionControllerTest::_initForFirmwareType(MAV_AUTOPILOT firmwareType)
_rgMissionControllerSignals[visualItemsChangedSignalIndex] = SIGNAL(visualItemsChanged());
// Master controller pulls offline vehicle info from settings
qgcApp()->toolbox()->settingsManager()->appSettings()->offlineEditingFirmwareType()->setRawValue(firmwareType);
qgcApp()->toolbox()->settingsManager()->appSettings()->offlineEditingFirmwareClass()->setRawValue(QGCMAVLink::firmwareClass(firmwareType));
_masterController = new PlanMasterController(this);
_masterController->setFlyView(false);
_missionController = _masterController->missionController();
......
......@@ -143,8 +143,8 @@ void PlanMasterController::_activeVehicleChanged(Vehicle* activeVehicle)
// Update controllerVehicle to the currently connected vehicle
AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings();
appSettings->offlineEditingFirmwareType()->setRawValue(AppSettings::offlineEditingFirmwareTypeFromFirmwareType(_managerVehicle->firmwareType()));
appSettings->offlineEditingVehicleType()->setRawValue(AppSettings::offlineEditingVehicleTypeFromVehicleType(_managerVehicle->vehicleType()));
appSettings->offlineEditingFirmwareClass()->setRawValue(QGCMAVLink::firmwareClass(_managerVehicle->firmwareType()));
appSettings->offlineEditingVehicleClass()->setRawValue(QGCMAVLink::vehicleClass(_managerVehicle->vehicleType()));
// We use these signals to sequence upload and download to the multiple controller/managers
connect(_managerVehicle->missionManager(), &MissionManager::newMissionItemsAvailable, this, &PlanMasterController::_loadMissionComplete);
......
......@@ -40,7 +40,6 @@ Rectangle {
property real _sectionSpacer: ScreenTools.defaultFontPixelWidth / 2 // spacing between section headings
property bool _singleComplexItem: _missionController.complexMissionItemNames.length === 1
property bool _readyForSave: missionItem.readyForSaveState === VisualMissionItem.ReadyForSave
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
readonly property real _editFieldWidth: Math.min(width - _innerMargin * 2, ScreenTools.defaultFontPixelWidth * 12)
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
......@@ -160,6 +159,7 @@ Rectangle {
id: commandDialog
MissionCommandDialog {
vehicle: masterController.controllerVehicle
missionItem: _root.missionItem
map: _root.map
// FIXME: Disabling fly through commands doesn't work since you may need to change from an RTL to something else
......@@ -207,6 +207,8 @@ Rectangle {
visible: missionItem.specifiesCoordinate
enabled: _activeVehicle
onTriggered: missionItem.coordinate = _activeVehicle.coordinate
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
}
QGCMenuItem {
......
......@@ -26,8 +26,8 @@ Rectangle {
property bool _vehicleHasHomePosition: _controllerVehicle.homePosition.isValid
property bool _showCruiseSpeed: !_controllerVehicle.multiRotor
property bool _showHoverSpeed: _controllerVehicle.multiRotor || _controllerVehicle.vtol
property bool _multipleFirmware: QGroundControl.supportedFirmwareCount > 2
property bool _multipleVehicleTypes: QGroundControl.supportedVehicleCount > 1
property bool _multipleFirmware: !QGroundControl.singleFirmwareSupport
property bool _multipleVehicleTypes: !QGroundControl.singleVehicleSupport
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 16
property bool _mobile: ScreenTools.isMobile
property var _savePath: QGroundControl.settingsManager.appSettings.missionSavePath
......@@ -194,7 +194,7 @@ Rectangle {
visible: _multipleFirmware
}
FactComboBox {
fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareType
fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
indexModel: false
Layout.preferredWidth: _fieldWidth
visible: _multipleFirmware && _noMissionItemsAdded
......@@ -210,7 +210,7 @@ Rectangle {
visible: _multipleVehicleTypes
}
FactComboBox {
fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleType
fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
indexModel: false
Layout.preferredWidth: _fieldWidth
visible: _multipleVehicleTypes && _noMissionItemsAdded
......
......@@ -19,12 +19,11 @@ import QGroundControl.Palette 1.0
QGCViewDialog {
id: root
property var vehicle
property var missionItem
property var map
property bool flyThroughCommandsAllowed
property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle
QGCPalette { id: qgcPal }
QGCLabel {
......@@ -38,10 +37,10 @@ QGCViewDialog {
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.left: categoryLabel.right
anchors.right: parent.right
model: QGroundControl.missionCommandTree.categoriesForVehicle(_vehicle)
model: QGroundControl.missionCommandTree.categoriesForVehicle(vehicle)
function categorySelected(category) {
commandList.model = QGroundControl.missionCommandTree.getCommandsForCategory(_vehicle, category, flyThroughCommandsAllowed)
commandList.model = QGroundControl.missionCommandTree.getCommandsForCategory(vehicle, category, flyThroughCommandsAllowed)
}
Component.onCompleted: {
......
......@@ -190,31 +190,28 @@ void QGroundControlQmlGlobal::setMavlinkSystemID(int id)
emit mavlinkSystemIDChanged(id);
}
int QGroundControlQmlGlobal::supportedFirmwareCount()
bool QGroundControlQmlGlobal::singleFirmwareSupport(void)
{
return _firmwarePluginManager->supportedFirmwareTypes().count();
return _firmwarePluginManager->supportedFirmwareClasses().count() == 1;
}
int QGroundControlQmlGlobal::supportedVehicleCount()
bool QGroundControlQmlGlobal::singleVehicleSupport(void)
{
int count = 0;
QList<MAV_AUTOPILOT> list = _firmwarePluginManager->supportedFirmwareTypes();
foreach(auto firmware, list) {
if(firmware != MAV_AUTOPILOT_GENERIC) {
count += _firmwarePluginManager->supportedVehicleTypes(firmware).count();
if (singleFirmwareSupport()) {
return _firmwarePluginManager->supportedVehicleClasses(_firmwarePluginManager->supportedFirmwareClasses()[0]).count() == 1;
}
}
return count;
return false;
}
bool QGroundControlQmlGlobal::px4ProFirmwareSupported()
{
return _firmwarePluginManager->supportedFirmwareTypes().contains(MAV_AUTOPILOT_PX4);
return _firmwarePluginManager->supportedFirmwareClasses().contains(QGCMAVLink::FirmwareClassPX4);
}
bool QGroundControlQmlGlobal::apmFirmwareSupported()
{
return _firmwarePluginManager->supportedFirmwareTypes().contains(MAV_AUTOPILOT_ARDUPILOTMEGA);
return _firmwarePluginManager->supportedFirmwareClasses().contains(QGCMAVLink::FirmwareClassArduPilot);
}
bool QGroundControlQmlGlobal::linesIntersect(QPointF line1A, QPointF line1B, QPointF line2A, QPointF line2B)
......
......@@ -7,12 +7,7 @@
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef QGroundControlQmlGlobal_H
#define QGroundControlQmlGlobal_H
#pragma once