Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
d6ad774b
Unverified
Commit
d6ad774b
authored
May 03, 2019
by
Don Gagne
Committed by
GitHub
May 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7414 from DonLakeFlyer/AllCommands
Command Tree contains all commands
parents
d22f4886
517b0ba1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
49 deletions
+38
-49
MissionCommandTree.cc
src/MissionManager/MissionCommandTree.cc
+29
-40
MissionCommandTree.h
src/MissionManager/MissionCommandTree.h
+9
-9
No files found.
src/MissionManager/MissionCommandTree.cc
View file @
d6ad774b
...
...
@@ -106,14 +106,6 @@ void MissionCommandTree::_collapseHierarchy(Vehicle*
_baseVehicleInfo
(
vehicle
,
baseFirmwareType
,
baseVehicleType
);
for
(
MAV_CMD
command
:
cmdList
->
commandIds
())
{
// Only add supported command to tree (MAV_CMD_NAV_LAST is used for planned home position)
if
(
!
qgcApp
()
->
runningUnitTests
()
&&
!
vehicle
->
firmwarePlugin
()
->
supportedMissionCommands
().
isEmpty
()
&&
!
vehicle
->
firmwarePlugin
()
->
supportedMissionCommands
().
contains
(
command
)
&&
command
!=
MAV_CMD_NAV_LAST
)
{
continue
;
}
MissionCommandUIInfo
*
uiInfo
=
cmdList
->
getUIInfo
(
command
);
if
(
uiInfo
)
{
if
(
collapsedTree
.
contains
(
command
))
{
...
...
@@ -125,22 +117,20 @@ void MissionCommandTree::_collapseHierarchy(Vehicle*
}
}
void
MissionCommandTree
::
_buildA
vailable
Commands
(
Vehicle
*
vehicle
)
void
MissionCommandTree
::
_buildA
ll
Commands
(
Vehicle
*
vehicle
)
{
MAV_AUTOPILOT
baseFirmwareType
;
MAV_TYPE
baseVehicleType
;
_baseVehicleInfo
(
vehicle
,
baseFirmwareType
,
baseVehicleType
);
if
(
_a
vailable
Commands
.
contains
(
baseFirmwareType
)
&&
_a
vailable
Commands
[
baseFirmwareType
].
contains
(
baseVehicleType
))
{
// A
vailable commands list a
lready built
if
(
_a
ll
Commands
.
contains
(
baseFirmwareType
)
&&
_a
ll
Commands
[
baseFirmwareType
].
contains
(
baseVehicleType
))
{
// Already built
return
;
}
// Build new available commands list
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>&
collapsedTree
=
_availableCommands
[
baseFirmwareType
][
baseVehicleType
];
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>&
collapsedTree
=
_allCommands
[
baseFirmwareType
][
baseVehicleType
];
// Any Firmware, Any Vehicle
_collapseHierarchy
(
vehicle
,
_staticCommandTree
[
MAV_AUTOPILOT_GENERIC
][
MAV_TYPE_GENERIC
],
collapsedTree
);
...
...
@@ -160,16 +150,17 @@ void MissionCommandTree::_buildAvailableCommands(Vehicle* vehicle)
}
}
// Build category list
Q
MapIterator
<
MAV_CMD
,
MissionCommandUIInfo
*>
iter
(
collapsedTree
);
while
(
iter
.
hasNext
())
{
i
ter
.
next
();
QString
newCategory
=
iter
.
value
()
->
category
();
if
(
!
_available
Categories
[
baseFirmwareType
][
baseVehicleType
].
contains
(
newCategory
))
{
_available
Categories
[
baseFirmwareType
][
baseVehicleType
].
append
(
newCategory
);
// Build category list
from supported commands
Q
List
<
MAV_CMD
>
supportedCommands
=
vehicle
->
firmwarePlugin
()
->
supportedMissionCommands
(
);
for
(
MAV_CMD
cmd
:
collapsedTree
.
keys
())
{
i
f
(
supportedCommands
.
contains
(
cmd
))
{
QString
newCategory
=
collapsedTree
[
cmd
]
->
category
();
if
(
!
_supported
Categories
[
baseFirmwareType
][
baseVehicleType
].
contains
(
newCategory
))
{
_supported
Categories
[
baseFirmwareType
][
baseVehicleType
].
append
(
newCategory
);
}
}
_availableCategories
[
baseFirmwareType
][
baseVehicleType
].
append
(
_allCommandsCategory
);
}
_supportedCategories
[
baseFirmwareType
][
baseVehicleType
].
append
(
_allCommandsCategory
);
}
QStringList
MissionCommandTree
::
_availableCategoriesForVehicle
(
Vehicle
*
vehicle
)
...
...
@@ -178,9 +169,9 @@ QStringList MissionCommandTree::_availableCategoriesForVehicle(Vehicle* vehicle)
MAV_TYPE
baseVehicleType
;
_baseVehicleInfo
(
vehicle
,
baseFirmwareType
,
baseVehicleType
);
_buildA
vailable
Commands
(
vehicle
);
_buildA
ll
Commands
(
vehicle
);
return
_
available
Categories
[
baseFirmwareType
][
baseVehicleType
];
return
_
supported
Categories
[
baseFirmwareType
][
baseVehicleType
];
}
QString
MissionCommandTree
::
friendlyName
(
MAV_CMD
command
)
...
...
@@ -191,7 +182,7 @@ QString MissionCommandTree::friendlyName(MAV_CMD command)
if
(
uiInfo
)
{
return
uiInfo
->
friendlyName
();
}
else
{
return
QString
(
"MAV_CMD(%1)"
).
arg
((
int
)
command
);
return
QString
Literal
(
"MAV_CMD(%1)"
).
arg
((
int
)
command
);
}
}
...
...
@@ -203,7 +194,7 @@ QString MissionCommandTree::rawName(MAV_CMD command)
if
(
uiInfo
)
{
return
uiInfo
->
rawName
();
}
else
{
return
QString
(
"MAV_CMD(%1)"
).
arg
((
int
)
command
);
return
QString
Literal
(
"MAV_CMD(%1)"
).
arg
((
int
)
command
);
}
}
...
...
@@ -218,13 +209,13 @@ const MissionCommandUIInfo* MissionCommandTree::getUIInfo(Vehicle* vehicle, MAV_
MAV_TYPE
baseVehicleType
;
_baseVehicleInfo
(
vehicle
,
baseFirmwareType
,
baseVehicleType
);
_buildA
vailable
Commands
(
vehicle
);
_buildA
ll
Commands
(
vehicle
);
const
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>&
infoMap
=
_a
vailable
Commands
[
baseFirmwareType
][
baseVehicleType
];
const
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>&
infoMap
=
_a
ll
Commands
[
baseFirmwareType
][
baseVehicleType
];
if
(
infoMap
.
contains
(
command
))
{
return
infoMap
[
command
];
}
else
{
return
NULL
;
return
nullptr
;
}
}
...
...
@@ -232,23 +223,21 @@ QVariantList MissionCommandTree::getCommandsForCategory(Vehicle* vehicle, const
{
MAV_AUTOPILOT
baseFirmwareType
;
MAV_TYPE
baseVehicleType
;
QList
<
MAV_CMD
>
supportedCommands
=
vehicle
->
firmwarePlugin
()
->
supportedMissionCommands
();
_baseVehicleInfo
(
vehicle
,
baseFirmwareType
,
baseVehicleType
);
_buildA
vailable
Commands
(
vehicle
);
_buildA
ll
Commands
(
vehicle
);
QVariantList
list
;
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>
commandMap
=
_a
vailable
Commands
[
baseFirmwareType
][
baseVehicleType
];
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>
commandMap
=
_a
ll
Commands
[
baseFirmwareType
][
baseVehicleType
];
for
(
MAV_CMD
command
:
commandMap
.
keys
())
{
if
(
command
==
MAV_CMD_NAV_LAST
)
{
// MAV_CMD_NAV_LAST is used for Mission Settings item. Although we want to be able to get command info for it.
// The user should not be able to use it as a command.
continue
;
}
if
(
supportedCommands
.
contains
(
command
))
{
MissionCommandUIInfo
*
uiInfo
=
commandMap
[
command
];
if
(
uiInfo
->
category
()
==
category
||
category
==
_allCommandsCategory
)
{
list
.
append
(
QVariant
::
fromValue
(
uiInfo
));
}
}
}
return
list
;
}
...
...
src/MissionManager/MissionCommandTree.h
View file @
d6ad774b
...
...
@@ -41,7 +41,7 @@ class MissionCommandTreeTest;
/// For known firmwares, the override files are requested from the FirmwarePlugin.
///
/// When ui info is requested for a specific vehicle the static hierarchy in _staticCommandTree is collapsed into the set of available commands in
/// _a
vailable
Commands taking into account the appropriate set of overrides for the MAV_AUTOPILOT/MAV_TYPE combination associated with the vehicle.
/// _a
ll
Commands taking into account the appropriate set of overrides for the MAV_AUTOPILOT/MAV_TYPE combination associated with the vehicle.
///
class
MissionCommandTree
:
public
QGCTool
{
...
...
@@ -71,7 +71,7 @@ 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
_buildAvailable
Commands
(
Vehicle
*
vehicle
);
void
_buildAll
Commands
(
Vehicle
*
vehicle
);
QStringList
_availableCategoriesForVehicle
(
Vehicle
*
vehicle
);
void
_baseVehicleInfo
(
Vehicle
*
vehicle
,
MAV_AUTOPILOT
&
baseFirmwareType
,
MAV_TYPE
&
baseVehicleType
)
const
;
...
...
@@ -85,10 +85,10 @@ private:
QMap
<
MAV_AUTOPILOT
,
QMap
<
MAV_TYPE
,
MissionCommandList
*>>
_staticCommandTree
;
/// Collapsed hierarchy for specific vehicle type
QMap
<
MAV_AUTOPILOT
,
QMap
<
MAV_TYPE
,
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>>>
_a
vailable
Commands
;
QMap
<
MAV_AUTOPILOT
,
QMap
<
MAV_TYPE
,
QMap
<
MAV_CMD
,
MissionCommandUIInfo
*>>>
_a
ll
Commands
;
/// Collapsed hierarchy for specific vehicle type
QMap
<
MAV_AUTOPILOT
,
QMap
<
MAV_TYPE
,
QStringList
>>
_available
Categories
;
QMap
<
MAV_AUTOPILOT
,
QMap
<
MAV_TYPE
,
QStringList
/* category */
>>
_supported
Categories
;
#ifdef UNITTEST_BUILD
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment