diff --git a/src/comm/LinkConfiguration.cc b/src/comm/LinkConfiguration.cc index 915c20cda6217c6c3fe51a135a4c7e4c95590651..c27239517cea29e159682d3c78ba52c2d2fa3473 100644 --- a/src/comm/LinkConfiguration.cc +++ b/src/comm/LinkConfiguration.cc @@ -37,6 +37,7 @@ LinkConfiguration::LinkConfiguration(const QString& name) , _name(name) , _dynamic(false) , _autoConnect(false) + , _highLatency(false) { _name = name; if (_name.isEmpty()) { @@ -50,6 +51,7 @@ LinkConfiguration::LinkConfiguration(LinkConfiguration* copy) _name = copy->name(); _dynamic = copy->isDynamic(); _autoConnect= copy->isAutoConnect(); + _highLatency= copy->isHighLatency(); Q_ASSERT(!_name.isEmpty()); } @@ -60,6 +62,7 @@ void LinkConfiguration::copyFrom(LinkConfiguration* source) _name = source->name(); _dynamic = source->isDynamic(); _autoConnect= source->isAutoConnect(); + _highLatency= source->isHighLatency(); } /*! diff --git a/src/comm/LinkConfiguration.h b/src/comm/LinkConfiguration.h index 76a4bed125f3d3f5f67d1c39c3731ce264a3a26a..8feda594d11c4cc3731a6354f733a6a28923cc30 100644 --- a/src/comm/LinkConfiguration.h +++ b/src/comm/LinkConfiguration.h @@ -33,6 +33,8 @@ public: Q_PROPERTY(bool autoConnect READ isAutoConnect WRITE setAutoConnect NOTIFY autoConnectChanged) Q_PROPERTY(bool autoConnectAllowed READ isAutoConnectAllowed CONSTANT) Q_PROPERTY(QString settingsURL READ settingsURL CONSTANT) + Q_PROPERTY(bool highLatency READ isHighLatency WRITE setHighLatency NOTIFY highLatencyChanged) + Q_PROPERTY(bool highLatencyAllowed READ isHighLatencyAllowed CONSTANT) // Property accessors @@ -76,6 +78,13 @@ public: */ bool isAutoConnect() { return _autoConnect; } + /*! + * + * Is this a High Latency configuration? + * @return True if this is an High Latency configuration (link with large delays). + */ + bool isHighLatency() { return _highLatency; } + /*! * Set if this is this a dynamic configuration. (decided at runtime) */ @@ -86,6 +95,11 @@ public: */ void setAutoConnect(bool autoc = true) { _autoConnect = autoc; emit autoConnectChanged(); } + /*! + * Set if this is this an High Latency configuration. + */ + void setHighLatency(bool hl = false) { _highLatency = hl; emit highLatencyChanged(); } + /// Virtual Methods /*! @@ -95,6 +109,13 @@ public: */ virtual bool isAutoConnectAllowed() { return false; } + /*! + * + * Is High Latency allowed for this type? + * @return True if this type can be set as an High Latency configuration + */ + virtual bool isHighLatencyAllowed() { return false; } + /*! * @brief Connection type * @@ -174,6 +195,7 @@ signals: void dynamicChanged (); void autoConnectChanged (); void linkChanged (LinkInterface* link); + void highLatencyChanged (); protected: LinkInterface* _link; ///< Link currently using this configuration (if any) @@ -181,6 +203,7 @@ private: QString _name; bool _dynamic; ///< A connection added automatically and not persistent (unless it's edited). bool _autoConnect; ///< This connection is started automatically at boot + bool _highLatency; }; typedef QSharedPointer SharedLinkConfigurationPointer; diff --git a/src/comm/LinkInterface.cc b/src/comm/LinkInterface.cc index 0dc594a9df52b8a78b4f140117277da4398de264..f2920712efce1b076baafeee3637bcf9fca352c5 100644 --- a/src/comm/LinkInterface.cc +++ b/src/comm/LinkInterface.cc @@ -23,7 +23,7 @@ uint8_t LinkInterface::mavlinkChannel(void) const LinkInterface::LinkInterface(SharedLinkConfigurationPointer& config) : QThread (0) , _config (config) - , _highLatency (false) + , _highLatency (config->isHighLatency()) , _mavlinkChannelSet (false) , _active (false) , _enableRateCollection (false) diff --git a/src/comm/SerialLink.h b/src/comm/SerialLink.h index a70e27a30c74542386c668bf6caf697e900f54f0..9430f20686586fd8193b571ef6b67db5944f3dac 100644 --- a/src/comm/SerialLink.h +++ b/src/comm/SerialLink.h @@ -86,6 +86,7 @@ public: /// From LinkConfiguration LinkType type () { return LinkConfiguration::TypeSerial; } void copyFrom (LinkConfiguration* source); + bool isHighLatencyAllowed () { return true; } void loadSettings (QSettings& settings, const QString& root); void saveSettings (QSettings& settings, const QString& root); void updateSettings (); diff --git a/src/comm/TCPLink.h b/src/comm/TCPLink.h index 9eb2827feb43a947f8ccec9e975e9dff23017050..907af9cbc5dfe0aa2ee6d479a114b066ce97826f 100644 --- a/src/comm/TCPLink.h +++ b/src/comm/TCPLink.h @@ -97,6 +97,7 @@ public: /// From LinkConfiguration LinkType type () { return LinkConfiguration::TypeTcp; } void copyFrom (LinkConfiguration* source); + bool isHighLatencyAllowed () { return true; } void loadSettings (QSettings& settings, const QString& root); void saveSettings (QSettings& settings, const QString& root); void updateSettings (); diff --git a/src/comm/UDPLink.h b/src/comm/UDPLink.h index c8632cecdcae919f8fe1964ed906aa4202bfd4b6..6e12c6af7bdef0ad4b2a951cc1ee2f5d1ef94e4e 100644 --- a/src/comm/UDPLink.h +++ b/src/comm/UDPLink.h @@ -126,6 +126,7 @@ public: void saveSettings (QSettings& settings, const QString& root); void updateSettings (); bool isAutoConnectAllowed () { return true; } + bool isHighLatencyAllowed () { return true; } QString settingsURL () { return "UdpSettings.qml"; } signals: diff --git a/src/ui/preferences/SerialSettings.qml b/src/ui/preferences/SerialSettings.qml index 07e495605085212cc6b9e53f5d25f3cc975e32cf..8438549d070b9ad7a6a3b8306bc3168c26accf53 100644 --- a/src/ui/preferences/SerialSettings.qml +++ b/src/ui/preferences/SerialSettings.qml @@ -235,5 +235,19 @@ Item { } } } + QGCCheckBox { + text: "High Latency" + checked: false + visible: editConfig ? editConfig.highLatencyAllowed : false + onCheckedChanged: { + if(editConfig) { + editConfig.highLatency = checked + } + } + Component.onCompleted: { + if(editConfig) + checked = editConfig.highLatency + } + } } } diff --git a/src/ui/preferences/TcpSettings.qml b/src/ui/preferences/TcpSettings.qml index 182cf4d6167459bb9702999a11322ee114bc5044..6f0ac0e2d57ef50820f784181fded58f14d88a67 100644 --- a/src/ui/preferences/TcpSettings.qml +++ b/src/ui/preferences/TcpSettings.qml @@ -75,5 +75,19 @@ Item { anchors.verticalCenter: parent.verticalCenter } } + QGCCheckBox { + text: "High Latency" + checked: false + visible: editConfig ? editConfig.highLatencyAllowed : false + onCheckedChanged: { + if(editConfig) { + editConfig.highLatency = checked + } + } + Component.onCompleted: { + if(editConfig) + checked = editConfig.highLatency + } + } } } diff --git a/src/ui/preferences/UdpSettings.qml b/src/ui/preferences/UdpSettings.qml index 825b1bd79b80efe7fdd7ee78fa749790510817a8..6332dc964933134b017b95b9ac68944f2d238c3f 100644 --- a/src/ui/preferences/UdpSettings.qml +++ b/src/ui/preferences/UdpSettings.qml @@ -175,5 +175,19 @@ Item { } } } + QGCCheckBox { + text: "High Latency" + checked: false + visible: editConfig ? editConfig.highLatencyAllowed : false + onCheckedChanged: { + if(editConfig) { + editConfig.highLatency = checked + } + } + Component.onCompleted: { + if(editConfig) + checked = editConfig.highLatency + } + } } }