QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LinkConfiguration.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QLoggingCategory>
4#include <QtCore/QSettings>
5#include <QtCore/QString>
6#include <QtQmlIntegration/QtQmlIntegration>
7
8class LinkInterface;
9
10Q_DECLARE_LOGGING_CATEGORY(LinkConfigurationLog)
11
12
13class LinkConfiguration : public QObject
14{
15 Q_OBJECT
16 QML_ELEMENT
17 QML_UNCREATABLE("")
18 Q_MOC_INCLUDE("LinkInterface.h")
19
20 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
21 Q_PROPERTY(LinkInterface *link READ link NOTIFY linkChanged)
22 Q_PROPERTY(LinkType linkType READ type CONSTANT)
23 Q_PROPERTY(bool dynamic READ isDynamic WRITE setDynamic NOTIFY dynamicChanged)
24 Q_PROPERTY(bool autoConnect READ isAutoConnect WRITE setAutoConnect NOTIFY autoConnectChanged)
25 Q_PROPERTY(QString settingsURL READ settingsURL CONSTANT)
26 Q_PROPERTY(QString settingsTitle READ settingsTitle CONSTANT)
27 Q_PROPERTY(bool highLatency READ isHighLatency WRITE setHighLatency NOTIFY highLatencyChanged)
28
29public:
30 LinkConfiguration(const QString &name, QObject *parent = nullptr);
31 LinkConfiguration(const LinkConfiguration *copy, QObject *parent = nullptr);
32 virtual ~LinkConfiguration();
33
34 QString name() const { return _name; }
35 void setName(const QString &name);
36
37 LinkInterface *link() const { return _link.lock().get(); }
38 void setLink(const std::shared_ptr<LinkInterface> link);
39
42 bool isDynamic() const { return _dynamic; }
43
45 void setDynamic(bool dynamic = true);
46
49 bool isForwarding() const { return _forwarding; }
50
52 void setForwarding(bool forwarding = true) { _forwarding = forwarding; };
53
54 bool isAutoConnect() const { return _autoConnect; }
55
57 virtual void setAutoConnect(bool autoc = true);
58
61 bool isHighLatency() const { return _highLatency; }
62
64 void setHighLatency(bool hl = false);
65
69 virtual void copyFrom(const LinkConfiguration *source);
70
73 enum LinkType {
74#ifndef QGC_NO_SERIAL_LINK
75 TypeSerial,
76#endif
77 TypeUdp,
78 TypeTcp,
79 TypeBluetooth,
80#ifdef QT_DEBUG
81 TypeMock,
82#endif
83 TypeLogReplay,
84 TypeLast // Last type value (type >= TypeLast == invalid)
85 };
86 Q_ENUM(LinkType)
87
88
90 virtual LinkType type() const = 0;
91
95 virtual void loadSettings(QSettings &settings, const QString &root) = 0;
96
100 virtual void saveSettings(QSettings &settings, const QString &root) const = 0;
101
103 virtual QString settingsURL() const = 0;
104
106 virtual QString settingsTitle() const = 0;
107
110 static LinkConfiguration *createSettings(int type, const QString &name);
111
114 static LinkConfiguration *duplicateSettings(const LinkConfiguration *source);
115
118 static QString settingsRoot() { return QStringLiteral("LinkConfigurations"); }
119
120signals:
121 void nameChanged(const QString &name);
126
127protected:
128 std::weak_ptr<LinkInterface> _link;
129
130private:
131 QString _name;
132 bool _dynamic = false;
133 bool _forwarding = false;
134 bool _autoConnect = false;
135 bool _highLatency = false;
136};
137
138typedef std::shared_ptr<LinkConfiguration> SharedLinkConfigurationPtr;
139typedef std::weak_ptr<LinkConfiguration> WeakLinkConfigurationPtr;
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
std::weak_ptr< LinkConfiguration > WeakLinkConfigurationPtr
Interface holding link specific settings.
std::weak_ptr< LinkInterface > _link
Link currently using this configuration (if any)
void autoConnectChanged()
void highLatencyChanged()
void nameChanged(const QString &name)
The link interface defines the interface for all links used to communicate with the ground station ap...