From 1da34402599802bdc6d4104decb1b4954e48ad62 Mon Sep 17 00:00:00 2001 From: acfloria Date: Fri, 2 Feb 2018 16:09:24 +0100 Subject: [PATCH] Add highLatency property to LinkConfiguration --- src/comm/LinkConfiguration.cc | 3 +++ src/comm/LinkConfiguration.h | 23 +++++++++++++++++++++++ src/comm/LinkInterface.cc | 2 +- src/comm/SerialLink.h | 1 + src/comm/TCPLink.h | 1 + src/comm/UDPLink.h | 1 + src/ui/preferences/SerialSettings.qml | 18 ++++++++++++++++++ src/ui/preferences/TcpSettings.qml | 18 ++++++++++++++++++ src/ui/preferences/UdpSettings.qml | 18 ++++++++++++++++++ 9 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/comm/LinkConfiguration.cc b/src/comm/LinkConfiguration.cc index 915c20cda..c27239517 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 76a4bed12..8feda594d 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 0dc594a9d..f2920712e 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 a70e27a30..9430f2068 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 9eb2827fe..907af9cbc 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 6bdf5da84..74e608184 100644 --- a/src/comm/UDPLink.h +++ b/src/comm/UDPLink.h @@ -134,6 +134,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 07e495605..64ceb78f6 100644 --- a/src/ui/preferences/SerialSettings.qml +++ b/src/ui/preferences/SerialSettings.qml @@ -43,6 +43,24 @@ Item { height: ScreenTools.defaultFontPixelHeight / 2 width: parent.width } + QGCCheckBox { + text: "High Latency" + checked: false + visible: editConfig ? editConfig.highLatencyAllowed : false + onCheckedChanged: { + if(editConfig) { + editConfig.highLatency = checked + } + } + Component.onCompleted: { + if(editConfig) + checked = editConfig.highLatency + } + } + Item { + height: ScreenTools.defaultFontPixelHeight / 2 + width: parent.width + } Row { spacing: ScreenTools.defaultFontPixelWidth QGCLabel { diff --git a/src/ui/preferences/TcpSettings.qml b/src/ui/preferences/TcpSettings.qml index 182cf4d61..15fa893ba 100644 --- a/src/ui/preferences/TcpSettings.qml +++ b/src/ui/preferences/TcpSettings.qml @@ -46,6 +46,24 @@ Item { height: ScreenTools.defaultFontPixelHeight / 2 width: parent.width } + QGCCheckBox { + text: "High Latency" + checked: false + visible: editConfig ? editConfig.highLatencyAllowed : false + onCheckedChanged: { + if(editConfig) { + editConfig.highLatency = checked + } + } + Component.onCompleted: { + if(editConfig) + checked = editConfig.highLatency + } + } + Item { + height: ScreenTools.defaultFontPixelHeight / 2 + width: parent.width + } Row { spacing: ScreenTools.defaultFontPixelWidth QGCLabel { diff --git a/src/ui/preferences/UdpSettings.qml b/src/ui/preferences/UdpSettings.qml index 825b1bd79..ecb822b9f 100644 --- a/src/ui/preferences/UdpSettings.qml +++ b/src/ui/preferences/UdpSettings.qml @@ -52,6 +52,24 @@ Item { height: ScreenTools.defaultFontPixelHeight / 2 width: parent.width } + QGCCheckBox { + text: "High Latency" + checked: false + visible: editConfig ? editConfig.highLatencyAllowed : false + onCheckedChanged: { + if(editConfig) { + editConfig.highLatency = checked + } + } + Component.onCompleted: { + if(editConfig) + checked = editConfig.highLatency + } + } + Item { + height: ScreenTools.defaultFontPixelHeight / 2 + width: parent.width + } Row { spacing: ScreenTools.defaultFontPixelWidth QGCLabel { -- 2.22.0