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
d95cf003
Commit
d95cf003
authored
Aug 01, 2013
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serial link selection in toolbar operational
parent
67239b4f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
116 additions
and
72 deletions
+116
-72
QGCCore.cc
src/QGCCore.cc
+0
-4
LinkManager.cc
src/comm/LinkManager.cc
+15
-0
LinkManager.h
src/comm/LinkManager.h
+4
-0
SerialLink.cc
src/comm/SerialLink.cc
+1
-0
MainWindow.cc
src/ui/MainWindow.cc
+14
-11
MainWindow.h
src/ui/MainWindow.h
+3
-1
QGCToolBar.cc
src/ui/QGCToolBar.cc
+78
-56
QGCToolBar.h
src/ui/QGCToolBar.h
+1
-0
No files found.
src/QGCCore.cc
View file @
d95cf003
...
...
@@ -176,15 +176,11 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
OpalLink
*
opalLink
=
new
OpalLink
();
MainWindow
::
instance
()
->
addLink
(
opalLink
);
#endif
MAVLinkSimulationLink
*
simulationLink
=
new
MAVLinkSimulationLink
(
":/demo-log.txt"
);
simulationLink
->
disconnect
();
//We want to have a default serial link available for "quick" connecting.
SerialLink
*
slink
=
new
SerialLink
();
MainWindow
::
instance
()
->
addLink
(
slink
);
mainWindow
=
MainWindow
::
instance
(
splashScreen
);
// Remove splash screen
splashScreen
->
finish
(
mainWindow
);
...
...
src/comm/LinkManager.cc
View file @
d95cf003
...
...
@@ -210,3 +210,18 @@ const QList<LinkInterface*> LinkManager::getLinks()
{
return
QList
<
LinkInterface
*>
(
links
);
}
const
QList
<
SerialLink
*>
LinkManager
::
getSerialLinks
()
{
QList
<
SerialLink
*>
s
;
foreach
(
LinkInterface
*
i
,
links
)
{
SerialLink
*
link
=
qobject_cast
<
SerialLink
*>
(
i
);
if
(
link
)
s
.
append
(
link
);
}
return
s
;
}
src/comm/LinkManager.h
View file @
d95cf003
...
...
@@ -36,6 +36,7 @@ This file is part of the PIXHAWK project
#include <QList>
#include <QMultiMap>
#include <LinkInterface.h>
#include <SerialLink.h>
#include <ProtocolInterface.h>
/**
...
...
@@ -64,6 +65,9 @@ public:
/** @brief Get a list of all links */
const
QList
<
LinkInterface
*>
getLinks
();
/** @brief Get a list of all serial links */
const
QList
<
SerialLink
*>
getSerialLinks
();
/** @brief Get a list of all protocols */
const
QList
<
ProtocolInterface
*>
getProtocols
()
{
return
protocolLinks
.
uniqueKeys
();
...
...
src/comm/SerialLink.cc
View file @
d95cf003
...
...
@@ -74,6 +74,7 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
// }
loadSettings
();
LinkManager
::
instance
()
->
add
(
this
);
}
void
SerialLink
::
requestReset
()
{
...
...
src/ui/MainWindow.cc
View file @
d95cf003
...
...
@@ -124,6 +124,7 @@ MainWindow::MainWindow(QWidget *parent):
darkStyleFileName
(
defaultDarkStyle
),
lightStyleFileName
(
defaultLightStyle
),
autoReconnect
(
false
),
simulationLink
(
NULL
),
lowPowerMode
(
false
),
isAdvancedMode
(
false
),
dockWidgetTitleBarEnabled
(
true
),
...
...
@@ -343,11 +344,11 @@ MainWindow::~MainWindow()
delete
mavlink
;
mavlink
=
NULL
;
}
//
if (simulationLink)
//
{
// simulationLink->deleteLater()
;
//
simulationLink = NULL;
//
}
if
(
simulationLink
)
{
delete
simulationLink
;
simulationLink
=
NULL
;
}
if
(
joystick
)
{
joystick
->
shutdown
();
...
...
@@ -1525,6 +1526,8 @@ void MainWindow::connectCommonActions()
connect
(
ui
.
actionJoystickSettings
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
configure
()));
// Application Settings
connect
(
ui
.
actionSettings
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
showSettings
()));
connect
(
ui
.
actionSimulate
,
SIGNAL
(
triggered
(
bool
)),
this
,
SLOT
(
simulateLink
(
bool
)));
}
void
MainWindow
::
showHelp
()
...
...
@@ -1672,15 +1675,15 @@ void MainWindow::addLink(LinkInterface *link)
// Error handling
connect
(
link
,
SIGNAL
(
communicationError
(
QString
,
QString
)),
this
,
SLOT
(
showCriticalMessage
(
QString
,
QString
)),
Qt
::
QueuedConnection
);
// Special case for simulationlink
MAVLinkSimulationLink
*
sim
=
dynamic_cast
<
MAVLinkSimulationLink
*>
(
link
);
if
(
sim
)
{
connect
(
ui
.
actionSimulate
,
SIGNAL
(
triggered
(
bool
)),
sim
,
SLOT
(
connectLink
(
bool
)));
}
}
}
void
MainWindow
::
simulateLink
(
bool
simulate
)
{
if
(
!
simulationLink
)
simulationLink
=
new
MAVLinkSimulationLink
(
":/demo-log.txt"
);
simulationLink
->
connectLink
(
simulate
);
}
//void MainWindow::configLink(LinkInterface *link)
//{
...
...
src/ui/MainWindow.h
View file @
d95cf003
...
...
@@ -204,6 +204,8 @@ public slots:
void
addLink
(
LinkInterface
*
link
);
bool
configLink
(
LinkInterface
*
link
);
void
configure
();
/** @brief Simulate a link */
void
simulateLink
(
bool
simulate
);
/** @brief Set the currently controlled UAS */
void
setActiveUAS
(
UASInterface
*
uas
);
...
...
@@ -387,7 +389,6 @@ protected:
// TODO Should be moved elsewhere, as the protocol does not belong to the UI
MAVLinkProtocol
*
mavlink
;
MAVLinkSimulationLink
*
simulationLink
;
LinkInterface
*
udpLink
;
QSettings
settings
;
...
...
@@ -490,6 +491,7 @@ protected:
QString
darkStyleFileName
;
QString
lightStyleFileName
;
bool
autoReconnect
;
MAVLinkSimulationLink
*
simulationLink
;
Qt
::
WindowStates
windowStateVal
;
bool
lowPowerMode
;
///< If enabled, QGC reduces the update rates of all widgets
QGCFlightGearLink
*
fgLink
;
...
...
src/ui/QGCToolBar.cc
View file @
d95cf003
...
...
@@ -158,20 +158,23 @@ void QGCToolBar::createUI()
portComboBox
=
new
QComboBox
(
this
);
portComboBox
->
setToolTip
(
tr
(
"Choose the COM port to use"
));
portComboBox
->
setEnabled
(
true
);
portComboBox
->
setMinimumWidth
(
2
00
);
portComboBox
->
setMinimumWidth
(
1
00
);
addWidget
(
portComboBox
);
baudcomboBox
=
new
QComboBox
(
this
);
baudcomboBox
->
setToolTip
(
tr
(
"Choose what baud rate to use"
));
baudcomboBox
->
setEnabled
(
true
);
baudcomboBox
->
setMinimumWidth
(
80
);
baudcomboBox
->
addItem
(
"9600"
);
baudcomboBox
->
addItem
(
"14400"
);
baudcomboBox
->
addItem
(
"19200"
);
baudcomboBox
->
addItem
(
"38400"
);
baudcomboBox
->
addItem
(
"57600"
);
baudcomboBox
->
addItem
(
"115200"
);
baudcomboBox
->
setCurrentIndex
(
5
);
baudcomboBox
->
setMinimumWidth
(
40
);
baudcomboBox
->
addItem
(
"9600"
,
9600
);
baudcomboBox
->
addItem
(
"14400"
,
14400
);
baudcomboBox
->
addItem
(
"19200"
,
19200
);
baudcomboBox
->
addItem
(
"38400"
,
38400
);
baudcomboBox
->
addItem
(
"57600"
,
57600
);
baudcomboBox
->
addItem
(
"115200"
,
115200
);
baudcomboBox
->
addItem
(
"230400"
,
230400
);
baudcomboBox
->
addItem
(
"460800"
,
460800
);
baudcomboBox
->
addItem
(
"921600"
,
921600
);
baudcomboBox
->
setCurrentIndex
(
baudcomboBox
->
findData
(
57600
));
addWidget
(
baudcomboBox
);
...
...
@@ -193,18 +196,25 @@ void QGCToolBar::createUI()
// Configure the toolbar for the current default UAS
setActiveUAS
(
UASManager
::
instance
()
->
getActiveUAS
());
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
qDebug
()
<<
"LINK COUNT"
<<
LinkManager
::
instance
()
->
getLinks
().
count
();
// Update label if required
if
(
LinkManager
::
instance
()
->
getSerialLinks
().
count
()
<
1
)
{
connectButton
->
setText
(
tr
(
"New Serial Link"
));
baudcomboBox
->
hide
();
portComboBox
->
hide
();
}
else
{
if
(
LinkManager
::
instance
()
->
getLinks
().
count
()
>
2
)
addLink
(
LinkManager
::
instance
()
->
getLinks
().
last
());
// XXX implies that connect button is always active for the last used link
connect
(
LinkManager
::
instance
(),
SIGNAL
(
newLink
(
LinkInterface
*
)),
this
,
SLOT
(
addLink
(
LinkInterface
*
)));
connect
(
LinkManager
::
instance
(),
SIGNAL
(
linkRemoved
(
LinkInterface
*
)),
this
,
SLOT
(
removeLink
(
LinkInterface
*
)));
QList
<
SerialLink
*>
links
=
LinkManager
::
instance
()
->
getSerialLinks
();
// Update label if required
if
(
LinkManager
::
instance
()
->
getLinks
().
count
()
<
3
)
{
connectButton
->
setText
(
tr
(
"New Link"
));
foreach
(
SerialLink
*
slink
,
links
)
{
addLink
(
slink
);
}
}
connect
(
LinkManager
::
instance
(),
SIGNAL
(
newLink
(
LinkInterface
*
)),
this
,
SLOT
(
addLink
(
LinkInterface
*
)));
connect
(
LinkManager
::
instance
(),
SIGNAL
(
linkRemoved
(
LinkInterface
*
)),
this
,
SLOT
(
removeLink
(
LinkInterface
*
)));
loadSettings
();
changed
=
false
;
...
...
@@ -591,27 +601,42 @@ void QGCToolBar::receiveTextMessage(int uasid, int componentid, int severity, QS
void
QGCToolBar
::
addLink
(
LinkInterface
*
link
)
{
// XXX magic number
if
(
LinkManager
::
instance
()
->
getLinks
().
count
()
>
2
)
{
// Accept only serial links as current link
SerialLink
*
serial
=
qobject_cast
<
SerialLink
*>
(
link
);
if
(
serial
&&
!
currentLink
)
{
baudcomboBox
->
show
();
portComboBox
->
show
();
currentLink
=
link
;
connect
(
currentLink
,
SIGNAL
(
connected
(
bool
)),
this
,
SLOT
(
updateLinkState
(
bool
)));
updateLinkState
(
link
->
isConnected
());
}
qDebug
()
<<
"ADD LINK"
;
updateComboBox
();
}
}
void
QGCToolBar
::
removeLink
(
LinkInterface
*
link
)
{
if
(
link
==
currentLink
)
{
currentLink
=
NULL
;
//portComboBox->setEnabled(false);
//portComboBox->clear();
// XXX magic number
if
(
LinkManager
::
instance
()
->
getLinks
().
count
()
>
2
)
{
currentLink
=
LinkManager
::
instance
()
->
getLinks
().
last
();
// Try to get a new serial link
foreach
(
SerialLink
*
s
,
LinkManager
::
instance
()
->
getSerialLinks
())
{
addLink
(
s
);
}
// Update GUI according to scan result
if
(
currentLink
)
{
updateLinkState
(
currentLink
->
isConnected
());
}
else
{
connectButton
->
setText
(
tr
(
"New Link"
));
connectButton
->
setText
(
tr
(
"New Serial Link"
));
portComboBox
->
hide
();
baudcomboBox
->
hide
();
}
}
updateComboBox
();
...
...
@@ -619,26 +644,31 @@ void QGCToolBar::removeLink(LinkInterface* link)
void
QGCToolBar
::
updateComboBox
()
{
portComboBox
->
clear
();
for
(
int
i
=
0
;
i
<
LinkManager
::
instance
()
->
getLinks
().
count
();
i
++
)
{
SerialLink
*
slink
=
qobject_cast
<
SerialLink
*>
(
LinkManager
::
instance
()
->
getLinks
()[
i
]);
if
(
slink
)
if
(
currentLink
)
{
//It's a serial link
SerialLink
*
slink
=
qobject_cast
<
SerialLink
*>
(
currentLink
);
QList
<
QString
>
portlist
=
slink
->
getCurrentPorts
();
//if (!slink->isConnected())
//{
for
(
int
j
=
0
;
j
<
portlist
.
count
();
j
++
)
foreach
(
QString
port
,
portlist
)
{
portComboBox
->
addItem
(
port
,
port
);
}
portComboBox
->
setCurrentIndex
(
portComboBox
->
findData
(
slink
->
getPortName
()));
if
(
slink
->
getPortName
().
trimmed
().
length
()
>
0
)
{
portComboBox
->
addItem
(
"Serial port:"
+
QString
::
number
(
i
)
+
":"
+
portlist
[
j
]
);
portComboBox
->
setEditText
(
slink
->
getPortName
()
);
}
//}
//We only really want to display from unconnected sources.
else
{
if
(
portlist
.
length
()
>
0
)
{
portComboBox
->
setEditText
(
portlist
.
first
());
}
else
{
portComboBox
->
addItem
(
LinkManager
::
instance
()
->
getLinks
()[
i
]
->
getName
());
portComboBox
->
setEditText
(
tr
(
"No serial port found"
));
}
}
baudcomboBox
->
setCurrentIndex
(
baudcomboBox
->
findData
(
slink
->
getBaudRate
()));
}
}
...
...
@@ -664,30 +694,22 @@ void QGCToolBar::updateLinkState(bool connected)
void
QGCToolBar
::
connectLink
(
bool
connect
)
{
// No serial port yet present
// XXX magic number
if
(
connect
&&
LinkManager
::
instance
()
->
getLinks
().
count
()
<
3
)
if
(
connect
&&
LinkManager
::
instance
()
->
getSerialLinks
().
count
()
==
0
)
{
MainWindow
::
instance
()
->
addLink
();
currentLink
=
LinkManager
::
instance
()
->
getLinks
().
last
();
}
else
if
(
connect
)
{
if
(
portComboBox
->
currentText
().
split
(
":"
).
count
()
>
2
)
{
int
linknum
=
portComboBox
->
currentText
().
split
(
":"
)[
1
].
toInt
();
SerialLink
*
link
=
qobject_cast
<
SerialLink
*>
(
LinkManager
::
instance
()
->
getLinks
().
at
(
linknum
));
SerialLink
*
link
=
qobject_cast
<
SerialLink
*>
(
currentLink
);
if
(
link
)
{
QString
portname
=
portComboBox
->
currentText
().
split
(
":"
)[
2
];
link
->
setPortName
(
portname
.
trimmed
());
}
link
->
setPortName
(
portComboBox
->
itemData
(
portComboBox
->
currentIndex
()).
toString
().
trimmed
());
int
baud
=
baudcomboBox
->
currentText
().
toInt
();
link
->
setBaudRate
(
baud
);
link
->
connect
();
}
else
{
LinkManager
::
instance
()
->
getLinks
().
last
()
->
connect
();
}
}
else
if
(
!
connect
&&
LinkManager
::
instance
()
->
getLinks
().
count
()
>
2
)
{
LinkManager
::
instance
()
->
getLinks
().
last
()
->
disconnect
();
}
else
if
(
!
connect
&&
currentLink
)
{
currentLink
->
disconnect
();
}
}
...
...
src/ui/QGCToolBar.h
View file @
d95cf003
...
...
@@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project
#include <QComboBox>
#include "UASInterface.h"
#include "QGCMAVLinkLogPlayer.h"
#include "SerialLink.h"
class
QGCToolBar
:
public
QToolBar
{
...
...
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