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
ee4d1384
Commit
ee4d1384
authored
Jul 01, 2020
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
c94f1661
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
0 deletions
+94
-0
PX4ParameterMetaData.cc
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
+88
-0
PX4ParameterMetaData.h
src/FirmwarePlugin/PX4/PX4ParameterMetaData.h
+6
-0
No files found.
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
View file @
ee4d1384
...
...
@@ -401,7 +401,95 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
}
xml
.
readNext
();
}
#ifdef GENERATE_PARAMETER_JSON
_generateParameterJson
();
#endif
}
#ifdef GENERATE_PARAMETER_JSON
void
_jsonWriteLine
(
QFile
&
file
,
int
indent
,
const
QString
&
line
)
{
while
(
indent
--
)
{
file
.
write
(
" "
);
}
file
.
write
(
line
.
toLocal8Bit
().
constData
());
file
.
write
(
"
\n
"
);
}
void
PX4ParameterMetaData
::
_generateParameterJson
()
{
qCDebug
(
ParameterManagerLog
)
<<
"PX4ParameterMetaData::_generateParameterJson"
;
int
indentLevel
=
0
;
QFile
jsonFile
(
QDir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)).
absoluteFilePath
(
"parameter.json"
));
jsonFile
.
open
(
QFile
::
WriteOnly
|
QFile
::
Truncate
|
QFile
::
Text
);
_jsonWriteLine
(
jsonFile
,
indentLevel
++
,
"{"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
"
\"
version
\"
: 1,"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
"
\"
uid
\"
: 1,"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
"
\"
scope
\"
:
\"
Firmware
\"
,"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
++
,
"
\"
parameters
\"
: ["
);
int
keyIndex
=
0
;
for
(
const
QString
&
paramName
:
_mapParameterName2FactMetaData
.
keys
())
{
const
FactMetaData
*
metaData
=
_mapParameterName2FactMetaData
[
paramName
];
_jsonWriteLine
(
jsonFile
,
indentLevel
++
,
"{"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
name
\"
:
\"
%1
\"
,"
).
arg
(
paramName
));
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
type
\"
:
\"
%1
\"
,"
).
arg
(
metaData
->
typeToString
(
metaData
->
type
())));
if
(
!
metaData
->
group
().
isEmpty
())
{
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
group
\"
:
\"
%1
\"
,"
).
arg
(
metaData
->
group
()));
}
if
(
!
metaData
->
category
().
isEmpty
())
{
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
category
\"
:
\"
%1
\"
,"
).
arg
(
metaData
->
category
()));
}
if
(
!
metaData
->
shortDescription
().
isEmpty
())
{
QString
text
=
metaData
->
shortDescription
();
text
.
replace
(
"
\"
"
,
"
\\\"
"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
shortDescription
\"
:
\"
%1
\"
,"
).
arg
(
text
));
}
if
(
!
metaData
->
longDescription
().
isEmpty
())
{
QString
text
=
metaData
->
longDescription
();
text
.
replace
(
"
\"
"
,
"
\\\"
"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
longDescription
\"
:
\"
%1
\"
,"
).
arg
(
text
));
}
if
(
!
metaData
->
rawUnits
().
isEmpty
())
{
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
units
\"
:
\"
%1
\"
,"
).
arg
(
metaData
->
rawUnits
()));
}
if
(
metaData
->
defaultValueAvailable
())
{
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
defaultValue
\"
: %1,"
).
arg
(
metaData
->
rawDefaultValue
().
toDouble
()));
}
if
(
!
qIsNaN
(
metaData
->
rawIncrement
()))
{
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
increment
\"
: %1,"
).
arg
(
metaData
->
rawIncrement
()));
}
if
(
metaData
->
enumValues
().
count
())
{
_jsonWriteLine
(
jsonFile
,
indentLevel
++
,
"
\"
values
\"
: ["
);
for
(
int
i
=
0
;
i
<
metaData
->
enumValues
().
count
();
i
++
)
{
_jsonWriteLine
(
jsonFile
,
indentLevel
++
,
"{"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
value
\"
: %1,"
).
arg
(
metaData
->
enumValues
()[
i
].
toDouble
()));
QString
text
=
metaData
->
enumStrings
()[
i
];
text
.
replace
(
"
\"
"
,
"
\\\"
"
);
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
description
\"
:
\"
%1
\"
"
).
arg
(
text
));
_jsonWriteLine
(
jsonFile
,
--
indentLevel
,
QStringLiteral
(
"}%1"
).
arg
(
i
==
metaData
->
enumValues
().
count
()
-
1
?
""
:
","
));
}
_jsonWriteLine
(
jsonFile
,
--
indentLevel
,
"],"
);
}
if
(
metaData
->
vehicleRebootRequired
())
{
_jsonWriteLine
(
jsonFile
,
indentLevel
,
"
\"
rebootRequired
\"
: true,"
);
}
if
(
metaData
->
volatileValue
())
{
_jsonWriteLine
(
jsonFile
,
indentLevel
,
"
\"
volatile
\"
: true,"
);
}
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
decimalPlaces
\"
:
\"
%1
\"
,"
).
arg
(
metaData
->
decimalPlaces
()));
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
minValue
\"
: %1,"
).
arg
(
metaData
->
rawMin
().
toDouble
()));
_jsonWriteLine
(
jsonFile
,
indentLevel
,
QStringLiteral
(
"
\"
maxValue
\"
: %1"
).
arg
(
metaData
->
rawMax
().
toDouble
()));
_jsonWriteLine
(
jsonFile
,
--
indentLevel
,
QStringLiteral
(
"}%1"
).
arg
(
++
keyIndex
==
_mapParameterName2FactMetaData
.
keys
().
count
()
?
""
:
","
));
}
_jsonWriteLine
(
jsonFile
,
--
indentLevel
,
"]"
);
_jsonWriteLine
(
jsonFile
,
--
indentLevel
,
"}"
);
}
#endif
FactMetaData
*
PX4ParameterMetaData
::
getMetaDataForFact
(
const
QString
&
name
,
MAV_TYPE
vehicleType
)
{
...
...
src/FirmwarePlugin/PX4/PX4ParameterMetaData.h
View file @
ee4d1384
...
...
@@ -25,6 +25,8 @@
Q_DECLARE_LOGGING_CATEGORY
(
PX4ParameterMetaDataLog
)
//#define GENERATE_PARAMETER_JSON
/// Loads and holds parameter fact meta data for PX4 stack
class
PX4ParameterMetaData
:
public
QObject
{
...
...
@@ -52,6 +54,10 @@ private:
QVariant
_stringToTypedVariant
(
const
QString
&
string
,
FactMetaData
::
ValueType_t
type
,
bool
*
convertOk
);
static
void
_outputFileWarning
(
const
QString
&
metaDataFile
,
const
QString
&
error1
,
const
QString
&
error2
);
#ifdef GENERATE_PARAMETER_JSON
void
_generateParameterJson
();
#endif
bool
_parameterMetaDataLoaded
;
///< true: parameter meta data already loaded
QMap
<
QString
,
FactMetaData
*>
_mapParameterName2FactMetaData
;
///< Maps from a parameter name to FactMetaData
};
...
...
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