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
50f2056b
Commit
50f2056b
authored
Dec 29, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse bit mask from meta data
parent
b33fb23e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
12 deletions
+76
-12
APMParameterMetaData.cc
src/FirmwarePlugin/APM/APMParameterMetaData.cc
+74
-12
APMParameterMetaData.h
src/FirmwarePlugin/APM/APMParameterMetaData.h
+2
-0
No files found.
src/FirmwarePlugin/APM/APMParameterMetaData.cc
View file @
50f2056b
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include <QDebug>
#include <QDebug>
QGC_LOGGING_CATEGORY
(
APMParameterMetaDataLog
,
"APMParameterMetaDataLog"
)
QGC_LOGGING_CATEGORY
(
APMParameterMetaDataLog
,
"APMParameterMetaDataLog"
)
QGC_LOGGING_CATEGORY
(
APMParameterMetaDataVerboseLog
,
"APMParameterMetaDataVerboseLog"
)
bool
APMParameterMetaData
::
_parameterMetaDataLoaded
=
false
;
bool
APMParameterMetaData
::
_parameterMetaDataLoaded
=
false
;
QMap
<
QString
,
ParameterNametoFactMetaDataMap
>
APMParameterMetaData
::
_vehicleTypeToParametersMap
;
QMap
<
QString
,
ParameterNametoFactMetaDataMap
>
APMParameterMetaData
::
_vehicleTypeToParametersMap
;
...
@@ -215,7 +216,7 @@ void APMParameterMetaData::_loadParameterFactMetaData()
...
@@ -215,7 +216,7 @@ void APMParameterMetaData::_loadParameterFactMetaData()
// so not setting currentCategory
// so not setting currentCategory
xmlState
.
push
(
XmlStateFoundParameters
);
xmlState
.
push
(
XmlStateFoundParameters
);
}
else
{
}
else
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"not interested in this block of parameters, skipping:"
<<
nameValue
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"not interested in this block of parameters, skipping:"
<<
nameValue
;
if
(
skipXMLBlock
(
xml
,
"parameters"
))
{
if
(
skipXMLBlock
(
xml
,
"parameters"
))
{
qCWarning
(
APMParameterMetaDataLog
)
<<
"something wrong with the xml, skip of the xml failed"
;
qCWarning
(
APMParameterMetaDataLog
)
<<
"something wrong with the xml, skip of the xml failed"
;
return
;
return
;
...
@@ -248,7 +249,7 @@ void APMParameterMetaData::_loadParameterFactMetaData()
...
@@ -248,7 +249,7 @@ void APMParameterMetaData::_loadParameterFactMetaData()
QString
longDescription
=
xml
.
attributes
().
value
(
"docmentation"
).
toString
();
QString
longDescription
=
xml
.
attributes
().
value
(
"docmentation"
).
toString
();
QString
userLevel
=
xml
.
attributes
().
value
(
"user"
).
toString
();
QString
userLevel
=
xml
.
attributes
().
value
(
"user"
).
toString
();
qCDebug
(
APMParameterMetaDataLog
)
<<
"Found parameter name:"
<<
name
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"Found parameter name:"
<<
name
<<
"short Desc:"
<<
shortDescription
<<
"short Desc:"
<<
shortDescription
<<
"longDescription:"
<<
longDescription
<<
"longDescription:"
<<
longDescription
<<
"user level: "
<<
userLevel
<<
"user level: "
<<
userLevel
...
@@ -261,7 +262,7 @@ void APMParameterMetaData::_loadParameterFactMetaData()
...
@@ -261,7 +262,7 @@ void APMParameterMetaData::_loadParameterFactMetaData()
qCWarning
(
APMParameterMetaDataLog
)
<<
"Duplicate parameter found:"
<<
name
;
qCWarning
(
APMParameterMetaDataLog
)
<<
"Duplicate parameter found:"
<<
name
;
badMetaData
=
true
;
badMetaData
=
true
;
}
else
{
}
else
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"inserting metadata for field"
<<
name
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"inserting metadata for field"
<<
name
;
_vehicleTypeToParametersMap
[
currentCategory
][
name
]
=
rawMetaData
;
_vehicleTypeToParametersMap
[
currentCategory
][
name
]
=
rawMetaData
;
rawMetaData
->
name
=
name
;
rawMetaData
->
name
=
name
;
rawMetaData
->
group
=
group
;
rawMetaData
->
group
=
group
;
...
@@ -291,17 +292,17 @@ void APMParameterMetaData::_loadParameterFactMetaData()
...
@@ -291,17 +292,17 @@ void APMParameterMetaData::_loadParameterFactMetaData()
if
(
elementName
==
"param"
&&
xmlState
.
top
()
==
XmlStateFoundParameter
)
{
if
(
elementName
==
"param"
&&
xmlState
.
top
()
==
XmlStateFoundParameter
)
{
// Done loading this parameter
// Done loading this parameter
// Reset for next parameter
// Reset for next parameter
qCDebug
(
APMParameterMetaDataLog
)
<<
"done loading parameter"
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"done loading parameter"
;
rawMetaData
=
NULL
;
rawMetaData
=
NULL
;
badMetaData
=
false
;
badMetaData
=
false
;
xmlState
.
pop
();
xmlState
.
pop
();
}
else
if
(
elementName
==
"parameters"
)
{
}
else
if
(
elementName
==
"parameters"
)
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"end of parameters for category: "
<<
currentCategory
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"end of parameters for category: "
<<
currentCategory
;
correctGroupMemberships
(
_vehicleTypeToParametersMap
[
currentCategory
],
groupMembers
);
correctGroupMemberships
(
_vehicleTypeToParametersMap
[
currentCategory
],
groupMembers
);
groupMembers
.
clear
();
groupMembers
.
clear
();
xmlState
.
pop
();
xmlState
.
pop
();
}
else
if
(
elementName
==
"vehicles"
)
{
}
else
if
(
elementName
==
"vehicles"
)
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"vehicles end here, libraries will follow"
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"vehicles end here, libraries will follow"
;
xmlState
.
pop
();
xmlState
.
pop
();
}
}
}
}
...
@@ -345,10 +346,10 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
...
@@ -345,10 +346,10 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
QString
range
=
xml
.
readElementText
().
trimmed
();
QString
range
=
xml
.
readElementText
().
trimmed
();
QStringList
rangeList
=
range
.
split
(
' '
);
QStringList
rangeList
=
range
.
split
(
' '
);
if
(
rangeList
.
count
()
!=
2
)
{
if
(
rangeList
.
count
()
!=
2
)
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"space seperator didn't work',trying 'to' separator"
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"space seperator didn't work',trying 'to' separator"
;
rangeList
=
range
.
split
(
"to"
);
rangeList
=
range
.
split
(
"to"
);
if
(
rangeList
.
count
()
!=
2
)
{
if
(
rangeList
.
count
()
!=
2
)
{
qCDebug
(
APMParameterMetaDataLog
)
<<
" 'to' seperaator didn't work', trying '-' as seperator"
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
" 'to' seperaator didn't work', trying '-' as seperator"
;
rangeList
=
range
.
split
(
'-'
);
rangeList
=
range
.
split
(
'-'
);
if
(
rangeList
.
count
()
!=
2
)
{
if
(
rangeList
.
count
()
!=
2
)
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"something wrong with range, all three separators have failed"
<<
range
;
qCDebug
(
APMParameterMetaDataLog
)
<<
"something wrong with range, all three separators have failed"
<<
range
;
...
@@ -368,24 +369,46 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
...
@@ -368,24 +369,46 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
if
(
rawMetaData
->
max
.
contains
(
' '
))
{
if
(
rawMetaData
->
max
.
contains
(
' '
))
{
rawMetaData
->
max
=
rawMetaData
->
max
.
split
(
' '
).
first
();
rawMetaData
->
max
=
rawMetaData
->
max
.
split
(
' '
).
first
();
}
}
qCDebug
(
APMParameterMetaDataLog
)
<<
"read field parameter "
<<
"min: "
<<
rawMetaData
->
min
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"read field parameter "
<<
"min: "
<<
rawMetaData
->
min
<<
"max: "
<<
rawMetaData
->
max
;
<<
"max: "
<<
rawMetaData
->
max
;
}
}
}
else
if
(
attributeName
==
"Increment"
)
{
}
else
if
(
attributeName
==
"Increment"
)
{
QString
increment
=
xml
.
readElementText
();
QString
increment
=
xml
.
readElementText
();
qCDebug
(
APMParameterMetaDataLog
)
<<
"read Increment: "
<<
increment
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"read Increment: "
<<
increment
;
rawMetaData
->
incrementSize
=
increment
;
rawMetaData
->
incrementSize
=
increment
;
}
else
if
(
attributeName
==
"Units"
)
{
}
else
if
(
attributeName
==
"Units"
)
{
QString
units
=
xml
.
readElementText
();
QString
units
=
xml
.
readElementText
();
qCDebug
(
APMParameterMetaDataLog
)
<<
"read Units: "
<<
units
;
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"read Units: "
<<
units
;
rawMetaData
->
units
=
units
;
rawMetaData
->
units
=
units
;
}
else
if
(
attributeName
==
"Bitmask"
)
{
bool
parseError
=
false
;
QString
bitmaskString
=
xml
.
readElementText
();
qCDebug
(
APMParameterMetaDataVerboseLog
)
<<
"read Bitmask: "
<<
bitmaskString
;
QStringList
bitmaskList
=
bitmaskString
.
split
(
","
);
if
(
bitmaskList
.
count
()
>
0
)
{
foreach
(
const
QString
&
bitmask
,
bitmaskList
)
{
QStringList
pair
=
bitmask
.
split
(
":"
);
if
(
pair
.
count
()
==
2
)
{
rawMetaData
->
bitmask
<<
QPair
<
QString
,
QString
>
(
pair
[
0
],
pair
[
1
]);
}
else
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"parse error: bitmask:"
<<
bitmaskString
<<
"pair count:"
<<
pair
.
count
();
parseError
=
true
;
break
;
}
}
}
if
(
parseError
)
{
rawMetaData
->
bitmask
.
clear
();
}
}
}
}
else
if
(
elementName
==
"values"
)
{
}
else
if
(
elementName
==
"values"
)
{
// doing nothing individual value will follow anyway. May be used for sanity checking.
// doing nothing individual value will follow anyway. May be used for sanity checking.
}
else
if
(
elementName
==
"value"
)
{
}
else
if
(
elementName
==
"value"
)
{
QString
valueValue
=
xml
.
attributes
().
value
(
"code"
).
toString
();
QString
valueValue
=
xml
.
attributes
().
value
(
"code"
).
toString
();
QString
valueName
=
xml
.
readElementText
();
QString
valueName
=
xml
.
readElementText
();
qCDebug
(
APMParameterMetaDataLog
)
<<
"read value parameter "
<<
"value desc: "
qCDebug
(
APMParameterMetaData
Verbose
Log
)
<<
"read value parameter "
<<
"value desc: "
<<
valueName
<<
"code: "
<<
valueValue
;
<<
valueName
<<
"code: "
<<
valueValue
;
values
<<
QPair
<
QString
,
QString
>
(
valueValue
,
valueName
);
values
<<
QPair
<
QString
,
QString
>
(
valueValue
,
valueName
);
rawMetaData
->
values
=
values
;
rawMetaData
->
values
=
values
;
...
@@ -488,6 +511,45 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
...
@@ -488,6 +511,45 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
}
}
}
}
if
(
rawMetaData
->
bitmask
.
count
()
>
0
)
{
QStringList
bitmaskStrings
;
QVariantList
bitmaskValues
;
for
(
int
i
=
0
;
i
<
rawMetaData
->
bitmask
.
count
();
i
++
)
{
QVariant
bitmaskValue
;
QString
errorString
;
QPair
<
QString
,
QString
>
bitmaskPair
=
rawMetaData
->
bitmask
[
i
];
bool
ok
=
false
;
unsigned
int
bitSet
=
bitmaskPair
.
first
.
toUInt
(
&
ok
);
bitSet
=
1
<<
bitSet
;
if
(
!
ok
)
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"Invalid bitmask value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" value:"
<<
bitmaskPair
.
first
<<
" error:"
<<
errorString
;
bitmaskStrings
.
clear
();
bitmaskValues
.
clear
();
break
;
}
if
(
metaData
->
convertAndValidateRaw
(
bitSet
,
false
/* validate */
,
bitmaskValue
,
errorString
))
{
bitmaskValues
<<
bitmaskValue
;
bitmaskStrings
<<
bitmaskPair
.
second
;
}
else
{
qCDebug
(
APMParameterMetaDataLog
)
<<
"Invalid bitmask value, name:"
<<
metaData
->
name
()
<<
" type:"
<<
metaData
->
type
()
<<
" value:"
<<
bitmaskPair
.
first
<<
" error:"
<<
errorString
;
bitmaskStrings
.
clear
();
bitmaskValues
.
clear
();
break
;
}
}
if
(
bitmaskStrings
.
count
()
!=
0
)
{
metaData
->
setBitmaskInfo
(
bitmaskStrings
,
bitmaskValues
);
}
}
// FixMe:: not handling increment size as their is no place for it in FactMetaData and no ui
// FixMe:: not handling increment size as their is no place for it in FactMetaData and no ui
fact
->
setMetaData
(
metaData
);
fact
->
setMetaData
(
metaData
);
}
}
src/FirmwarePlugin/APM/APMParameterMetaData.h
View file @
50f2056b
...
@@ -46,12 +46,14 @@ public:
...
@@ -46,12 +46,14 @@ public:
QString
incrementSize
;
QString
incrementSize
;
QString
units
;
QString
units
;
QList
<
QPair
<
QString
,
QString
>
>
values
;
QList
<
QPair
<
QString
,
QString
>
>
values
;
QList
<
QPair
<
QString
,
QString
>
>
bitmask
;
};
};
/// @file
/// @file
/// @author Don Gagne <don@thegagnes.com>
/// @author Don Gagne <don@thegagnes.com>
Q_DECLARE_LOGGING_CATEGORY
(
APMParameterMetaDataLog
)
Q_DECLARE_LOGGING_CATEGORY
(
APMParameterMetaDataLog
)
Q_DECLARE_LOGGING_CATEGORY
(
APMParameterMetaDataVerboseLog
)
/// Collection of Parameter Facts for PX4 AutoPilot
/// Collection of Parameter Facts for PX4 AutoPilot
...
...
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