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
517b0ba1
Commit
517b0ba1
authored
May 03, 2019
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
1ee48046
Changes
2
Hide 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 @
517b0ba1
...
...
@@ -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
QMapIterator
<
MAV_CMD
,
MissionCommandUIInfo
*>
iter
(
collapsedTree
);
while
(
iter
.
hasNext
())
{
iter
.
next
();
QString
newCategory
=
iter
.
value
()
->
category
();
if
(
!
_availableCategories
[
baseFirmwareType
][
baseVehicleType
].
contains
(
newCategory
))
{
_availableCategories
[
baseFirmwareType
][
baseVehicleType
].
append
(
newCategory
);
// Build category list from supported commands
QList
<
MAV_CMD
>
supportedCommands
=
vehicle
->
firmwarePlugin
()
->
supportedMissionCommands
();
for
(
MAV_CMD
cmd
:
collapsedTree
.
keys
())
{
if
(
supportedCommands
.
contains
(
cmd
))
{
QString
newCategory
=
collapsedTree
[
cmd
]
->
category
();
if
(
!
_supportedCategories
[
baseFirmwareType
][
baseVehicleType
].
contains
(
newCategory
))
{
_supportedCategories
[
baseFirmwareType
][
baseVehicleType
].
append
(
newCategory
);
}
}
}
_
available
Categories
[
baseFirmwareType
][
baseVehicleType
].
append
(
_allCommandsCategory
);
_
supported
Categories
[
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,21 +223,19 @@ 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
;
}
MissionCommandUIInfo
*
uiInfo
=
commandMap
[
command
];
if
(
uiInfo
->
category
()
==
category
||
category
==
_allCommandsCategory
)
{
list
.
append
(
QVariant
::
fromValue
(
uiInfo
));
if
(
supportedCommands
.
contains
(
command
))
{
MissionCommandUIInfo
*
uiInfo
=
commandMap
[
command
];
if
(
uiInfo
->
category
()
==
category
||
category
==
_allCommandsCategory
)
{
list
.
append
(
QVariant
::
fromValue
(
uiInfo
));
}
}
}
...
...
src/MissionManager/MissionCommandTree.h
View file @
517b0ba1
...
...
@@ -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
{
...
...
@@ -68,12 +68,12 @@ public:
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
_buildAvailable
Commands
(
Vehicle
*
vehicle
);
QStringList
_availableCategoriesForVehicle
(
Vehicle
*
vehicle
);
void
_baseVehicleInfo
(
Vehicle
*
vehicle
,
MAV_AUTOPILOT
&
baseFirmwareType
,
MAV_TYPE
&
baseVehicleType
)
const
;
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
_buildAll
Commands
(
Vehicle
*
vehicle
);
QStringList
_availableCategoriesForVehicle
(
Vehicle
*
vehicle
);
void
_baseVehicleInfo
(
Vehicle
*
vehicle
,
MAV_AUTOPILOT
&
baseFirmwareType
,
MAV_TYPE
&
baseVehicleType
)
const
;
private:
QString
_allCommandsCategory
;
///< Category which contains all available commands
...
...
@@ -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