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
42351ee0
Commit
42351ee0
authored
Dec 09, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restructure LinkManager/MAVLinkProtocol
parent
e7d85710
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
249 additions
and
284 deletions
+249
-284
QGCApplication.cc
src/QGCApplication.cc
+2
-2
LinkInterface.h
src/comm/LinkInterface.h
+0
-5
LinkManager.cc
src/comm/LinkManager.cc
+35
-67
LinkManager.h
src/comm/LinkManager.h
+41
-46
MAVLinkProtocol.cc
src/comm/MAVLinkProtocol.cc
+18
-7
MAVLinkProtocol.h
src/comm/MAVLinkProtocol.h
+10
-4
MAVLinkSimulationLink.cc
src/comm/MAVLinkSimulationLink.cc
+1
-3
SerialLink.cc
src/comm/SerialLink.cc
+0
-3
TCPLink.cc
src/comm/TCPLink.cc
+0
-2
UDPLink.cc
src/comm/UDPLink.cc
+0
-2
LinkManagerTest.cc
src/qgcunittest/LinkManagerTest.cc
+4
-4
MainWindowTest.cc
src/qgcunittest/MainWindowTest.cc
+1
-2
MavlinkLogTest.cc
src/qgcunittest/MavlinkLogTest.cc
+1
-2
MockLink.cc
src/qgcunittest/MockLink.cc
+0
-2
TCPLinkTest.cc
src/qgcunittest/TCPLinkTest.cc
+7
-14
TCPLinkTest.h
src/qgcunittest/TCPLinkTest.h
+0
-2
UnitTest.cc
src/qgcunittest/UnitTest.cc
+2
-0
QGCUASFileManager.cc
src/uas/QGCUASFileManager.cc
+1
-1
UAS.cc
src/uas/UAS.cc
+1
-1
UASParameterCommsMgr.cc
src/uas/UASParameterCommsMgr.cc
+1
-1
CommConfigurationWindow.cc
src/ui/CommConfigurationWindow.cc
+20
-19
CommConfigurationWindow.h
src/ui/CommConfigurationWindow.h
+6
-2
DebugConsole.cc
src/ui/DebugConsole.cc
+14
-4
DebugConsole.h
src/ui/DebugConsole.h
+7
-2
MAVLinkSettingsWidget.cc
src/ui/MAVLinkSettingsWidget.cc
+1
-1
MainWindow.cc
src/ui/MainWindow.cc
+22
-41
MainWindow.h
src/ui/MainWindow.h
+1
-10
OpalLinkConfigurationWindow.cc
src/ui/OpalLinkConfigurationWindow.cc
+13
-2
OpalLinkConfigurationWindow.h
src/ui/OpalLinkConfigurationWindow.h
+5
-3
QGCToolBar.cc
src/ui/QGCToolBar.cc
+21
-11
QGCToolBar.h
src/ui/QGCToolBar.h
+8
-2
SerialConfigurationWindow.cc
src/ui/SerialConfigurationWindow.cc
+0
-4
SettingsDialog.cc
src/ui/SettingsDialog.cc
+2
-9
UASListWidget.cc
src/ui/uas/UASListWidget.cc
+4
-4
No files found.
src/QGCApplication.cc
View file @
42351ee0
...
...
@@ -281,11 +281,11 @@ bool QGCApplication::_initForNormalAppBoot(void)
// to make sure that all components are initialized when the
// first messages arrive
udpLink
=
new
UDPLink
(
QHostAddress
::
Any
,
14550
);
LinkManager
::
instance
()
->
add
(
udpLink
);
LinkManager
::
instance
()
->
add
Link
(
udpLink
);
}
else
{
// We want to have a default serial link available for "quick" connecting.
SerialLink
*
slink
=
new
SerialLink
();
LinkManager
::
instance
()
->
add
(
slink
);
LinkManager
::
instance
()
->
add
Link
(
slink
);
}
#ifdef QGC_RTLAB_ENABLED
...
...
src/comm/LinkInterface.h
View file @
42351ee0
...
...
@@ -186,11 +186,6 @@ signals:
**/
void
disconnected
();
/**
* @brief This signal is emitted instantly when the link status changes
**/
void
connected
(
bool
connected
);
/**
* @brief This signal is emitted if the human readable name of this link changes
*/
...
...
src/comm/LinkManager.cc
View file @
42351ee0
...
...
@@ -43,7 +43,7 @@ LinkManager* LinkManager::_instance = NULL;
LinkManager
*
LinkManager
::
instance
(
void
)
{
if
(
_instance
==
0
)
{
_instance
=
new
LinkManager
(
qgcApp
());
new
LinkManager
(
qgcApp
());
Q_CHECK_PTR
(
_instance
);
}
...
...
@@ -65,10 +65,14 @@ void LinkManager::deleteInstance(void)
**/
LinkManager
::
LinkManager
(
QObject
*
parent
,
bool
registerSingleton
)
:
QGCSingleton
(
parent
,
registerSingleton
),
_connectionsSuspended
(
false
)
_connectionsSuspended
(
false
),
_mavlink
(
NULL
)
{
_links
=
QList
<
LinkInterface
*>
();
_protocolLinks
=
QMap
<
ProtocolInterface
*
,
LinkInterface
*>
();
Q_ASSERT
(
_instance
==
NULL
);
_instance
=
this
;
_mavlink
=
new
MAVLinkProtocol
;
Q_CHECK_PTR
(
_mavlink
);
}
LinkManager
::~
LinkManager
()
...
...
@@ -80,69 +84,39 @@ LinkManager::~LinkManager()
deleteLink
(
link
);
}
_links
.
clear
();
// Clear out the queue so disconnects make it all the way through threads
qgcApp
()
->
processEvents
(
QEventLoop
::
ExcludeUserInputEvents
);
delete
_mavlink
;
}
void
LinkManager
::
add
(
LinkInterface
*
link
)
void
LinkManager
::
add
Link
(
LinkInterface
*
link
)
{
Q_ASSERT
(
link
);
// Take ownership for delete
link
->
_ownedByLinkManager
=
true
;
_
data
Mutex
.
lock
();
_
linkList
Mutex
.
lock
();
if
(
!
_links
.
contains
(
link
))
{
_links
.
append
(
link
);
_
data
Mutex
.
unlock
();
_
linkList
Mutex
.
unlock
();
emit
newLink
(
link
);
}
else
{
_
data
Mutex
.
unlock
();
_
linkList
Mutex
.
unlock
();
}
}
void
LinkManager
::
addProtocol
(
LinkInterface
*
link
,
ProtocolInterface
*
protocol
)
{
Q_ASSERT
(
link
);
Q_ASSERT
(
protocol
);
// Connect link to protocol
// the protocol will receive new bytes from the link
_dataMutex
.
lock
();
QList
<
LinkInterface
*>
linkList
=
_protocolLinks
.
values
(
protocol
);
// If protocol has not been added before (list length == 0)
// OR if link has not been added to protocol, add
if
(
!
linkList
.
contains
(
link
))
{
// Protocol is new, add
connect
(
link
,
SIGNAL
(
bytesReceived
(
LinkInterface
*
,
QByteArray
)),
protocol
,
SLOT
(
receiveBytes
(
LinkInterface
*
,
QByteArray
)));
// Add status
connect
(
link
,
SIGNAL
(
connected
(
bool
)),
protocol
,
SLOT
(
linkStatusChanged
(
bool
)));
// Store the connection information in the protocol links map
_protocolLinks
.
insertMulti
(
protocol
,
link
);
_dataMutex
.
unlock
();
// Make sure the protocol clears its metadata for this link.
protocol
->
resetMetadataForLink
(
link
);
}
else
{
_dataMutex
.
unlock
();
// MainWindow may be around when doing things like running unit tests
if
(
MainWindow
::
instance
())
{
connect
(
link
,
SIGNAL
(
communicationError
(
QString
,
QString
)),
MainWindow
::
instance
(),
SLOT
(
showCriticalMessage
(
QString
,
QString
)),
Qt
::
QueuedConnection
);
}
//qDebug() << __FILE__ << __LINE__ << "ADDED LINK TO PROTOCOL" << link->getName() << protocol->getName() << "NEW SIZE OF LINK LIST:" << _protocolLinks.size();
}
QList
<
LinkInterface
*>
LinkManager
::
getLinksForProtocol
(
ProtocolInterface
*
protocol
)
{
_dataMutex
.
lock
();
QList
<
LinkInterface
*>
links
=
_protocolLinks
.
values
(
protocol
);
_dataMutex
.
unlock
();
return
links
;
}
ProtocolInterface
*
LinkManager
::
getProtocolForLink
(
LinkInterface
*
link
)
{
_dataMutex
.
lock
();
ProtocolInterface
*
protocol
=
_protocolLinks
.
key
(
link
);
_dataMutex
.
unlock
();
return
protocol
;
connect
(
link
,
&
LinkInterface
::
bytesReceived
,
_mavlink
,
&
MAVLinkProtocol
::
receiveBytes
);
connect
(
link
,
&
LinkInterface
::
connected
,
_mavlink
,
&
MAVLinkProtocol
::
linkConnected
);
connect
(
link
,
&
LinkInterface
::
disconnected
,
_mavlink
,
&
MAVLinkProtocol
::
linkDisconnected
);
_mavlink
->
resetMetadataForLink
(
link
);
}
bool
LinkManager
::
connectAll
()
...
...
@@ -153,14 +127,14 @@ bool LinkManager::connectAll()
bool
allConnected
=
true
;
_
data
Mutex
.
lock
();
_
linkList
Mutex
.
lock
();
foreach
(
LinkInterface
*
link
,
_links
)
{
Q_ASSERT
(
link
);
if
(
!
link
->
_connect
())
{
allConnected
=
false
;
}
}
_
data
Mutex
.
unlock
();
_
linkList
Mutex
.
unlock
();
return
allConnected
;
}
...
...
@@ -169,7 +143,7 @@ bool LinkManager::disconnectAll()
{
bool
allDisconnected
=
true
;
_
data
Mutex
.
lock
();
_
linkList
Mutex
.
lock
();
foreach
(
LinkInterface
*
link
,
_links
)
{
Q_ASSERT
(
link
);
...
...
@@ -177,7 +151,7 @@ bool LinkManager::disconnectAll()
allDisconnected
=
false
;
}
}
_
data
Mutex
.
unlock
();
_
linkList
Mutex
.
unlock
();
return
allDisconnected
;
}
...
...
@@ -203,19 +177,13 @@ void LinkManager::deleteLink(LinkInterface* link)
{
Q_ASSERT
(
link
);
_
data
Mutex
.
lock
();
_
linkList
Mutex
.
lock
();
Q_ASSERT
(
_links
.
contains
(
link
));
_links
.
removeOne
(
link
);
Q_ASSERT
(
!
_links
.
contains
(
link
));
// Remove link from protocol map
QList
<
ProtocolInterface
*
>
protocols
=
_protocolLinks
.
keys
(
link
);
foreach
(
ProtocolInterface
*
proto
,
protocols
)
{
_protocolLinks
.
remove
(
proto
,
link
);
}
_dataMutex
.
unlock
();
_linkListMutex
.
unlock
();
// Emit removal of link
emit
linkDeleted
(
link
);
...
...
@@ -230,15 +198,15 @@ void LinkManager::deleteLink(LinkInterface* link)
*/
const
QList
<
LinkInterface
*>
LinkManager
::
getLinks
()
{
_
data
Mutex
.
lock
();
_
linkList
Mutex
.
lock
();
QList
<
LinkInterface
*>
ret
(
_links
);
_
data
Mutex
.
unlock
();
_
linkList
Mutex
.
unlock
();
return
ret
;
}
const
QList
<
SerialLink
*>
LinkManager
::
getSerialLinks
()
{
_
data
Mutex
.
lock
();
_
linkList
Mutex
.
lock
();
QList
<
SerialLink
*>
s
;
foreach
(
LinkInterface
*
link
,
_links
)
...
...
@@ -250,7 +218,7 @@ const QList<SerialLink*> LinkManager::getSerialLinks()
if
(
serialLink
)
s
.
append
(
serialLink
);
}
_
data
Mutex
.
unlock
();
_
linkList
Mutex
.
unlock
();
return
s
;
}
...
...
src/comm/LinkManager.h
View file @
42351ee0
...
...
@@ -21,13 +21,8 @@ This file is part of the PIXHAWK project
======================================================================*/
/**
* @file
* @brief Manage communication links
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
/// @file
/// @author Lorenz Meier <mavteam@student.ethz.ch>
#ifndef _LINKMANAGER_H_
#define _LINKMANAGER_H_
...
...
@@ -41,15 +36,16 @@ This file is part of the PIXHAWK project
#include "SerialLink.h"
#include "ProtocolInterface.h"
#include "QGCSingleton.h"
#include "MAVLinkProtocol.h"
class
LinkManagerTest
;
/
**
* The Link Manager organizes the physical Links. It can manage arbitrary
* links and takes care of connecting them as well assigning the correct
* protocol instance to transport the link data into the application.
*
**/
/
// Manage communication links
///
/// The Link Manager organizes the physical Links. It can manage arbitrary
/// links and takes care of connecting them as well assigning the correct
/// protocol instance to transport the link data into the application.
class
LinkManager
:
public
QGCSingleton
{
Q_OBJECT
...
...
@@ -62,65 +58,64 @@ public:
~
LinkManager
();
QList
<
LinkInterface
*>
getLinksForProtocol
(
ProtocolInterface
*
protocol
);
ProtocolInterface
*
getProtocolForLink
(
LinkInterface
*
link
);
/** @brief Get a list of all links */
/// Returns list of all links
const
QList
<
LinkInterface
*>
getLinks
();
/
** @brief Get a list of all serial links */
/
/ Returns list of all serial links
const
QList
<
SerialLink
*>
getSerialLinks
();
/** @brief Get a list of all protocols */
const
QList
<
ProtocolInterface
*>
getProtocols
()
{
return
_protocolLinks
.
uniqueKeys
();
}
/// @brief Sets the lag to suspend the all new connections
/// Sets the flag to suspend the all new connections
/// @param reason User visible reason to suspend connections
void
setConnectionsSuspended
(
QString
reason
);
///
@brief
Sets the flag to allow new connections to be made
/// Sets the flag to allow new connections to be made
void
setConnectionsAllowed
(
void
)
{
_connectionsSuspended
=
false
;
}
/// @brief Deletes the specified link. Will disconnect if connected.
/// Adds the link to the LinkManager. LinkManager takes ownership of this object. To delete
/// it, call LinkManager::deleteLink.
void
addLink
(
LinkInterface
*
link
);
/// Deletes the specified link. Will disconnect if connected.
void
deleteLink
(
LinkInterface
*
link
);
public
slots
:
/// @brief Adds the link to the LinkManager. LinkManager takes ownership of this object. To delete
// it, call LinkManager::deleteLink.
void
add
(
LinkInterface
*
link
);
void
addProtocol
(
LinkInterface
*
link
,
ProtocolInterface
*
protocol
);
/// Re-connects all existing links
bool
connectAll
();
bool
connectLink
(
LinkInterface
*
link
);
/// Disconnects all existing links
bool
disconnectAll
();
/// Connect the specified link
bool
connectLink
(
LinkInterface
*
link
);
/// Disconnect the specified link
bool
disconnectLink
(
LinkInterface
*
link
);
/// Returns the one mavlink protocol object in the system
MAVLinkProtocol
*
mavlink
(
void
)
{
return
_mavlink
;
}
signals:
void
newLink
(
LinkInterface
*
link
);
void
linkDeleted
(
LinkInterface
*
link
);
private:
///
@brief
All access to LinkManager is through LinkManager::instance
/// All access to LinkManager is through LinkManager::instance
LinkManager
(
QObject
*
parent
=
NULL
,
bool
registerSingleton
=
true
);
// LinkManager unit test is allowed to new LinkManager objects
//
/
LinkManager unit test is allowed to new LinkManager objects
friend
class
LinkManagerTest
;
static
LinkManager
*
_instance
;
bool
_connectionsSuspendedMsg
(
void
)
;
QList
<
LinkInterface
*>
_links
;
QMultiMap
<
ProtocolInterface
*
,
LinkInterface
*>
_protocolLinks
;
QMutex
_dataMutex
;
static
LinkManager
*
_instance
;
/// LinkManager singleton
bool
_connectionsSuspendedMsg
(
void
);
QList
<
LinkInterface
*>
_links
;
///< List of available links
QMutex
_linkListMutex
;
///< Mutex for thread safe access to _links list
bool
_connectionsSuspended
;
///< true: all new connections should not be allowed
QString
_connectionsSuspendedReason
;
///< User visible reason for suspension
bool
_connectionsSuspended
;
///< true: all new connections should not be allowed
QString
_connectionsSuspendedReason
;
///< User visible reason for suspension
MAVLinkProtocol
*
_mavlink
;
///< The one and only mavlink protocol
};
#endif
src/comm/MAVLinkProtocol.cc
View file @
42351ee0
...
...
@@ -179,14 +179,25 @@ void MAVLinkProtocol::resetMetadataForLink(const LinkInterface *link)
currLossCounter
[
linkId
]
=
0
;
}
void
MAVLinkProtocol
::
link
StatusChanged
(
bool
connecte
d
)
void
MAVLinkProtocol
::
link
Connected
(
voi
d
)
{
LinkInterface
*
link
=
qobject_cast
<
LinkInterface
*>
(
QObject
::
sender
());
Q_ASSERT
(
link
);
if
(
link
==
NULL
)
{
Q_ASSERT
(
false
);
return
;
}
_linkStatusChanged
(
link
,
true
);
}
void
MAVLinkProtocol
::
linkDisconnected
(
void
)
{
LinkInterface
*
link
=
qobject_cast
<
LinkInterface
*>
(
QObject
::
sender
());
Q_ASSERT
(
link
);
_linkStatusChanged
(
link
,
false
);
}
void
MAVLinkProtocol
::
_linkStatusChanged
(
LinkInterface
*
link
,
bool
connected
)
{
Q_ASSERT
(
link
);
if
(
connected
)
{
Q_ASSERT
(
!
_connectedLinks
.
contains
(
link
));
...
...
@@ -441,7 +452,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
if
(
m_multiplexingEnabled
)
{
// Get all links connected to this unit
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
ForProtocol
(
this
);
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
(
);
// Emit message on all links that are currently connected
foreach
(
LinkInterface
*
currLink
,
links
)
...
...
@@ -486,7 +497,7 @@ int MAVLinkProtocol::getComponentId()
void
MAVLinkProtocol
::
sendMessage
(
mavlink_message_t
message
)
{
// Get all links connected to this unit
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
ForProtocol
(
this
);
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
(
);
// Emit message on all links that are currently connected
QList
<
LinkInterface
*>::
iterator
i
;
...
...
src/comm/MAVLinkProtocol.h
View file @
42351ee0
...
...
@@ -38,7 +38,6 @@ This file is part of the QGROUNDCONTROL project
#include <QMap>
#include <QByteArray>
#include "ProtocolInterface.h"
#include "LinkInterface.h"
#include "QGCMAVLink.h"
#include "QGC.h"
...
...
@@ -51,10 +50,10 @@ This file is part of the QGROUNDCONTROL project
* for more information, please see the official website.
* @ref http://pixhawk.ethz.ch/software/mavlink/
**/
class
MAVLinkProtocol
:
public
ProtocolInterface
class
MAVLinkProtocol
:
public
QThread
{
Q_OBJECT
public:
MAVLinkProtocol
();
~
MAVLinkProtocol
();
...
...
@@ -143,7 +142,10 @@ public:
public
slots
:
/** @brief Receive bytes from a communication interface */
void
receiveBytes
(
LinkInterface
*
link
,
QByteArray
b
);
void
linkStatusChanged
(
bool
connected
);
void
linkConnected
(
void
);
void
linkDisconnected
(
void
);
/** @brief Send MAVLink message through serial interface */
void
sendMessage
(
mavlink_message_t
message
);
/** @brief Send MAVLink message */
...
...
@@ -257,6 +259,9 @@ signals:
void
actionGuardChanged
(
bool
enabled
);
/** @brief Emitted if actiion request timeout changed */
void
actionRetransmissionTimeoutChanged
(
int
ms
);
/** @brief Update the packet loss from one system */
void
receiveLossChanged
(
int
uasId
,
float
loss
);
/**
* @brief Emitted if a new radio status packet received
*
...
...
@@ -275,6 +280,7 @@ signals:
void
saveTempFlightDataLog
(
QString
tempLogfile
);
private:
void
_linkStatusChanged
(
LinkInterface
*
link
,
bool
connected
);
bool
_closeLogFile
(
void
);
void
_startLogging
(
void
);
void
_stopLogging
(
void
);
...
...
src/comm/MAVLinkSimulationLink.cc
View file @
42351ee0
...
...
@@ -106,7 +106,7 @@ MAVLinkSimulationLink::MAVLinkSimulationLink(QString readFile, QString writeFile
srand
(
QTime
::
currentTime
().
msec
());
maxTimeNoise
=
0
;
this
->
id
=
getNextLinkId
();
LinkManager
::
instance
()
->
add
(
this
);
LinkManager
::
instance
()
->
add
Link
(
this
);
}
MAVLinkSimulationLink
::~
MAVLinkSimulationLink
()
...
...
@@ -802,7 +802,6 @@ bool MAVLinkSimulationLink::_disconnect(void)
_isConnected
=
false
;
emit
disconnected
();
emit
connected
(
false
);
//exit();
}
...
...
@@ -820,7 +819,6 @@ bool MAVLinkSimulationLink::_connect(void)
{
_isConnected
=
true
;
emit
connected
();
emit
connected
(
true
);
start
(
LowPriority
);
MAVLinkSimulationMAV
*
mav1
=
new
MAVLinkSimulationMAV
(
this
,
1
,
37.480391
,
-
122.282883
);
...
...
src/comm/SerialLink.cc
View file @
42351ee0
...
...
@@ -240,7 +240,6 @@ void SerialLink::run()
m_port
=
NULL
;
emit
disconnected
();
emit
connected
(
false
);
}
QGC
::
SLEEP
::
msleep
(
500
);
...
...
@@ -340,7 +339,6 @@ void SerialLink::run()
m_port
=
NULL
;
emit
disconnected
();
emit
connected
(
false
);
}
}
...
...
@@ -503,7 +501,6 @@ bool SerialLink::hardwareConnect(QString &type)
emit
communicationUpdate
(
getName
(),
"Opened port!"
);
emit
connected
();
emit
connected
(
true
);
qDebug
()
<<
"CONNECTING LINK: "
<<
__FILE__
<<
__LINE__
<<
"type:"
<<
type
<<
"with settings"
<<
m_port
->
portName
()
<<
getBaudRate
()
<<
getDataBits
()
<<
getParityType
()
<<
getStopBits
();
...
...
src/comm/TCPLink.cc
View file @
42351ee0
...
...
@@ -191,7 +191,6 @@ bool TCPLink::_disconnect(void)
_socket
=
NULL
;
emit
disconnected
();
emit
connected
(
false
);
}
return
true
;
...
...
@@ -241,7 +240,6 @@ bool TCPLink::_hardwareConnect(void)
}
_socketIsConnected
=
true
;
emit
connected
(
true
);
emit
connected
();
return
true
;
...
...
src/comm/UDPLink.cc
View file @
42351ee0
...
...
@@ -287,7 +287,6 @@ bool UDPLink::_disconnect(void)
connectState
=
false
;
emit
disconnected
();
emit
connected
(
false
);
return
!
connectState
;
}
...
...
@@ -352,7 +351,6 @@ bool UDPLink::hardwareConnect(void)
//QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
QObject
::
connect
(
socket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readBytes
()));
emit
connected
(
connectState
);
if
(
connectState
)
{
emit
connected
();
}
...
...
src/qgcunittest/LinkManagerTest.cc
View file @
42351ee0
...
...
@@ -85,7 +85,7 @@ void LinkManagerTest::_add_test(void)
Q_ASSERT
(
_linkMgr
->
getLinks
().
count
()
==
0
);
MockLink
*
link
=
new
MockLink
();
_linkMgr
->
add
(
link
);
_linkMgr
->
add
Link
(
link
);
QList
<
LinkInterface
*>
links
=
_linkMgr
->
getLinks
();
QCOMPARE
(
links
.
count
(),
1
);
...
...
@@ -98,7 +98,7 @@ void LinkManagerTest::_delete_test(void)
Q_ASSERT
(
_linkMgr
->
getLinks
().
count
()
==
0
);
MockLink
*
link
=
new
MockLink
();
_linkMgr
->
add
(
link
);
_linkMgr
->
add
Link
(
link
);
_linkMgr
->
deleteLink
(
link
);
QCOMPARE
(
_linkMgr
->
getLinks
().
count
(),
0
);
...
...
@@ -111,7 +111,7 @@ void LinkManagerTest::_addSignals_test(void)
Q_ASSERT
(
_multiSpy
->
checkNoSignals
()
==
true
);
MockLink
*
link
=
new
MockLink
();
_linkMgr
->
add
(
link
);
_linkMgr
->
add
Link
(
link
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
newLinkSignalMask
),
true
);
QSignalSpy
*
spy
=
_multiSpy
->
getSpyByIndex
(
newLinkSignalIndex
);
...
...
@@ -132,7 +132,7 @@ void LinkManagerTest::_deleteSignals_test(void)
Q_ASSERT
(
_multiSpy
->
checkNoSignals
()
==
true
);
MockLink
*
link
=
new
MockLink
();
_linkMgr
->
add
(
link
);
_linkMgr
->
add
Link
(
link
);
_multiSpy
->
clearAllSignals
();
_linkMgr
->
deleteLink
(
link
);
...
...
src/qgcunittest/MainWindowTest.cc
View file @
42351ee0
...
...
@@ -76,8 +76,7 @@ void MainWindowTest::_connectWindowClose_test(void)
MockLink
*
link
=
new
MockLink
();
Q_CHECK_PTR
(
link
);
// FIXME: LinkManager/MainWindow needs to be re-architected so that you don't have to addLink to MainWindow to get things to work
_mainWindow
->
addLink
(
link
);
LinkManager
::
instance
()
->
addLink
(
link
);
linkMgr
->
connectLink
(
link
);
QTest
::
qWait
(
5000
);
// Give enough time for UI to settle and heartbeats to go through
...
...
src/qgcunittest/MavlinkLogTest.cc
View file @
42351ee0
...
...
@@ -147,8 +147,7 @@ void MavlinkLogTest::_connectLog_test(void)
MockLink
*
link
=
new
MockLink
();
Q_CHECK_PTR
(
link
);
// FIXME: LinkManager/MainWindow needs to be re-architected so that you don't have to addLink to MainWindow to get things to work
mainWindow
->
addLink
(
link
);
LinkManager
::
instance
()
->
addLink
(
link
);
linkMgr
->
connectLink
(
link
);
QTest
::
qWait
(
5000
);
// Give enough time for UI to settle and heartbeats to go through
...
...
src/qgcunittest/MockLink.cc
View file @
42351ee0
...
...
@@ -104,7 +104,6 @@ bool MockLink::_connect(void)
_connected
=
true
;
start
();
emit
connected
();
emit
connected
(
true
);
}
return
true
;
...
...
@@ -116,7 +115,6 @@ bool MockLink::_disconnect(void)
_connected
=
false
;
exit
();
emit
disconnected
();
emit
connected
(
false
);
}
return
true
;
...
...
src/qgcunittest/TCPLinkTest.cc
View file @
42351ee0
...
...
@@ -56,7 +56,6 @@ void TCPLinkUnitTest::init(void)
_rgSignals
[
bytesReceivedSignalIndex
]
=
SIGNAL
(
bytesReceived
(
LinkInterface
*
,
QByteArray
));
_rgSignals
[
connectedSignalIndex
]
=
SIGNAL
(
connected
(
void
));
_rgSignals
[
disconnectedSignalIndex
]
=
SIGNAL
(
disconnected
(
void
));
_rgSignals
[
connected2SignalIndex
]
=
SIGNAL
(
connected
(
bool
));
_rgSignals
[
nameChangedSignalIndex
]
=
SIGNAL
(
nameChanged
(
QString
));
_rgSignals
[
communicationErrorSignalIndex
]
=
SIGNAL
(
communicationError
(
const
QString
&
,
const
QString
&
));
_rgSignals
[
communicationUpdateSignalIndex
]
=
SIGNAL
(
communicationUpdate
(
const
QString
&
,
const
QString
&
));
...
...
@@ -157,11 +156,9 @@ void TCPLinkUnitTest::_connectSucceed_test(void)
// Connect to the server
QCOMPARE
(
_link
->
_connect
(),
true
);
// Make sure we get the
two different
connected signals
// Make sure we get the connected signals
QCOMPARE
(
_multiSpy
->
waitForSignalByIndex
(
connectedSignalIndex
,
10000
),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
connectedSignalMask
|
connected2SignalMask
),
true
);
QList
<
QVariant
>
arguments
=
_multiSpy
->
getSpyByIndex
(
connected2SignalIndex
)
->
takeFirst
();
QCOMPARE
(
arguments
.
at
(
0
).
toBool
(),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
connectedSignalMask
),
true
);
_multiSpy
->
clearAllSignals
();
// Test link->server data path
...
...
@@ -186,7 +183,7 @@ void TCPLinkUnitTest::_connectSucceed_test(void)
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
bytesReceivedSignalMask
),
true
);
// Read the data and make sure it matches
arguments
=
_multiSpy
->
getSpyByIndex
(
bytesReceivedSignalIndex
)
->
takeFirst
();
QList
<
QVariant
>
arguments
=
_multiSpy
->
getSpyByIndex
(
bytesReceivedSignalIndex
)
->
takeFirst
();
QVERIFY
(
arguments
.
at
(
1
).
toByteArray
()
==
bytesOut
);
_multiSpy
->
clearAllSignals
();
...
...
@@ -194,11 +191,9 @@ void TCPLinkUnitTest::_connectSucceed_test(void)
// Disconnect the link
_link
->
_disconnect
();
// Make sure we get the disconnected signal
s
on link side
// Make sure we get the disconnected signal on link side
QCOMPARE
(
_multiSpy
->
waitForSignalByIndex
(
disconnectedSignalIndex
,
1000
),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
disconnectedSignalMask
|
connected2SignalMask
),
true
);
arguments
=
_multiSpy
->
getSpyByIndex
(
connected2SignalIndex
)
->
takeFirst
();
QCOMPARE
(
arguments
.
at
(
0
).
toBool
(),
false
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
disconnectedSignalMask
),
true
);
_multiSpy
->
clearAllSignals
();
// Try to connect again to make sure everything was cleaned up correctly from previous connection
...
...
@@ -206,11 +201,9 @@ void TCPLinkUnitTest::_connectSucceed_test(void)
// Connect to the server
QCOMPARE
(
_link
->
_connect
(),
true
);
// Make sure we get the
two different connected signals
// Make sure we get the
connected signal
QCOMPARE
(
_multiSpy
->
waitForSignalByIndex
(
connectedSignalIndex
,
1000
),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
connectedSignalMask
|
connected2SignalMask
),
true
);
arguments
=
_multiSpy
->
getSpyByIndex
(
connected2SignalIndex
)
->
takeFirst
();
QCOMPARE
(
arguments
.
at
(
0
).
toBool
(),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
connectedSignalMask
),
true
);
_multiSpy
->
clearAllSignals
();
server
->
quit
();
...
...
src/qgcunittest/TCPLinkTest.h
View file @
42351ee0
...
...
@@ -58,7 +58,6 @@ private:
bytesReceivedSignalIndex
=
0
,
connectedSignalIndex
,
disconnectedSignalIndex
,
connected2SignalIndex
,
nameChangedSignalIndex
,
communicationErrorSignalIndex
,
communicationUpdateSignalIndex
,
...
...
@@ -70,7 +69,6 @@ private:
bytesReceivedSignalMask
=
1
<<
bytesReceivedSignalIndex
,
connectedSignalMask
=
1
<<
connectedSignalIndex
,
disconnectedSignalMask
=
1
<<
disconnectedSignalIndex
,
connected2SignalMask
=
1
<<
connected2SignalIndex
,
nameChangedSignalMask
=
1
<<
nameChangedSignalIndex
,
communicationErrorSignalMask
=
1
<<
communicationErrorSignalIndex
,
communicationUpdateSignalMask
=
1
<<
communicationUpdateSignalIndex
,
...
...
src/qgcunittest/UnitTest.cc
View file @
42351ee0
...
...
@@ -135,6 +135,8 @@ void UnitTest::cleanup(void)
QEXPECT_FAIL
(
""
,
"Expecting failure due internal testing"
,
Continue
);
}
QCOMPARE
(
_missedFileDialogCount
,
0
);
qgcApp
()
->
destroySingletonsForUnitTest
();
}
void
UnitTest
::
setExpectedMessageBox
(
QMessageBox
::
StandardButton
response
)
...
...
src/uas/QGCUASFileManager.cc
View file @
42351ee0
...
...
@@ -481,7 +481,7 @@ void QGCUASFileManager::_sendRequest(Request* request)
request
->
hdr
.
seqNumber
=
_lastOutgoingSeqNumber
;
if
(
_systemIdQGC
==
0
)
{
_systemIdQGC
=
MainWindow
::
instance
()
->
getMAVL
ink
()
->
getSystemId
();
_systemIdQGC
=
LinkManager
::
instance
()
->
mavl
ink
()
->
getSystemId
();
}
Q_ASSERT
(
_mav
);
...
...
src/uas/UAS.cc
View file @
42351ee0
...
...
@@ -1765,7 +1765,7 @@ void UAS::sendMessage(mavlink_message_t message)
void
UAS
::
forwardMessage
(
mavlink_message_t
message
)
{
// Emit message on all links that are currently connected
QList
<
LinkInterface
*>
link_list
=
LinkManager
::
instance
()
->
getLinks
ForProtocol
(
mavlink
);
QList
<
LinkInterface
*>
link_list
=
LinkManager
::
instance
()
->
getLinks
(
);
foreach
(
LinkInterface
*
link
,
link_list
)
{
...
...
src/uas/UASParameterCommsMgr.cc
View file @
42351ee0
...
...
@@ -71,7 +71,7 @@ void UASParameterCommsMgr::loadParamCommsSettings()
void
UASParameterCommsMgr
::
_sendParamRequestListMsg
(
void
)
{
MAVLinkProtocol
*
mavlink
=
MainWindow
::
instance
()
->
getMAVL
ink
();
MAVLinkProtocol
*
mavlink
=
LinkManager
::
instance
()
->
mavl
ink
();
Q_ASSERT
(
mavlink
);
mavlink_message_t
msg
;
...
...
src/ui/CommConfigurationWindow.cc
View file @
42351ee0
...
...
@@ -60,7 +60,7 @@ This file is part of the QGROUNDCONTROL project
#include "LinkManager.h"
#include "MainWindow.h"
CommConfigurationWindow
::
CommConfigurationWindow
(
LinkInterface
*
link
,
ProtocolInterface
*
protocol
,
QWidget
*
parent
)
:
QDialog
(
parent
)
CommConfigurationWindow
::
CommConfigurationWindow
(
LinkInterface
*
link
,
QWidget
*
parent
)
:
QDialog
(
parent
)
{