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
eccfcb0a
Commit
eccfcb0a
authored
Aug 24, 2013
by
tstellanova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
workaround for QVariants incoming as QString meta type
parent
42c62368
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
UASParameterDataModel.cc
src/uas/UASParameterDataModel.cc
+19
-12
UASParameterDataModel.h
src/uas/UASParameterDataModel.h
+3
-2
No files found.
src/uas/UASParameterDataModel.cc
View file @
eccfcb0a
...
...
@@ -80,11 +80,8 @@ void UASParameterDataModel::setPendingParam(int compId, const QString& key, con
{
//ensure we have a placeholder map for this component
addComponent
(
compId
);
QMap
<
QString
,
QVariant
>
*
pendParams
=
getPendingParamsForComponent
(
compId
);
if
(
pendParams
)
{
pendParams
->
insert
(
key
,
value
);
emit
pendingParamUpdate
(
compId
,
key
,
value
,
true
);
}
setParamWithTypeInMap
(
compId
,
key
,
value
,
pendingParameters
);
emit
pendingParamUpdate
(
compId
,
key
,
value
,
true
);
}
void
UASParameterDataModel
::
removePendingParam
(
int
compId
,
const
QString
&
key
)
...
...
@@ -105,11 +102,12 @@ void UASParameterDataModel::setOnboardParam(int compId, const QString &key, con
{
//ensure we have a placeholder map for this component
addComponent
(
compId
);
//TODO use setParamWithTypeInMap instead and verify
QMap
<
QString
,
QVariant
>
*
params
=
getOnboardParamsForComponent
(
compId
);
params
->
insert
(
key
,
value
);
}
void
UASParameterDataModel
::
set
OnboardParamWithType
(
int
compId
,
const
QString
&
key
,
const
QVariant
&
value
)
void
UASParameterDataModel
::
set
ParamWithTypeInMap
(
int
compId
,
const
QString
&
key
,
const
QVariant
&
value
,
QMap
<
int
,
QMap
<
QString
,
QVariant
>*
>&
map
)
{
switch
((
int
)
value
.
type
())
...
...
@@ -117,25 +115,35 @@ void UASParameterDataModel::setOnboardParamWithType(int compId, const QString& k
case
QVariant
:
:
Int
:
{
QVariant
fixedValue
(
value
.
toInt
());
onboardParameters
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
map
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
}
break
;
case
QVariant
:
:
UInt
:
{
QVariant
fixedValue
(
value
.
toUInt
());
onboardParameters
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
map
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
}
break
;
case
QMetaType
:
:
Float
:
{
QVariant
fixedValue
(
value
.
toFloat
());
onboardParameters
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
map
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
}
break
;
case
QMetaType
:
:
QChar
:
{
QVariant
fixedValue
(
QChar
((
unsigned
char
)
value
.
toUInt
()));
onboardParameters
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
map
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
}
break
;
case
QMetaType
:
:
QString
:
{
QString
strVal
=
value
.
toString
();
float
floatVal
=
strVal
.
toFloat
();
QVariant
fixedValue
(
floatVal
);
//TODO track down WHY we're getting unexpected QString values here...this is a workaround
qDebug
()
<<
"Unexpected string QVariant:"
<<
key
<<
" val:"
<<
value
<<
"fixedVal:"
<<
fixedValue
;
map
.
value
(
compId
)
->
insert
(
key
,
fixedValue
);
}
break
;
default:
...
...
@@ -165,8 +173,7 @@ void UASParameterDataModel::handleParamUpdate(int compId, const QString ¶mNa
QVariant
reqVal
=
pendingParams
->
value
(
paramName
);
if
(
reqVal
==
value
)
{
//notify everyone that this item is being removed from the pending parameters list since it's now confirmed
emit
pendingParamUpdate
(
compId
,
paramName
,
value
,
false
);
pendingParams
->
remove
(
paramName
);
removePendingParam
(
compId
,
paramName
);
}
else
{
qDebug
()
<<
"Pending commit for "
<<
paramName
<<
" want: "
<<
reqVal
<<
" got: "
<<
value
;
...
...
src/uas/UASParameterDataModel.h
View file @
eccfcb0a
...
...
@@ -41,8 +41,6 @@ public:
*/
virtual
QList
<
int
>
getComponentForOnboardParam
(
const
QString
&
parameter
)
const
;
/** @brief Save the onboard parameter with a the type specified in the QVariant as fixed */
virtual
void
setOnboardParamWithType
(
int
componentId
,
const
QString
&
key
,
const
QVariant
&
value
);
/** @brief clears every parameter for every loaded component */
virtual
void
forgetAllOnboardParams
();
...
...
@@ -91,6 +89,9 @@ protected:
/** @brief set the confirmed value of a parameter in the onboard params list */
virtual
void
setOnboardParam
(
int
componentId
,
const
QString
&
key
,
const
QVariant
&
value
);
/** @brief Save the parameter with a the type specified in the QVariant as fixed */
void
setParamWithTypeInMap
(
int
compId
,
const
QString
&
key
,
const
QVariant
&
value
,
QMap
<
int
,
QMap
<
QString
,
QVariant
>*
>&
map
);
/** @brief Write a new pending parameter value that may be eventually sent to the UAS */
virtual
void
setPendingParam
(
int
componentId
,
const
QString
&
key
,
const
QVariant
&
value
);
/** @brief remove a parameter from the pending list */
...
...
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