QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LinkManager Class Reference

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. More...

#include <LinkManager.h>

Inheritance diagram for LinkManager:
Collaboration diagram for LinkManager:

Signals

void mavlinkSupportForwardingEnabledChanged ()
void isBluetoothAvailableChanged ()
void commPortStringsChanged ()
void commPortsChanged ()

Public Member Functions

 LinkManager (QObject *parent=nullptr)
 ~LinkManager ()
void init ()
Q_INVOKABLE LinkConfiguration * createConfiguration (int type, const QString &name)
 Create/Edit Link Configuration.
Q_INVOKABLE LinkConfiguration * startConfigurationEditing (LinkConfiguration *config)
Q_INVOKABLE void cancelConfigurationEditing (LinkConfiguration *config) const
Q_INVOKABLE void endConfigurationEditing (LinkConfiguration *config, LinkConfiguration *editedConfig)
Q_INVOKABLE void endCreateConfiguration (LinkConfiguration *config)
Q_INVOKABLE void removeConfiguration (LinkConfiguration *config)
Q_INVOKABLE void createConnectedLink (const LinkConfiguration *config)
 This should only be used by Qml code.
Q_INVOKABLE void disconnectLink (LinkInterface *link)
Q_INVOKABLE void disconnectLinkConfiguration (LinkConfiguration *config)
 Stop a link and suppress auto-reconnect, working whether or not a live link currently exists.
Q_INVOKABLE void createMavlinkForwardingSupportLink ()
Q_INVOKABLE void shutdown ()
 Called to signal app shutdown. Disconnects all links while turning off auto-connect.
Q_INVOKABLE LogReplayLink * startLogReplay (const QString &logFile)
QList< SharedLinkInterfacePtr > links ()
QStringList linkTypeStrings () const
bool mavlinkSupportForwardingEnabled () const
void loadLinkConfigurationList ()
void saveLinkConfigurationList ()
void setConnectionsSuspended (const QString &reason)
void setConnectionsAllowed ()
 Sets the flag to allow new connections to be made.
bool connectionsSuspended () const
bool createConnectedLink (SharedLinkConfigurationPtr &config)
 Creates, connects (and adds) a link based on the given configuration instance.
SharedLinkInterfacePtr mavlinkForwardingLink ()
 Returns pointer to the mavlink forwarding link, or nullptr if it does not exist.
SharedLinkInterfacePtr mavlinkForwardingSupportLink ()
 Returns pointer to the mavlink support forwarding link, or nullptr if it does not exist.
void disconnectAll ()
uint8_t allocateMavlinkChannel ()
void freeMavlinkChannel (uint8_t channel)
SharedLinkInterfacePtr sharedLinkInterfacePointerForLink (const LinkInterface *link)
bool containsLink (const LinkInterface *link)
SharedLinkConfigurationPtr addConfiguration (LinkConfiguration *config)
bool containsConfiguration (const QString &name) const
void startAutoConnectedLinks ()
QStringList serialPortStrings ()
QStringList serialPorts ()
Q_INVOKABLE bool serialPortHasFlowControl (const QString &portName) const

Static Public Member Functions

static LinkManager * instance ()
static bool isBluetoothAvailable ()
static bool isLinkUSBDirect (const LinkInterface *link)
static constexpr uint8_t invalidMavlinkChannel ()
static QStringList serialBaudRates ()

Friends

class LinkManagerTest

Detailed Description

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.

Definition at line 30 of file LinkManager.h.

Constructor & Destructor Documentation

◆ LinkManager()

LinkManager::LinkManager ( QObject * parent = nullptr)
explicit

◆ ~LinkManager()

LinkManager::~LinkManager ( )

Definition at line 61 of file LinkManager.cc.

Member Function Documentation

◆ addConfiguration()

◆ allocateMavlinkChannel()

uint8_t LinkManager::allocateMavlinkChannel ( )

Allocates a mavlink channel for use

Returns
Mavlink channel index, invalidMavlinkChannel() for no channels available

Definition at line 907 of file LinkManager.cc.

References invalidMavlinkChannel(), MAVLINK_COMM_NUM_BUFFERS, and mavlink_get_channel_status().

