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
2eac0e2e
Commit
2eac0e2e
authored
Aug 06, 2013
by
tstellanova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring comms code
parent
79e10356
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
278 additions
and
232 deletions
+278
-232
QGCUASParamManager.cc
src/uas/QGCUASParamManager.cc
+154
-0
QGCUASParamManager.h
src/uas/QGCUASParamManager.h
+15
-1
QGCParamWidget.cc
src/ui/QGCParamWidget.cc
+102
-222
QGCParamWidget.h
src/ui/QGCParamWidget.h
+7
-9
No files found.
src/uas/QGCUASParamManager.cc
View file @
2eac0e2e
...
...
@@ -28,3 +28,157 @@ bool QGCUASParamManager::getParameterValue(int component, const QString& paramet
return
paramDataModel
->
getOnboardParameterValue
(
component
,
parameter
,
value
);
}
/**
* Send a request to deliver the list of onboard parameters
* to the MAV.
*/
void
QGCUASParamManager
::
requestParameterList
()
{
if
(
!
mav
)
{
return
;
}
paramDataModel
->
forgetAllOnboardParameters
();
received
.
clear
();
// Clear transmission state
transmissionListMode
=
true
;
transmissionListSizeKnown
.
clear
();
foreach
(
int
key
,
transmissionMissingPackets
.
keys
())
{
transmissionMissingPackets
.
value
(
key
)
->
clear
();
}
transmissionActive
=
true
;
setParameterStatusMsg
(
tr
(
"Requested param list.. waiting"
));
mav
->
requestParameters
();
}
/**
* Enabling the retransmission guard enables the parameter widget to track
* dropped parameters and to re-request them. This works for both individual
* parameter reads as well for whole list requests.
*
* @param enabled True if retransmission checking should be enabled, false else
*/
void
QGCUASParamManager
::
setRetransmissionGuardEnabled
(
bool
enabled
)
{
if
(
enabled
)
{
retransmissionTimer
.
start
(
retransmissionTimeout
);
}
else
{
retransmissionTimer
.
stop
();
}
}
void
QGCUASParamManager
::
setParameterStatusMsg
(
const
QString
&
msg
)
{
parameterStatusMsg
=
msg
;
}
void
QGCUASParamManager
::
retransmissionGuardTick
()
{
if
(
transmissionActive
)
{
//qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD ACTIVE, CHECKING FOR DROPS..";
// Check for timeout
// stop retransmission attempts on timeout
if
(
QGC
::
groundTimeMilliseconds
()
>
transmissionTimeout
)
{
setRetransmissionGuardEnabled
(
false
);
transmissionActive
=
false
;
// Empty read retransmission list
// Empty write retransmission list
int
missingReadCount
=
0
;
QList
<
int
>
readKeys
=
transmissionMissingPackets
.
keys
();
foreach
(
int
component
,
readKeys
)
{
missingReadCount
+=
transmissionMissingPackets
.
value
(
component
)
->
count
();
transmissionMissingPackets
.
value
(
component
)
->
clear
();
}
// Empty write retransmission list
int
missingWriteCount
=
0
;
QList
<
int
>
writeKeys
=
transmissionMissingWriteAckPackets
.
keys
();
foreach
(
int
component
,
writeKeys
)
{
missingWriteCount
+=
transmissionMissingWriteAckPackets
.
value
(
component
)
->
count
();
transmissionMissingWriteAckPackets
.
value
(
component
)
->
clear
();
}
setParameterStatusMsg
(
tr
(
"TIMEOUT! MISSING: %1 read, %2 write."
).
arg
(
missingReadCount
).
arg
(
missingWriteCount
));
}
// Re-request at maximum retransmissionBurstRequestSize parameters at once
// to prevent link flooding
QMap
<
int
,
QMap
<
QString
,
QVariant
>*>::
iterator
i
;
QMap
<
int
,
QMap
<
QString
,
QVariant
>*>
onboardParams
=
paramDataModel
->
getOnboardParameters
();
for
(
i
=
onboardParams
.
begin
();
i
!=
onboardParams
.
end
();
++
i
)
{
// Iterate through the parameters of the component
int
component
=
i
.
key
();
// Request n parameters from this component (at maximum)
QList
<
int
>
*
paramList
=
transmissionMissingPackets
.
value
(
component
,
NULL
);
if
(
paramList
)
{
int
count
=
0
;
foreach
(
int
id
,
*
paramList
)
{
if
(
count
<
retransmissionBurstRequestSize
)
{
//qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD REQUESTS RETRANSMISSION OF PARAM #" << id << "FROM COMPONENT #" << component;
//TODO mavlink msg type for "request parameter set" ?
emit
requestParameter
(
component
,
id
);
setParameterStatusMsg
(
tr
(
"Requested retransmission of #%1"
).
arg
(
id
+
1
));
count
++
;
}
else
{
break
;
}
}
}
}
// Re-request at maximum retransmissionBurstRequestSize parameters at once
// to prevent write-request link flooding
// Empty write retransmission list
QList
<
int
>
writeKeys
=
transmissionMissingWriteAckPackets
.
keys
();
foreach
(
int
component
,
writeKeys
)
{
int
count
=
0
;
QMap
<
QString
,
QVariant
>*
missingParams
=
transmissionMissingWriteAckPackets
.
value
(
component
);
foreach
(
QString
key
,
missingParams
->
keys
())
{
if
(
count
<
retransmissionBurstRequestSize
)
{
// Re-request write operation
QVariant
value
=
missingParams
->
value
(
key
);
switch
((
int
)
onboardParams
.
value
(
component
)
->
value
(
key
).
type
())
{
case
QVariant
:
:
Int
:
{
QVariant
fixedValue
(
value
.
toInt
());
emit
parameterChanged
(
component
,
key
,
fixedValue
);
}
break
;
case
QVariant
:
:
UInt
:
{
QVariant
fixedValue
(
value
.
toUInt
());
emit
parameterChanged
(
component
,
key
,
fixedValue
);
}
break
;
case
QMetaType
:
:
Float
:
{
QVariant
fixedValue
(
value
.
toFloat
());
emit
parameterChanged
(
component
,
key
,
fixedValue
);
}
break
;
default:
//qCritical() << "ABORTED PARAM RETRANSMISSION, NO VALID QVARIANT TYPE";
return
;
}
setParameterStatusMsg
(
tr
(
"Requested rewrite of: %1: %2"
).
arg
(
key
).
arg
(
missingParams
->
value
(
key
).
toDouble
()));
count
++
;
}
else
{
break
;
}
}
}
}
else
{
//qDebug() << __FILE__ << __LINE__ << "STOPPING RETRANSMISSION GUARD GRACEFULLY";
setRetransmissionGuardEnabled
(
false
);
}
}
src/uas/QGCUASParamManager.h
View file @
2eac0e2e
...
...
@@ -31,16 +31,29 @@ public:
/** @brief Request an update for this specific parameter */
virtual
void
requestParameterUpdate
(
int
component
,
const
QString
&
parameter
)
=
0
;
protected:
/** @brief Check for missing parameters */
virtual
void
retransmissionGuardTick
();
/** @brief Activate / deactivate parameter retransmission */
virtual
void
setRetransmissionGuardEnabled
(
bool
enabled
);
//TODO decouple this UI message display further
virtual
void
setParameterStatusMsg
(
const
QString
&
msg
);
signals:
void
parameterChanged
(
int
component
,
QString
parameter
,
QVariant
value
);
void
parameterChanged
(
int
component
,
int
parameterIndex
,
QVariant
value
);
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 */
virtual
void
setParameter
(
int
component
,
QString
parameterName
,
QVariant
value
)
=
0
;
/** @brief Request list of parameters from MAV */
virtual
void
requestParameterList
()
=
0
;
virtual
void
requestParameterList
();
protected:
...
...
@@ -60,6 +73,7 @@ protected:
int
retransmissionTimeout
;
///< Retransmission request timeout, in milliseconds
int
rewriteTimeout
;
///< Write request timeout, in milliseconds
int
retransmissionBurstRequestSize
;
///< Number of packets requested for retransmission per burst
QString
parameterStatusMsg
;
};
...
...
src/ui/QGCParamWidget.cc
View file @
2eac0e2e
This diff is collapsed.
Click to expand it.
src/ui/QGCParamWidget.h
View file @
2eac0e2e
...
...
@@ -60,13 +60,13 @@ public:
QString
getParamInfo
(
const
QString
&
param
)
{
return
paramToolTips
.
value
(
param
,
""
);
}
void
setParamInfo
(
const
QMap
<
QString
,
QString
>&
paramInfo
);
protected:
virtual
void
setParameterStatusMsg
(
const
QString
&
msg
);
signals:
/** @brief A parameter was changed in the widget, NOT onboard */
//void parameterChanged(int component, QString parametername, float value); // defined in QGCUASParamManager already
/** @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 Add a component to the list */
void
addComponent
(
int
uas
,
int
component
,
QString
componentName
);
...
...
@@ -75,7 +75,7 @@ public slots:
/** @brief Add a parameter to the list */
void
receivedParameterUpdate
(
int
uas
,
int
component
,
QString
parameterName
,
QVariant
value
);
/** @brief Request list of parameters from MAV */
void
requestParameterList
();
void
requestParameterList
Update
();
/** @brief Request one single parameter */
void
requestParameterUpdate
(
int
component
,
const
QString
&
parameter
);
/** @brief Set one parameter, changes value in RAM of MAV */
...
...
@@ -96,8 +96,7 @@ public slots:
/** @brief Load parameters from a file */
void
loadParametersFromFile
();
/** @brief Check for missing parameters */
void
retransmissionGuardTick
();
protected:
QTreeWidget
*
tree
;
///< The parameter tree
...
...
@@ -112,8 +111,7 @@ protected:
QMap
<
QString
,
double
>
paramDefault
;
///< Default param values
QMap
<
QString
,
double
>
paramMax
;
///< Minimum param values
/** @brief Activate / deactivate parameter retransmission */
void
setRetransmissionGuardEnabled
(
bool
enabled
);
/** @brief Load settings */
void
loadSettings
();
/** @brief Load meta information from CSV */
...
...
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