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
2803796c
Unverified
Commit
2803796c
authored
Oct 29, 2020
by
Don Gagne
Committed by
GitHub
Oct 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for new FactMetaData json values/bitmask formats. (#9148)
parent
fd10ea55
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12015 additions
and
11860 deletions
+12015
-11860
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+161
-23
FactMetaData.h
src/FactSystem/FactMetaData.h
+18
-5
JsonHelper.cc
src/JsonHelper.cc
+6
-65
JsonHelper.h
src/JsonHelper.h
+0
-6
MockLink.Parameter.MetaData.json
src/comm/MockLink.Parameter.MetaData.json
+11830
-11761
MockLink.Parameter.MetaData.json.gz
src/comm/MockLink.Parameter.MetaData.json.gz
+0
-0
No files found.
src/FactSystem/FactMetaData.cc
View file @
2803796c
This diff is collapsed.
Click to expand it.
src/FactSystem/FactMetaData.h
View file @
2803796c
...
...
@@ -54,8 +54,10 @@ public:
FactMetaData
(
ValueType_t
type
,
const
QString
name
,
QObject
*
parent
=
nullptr
);
FactMetaData
(
const
FactMetaData
&
other
,
QObject
*
parent
=
nullptr
);
typedef
QMap
<
QString
,
QString
>
DefineMap_t
;
static
QMap
<
QString
,
FactMetaData
*>
createMapFromJsonFile
(
const
QString
&
jsonFilename
,
QObject
*
metaDataParent
);
static
QMap
<
QString
,
FactMetaData
*>
createMapFromJsonArray
(
const
QJsonArray
jsonArray
,
QMap
<
QString
,
QString
>
&
defineMap
,
QObject
*
metaDataParent
);
static
QMap
<
QString
,
FactMetaData
*>
createMapFromJsonArray
(
const
QJsonArray
jsonArray
,
DefineMap_t
&
defineMap
,
QObject
*
metaDataParent
);
static
FactMetaData
*
createFromJsonObject
(
const
QJsonObject
&
json
,
QMap
<
QString
,
QString
>&
defineMap
,
QObject
*
metaDataParent
);
...
...
@@ -204,10 +206,9 @@ public:
static
const
char
*
qgcFileType
;
private:
QVariant
_minForType
(
void
)
const
;
QVariant
_maxForType
(
void
)
const
;
void
_setAppSettingsTranslators
(
void
);
QVariant
_minForType
(
void
)
const
;
QVariant
_maxForType
(
void
)
const
;
void
_setAppSettingsTranslators
(
void
);
/// Clamp a value to be within cookedMin and cookedMax
template
<
class
T
>
...
...
@@ -232,6 +233,10 @@ private:
bool
isInRawMinLimit
(
const
QVariant
&
variantValue
)
const
;
bool
isInRawMaxLimit
(
const
QVariant
&
variantValue
)
const
;
static
bool
_parseEnum
(
const
QJsonObject
&
jsonObject
,
DefineMap_t
defineMap
,
QStringList
&
rgDescriptions
,
QStringList
&
rgValues
,
QString
&
errorString
);
static
bool
_parseValuesArray
(
const
QJsonObject
&
jsonObject
,
QStringList
&
rgDescriptions
,
QList
<
double
>&
rgValues
,
QString
&
errorString
);
static
bool
_parseBitmaskArray
(
const
QJsonObject
&
jsonObject
,
QStringList
&
rgDescriptions
,
QList
<
double
>&
rgValues
,
QString
&
errorString
);
// Built in translators
static
QVariant
_defaultTranslator
(
const
QVariant
&
from
)
{
return
from
;
}
static
QVariant
_degreesToRadians
(
const
QVariant
&
degrees
);
...
...
@@ -366,6 +371,14 @@ private:
static
const
char
*
_categoryJsonKey
;
static
const
char
*
_groupJsonKey
;
static
const
char
*
_volatileJsonKey
;
static
const
char
*
_enumStringsJsonKey
;
static
const
char
*
_enumValuesJsonKey
;
static
const
char
*
_enumValuesArrayJsonKey
;
static
const
char
*
_enumBitmaskArrayJsonKey
;
static
const
char
*
_enumValuesArrayValueJsonKey
;
static
const
char
*
_enumValuesArrayDescriptionJsonKey
;
static
const
char
*
_enumBitmaskArrayIndexJsonKey
;
static
const
char
*
_enumBitmaskArrayDescriptionJsonKey
;
static
const
char
*
_jsonMetaDataDefinesName
;
static
const
char
*
_jsonMetaDataFactsName
;
...
...
src/JsonHelper.cc
View file @
2803796c
...
...
@@ -22,14 +22,12 @@
#include <QFile>
#include <QTranslator>
const
char
*
JsonHelper
::
_enumStringsJsonKey
=
"enumStrings"
;
const
char
*
JsonHelper
::
_enumValuesJsonKey
=
"enumValues"
;
const
char
*
JsonHelper
::
jsonVersionKey
=
"version"
;
const
char
*
JsonHelper
::
jsonGroundStationKey
=
"groundStation"
;
const
char
*
JsonHelper
::
jsonGroundStationValue
=
"QGroundControl"
;
const
char
*
JsonHelper
::
jsonFileTypeKey
=
"fileType"
;
const
char
*
JsonHelper
::
_translateKeysKey
=
"translateKeys"
;
const
char
*
JsonHelper
::
_arrayIDKeysKey
=
"_arrayIDKeys"
;
const
char
*
JsonHelper
::
jsonVersionKey
=
"version"
;
const
char
*
JsonHelper
::
jsonGroundStationKey
=
"groundStation"
;
const
char
*
JsonHelper
::
jsonGroundStationValue
=
"QGroundControl"
;
const
char
*
JsonHelper
::
jsonFileTypeKey
=
"fileType"
;
const
char
*
JsonHelper
::
_translateKeysKey
=
"translateKeys"
;
const
char
*
JsonHelper
::
_arrayIDKeysKey
=
"_arrayIDKeys"
;
bool
JsonHelper
::
validateRequiredKeys
(
const
QJsonObject
&
jsonObject
,
const
QStringList
&
keys
,
QString
&
errorString
)
{
...
...
@@ -159,63 +157,6 @@ bool JsonHelper::validateKeyTypes(const QJsonObject& jsonObject, const QStringLi
return
true
;
}
bool
JsonHelper
::
_parseEnumWorker
(
const
QJsonObject
&
jsonObject
,
QMap
<
QString
,
QString
>&
defineMap
,
QStringList
&
enumStrings
,
QStringList
&
enumValues
,
QString
&
errorString
,
QString
valueName
)
{
if
(
jsonObject
.
value
(
_enumStringsJsonKey
).
isArray
())
{
// "enumStrings": ["Auto" , "Manual", "Shutter Priority", "Aperture Priority"],
QJsonArray
jArray
=
jsonObject
.
value
(
_enumStringsJsonKey
).
toArray
();
for
(
int
i
=
0
;
i
<
jArray
.
count
();
++
i
)
{
enumStrings
<<
jArray
.
at
(
i
).
toString
();
}
}
else
{
// "enumStrings": "Auto,Manual,Shutter Priority,Aperture Priority",
QString
value
=
jsonObject
.
value
(
_enumStringsJsonKey
).
toString
();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
enumStrings
=
defineMap
.
value
(
value
,
value
).
split
(
","
,
QString
::
SkipEmptyParts
);
#else
enumStrings
=
defineMap
.
value
(
value
,
value
).
split
(
","
,
Qt
::
SkipEmptyParts
);
#endif
}
if
(
jsonObject
.
value
(
_enumValuesJsonKey
).
isArray
())
{
// "enumValues": [0, 1, 2, 3, 4, 5],
QJsonArray
jArray
=
jsonObject
.
value
(
_enumValuesJsonKey
).
toArray
();
// This should probably be a variant list and not a string list.
for
(
int
i
=
0
;
i
<
jArray
.
count
();
++
i
)
{
if
(
jArray
.
at
(
i
).
isString
())
enumValues
<<
jArray
.
at
(
i
).
toString
();
else
enumValues
<<
QString
::
number
(
jArray
.
at
(
i
).
toDouble
());
}
}
else
{
// "enumValues": "0,1,2,3,4,5",
QString
value
=
jsonObject
.
value
(
_enumValuesJsonKey
).
toString
();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
enumValues
=
defineMap
.
value
(
value
,
value
).
split
(
","
,
QString
::
SkipEmptyParts
);
#else
enumValues
=
defineMap
.
value
(
value
,
value
).
split
(
","
,
Qt
::
SkipEmptyParts
);
#endif
}
if
(
enumStrings
.
count
()
!=
enumValues
.
count
())
{
errorString
=
QObject
::
tr
(
"enum strings/values count mismatch in %3 strings:values %1:%2"
).
arg
(
enumStrings
.
count
()).
arg
(
enumValues
.
count
()).
arg
(
valueName
);
return
false
;
}
return
true
;
}
bool
JsonHelper
::
parseEnum
(
const
QJsonObject
&
jsonObject
,
QMap
<
QString
,
QString
>&
defineMap
,
QStringList
&
enumStrings
,
QStringList
&
enumValues
,
QString
&
errorString
,
QString
valueName
)
{
return
_parseEnumWorker
(
jsonObject
,
defineMap
,
enumStrings
,
enumValues
,
errorString
,
valueName
);
}
bool
JsonHelper
::
parseEnum
(
const
QJsonObject
&
jsonObject
,
QStringList
&
enumStrings
,
QStringList
&
enumValues
,
QString
&
errorString
,
QString
valueName
)
{
QMap
<
QString
,
QString
>
defineMap
;
return
_parseEnumWorker
(
jsonObject
,
defineMap
,
enumStrings
,
enumValues
,
errorString
,
valueName
);
}
bool
JsonHelper
::
isJsonFile
(
const
QByteArray
&
bytes
,
QJsonDocument
&
jsonDoc
,
QString
&
errorString
)
{
QJsonParseError
parseError
;
...
...
src/JsonHelper.h
View file @
2803796c
...
...
@@ -155,9 +155,6 @@ public:
static
void
savePolygon
(
QmlObjectListModel
&
list
,
///< List which contains vertices
QJsonArray
&
polygonArray
);
///< Array to save into
static
bool
parseEnum
(
const
QJsonObject
&
jsonObject
,
QStringList
&
enumStrings
,
QStringList
&
enumValues
,
QString
&
errorString
,
QString
valueName
=
QString
());
static
bool
parseEnum
(
const
QJsonObject
&
jsonObject
,
QMap
<
QString
,
QString
>&
defineMap
,
QStringList
&
enumStrings
,
QStringList
&
enumValues
,
QString
&
errorString
,
QString
valueName
=
QString
());
/// Returns NaN if the value is null, or if not, the double value
static
double
possibleNaNJsonValue
(
const
QJsonValue
&
value
);
...
...
@@ -177,14 +174,11 @@ private:
bool
writeAltitude
,
QJsonValue
&
jsonValue
,
bool
geoJsonFormat
);
static
bool
_parseEnumWorker
(
const
QJsonObject
&
jsonObject
,
QMap
<
QString
,
QString
>&
defineMap
,
QStringList
&
enumStrings
,
QStringList
&
enumValues
,
QString
&
errorString
,
QString
valueName
);
static
QStringList
_addDefaultLocKeys
(
QJsonObject
&
jsonObject
);
static
QJsonObject
_translateRoot
(
QJsonObject
&
jsonObject
,
const
QString
&
translateContext
,
const
QStringList
&
translateKeys
);
static
QJsonObject
_translateObject
(
QJsonObject
&
jsonObject
,
const
QString
&
translateContext
,
const
QStringList
&
translateKeys
);
static
QJsonArray
_translateArray
(
QJsonArray
&
jsonArray
,
const
QString
&
translateContext
,
const
QStringList
&
translateKeys
);
static
const
char
*
_enumStringsJsonKey
;
static
const
char
*
_enumValuesJsonKey
;
static
const
char
*
_translateKeysKey
;
static
const
char
*
_arrayIDKeysKey
;
};
src/comm/MockLink.Parameter.MetaData.json
View file @
2803796c
This diff is collapsed.
Click to expand it.
src/comm/MockLink.Parameter.MetaData.json.gz
0 → 100644
View file @
2803796c
File added
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