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
e87b4ca5
Commit
e87b4ca5
authored
Aug 06, 2013
by
tstellanova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consolidating comms-related methods
parent
5e211bb9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
60 deletions
+42
-60
QGCUASParamManager.cc
src/uas/QGCUASParamManager.cc
+9
-3
QGCUASParamManager.h
src/uas/QGCUASParamManager.h
+5
-5
ParameterInterface.cc
src/ui/ParameterInterface.cc
+3
-2
QGCParamWidget.cc
src/ui/QGCParamWidget.cc
+23
-46
QGCParamWidget.h
src/ui/QGCParamWidget.h
+2
-4
No files found.
src/uas/QGCUASParamManager.cc
View file @
e87b4ca5
...
...
@@ -16,13 +16,19 @@ QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) :
}
bool
QGCUASParamManager
::
getParameterValue
(
int
component
,
const
QString
&
parameter
,
QVariant
&
value
)
const
{
bool
QGCUASParamManager
::
getParameterValue
(
int
component
,
const
QString
&
parameter
,
QVariant
&
value
)
const
{
return
paramDataModel
->
getOnboardParameterValue
(
component
,
parameter
,
value
);
}
void
QGCUASParamManager
::
requestParameterUpdate
(
int
component
,
const
QString
&
parameter
)
{
if
(
mav
)
{
mav
->
requestParameter
(
component
,
parameter
);
}
}
/**
* Send a request to deliver the list of onboard parameters
* to the MAV.
...
...
src/uas/QGCUASParamManager.h
View file @
e87b4ca5
...
...
@@ -17,9 +17,6 @@ public:
virtual
bool
getParameterValue
(
int
component
,
const
QString
&
parameter
,
QVariant
&
value
)
const
;
/** @brief Request an update for this specific parameter */
virtual
void
requestParameterUpdate
(
int
component
,
const
QString
&
parameter
)
=
0
;
/** @brief Provide tooltips / user-visible descriptions for parameters */
virtual
void
setParamDescriptions
(
const
QMap
<
QString
,
QString
>&
paramDescs
);
...
...
@@ -36,8 +33,7 @@ signals:
void
parameterListUpToDate
(
int
component
);
/** @brief Request a single parameter */
void
requestParameter
(
int
component
,
int
parameter
);
/** @brief Request a single parameter by name */
void
requestParameter
(
int
component
,
const
QString
&
parameter
);
public
slots
:
/** @brief Write one parameter to the MAV */
...
...
@@ -47,6 +43,10 @@ public slots:
/** @brief Check for missing parameters */
virtual
void
retransmissionGuardTick
();
/** @brief Request one single parameter */
virtual
void
requestParameterUpdate
(
int
component
,
const
QString
&
parameter
);
protected:
// Parameter data model
...
...
src/ui/ParameterInterface.cc
View file @
e87b4ca5
...
...
@@ -72,6 +72,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
ParameterInterface
::~
ParameterInterface
()
{
delete
paramWidgets
;
delete
m_ui
;
}
...
...
@@ -97,8 +98,8 @@ void ParameterInterface::addUAS(UASInterface* uas)
QGCParamWidget
*
param
=
new
QGCParamWidget
(
uas
,
this
);
QString
ptrStr
;
ptrStr
.
sprintf
(
"
%8p"
,
param
);
qDebug
()
<<
"Created
QGCParamWidget "
<<
ptrStr
<<
"
for UAS id: "
<<
uasId
<<
" count: "
<<
paramWidgets
->
count
();
ptrStr
.
sprintf
(
"
QGCParamWidget %8p (parent %8p)"
,
param
,
this
);
qDebug
()
<<
"Created
"
<<
ptrStr
<<
"
for UAS id: "
<<
uasId
<<
" count: "
<<
paramWidgets
->
count
();
paramWidgets
->
insert
(
uasId
,
param
);
m_ui
->
stackedWidget
->
addWidget
(
param
);
...
...
src/ui/QGCParamWidget.cc
View file @
e87b4ca5
...
...
@@ -49,7 +49,7 @@ This file is part of the QGROUNDCONTROL project
*/
QGCParamWidget
::
QGCParamWidget
(
UASInterface
*
uas
,
QWidget
*
parent
)
:
QGCUASParamManager
(
uas
,
parent
),
components
(
new
QMap
<
int
,
QTreeWidgetItem
*>
())
component
Item
s
(
new
QMap
<
int
,
QTreeWidgetItem
*>
())
{
// Load settings
loadSettings
();
...
...
@@ -145,8 +145,8 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
connect
(
uas
,
SIGNAL
(
parameterChanged
(
int
,
int
,
int
,
int
,
QString
,
QVariant
)),
this
,
SLOT
(
receivedParameterUpdate
(
int
,
int
,
int
,
int
,
QString
,
QVariant
)));
// Connect retransmission guard
connect
(
this
,
SIGNAL
(
requestParameter
(
int
,
QString
)),
uas
,
SLOT
(
requestParameter
(
int
,
QString
)));
connect
(
this
,
SIGNAL
(
requestParameter
(
int
,
int
)),
uas
,
SLOT
(
requestParameter
(
int
,
int
)));
connect
(
this
,
SIGNAL
(
requestParameter
ByName
(
int
,
QString
)),
uas
,
SLOT
(
requestParameterByName
(
int
,
QString
)));
connect
(
this
,
SIGNAL
(
requestParameter
ByName
(
int
,
int
)),
uas
,
SLOT
(
requestParameterByName
(
int
,
int
)));
connect
(
&
retransmissionTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
retransmissionGuardTick
()));
// Get parameters
...
...
@@ -214,20 +214,20 @@ UASInterface* QGCParamWidget::getUAS()
* @param component id of the component
* @param componentName human friendly name of the component
*/
void
QGCParamWidget
::
addComponent
(
int
uas
,
int
component
,
QString
componentName
)
void
QGCParamWidget
::
addComponent
Item
(
int
uas
,
int
component
,
QString
componentName
)
{
Q_UNUSED
(
uas
);
if
(
components
->
contains
(
component
))
{
if
(
component
Item
s
->
contains
(
component
))
{
// Update existing
components
->
value
(
component
)
->
setData
(
0
,
Qt
::
DisplayRole
,
QString
(
"%1 (#%2)"
).
arg
(
componentName
).
arg
(
component
));
component
Item
s
->
value
(
component
)
->
setData
(
0
,
Qt
::
DisplayRole
,
QString
(
"%1 (#%2)"
).
arg
(
componentName
).
arg
(
component
));
//components->value(component)->setData(1, Qt::DisplayRole, QString::number(component));
components
->
value
(
component
)
->
setFirstColumnSpanned
(
true
);
component
Item
s
->
value
(
component
)
->
setFirstColumnSpanned
(
true
);
}
else
{
// Add new
QStringList
list
(
QString
(
"%1 (#%2)"
).
arg
(
componentName
).
arg
(
component
));
QTreeWidgetItem
*
comp
=
new
QTreeWidgetItem
(
list
);
comp
->
setFirstColumnSpanned
(
true
);
components
->
insert
(
component
,
comp
);
component
Item
s
->
insert
(
component
,
comp
);
// Create grouping and update maps
paramGroups
.
insert
(
component
,
new
QMap
<
QString
,
QTreeWidgetItem
*>
());
tree
->
addTopLevelItem
(
comp
);
...
...
@@ -391,40 +391,26 @@ void QGCParamWidget::receivedParameterUpdate(int uas, int component, int paramCo
* @param component id of the component
* @param parameterName human friendly name of the parameter
*/
void
QGCParamWidget
::
updateParameterDisplay
(
int
uas
,
int
component
,
QString
parameterName
,
QVariant
value
)
void
QGCParamWidget
::
updateParameterDisplay
(
int
uas
,
int
component
Id
,
QString
parameterName
,
QVariant
value
)
{
Q_UNUSED
(
uas
);
QString
ptrStr
;
ptrStr
.
sprintf
(
"%8p"
,
this
);
qDebug
()
<<
"QGCParamWidget "
<<
ptrStr
<<
" got param"
<<
parameterName
;
//
QString ptrStr;
//
ptrStr.sprintf("%8p", this);
//
qDebug() << "QGCParamWidget " << ptrStr << " got param" << parameterName;
// Reference to item in tree
QTreeWidgetItem
*
parameterItem
=
NULL
;
// Get component
if
(
!
components
->
contains
(
component
))
{
// QString componentName;
// switch (component)
// {
// case MAV_COMP_ID_CAMERA:
// componentName = tr("Camera (#%1)").arg(component);
// break;
// case MAV_COMP_ID_IMU:
// componentName = tr("IMU (#%1)").arg(component);
// break;
// default:
// componentName = tr("Component #").arg(component);
// break;
// }
QString
componentName
=
tr
(
"Component #%1"
).
arg
(
component
);
addComponent
(
uas
,
component
,
componentName
);
if
(
!
componentItems
->
contains
(
componentId
))
{
QString
componentName
=
tr
(
"Component #%1"
).
arg
(
componentId
);
addComponentItem
(
uas
,
componentId
,
componentName
);
}
// Replace value in data model
paramDataModel
->
handleParameterUpdate
(
component
,
parameterName
,
value
);
paramDataModel
->
handleParameterUpdate
(
component
Id
,
parameterName
,
value
);
QString
splitToken
=
"_"
;
...
...
@@ -432,7 +418,7 @@ void QGCParamWidget::updateParameterDisplay(int uas, int component, QString para
if
(
parameterName
.
contains
(
splitToken
))
{
QString
parent
=
parameterName
.
section
(
splitToken
,
0
,
0
,
QString
::
SectionSkipEmpty
);
QMap
<
QString
,
QTreeWidgetItem
*>*
compParamGroups
=
paramGroups
.
value
(
component
);
QMap
<
QString
,
QTreeWidgetItem
*>*
compParamGroups
=
paramGroups
.
value
(
component
Id
);
if
(
!
compParamGroups
->
contains
(
parent
))
{
// Insert group item
...
...
@@ -440,7 +426,7 @@ void QGCParamWidget::updateParameterDisplay(int uas, int component, QString para
glist
.
append
(
parent
);
QTreeWidgetItem
*
item
=
new
QTreeWidgetItem
(
glist
);
compParamGroups
->
insert
(
parent
,
item
);
component
s
->
value
(
component
)
->
addChild
(
item
);
component
Items
->
value
(
componentId
)
->
addChild
(
item
);
}
// Append child to group
...
...
@@ -489,7 +475,7 @@ void QGCParamWidget::updateParameterDisplay(int uas, int component, QString para
else
{
bool
found
=
false
;
QTreeWidgetItem
*
parent
=
component
s
->
value
(
component
);
QTreeWidgetItem
*
parent
=
component
Items
->
value
(
componentId
);
for
(
int
i
=
0
;
i
<
parent
->
childCount
();
i
++
)
{
QTreeWidgetItem
*
child
=
parent
->
child
(
i
);
...
...
@@ -513,7 +499,7 @@ void QGCParamWidget::updateParameterDisplay(int uas, int component, QString para
// CONFIGURE PARAMETER ITEM
parameterItem
->
setData
(
1
,
Qt
::
DisplayRole
,
value
);
component
s
->
value
(
component
)
->
addChild
(
parameterItem
);
component
Items
->
value
(
componentId
)
->
addChild
(
parameterItem
);
parameterItem
->
setFlags
(
parameterItem
->
flags
()
|
Qt
::
ItemIsEditable
);
}
//tree->expandAll();
...
...
@@ -535,7 +521,7 @@ void QGCParamWidget::updateParameterDisplay(int uas, int component, QString para
parameterItem
->
setToolTip
(
0
,
tooltipFormat
);
parameterItem
->
setToolTip
(
1
,
tooltipFormat
);
paramDataModel
->
handleParameterUpdate
(
component
,
parameterName
,
value
);
paramDataModel
->
handleParameterUpdate
(
component
Id
,
parameterName
,
value
);
}
...
...
@@ -549,7 +535,7 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column)
parent
=
parent
->
parent
();
}
// Parent is now top-level component
int
componentId
=
components
->
key
(
parent
);
int
componentId
=
component
Item
s
->
key
(
parent
);
QString
key
=
current
->
data
(
0
,
Qt
::
DisplayRole
).
toString
();
QVariant
value
=
current
->
data
(
1
,
Qt
::
DisplayRole
);
...
...
@@ -603,7 +589,6 @@ void QGCParamWidget::loadParametersFromFile()
QTextStream
in
(
&
file
);
paramDataModel
->
readUpdateParametersFromStream
(
in
);
file
.
close
();
}
void
QGCParamWidget
::
setParameterStatusMsg
(
const
QString
&
msg
)
...
...
@@ -632,14 +617,6 @@ void QGCParamWidget::requestAllParamsUpdate()
requestParameterList
();
}
/**
* The .. signal is emitted
*/
void
QGCParamWidget
::
requestParameterUpdate
(
int
component
,
const
QString
&
parameter
)
{
if
(
mav
)
mav
->
requestParameter
(
component
,
parameter
);
}
/**
...
...
@@ -830,5 +807,5 @@ void QGCParamWidget::readParameters()
void
QGCParamWidget
::
clear
()
{
tree
->
clear
();
components
->
clear
();
component
Item
s
->
clear
();
}
src/ui/QGCParamWidget.h
View file @
e87b4ca5
...
...
@@ -61,15 +61,13 @@ signals:
public
slots
:
/** @brief Add a component to the list */
void
addComponent
(
int
uas
,
int
component
,
QString
componentName
);
void
addComponent
Item
(
int
uas
,
int
component
,
QString
componentName
);
/** @brief Add a parameter to the list with retransmission / safety checks */
void
receivedParameterUpdate
(
int
uas
,
int
component
,
int
paramCount
,
int
paramId
,
QString
parameterName
,
QVariant
value
);
/** @brief Add a parameter to the list */
void
updateParameterDisplay
(
int
uas
,
int
component
,
QString
parameterName
,
QVariant
value
);
/** @brief Request list of parameters from MAV */
void
requestAllParamsUpdate
();
/** @brief Request one single parameter */
void
requestParameterUpdate
(
int
component
,
const
QString
&
parameter
);
/** @brief Set one parameter, changes value in RAM of MAV */
void
setParameter
(
int
component
,
QString
parameterName
,
QVariant
value
);
/** @brief Set all parameters, changes the value in RAM of MAV */
...
...
@@ -93,7 +91,7 @@ public slots:
protected:
QTreeWidget
*
tree
;
///< The parameter tree
QLabel
*
statusLabel
;
///< Parameter transmission label
QMap
<
int
,
QTreeWidgetItem
*>*
component
s
;
///< The list of components
QMap
<
int
,
QTreeWidgetItem
*>*
component
Items
;
///< The list of component items, stored by component ID
QMap
<
int
,
QMap
<
QString
,
QTreeWidgetItem
*>*
>
paramGroups
;
///< Parameter groups
...
...
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