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
46604020
Commit
46604020
authored
Dec 15, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2414 from DonLakeFlyer/UnknownEnum
Handle unknown enum values in meta data
parents
9b842b72
763635c9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
28 deletions
+65
-28
Fact.cc
src/FactSystem/Fact.cc
+9
-2
Fact.h
src/FactSystem/Fact.h
+7
-4
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+6
-0
FactMetaData.h
src/FactSystem/FactMetaData.h
+3
-0
MissionItem.cc
src/MissionManager/MissionItem.cc
+40
-22
No files found.
src/FactSystem/Fact.cc
View file @
46604020
...
...
@@ -165,7 +165,7 @@ QVariant Fact::cookedValue(void) const
}
}
QString
Fact
::
enumStringValue
(
void
)
const
QString
Fact
::
enumStringValue
(
void
)
{
if
(
_metaData
)
{
int
enumIndex
=
this
->
enumIndex
();
...
...
@@ -179,16 +179,23 @@ QString Fact::enumStringValue(void) const
return
QString
();
}
int
Fact
::
enumIndex
(
void
)
const
int
Fact
::
enumIndex
(
void
)
{
if
(
_metaData
)
{
int
index
=
0
;
foreach
(
QVariant
enumValue
,
_metaData
->
enumValues
())
{
if
(
enumValue
==
rawValue
())
{
return
index
;
}
index
++
;
}
// Current value is not in list, add it manually
_metaData
->
addEnumInfo
(
QString
(
"Unknown: %1"
).
arg
(
rawValue
().
toString
()),
rawValue
());
emit
enumStringsChanged
();
emit
enumValuesChanged
();
return
index
;
}
else
{
qWarning
()
<<
"Meta data pointer missing"
;
}
...
...
src/FactSystem/Fact.h
View file @
46604020
...
...
@@ -52,9 +52,9 @@ public:
Q_PROPERTY
(
QString
defaultValueString
READ
defaultValueString
CONSTANT
)
Q_PROPERTY
(
bool
defaultValueAvailable
READ
defaultValueAvailable
CONSTANT
)
Q_PROPERTY
(
int
enumIndex
READ
enumIndex
WRITE
setEnumIndex
NOTIFY
valueChanged
)
Q_PROPERTY
(
QStringList
enumStrings
READ
enumStrings
CONSTANT
)
Q_PROPERTY
(
QStringList
enumStrings
READ
enumStrings
NOTIFY
enumStringsChanged
)
Q_PROPERTY
(
QString
enumStringValue
READ
enumStringValue
WRITE
setEnumStringValue
NOTIFY
valueChanged
)
Q_PROPERTY
(
QVariantList
enumValues
READ
enumValues
CONSTANT
)
Q_PROPERTY
(
QVariantList
enumValues
READ
enumValues
NOTIFY
enumValuesChanged
)
Q_PROPERTY
(
QString
group
READ
group
CONSTANT
)
Q_PROPERTY
(
QString
longDescription
READ
longDescription
CONSTANT
)
Q_PROPERTY
(
QVariant
max
READ
max
CONSTANT
)
...
...
@@ -81,9 +81,9 @@ public:
QVariant
defaultValue
(
void
)
const
;
bool
defaultValueAvailable
(
void
)
const
;
QString
defaultValueString
(
void
)
const
;
int
enumIndex
(
void
)
const
;
int
enumIndex
(
void
)
;
// This is not const, since an unknown value can modify the enum lists
QStringList
enumStrings
(
void
)
const
;
QString
enumStringValue
(
void
)
const
;
QString
enumStringValue
(
void
)
;
// This is not const, since an unknown value can modify the enum lists
QVariantList
enumValues
(
void
)
const
;
QString
group
(
void
)
const
;
QString
longDescription
(
void
)
const
;
...
...
@@ -120,6 +120,9 @@ public:
void
_setName
(
const
QString
&
name
)
{
_name
=
name
;
}
signals:
void
enumStringsChanged
(
void
);
void
enumValuesChanged
(
void
);
/// QObject Property System signal for value property changes
///
/// This signal is only meant for use by the QT property system. It should not be connected to by client code.
...
...
src/FactSystem/FactMetaData.cc
View file @
46604020
...
...
@@ -260,3 +260,9 @@ void FactMetaData::setTranslators(Translator rawTranslator, Translator cookedTra
_rawTranslator
=
rawTranslator
;
_cookedTranslator
=
cookedTranslator
;
}
void
FactMetaData
::
addEnumInfo
(
const
QString
&
name
,
const
QVariant
&
value
)
{
_enumStrings
<<
name
;
_enumValues
<<
value
;
}
src/FactSystem/FactMetaData.h
View file @
46604020
...
...
@@ -79,6 +79,9 @@ public:
Translator
rawTranslator
(
void
)
const
{
return
_rawTranslator
;
}
Translator
cookedTranslator
(
void
)
const
{
return
_cookedTranslator
;
}
/// Used to add new values to the enum lists after the meta data has been loaded
void
addEnumInfo
(
const
QString
&
name
,
const
QVariant
&
value
);
void
setDecimalPlaces
(
int
decimalPlaces
)
{
_decimalPlaces
=
decimalPlaces
;
}
void
setDefaultValue
(
const
QVariant
&
defaultValue
);
void
setEnumInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
);
...
...
src/MissionManager/MissionItem.cc
View file @
46604020
...
...
@@ -45,18 +45,18 @@ struct EnumInfo_s {
};
static
const
struct
EnumInfo_s
_rgMavFrameInfo
[]
=
{
{
"MAV_FRAME_GLOBAL"
,
MAV_FRAME_GLOBAL
},
{
"MAV_FRAME_LOCAL_NED"
,
MAV_FRAME_LOCAL_NED
},
{
"MAV_FRAME_MISSION"
,
MAV_FRAME_MISSION
},
{
"MAV_FRAME_GLOBAL_RELATIVE_ALT"
,
MAV_FRAME_GLOBAL_RELATIVE_ALT
},
{
"MAV_FRAME_LOCAL_ENU"
,
MAV_FRAME_LOCAL_ENU
},
{
"MAV_FRAME_GLOBAL_INT"
,
MAV_FRAME_GLOBAL_INT
},
{
"MAV_FRAME_GLOBAL_RELATIVE_ALT_INT"
,
MAV_FRAME_GLOBAL_RELATIVE_ALT_INT
},
{
"MAV_FRAME_LOCAL_OFFSET_NED"
,
MAV_FRAME_LOCAL_OFFSET_NED
},
{
"MAV_FRAME_BODY_NED"
,
MAV_FRAME_BODY_NED
},
{
"MAV_FRAME_BODY_OFFSET_NED"
,
MAV_FRAME_BODY_OFFSET_NED
},
{
"MAV_FRAME_GLOBAL_TERRAIN_ALT"
,
MAV_FRAME_GLOBAL_TERRAIN_ALT
},
{
"MAV_FRAME_GLOBAL_TERRAIN_ALT_INT"
,
MAV_FRAME_GLOBAL_TERRAIN_ALT_INT
},
{
"MAV_FRAME_GLOBAL"
,
MAV_FRAME_GLOBAL
},
{
"MAV_FRAME_LOCAL_NED"
,
MAV_FRAME_LOCAL_NED
},
{
"MAV_FRAME_MISSION"
,
MAV_FRAME_MISSION
},
{
"MAV_FRAME_GLOBAL_RELATIVE_ALT"
,
MAV_FRAME_GLOBAL_RELATIVE_ALT
},
{
"MAV_FRAME_LOCAL_ENU"
,
MAV_FRAME_LOCAL_ENU
},
{
"MAV_FRAME_GLOBAL_INT"
,
MAV_FRAME_GLOBAL_INT
},
{
"MAV_FRAME_GLOBAL_RELATIVE_ALT_INT"
,
MAV_FRAME_GLOBAL_RELATIVE_ALT_INT
},
{
"MAV_FRAME_LOCAL_OFFSET_NED"
,
MAV_FRAME_LOCAL_OFFSET_NED
},
{
"MAV_FRAME_BODY_NED"
,
MAV_FRAME_BODY_NED
},
{
"MAV_FRAME_BODY_OFFSET_NED"
,
MAV_FRAME_BODY_OFFSET_NED
},
{
"MAV_FRAME_GLOBAL_TERRAIN_ALT"
,
MAV_FRAME_GLOBAL_TERRAIN_ALT
},
{
"MAV_FRAME_GLOBAL_TERRAIN_ALT_INT"
,
MAV_FRAME_GLOBAL_TERRAIN_ALT_INT
},
};
QDebug
operator
<<
(
QDebug
dbg
,
const
MissionItem
&
missionItem
)
...
...
@@ -514,17 +514,30 @@ void MissionItem::setParam7(double param)
bool
MissionItem
::
standaloneCoordinate
(
void
)
const
{
return
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
standaloneCoordinate
();
if
(
_mavCmdInfoMap
.
contains
((
MAV_CMD
)
command
()))
{
return
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
standaloneCoordinate
();
}
else
{
return
false
;
}
}
bool
MissionItem
::
specifiesCoordinate
(
void
)
const
{
return
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
specifiesCoordinate
();
if
(
_mavCmdInfoMap
.
contains
((
MAV_CMD
)
command
()))
{
return
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
specifiesCoordinate
();
}
else
{
return
false
;
}
}
QString
MissionItem
::
commandDescription
(
void
)
const
{
return
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
description
();
if
(
_mavCmdInfoMap
.
contains
((
MAV_CMD
)
command
()))
{
return
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
description
();
}
else
{
qWarning
()
<<
"Should not ask for command description on unknown command"
;
return
QString
();
}
}
void
MissionItem
::
_clearParamMetaData
(
void
)
...
...
@@ -676,7 +689,7 @@ void MissionItem::setCoordinate(const QGeoCoordinate& coordinate)
bool
MissionItem
::
friendlyEditAllowed
(
void
)
const
{
if
(
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
friendlyEdit
())
{
if
(
_mavCmdInfoMap
.
contains
((
MAV_CMD
)
command
())
&&
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
friendlyEdit
())
{
if
(
!
autoContinue
())
{
return
false
;
}
...
...
@@ -797,10 +810,12 @@ void MissionItem::setDefaultsForCommand(void)
// We set these global defaults first, then if there are param defaults they will get reset
setParam7
(
defaultAltitude
);
foreach
(
const
MavCmdParamInfo
*
paramInfo
,
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
paramInfoMap
())
{
Fact
*
rgParamFacts
[
7
]
=
{
&
_param1Fact
,
&
_param2Fact
,
&
_param3Fact
,
&
_param4Fact
,
&
_param5Fact
,
&
_param6Fact
,
&
_param7Fact
};
if
(
_mavCmdInfoMap
.
contains
((
MAV_CMD
)
command
()))
{
foreach
(
const
MavCmdParamInfo
*
paramInfo
,
_mavCmdInfoMap
[(
MAV_CMD
)
command
()]
->
paramInfoMap
())
{
Fact
*
rgParamFacts
[
7
]
=
{
&
_param1Fact
,
&
_param2Fact
,
&
_param3Fact
,
&
_param4Fact
,
&
_param5Fact
,
&
_param6Fact
,
&
_param7Fact
};
rgParamFacts
[
paramInfo
->
param
()
-
1
]
->
setRawValue
(
paramInfo
->
defaultValue
());
rgParamFacts
[
paramInfo
->
param
()
-
1
]
->
setRawValue
(
paramInfo
->
defaultValue
());
}
}
setAutoContinue
(
true
);
...
...
@@ -825,9 +840,12 @@ void MissionItem::_sendCommandChanged(void)
QString
MissionItem
::
commandName
(
void
)
const
{
const
MavCmdInfo
*
mavCmdInfo
=
_mavCmdInfoMap
[(
MAV_CMD
)
command
()];
return
mavCmdInfo
->
friendlyName
().
isEmpty
()
?
mavCmdInfo
->
rawName
()
:
mavCmdInfo
->
friendlyName
();
if
(
_mavCmdInfoMap
.
contains
((
MAV_CMD
)
command
()))
{
const
MavCmdInfo
*
mavCmdInfo
=
_mavCmdInfoMap
[(
MAV_CMD
)
command
()];
return
mavCmdInfo
->
friendlyName
().
isEmpty
()
?
mavCmdInfo
->
rawName
()
:
mavCmdInfo
->
friendlyName
();
}
else
{
return
QString
(
"Unknown: %1"
).
arg
(
command
());
}
}
QVariant
MissionItem
::
_degreesToRadians
(
const
QVariant
&
degrees
)
...
...
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