9#include <QtCore/QApplicationStatic>
18 qCDebug(MissionCommandTreeLog) <<
this;
34 if (!overrideFile.isEmpty()) {
36 _staticCommandTree[firmwareClass][vehicleClass] =
new MissionCommandList(overrideFile, baseCommandList,
this);
45 for (
const auto &vehicleMap : std::as_const(_allCommands)) {
46 for (
const auto &commandMap : vehicleMap) {
54 qCDebug(MissionCommandTreeLog) <<
this;
59 return _missionCommandTreeInstance();
63 QMap<MAV_CMD, MissionCommandUIInfo*>& collapsedTree,
bool baseList)
const
69 for (
const MAV_CMD command: cmdList->commandIds()) {
72 if (collapsedTree.contains(command)) {
73 collapsedTree[
command]->_overrideInfo(uiInfo);
74 }
else if (baseList) {
78 qCWarning(MissionCommandTreeLog) <<
"Skipping override with no base command info" <<
command;
89 _firmwareAndVehicleClassInfo(vehicle, vtolMode, firmwareClass, vehicleClass);
91 if (_allCommands.contains(firmwareClass) && _allCommands[firmwareClass].contains(vehicleClass)) {
96 QMap<MAV_CMD, MissionCommandUIInfo*> &collapsedTree = _allCommands[firmwareClass][vehicleClass];
113 _collapseHierarchy(_staticCommandTree[firmwareClass][vehicleClass], collapsedTree);
119 for (
const MAV_CMD cmd: collapsedTree.
keys()) {
120 if (supportedCommands.contains(cmd)) {
121 const QString newCategory = collapsedTree[cmd]->category();
122 if (!_supportedCategories[firmwareClass][vehicleClass].contains(newCategory)) {
123 _supportedCategories[firmwareClass][vehicleClass].append(newCategory);
128 _supportedCategories[firmwareClass][vehicleClass].append(_allCommandsCategory);
131QStringList MissionCommandTree::_availableCategoriesForVehicle(
Vehicle *vehicle)
139 return _supportedCategories[firmwareClass][vehicleClass];
147 return uiInfo ? uiInfo->
friendlyName() : QStringLiteral(
"MAV_CMD(%1)").arg(
static_cast<int>(command));
155 return uiInfo ? uiInfo->
rawName() : QStringLiteral(
"MAV_CMD(%1)").arg(
static_cast<int>(command));
184 _firmwareAndVehicleClassInfo(vehicle, vtolMode, firmwareClass, vehicleClass);
185 _buildAllCommands(vehicle, vtolMode);
189 const QMap<MAV_CMD, MissionCommandUIInfo*> &infoMap = _allCommands[firmwareClass][vehicleClass];
190 if (infoMap.contains(command)) {
191 result = infoMap[command];
199 return _availableCategoriesForVehicle(vehicle);
215 const QMap<MAV_CMD, MissionCommandUIInfo*> commandMap = _allCommands[firmwareClass][vehicleClass];
217 for (
const MAV_CMD command: commandMap.keys()) {
218 if (supportedCommands.isEmpty() || supportedCommands.contains(command)) {
221 list.append(QVariant::fromValue(uiInfo));
234 vehicleClass = vtolMode;
Q_APPLICATION_STATIC(MissionCommandTree, _missionCommandTreeInstance)
#define QGC_LOGGING_CATEGORY(name, categoryStr)
std::array< MsgOutKey, 4 > keys
FirmwarePlugin * firmwarePluginForAutopilot(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType)
QList< QGCMAVLink::FirmwareClass_t > supportedFirmwareClasses()
Returns list of firmwares which are supported by the system.
static FirmwarePluginManager * instance()
The FirmwarePlugin class represents the methods and objects which are specific to a certain Firmware ...
virtual QString missionCommandOverrides(QGCMAVLinkTypes::VehicleClass_t vehicleClass) const
virtual QList< MAV_CMD > supportedMissionCommands(QGCMAVLinkTypes::VehicleClass_t) const
List of supported mission commands. Empty list for all commands supported.
Maintains a list of MissionCommandUIInfo objects loaded from a json file.
MissionCommandUIInfo * getUIInfo(MAV_CMD command) const
Returns the ui info for specified command, NULL if command not found.
Manages a hierarchy of MissionCommandUIInfo.
bool isTakeoffCommand(MAV_CMD command) const
MissionCommandTree(bool unitTest=false, QObject *parent=nullptr)
bool isLandCommand(MAV_CMD command) const
~MissionCommandTree()
Destructor for the MissionCommandTree class.
const QList< MAV_CMD > & allCommandIds() const
static MissionCommandTree * instance()
QString rawName(MAV_CMD command) const
Returns the raw name for the specified command.
Q_INVOKABLE QVariantList getCommandsForCategory(Vehicle *vehicle, const QString &category, bool showFlyThroughCommands)
QString friendlyName(MAV_CMD command) const
Returns the friendly name for the specified command.
Q_INVOKABLE QStringList categoriesForVehicle(Vehicle *vehicle)
const MissionCommandUIInfo * getUIInfo(Vehicle *vehicle, QGCMAVLink::VehicleClass_t vtolMode, MAV_CMD command)
UI Information associated with a mission command (MAV_CMD)
QString category(void) const
bool isTakeoffCommand(void) const
QString friendlyName(void) const
bool specifiesCoordinate(void) const
bool isStandaloneCoordinate(void) const
QString rawName(void) const
bool isLandCommand(void) const
static VehicleClass_t vehicleClass(MAV_TYPE mavType)
static constexpr const VehicleClass_t VehicleClassSub
static constexpr const VehicleClass_t VehicleClassFixedWing
static constexpr const VehicleClass_t VehicleClassMultiRotor
static MAV_TYPE vehicleClassToMavType(VehicleClass_t vehicleClass)
static MAV_AUTOPILOT firmwareClassToAutopilot(FirmwareClass_t firmwareClass)
static constexpr const FirmwareClass_t FirmwareClassGeneric
static constexpr const VehicleClass_t VehicleClassRoverBoat
static FirmwareClass_t firmwareClass(MAV_AUTOPILOT autopilot)
static constexpr const VehicleClass_t VehicleClassVTOL
static QList< VehicleClass_t > allVehicleClasses(void)
MAV_TYPE vehicleType() const
FirmwarePlugin * firmwarePlugin()
Provides access to the Firmware Plugin for this Vehicle.
MAV_AUTOPILOT firmwareType() const
GPSCommandSequence::Command command(QByteArrayView body, GPSTextMatcher reply, std::chrono::milliseconds timeout)
body labelled by its text, framed as a sentence, and completed by reply within timeout.
static constexpr VehicleClass_t VehicleClassGeneric