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
f053edc8
Commit
f053edc8
authored
Mar 30, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1403 from DonLakeFlyer/DebugConsole
Track links using shared pointed
parents
8dd7b72d
f712a7f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
24 deletions
+45
-24
DebugConsole.cc
src/ui/DebugConsole.cc
+40
-23
DebugConsole.h
src/ui/DebugConsole.h
+5
-1
No files found.
src/ui/DebugConsole.cc
View file @
f053edc8
...
...
@@ -91,8 +91,7 @@ DebugConsole::DebugConsole(QWidget *parent) :
// Connect to UAS manager to get notified about new UAS
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
uasCreated
(
UASInterface
*
)));
// Get a list of all existing links
links
=
QList
<
LinkInterface
*>
();
// Add all existing links
foreach
(
LinkInterface
*
link
,
LinkManager
::
instance
()
->
getLinks
())
{
addLink
(
link
);
}
...
...
@@ -171,12 +170,16 @@ void DebugConsole::uasCreated(UASInterface* uas)
*/
void
DebugConsole
::
addLink
(
LinkInterface
*
link
)
{
// Add link to link list
links
.
insert
(
link
->
getMavlinkChannel
(),
link
);
// Add link to list
foreach
(
SharedLinkInterface
sharedLink
,
_links
)
{
Q_ASSERT
(
sharedLink
.
data
()
!=
link
);
}
_links
.
append
(
LinkManager
::
instance
()
->
sharedPointerForLink
(
link
));
m_ui
->
linkComboBox
->
insertItem
(
link
->
getMavlinkChannel
(),
link
->
getName
());
// Set new item as current
m_ui
->
linkComboBox
->
setCurrentIndex
(
qMax
(
0
,
links
.
size
()
-
1
));
m_ui
->
linkComboBox
->
setCurrentIndex
(
qMax
(
0
,
_
links
.
size
()
-
1
));
linkSelected
(
m_ui
->
linkComboBox
->
currentIndex
());
// Register for name changes
...
...
@@ -184,18 +187,24 @@ void DebugConsole::addLink(LinkInterface* link)
connect
(
LinkManager
::
instance
(),
&
LinkManager
::
linkDisconnected
,
this
,
&
DebugConsole
::
removeLink
,
Qt
::
UniqueConnection
);
}
void
DebugConsole
::
removeLink
(
LinkInterface
*
const
link
Interface
)
void
DebugConsole
::
removeLink
(
LinkInterface
*
const
link
)
{
// Add link to link list
if
(
links
.
contains
(
linkInterface
))
{
int
linkIndex
=
links
.
indexOf
(
linkInterface
);
links
.
removeAt
(
linkIndex
);
m_ui
->
linkComboBox
->
removeItem
(
linkIndex
);
bool
found
=
false
;
int
linkIndex
;
for
(
linkIndex
=
0
;
linkIndex
<
_links
.
count
();
linkIndex
++
)
{
if
(
_links
[
linkIndex
].
data
()
==
link
)
{
found
=
true
;
_links
.
removeAt
(
linkIndex
);
break
;
}
}
Q_UNUSED
(
found
);
Q_ASSERT
(
found
);
m_ui
->
linkComboBox
->
removeItem
(
linkIndex
);
// Now if this was the current link, clean up some stuff.
if
(
link
Interface
==
currLink
)
if
(
link
==
currLink
)
{
// Like disable the update time for the UI.
snapShotTimer
.
stop
();
...
...
@@ -211,7 +220,7 @@ void DebugConsole::linkStatusUpdate(const QString& name,const QString& text)
m_ui
->
receiveText
->
ensureCursorVisible
();
}
void
DebugConsole
::
linkSelected
(
int
linkI
d
)
void
DebugConsole
::
linkSelected
(
int
linkI
ndex
)
{
// Disconnect
if
(
currLink
)
...
...
@@ -226,8 +235,8 @@ void DebugConsole::linkSelected(int linkId)
m_ui
->
receiveText
->
clear
();
// Connect new link
if
(
linkI
d
!=
-
1
)
{
currLink
=
links
[
linkId
]
;
if
(
linkI
ndex
!=
-
1
)
{
currLink
=
_links
[
linkIndex
].
data
()
;
connect
(
currLink
,
SIGNAL
(
bytesReceived
(
LinkInterface
*
,
QByteArray
)),
this
,
SLOT
(
receiveBytes
(
LinkInterface
*
,
QByteArray
)));
disconnect
(
currLink
,
&
LinkInterface
::
connected
,
this
,
&
DebugConsole
::
_linkConnected
);
connect
(
currLink
,
SIGNAL
(
communicationUpdate
(
QString
,
QString
)),
this
,
SLOT
(
linkStatusUpdate
(
QString
,
QString
)));
...
...
@@ -241,13 +250,21 @@ void DebugConsole::linkSelected(int linkId)
*/
void
DebugConsole
::
updateLinkName
(
QString
name
)
{
// Set name if signal came from a link
LinkInterface
*
link
=
qobject_cast
<
LinkInterface
*>
(
sender
());
if
((
link
!=
NULL
)
&&
(
links
.
contains
(
link
)))
{
const
qint16
&
linkIndex
(
links
.
indexOf
(
link
));
m_ui
->
linkComboBox
->
setItemText
(
linkIndex
,
name
);
}
if
(
link
!=
NULL
)
{
bool
found
=
false
;
int
linkIndex
;
for
(
linkIndex
=
0
;
linkIndex
<
_links
.
count
();
linkIndex
++
)
{
if
(
_links
[
linkIndex
].
data
()
==
link
)
{
found
=
true
;
break
;
}
}
if
(
found
)
{
m_ui
->
linkComboBox
->
setItemText
(
linkIndex
,
name
);
}
}
}
void
DebugConsole
::
setAutoHold
(
bool
hold
)
...
...
src/ui/DebugConsole.h
View file @
f053edc8
...
...
@@ -116,7 +116,6 @@ protected:
/** @brief Cycle through the command history */
void
cycleCommandHistory
(
bool
up
);
QList
<
LinkInterface
*>
links
;
LinkInterface
*
currLink
;
bool
holdOn
;
///< Hold current view, ignore new data
...
...
@@ -150,6 +149,11 @@ private slots:
private:
/** @brief Set connection state of the current link */
void
_setConnectionState
(
bool
);
/// List of all links we are keeping track of. We keep SharedLinkInterface objects
/// which are QSharedPointer's in order to maintain reference counts. Otherwise signals
/// can get out of order and the link may be deleted before we clean up our side.
QList
<
SharedLinkInterface
>
_links
;
Ui
::
DebugConsole
*
m_ui
;
};
...
...
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