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
137b6287
Commit
137b6287
authored
Feb 12, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use helper routines
parent
5a90520b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
46 deletions
+12
-46
PX4ParameterMetaData.cc
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
+3
-24
MissionCommandList.cc
src/MissionManager/MissionCommandList.cc
+9
-21
MissionCommandList.h
src/MissionManager/MissionCommandList.h
+0
-1
No files found.
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
View file @
137b6287
...
...
@@ -198,30 +198,9 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
qCDebug
(
PX4ParameterMetaDataLog
)
<<
"Found parameter name:"
<<
name
<<
" type:"
<<
type
<<
" default:"
<<
strDefault
;
// Convert type from string to FactMetaData::ValueType_t
struct
String2Type
{
const
char
*
strType
;
FactMetaData
::
ValueType_t
type
;
};
static
const
struct
String2Type
rgString2Type
[]
=
{
{
"FLOAT"
,
FactMetaData
::
valueTypeFloat
},
{
"INT32"
,
FactMetaData
::
valueTypeInt32
},
};
static
const
size_t
crgString2Type
=
sizeof
(
rgString2Type
)
/
sizeof
(
rgString2Type
[
0
]);
bool
found
=
false
;
FactMetaData
::
ValueType_t
foundType
;
for
(
size_t
i
=
0
;
i
<
crgString2Type
;
i
++
)
{
const
struct
String2Type
*
info
=
&
rgString2Type
[
i
];
if
(
type
==
info
->
strType
)
{
found
=
true
;
foundType
=
info
->
type
;
break
;
}
}
if
(
!
found
)
{
bool
unknownType
;
FactMetaData
::
ValueType_t
foundType
=
FactMetaData
::
stringToType
(
type
,
unknownType
);
if
(
unknownType
)
{
qWarning
()
<<
"Parameter meta data with bad type:"
<<
type
<<
" name:"
<<
name
;
return
;
}
...
...
src/MissionManager/MissionCommandList.cc
View file @
137b6287
...
...
@@ -26,6 +26,7 @@ This file is part of the QGROUNDCONTROL project
#include "FirmwarePluginManager.h"
#include "QGCApplication.h"
#include "QGroundControlQmlGlobal.h"
#include "JsonHelper.h"
#include <QStringList>
#include <QJsonDocument>
...
...
@@ -62,20 +63,6 @@ MissionCommandList::MissionCommandList(const QString& jsonFilename, QObject* par
_loadMavCmdInfoJson
(
jsonFilename
);
}
bool
MissionCommandList
::
_validateKeyTypes
(
QJsonObject
&
jsonObject
,
const
QStringList
&
keys
,
const
QList
<
QJsonValue
::
Type
>&
types
)
{
for
(
int
i
=
0
;
i
<
keys
.
count
();
i
++
)
{
if
(
jsonObject
.
contains
(
keys
[
i
]))
{
if
(
jsonObject
.
value
(
keys
[
i
]).
type
()
!=
types
[
i
])
{
qWarning
()
<<
"Incorrect type key:type:expected"
<<
keys
[
i
]
<<
jsonObject
.
value
(
keys
[
i
]).
type
()
<<
types
[
i
];
return
false
;
}
}
}
return
true
;
}
void
MissionCommandList
::
_loadMavCmdInfoJson
(
const
QString
&
jsonFilename
)
{
if
(
jsonFilename
.
isEmpty
())
{
...
...
@@ -122,13 +109,12 @@ void MissionCommandList::_loadMavCmdInfoJson(const QString& jsonFilename)
QJsonObject
jsonObject
=
info
.
toObject
();
// Make sure we have the required keys
QString
errorString
;
QStringList
requiredKeys
;
requiredKeys
<<
_idJsonKey
<<
_rawNameJsonKey
;
foreach
(
const
QString
&
key
,
requiredKeys
)
{
if
(
!
jsonObject
.
contains
(
key
))
{
qWarning
()
<<
"Mission required key"
<<
key
;
return
;
}
if
(
!
JsonHelper
::
validateRequiredKeys
(
jsonObject
,
requiredKeys
,
errorString
))
{
qWarning
()
<<
errorString
;
return
;
}
// Validate key types
...
...
@@ -139,7 +125,8 @@ void MissionCommandList::_loadMavCmdInfoJson(const QString& jsonFilename)
<<
_param1JsonKey
<<
_param2JsonKey
<<
_param3JsonKey
<<
_param4JsonKey
<<
_categoryJsonKey
;
types
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
Bool
<<
QJsonValue
::
Bool
<<
QJsonValue
::
Bool
<<
QJsonValue
::
Object
<<
QJsonValue
::
Object
<<
QJsonValue
::
Object
<<
QJsonValue
::
Object
<<
QJsonValue
::
String
;
if
(
!
_validateKeyTypes
(
jsonObject
,
keys
,
types
))
{
if
(
!
JsonHelper
::
validateKeyTypes
(
jsonObject
,
keys
,
types
,
errorString
))
{
qWarning
()
<<
errorString
;
return
;
}
...
...
@@ -184,7 +171,8 @@ void MissionCommandList::_loadMavCmdInfoJson(const QString& jsonFilename)
QList
<
QJsonValue
::
Type
>
types
;
keys
<<
_defaultJsonKey
<<
_decimalPlacesJsonKey
<<
_enumStringsJsonKey
<<
_enumValuesJsonKey
<<
_labelJsonKey
<<
_unitsJsonKey
;
types
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
;
if
(
!
_validateKeyTypes
(
paramObject
,
keys
,
types
))
{
if
(
!
JsonHelper
::
validateKeyTypes
(
jsonObject
,
keys
,
types
,
errorString
))
{
qWarning
()
<<
errorString
;
return
;
}
...
...
src/MissionManager/MissionCommandList.h
View file @
137b6287
...
...
@@ -143,7 +143,6 @@ public:
private:
void
_loadMavCmdInfoJson
(
const
QString
&
jsonFilename
);
bool
_validateKeyTypes
(
QJsonObject
&
jsonObject
,
const
QStringList
&
keys
,
const
QList
<
QJsonValue
::
Type
>&
types
);
private:
QMap
<
MAV_CMD
,
MavCmdInfo
*>
_mavCmdInfoMap
;
...
...
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