Referenced by LinkInterface::_allocateMavlinkChannel().

◆ cancelConfigurationEditing()

Q_INVOKABLE void LinkManager::cancelConfigurationEditing ( LinkConfiguration * config) const
inline

Definition at line 55 of file LinkManager.h.

References cancelConfigurationEditing().

Referenced by cancelConfigurationEditing().

◆ commPortsChanged

void LinkManager::commPortsChanged ( )
signal

◆ commPortStringsChanged

void LinkManager::commPortStringsChanged ( )
signal

◆ connectionsSuspended()

bool LinkManager::connectionsSuspended ( ) const
inline

Definition at line 83 of file LinkManager.h.

Referenced by GPSManager::init().

◆ containsConfiguration()

bool LinkManager::containsConfiguration ( const QString & name) const

Definition at line 890 of file LinkManager.cc.

◆ containsLink()

bool LinkManager::containsLink ( const LinkInterface * link)

Definition at line 869 of file LinkManager.cc.

◆ createConfiguration()

LinkConfiguration * LinkManager::createConfiguration ( int type,
const QString & name )

Create/Edit Link Configuration.

Definition at line 775 of file LinkManager.cc.

References LinkConfiguration::createSettings(), and LinkConfiguration::TypeSerial.

Referenced by LinkManagerTest.

◆ createConnectedLink() [1/2]

void LinkManager::createConnectedLink ( const LinkConfiguration * config)

This should only be used by Qml code.

Definition at line 110 of file LinkManager.cc.

References createConnectedLink().

Referenced by createConnectedLink(), createMavlinkForwardingSupportLink(), init(), startAutoConnectedLinks(), and startLogReplay().

◆ createConnectedLink() [2/2]

◆ createMavlinkForwardingSupportLink()

◆ disconnectAll()

void LinkManager::disconnectAll ( )

Definition at line 397 of file LinkManager.cc.

References links().

Referenced by shutdown(), and FirmwareUpgradeController::startBoardSearch().

◆ disconnectLink()

void LinkManager::disconnectLink ( LinkInterface * link)

◆ disconnectLinkConfiguration()

void LinkManager::disconnectLinkConfiguration ( LinkConfiguration * config)

Stop a link and suppress auto-reconnect, working whether or not a live link currently exists.

Definition at line 238 of file LinkManager.cc.

References LinkConfiguration::link(), and LinkConfiguration::setSuppressAutoReconnect().

◆ endConfigurationEditing()

void LinkManager::endConfigurationEditing ( LinkConfiguration * config,
LinkConfiguration * editedConfig )

◆ endCreateConfiguration()

void LinkManager::endCreateConfiguration ( LinkConfiguration * config)

Definition at line 760 of file LinkManager.cc.

References addConfiguration(), and saveLinkConfigurationList().

◆ freeMavlinkChannel()

void LinkManager::freeMavlinkChannel ( uint8_t channel)

Definition at line 926 of file LinkManager.cc.

References invalidMavlinkChannel().

Referenced by LinkInterface::_freeMavlinkChannel().

◆ init()

◆ instance()

◆ invalidMavlinkChannel()

constexpr uint8_t LinkManager::invalidMavlinkChannel ( )
inlinestaticconstexpr

◆ isBluetoothAvailable()

bool LinkManager::isBluetoothAvailable ( )
static

Definition at line 864 of file LinkManager.cc.

References QGCNetworkHelper::isBluetoothAvailable().

◆ isBluetoothAvailableChanged

void LinkManager::isBluetoothAvailableChanged ( )
signal

◆ isLinkUSBDirect()

bool LinkManager::isLinkUSBDirect ( const LinkInterface * link)
static

◆ links()

QList< SharedLinkInterfacePtr > LinkManager::links ( )

Definition at line 99 of file LinkManager.cc.

Referenced by disconnectAll(), and QGroundControlQmlGlobal::stopOneMockLink().

◆ linkTypeStrings()

QStringList LinkManager::linkTypeStrings ( ) const

Definition at line 716 of file LinkManager.cc.

References LinkConfiguration::TypeLast.

