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
16e8aab2
Commit
16e8aab2
authored
Dec 22, 2013
by
Bryant Mairs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add display of the outgoing data rate to the debug console widget.
parent
c4db113d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
25 deletions
+43
-25
DebugConsole.cc
src/ui/DebugConsole.cc
+39
-20
DebugConsole.h
src/ui/DebugConsole.h
+4
-5
No files found.
src/ui/DebugConsole.cc
View file @
16e8aab2
...
...
@@ -23,7 +23,7 @@ This file is part of the QGROUNDCONTROL project
/**
* @file
* @brief
Implementation of DebugConsole
* @brief
This file implements the Debug Console, a serial console built-in to QGC.
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
...
...
@@ -31,6 +31,7 @@ This file is part of the QGROUNDCONTROL project
#include <QPainter>
#include <QSettings>
#include <QScrollBar>
#include <QDebug>
#include "DebugConsole.h"
#include "ui_DebugConsole.h"
...
...
@@ -39,7 +40,8 @@ This file is part of the QGROUNDCONTROL project
#include "protocol.h"
#include "QGC.h"
#include <QDebug>
// Set the snapshot interval to 500ms.
#define DEBUGCONSOLE_SNAPSHOT_INTERVAL 500
DebugConsole
::
DebugConsole
(
QWidget
*
parent
)
:
QWidget
(
parent
),
...
...
@@ -58,11 +60,10 @@ DebugConsole::DebugConsole(QWidget *parent) :
lastLineBuffer
(
0
),
lineBufferTimer
(),
snapShotTimer
(),
snapShotInterval
(
500
),
snapShotBytes
(
0
),
dataRate
(
0.0
f
),
lowpassDataRate
(
0.0
f
),
dataRateThreshold
(
0.4
),
snapShotInterval
(
DEBUGCONSOLE_SNAPSHOT_INTERVAL
),
lowpassInDataRate
(
0.0
f
),
inDataRateThreshold
(
0.4
),
lowpassOutDataRate
(
0.0
f
),
commandIndex
(
0
),
m_ui
(
new
Ui
::
DebugConsole
)
{
...
...
@@ -79,7 +80,7 @@ DebugConsole::DebugConsole(QWidget *parent) :
// Allow to wrap everywhere
m_ui
->
receiveText
->
setWordWrapMode
(
QTextOption
::
WrapAnywhere
);
// Load settings for th
e DebugConsole
// Load settings for th
is widget
loadSettings
();
// Enable traffic measurements
...
...
@@ -311,22 +312,41 @@ void DebugConsole::receiveTextMessage(int id, int component, int severity, QStri
}
}
/**
* This function updates the speed indicator text in the GUI.
* Additionally, if this speed is too high, the display of incoming characters is disabled.
*/
void
DebugConsole
::
updateTrafficMeasurements
()
{
// Low-pass the calculated data rate with a very low frequency digital FIR filter.
dataRate
=
(
float
)
snapShotBytes
/
(
float
)
snapShotInterval
;
lowpassDataRate
=
0.9
f
*
lowpassDataRate
+
0.1
f
*
dataRate
;
snapShotBytes
=
0
;
// Check if the hold rate limit has been exceeded, and if so, stop displaying the incoming data stream.
// We use the real data rate here because we want this to kick in immediately.
if
((
dataRate
>
dataRateThreshold
)
&&
autoHold
)
{
// We need a link to read its data rates from, so if there isn't one, don't do anything.
if
(
!
currLink
)
{
return
;
}
// Calculate the rate of incoming data, converting to
// kilobytes per second from the received bits per second.
qint64
inDataRate
=
currLink
->
getCurrentInDataRate
()
/
1000.0
f
;
lowpassInDataRate
=
lowpassInDataRate
*
0.9
f
+
(
0.1
f
*
inDataRate
/
8.0
f
);
// If the incoming data rate is faster than our threshold, don't display the data.
// We don't use the low-passed data rate as we want the true data rate. The low-passed data
// is just for displaying to the user to remove jitter.
if
((
inDataRate
>
inDataRateThreshold
)
&&
autoHold
)
{
// Enable auto-hold
m_ui
->
holdButton
->
setChecked
(
true
);
hold
(
true
);
}
// Update the rate label.
m_ui
->
downSpeedLabel
->
setText
(
tr
(
"%L1 kB/s"
).
arg
(
lowpassDataRate
,
4
,
'f'
,
1
,
'0'
));
// Update the incoming data rate label.
m_ui
->
downSpeedLabel
->
setText
(
tr
(
"%L1 kB/s"
).
arg
(
lowpassInDataRate
,
4
,
'f'
,
1
,
'0'
));
// Calculate the rate of outgoing data, converting to
// kilobytes per second from the received bits per second.
lowpassOutDataRate
=
lowpassOutDataRate
*
0.9
f
+
(
0.1
f
*
currLink
->
getCurrentOutDataRate
()
/
8.0
f
/
1000.0
f
);
// Update the outoing data rate label.
m_ui
->
upSpeedLabel
->
setText
(
tr
(
"%L1 kB/s"
).
arg
(
lowpassOutDataRate
,
4
,
'f'
,
1
,
'0'
));
}
void
DebugConsole
::
paintEvent
(
QPaintEvent
*
event
)
...
...
@@ -336,7 +356,6 @@ void DebugConsole::paintEvent(QPaintEvent *event)
void
DebugConsole
::
receiveBytes
(
LinkInterface
*
link
,
QByteArray
bytes
)
{
snapShotBytes
+=
bytes
.
size
();
int
len
=
bytes
.
size
();
int
lastSpace
=
0
;
if
((
this
->
bytesToIgnore
>
260
)
||
(
this
->
bytesToIgnore
<
-
2
))
this
->
bytesToIgnore
=
0
;
...
...
@@ -725,7 +744,7 @@ void DebugConsole::hold(bool hold)
// TODO No conversion is done to the bytes in the hold buffer
m_ui
->
receiveText
->
appendPlainText
(
QString
(
holdBuffer
));
holdBuffer
.
clear
();
lowpassDataRate
=
0.0
f
;
lowpass
In
DataRate
=
0.0
f
;
}
this
->
holdOn
=
hold
;
...
...
src/ui/DebugConsole.h
View file @
16e8aab2
...
...
@@ -137,11 +137,10 @@ protected:
quint64
lastLineBuffer
;
///< Last line buffer emission time
QTimer
lineBufferTimer
;
///< Line buffer timer
QTimer
snapShotTimer
;
///< Timer for measuring traffic snapshots
int
snapShotInterval
;
///< Snapshot interval for traffic measurements
int
snapShotBytes
;
///< Number of bytes received in current snapshot
float
dataRate
;
///< Current data rate (kB/s)
float
lowpassDataRate
;
///< Lowpass filtered data rate (kB/s)
float
dataRateThreshold
;
///< Threshold of when to enable auto-hold (kB/s)
int
snapShotInterval
;
///< Set the time between UI updates for the data rate (ms)
float
lowpassInDataRate
;
///< Lowpass filtered data rate (kilobytes/s)
float
inDataRateThreshold
;
///< Threshold where to enable auto-hold (kilobytes/s)
float
lowpassOutDataRate
;
///< Low-pass filtered outgoing data rate (kilobytes/s)
QStringList
commandHistory
;
QString
currCommand
;
int
commandIndex
;
...
...
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