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