Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
a87e00e1
Commit
a87e00e1
authored
Aug 22, 2013
by
tstellanova
Browse files
use a real component ID when we know what it is
parent
a6fcb120
Changes
2
Show whitespace changes
Inline
Side-by-side
src/uas/QGCUASParamManager.cc
View file @
a87e00e1
...
...
@@ -11,7 +11,8 @@ QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QObject
(
parent
),
mav
(
NULL
),
paramDataModel
(
this
),
paramCommsMgr
(
NULL
)
paramCommsMgr
(
NULL
),
defaultComponentId
(
-
1
)
{
...
...
@@ -57,6 +58,27 @@ void QGCUASParamManager::clearAllPendingParams()
paramDataModel
.
clearAllPendingParams
();
}
int
QGCUASParamManager
::
getDefaultComponentId
()
{
int
result
=
0
;
if
(
-
1
!=
defaultComponentId
)
return
defaultComponentId
;
QList
<
int
>
components
=
getComponentForParam
(
"SYS_AUTOSTART"
);
//TODO is this the best way to find the right component?
// Guard against multiple components responding - this will never show in practice
if
(
1
==
components
.
count
())
{
result
=
components
.
first
();
defaultComponentId
=
result
;
}
qDebug
()
<<
"Default compId: "
<<
result
;
return
result
;
}
QList
<
int
>
QGCUASParamManager
::
getComponentForParam
(
const
QString
&
parameter
)
const
{
return
paramDataModel
.
getComponentForOnboardParam
(
parameter
);
...
...
@@ -95,6 +117,7 @@ void QGCUASParamManager::requestParameterListIfEmpty()
if
(
mav
)
{
int
totalOnboard
=
paramDataModel
.
countOnboardParams
();
if
(
totalOnboard
<
2
)
{
//TODO arbitrary constant, maybe 0 is OK?
defaultComponentId
=
-
1
;
//reset this ...we have no idea what the default component ID is
requestParameterList
();
}
}
...
...
@@ -108,6 +131,10 @@ void QGCUASParamManager::setParamDescriptions(const QMap<QString,QString>& param
void
QGCUASParamManager
::
setParameter
(
int
compId
,
QString
paramName
,
QVariant
value
)
{
if
((
0
==
compId
)
||
(
-
1
==
compId
))
{
//attempt to get an actual component ID
compId
=
getDefaultComponentId
();
}
paramDataModel
.
updatePendingParamWithValue
(
compId
,
paramName
,
value
);
}
...
...
@@ -121,6 +148,10 @@ void QGCUASParamManager::sendPendingParameters(bool persistAfterSend)
void
QGCUASParamManager
::
setPendingParam
(
int
compId
,
const
QString
&
paramName
,
const
QVariant
&
value
)
{
if
((
0
==
compId
)
||
(
-
1
==
compId
))
{
//attempt to get an actual component ID
compId
=
getDefaultComponentId
();
}
paramDataModel
.
updatePendingParamWithValue
(
compId
,
paramName
,
value
);
}
...
...
src/uas/QGCUASParamManager.h
View file @
a87e00e1
...
...
@@ -23,6 +23,9 @@ public:
/** @brief Get the known, confirmed value of a parameter */
virtual
bool
getParameterValue
(
int
component
,
const
QString
&
parameter
,
QVariant
&
value
)
const
;
/** @brief determine which component is the root component for the UAS and return its ID or 0 if unknown */
virtual
int
getDefaultComponentId
();
/**
* @brief Get a list of all component IDs using this parameter name
* @param parameter The string encoding the parameter name
...
...
@@ -122,6 +125,7 @@ protected:
UASInterface
*
mav
;
///< The MAV this manager is controlling
UASParameterDataModel
paramDataModel
;
///< Shared data model of parameters
UASParameterCommsMgr
*
paramCommsMgr
;
///< Shared comms mgr for parameters
int
defaultComponentId
;
///< Cached default component ID
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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