◆ loadLinkConfigurationList()

◆ mavlinkForwardingLink()

SharedLinkInterfacePtr LinkManager::mavlinkForwardingLink ( )

Returns pointer to the mavlink forwarding link, or nullptr if it does not exist.

Definition at line 369 of file LinkManager.cc.

References LinkInterface::linkConfiguration(), and LinkConfiguration::TypeUdp.

◆ mavlinkForwardingSupportLink()

SharedLinkInterfacePtr LinkManager::mavlinkForwardingSupportLink ( )

Returns pointer to the mavlink support forwarding link, or nullptr if it does not exist.

Definition at line 383 of file LinkManager.cc.

References LinkInterface::linkConfiguration(), and LinkConfiguration::TypeUdp.

◆ mavlinkSupportForwardingEnabled()

bool LinkManager::mavlinkSupportForwardingEnabled ( ) const
inline

Definition at line 71 of file LinkManager.h.

◆ mavlinkSupportForwardingEnabledChanged

void LinkManager::mavlinkSupportForwardingEnabledChanged ( )
signal

◆ removeConfiguration()

void LinkManager::removeConfiguration ( LinkConfiguration * config)

◆ saveLinkConfigurationList()

void LinkManager::saveLinkConfigurationList ( )

◆ serialBaudRates()

QStringList LinkManager::serialBaudRates ( )
static

Definition at line 1032 of file LinkManager.cc.

References SerialConfiguration::supportedBaudRates().

Referenced by isBluetoothAvailableChanged().

◆ serialPortHasFlowControl()

bool LinkManager::serialPortHasFlowControl ( const QString & portName) const

Whether the serial port of this name can be set to hardware flow control. A port that is not listed is taken for one that can.

Definition at line 1037 of file LinkManager.cc.

References SerialPortManager::instance(), and SerialPortManager::port().

◆ serialPorts()

QStringList LinkManager::serialPorts ( )

Definition at line 1023 of file LinkManager.cc.

Referenced by isBluetoothAvailableChanged().

◆ serialPortStrings()

QStringList LinkManager::serialPortStrings ( )

Definition at line 1014 of file LinkManager.cc.

Referenced by isBluetoothAvailableChanged().

◆ setConnectionsAllowed()

void LinkManager::setConnectionsAllowed ( )
inline

Sets the flag to allow new connections to be made.

Definition at line 81 of file LinkManager.h.

Referenced by LogReplayWorker::pause(), and FirmwareUpgradeController::~FirmwareUpgradeController().

◆ setConnectionsSuspended()

void LinkManager::setConnectionsSuspended ( const QString & reason)
inline

Sets the flag to suspend the all new connections

Parameters
reasonUser visible reason to suspend connections

Definition at line 78 of file LinkManager.h.

Referenced by LogReplayWorker::play(), shutdown(), and FirmwareUpgradeController::startBoardSearch().

◆ sharedLinkInterfacePointerForLink()

SharedLinkInterfacePtr LinkManager::sharedLinkInterfacePointerForLink ( const LinkInterface * link)

If you are going to hold a reference to a LinkInterface* in your object you must reference count it by using this method to get access to the shared pointer.

Definition at line 460 of file LinkManager.cc.

Referenced by MAVLinkProtocol::receiveBytes().

◆ shutdown()

void LinkManager::shutdown ( )

Called to signal app shutdown. Disconnects all links while turning off auto-connect.

Definition at line 705 of file LinkManager.cc.

References disconnectAll(), MultiVehicleManager::instance(), and setConnectionsSuspended().

◆ startAutoConnectedLinks()

void LinkManager::startAutoConnectedLinks ( )

Definition at line 897 of file LinkManager.cc.

References createConnectedLink().

◆ startConfigurationEditing()

LinkConfiguration * LinkManager::startConfigurationEditing ( LinkConfiguration * config)

Definition at line 786 of file LinkManager.cc.

References LinkConfiguration::duplicateSettings(), and SerialPortManager::instance().

Referenced by LinkManagerTest.

◆ startLogReplay()

◆ LinkManagerTest

friend class LinkManagerTest
friend

The documentation for this class was generated from the following files: