QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
NTRIPConnectionStatus.qml
Go to the documentation of this file.
1pragma ComponentBehavior: Bound
2
3import QtQuick
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.Controls
8import QGroundControl.GPS
9
10/// NTRIP connection status and control: connection-state row with the
11/// connect/retry action, the disconnect-on-error action, and live stream details.
12SettingsGroupLayout {
13 id: root
14
15 property NTRIPManager ntripManager: QGroundControl.gpsManager.ntrip
16 property Fact enabledFact: root._ntripSettings.ntripServerConnectEnabled
17 /// Supplies the bytes queued to vehicle links.
18 property GPSCorrectionManager corrections: QGroundControl.gpsManager.corrections
19
20 readonly property NTRIPSettings _ntripSettings: QGroundControl.settingsManager.ntripSettings
21 readonly property bool _isActive: root.enabledFact.rawValue
22 readonly property bool _hasHost: root._ntripSettings.ntripServerHostAddress.rawValue !== ""
23 readonly property int _status: root.ntripManager.connectionStatus
24 readonly property NTRIPConnectionStats _stats: root.ntripManager.connectionStats
25 readonly property bool _connected: root._status === NTRIPManager.Connected
26 readonly property string _ggaSource: root.ntripManager.ggaSource
27 readonly property string _securityWarning: root.ntripManager.securityWarning
28 readonly property string _mountpoint: root._ntripSettings.ntripMountpoint.valueString
29
30 heading: qsTr("NTRIP Connection")
31 visible: root._ntripSettings.userVisible
32 showDividers: false
33
34 QGCPalette { id: qgcPal }
35
36 ConnectionStatusRow {
37 Layout.fillWidth: true
38 buttonObjectName: "ntripConnectButton"
39 statusColor: {
40 switch (root._status) {
41 case NTRIPManager.Connected: return qgcPal.colorGreen
42 case NTRIPManager.Connecting:
43 case NTRIPManager.Reconnecting: return qgcPal.colorOrange
44 case NTRIPManager.Error: return qgcPal.colorRed
45 default: return qgcPal.colorGrey
46 }
47 }
48 statusText: root.ntripManager.statusMessage || root.ntripManager.connectionStatusText
49 buttonText: {
50 switch (root._status) {
51 case NTRIPManager.Connecting: return qsTr("Connecting…")
52 case NTRIPManager.Reconnecting: return qsTr("Cancel reconnect")
53 case NTRIPManager.Connected: return qsTr("Disconnect")
54 case NTRIPManager.Error: return qsTr("Retry")
55 default: return qsTr("Connect")
56 }
57 }
58 buttonEnabled: root._status !== NTRIPManager.Connecting && (root._isActive || root._hasHost)
59 // Explicit targets keep repeated clicks idempotent while the manager debounces the setting change.
60 onClicked: {
61 switch (root._status) {
62 case NTRIPManager.Error:
63 root.ntripManager.retryNTRIP()
64 break
65 case NTRIPManager.Disconnected:
66 root.enabledFact.rawValue = true
67 break
68 default:
69 root.enabledFact.rawValue = false
70 break
71 }
72 }
73 }
74
75 QGCButton {
76 objectName: "ntripDisconnectButton"
77 text: qsTr("Disconnect")
78 visible: root._isActive && root._status === NTRIPManager.Error
79 onClicked: root.enabledFact.rawValue = false
80 }
81
82 GPSNoteLabel {
83 text: qsTr("Connected but no data received recently")
84 warning: true
85 visible: root._stats.dataStale && root._connected
86 }
87
88 LabelledLabel {
89 label: qsTr("Mountpoint")
90 labelText: root._mountpoint
91 labelTextFormat: Text.PlainText
92 visible: root._mountpoint !== "" && root._connected
93 }
94
95 LabelledLabel {
96 objectName: "ntripCorrectionAge"
97 label: qsTr("Last correction")
98 //: %1 is the time in seconds since the last correction was received
99 labelText: qsTr("%1 s ago").arg(root._stats.correctionAgeSec.toFixed(1))
100 visible: root._connected && root._stats.correctionAgeSec >= 0
101 }
102
103 LabelledLabel {
104 label: qsTr("Messages")
105 labelText: root._stats.messagesReceived
106 visible: root._connected && root._stats.messagesReceived > 0
107 }
108
109 ColumnLayout {
110 Layout.fillWidth: true
111 spacing: ScreenTools.defaultFontPixelHeight / 4
112 visible: root._connected && root._stats.messageCountsById.length > 0
113
114 QGCLabel {
115 text: qsTr("Message Types")
116 font.pointSize: ScreenTools.smallFontPointSize
117 color: qgcPal.colorGrey
118 }
119
120 RTCMMessageChips {
121 Layout.fillWidth: true
122 Layout.minimumWidth: 0
123 Layout.preferredWidth: 0
124 messageCounts: root._stats.messageCountsById
125 }
126 }
127
128 LabelledLabel {
129 label: qsTr("Data Received")
130 //: %1 is the total data size, %2 the data size received per second
131 labelText: qsTr("%1 (%2/s)").arg(QGroundControl.bigSizeToString(root._stats.bytesReceived))
132 .arg(QGroundControl.bigSizeToString(root._stats.dataRateBytesPerSec))
133 visible: root._connected && root._stats.bytesReceived > 0
134 }
135
136 GPSNoteLabel {
137 text: qsTr("Warning: Data usage: %1 — consider connection costs").arg(QGroundControl.bigSizeToString(root._stats.bytesReceived))
138 warning: true
139 visible: root._connected && root._stats.dataUsageHigh
140 }
141
142 LabelledLabel {
143 label: qsTr("Queued to vehicle links (any source)")
144 labelText: QGroundControl.bigSizeToString(root.corrections.vehicleBytesSubmitted)
145 visible: root._connected && root.corrections.vehicleBytesSubmitted > 0
146 }
147
148 LabelledLabel {
149 label: qsTr("GGA Source")
150 labelText: root._ggaSource
151 labelTextFormat: Text.PlainText
152 visible: root._connected && root._ggaSource !== ""
153 }
154
155 GPSNoteLabel {
156 objectName: "ntripNoGgaPosition"
157 text: qsTr("No position is available to send to the caster. Network (VRS) mountpoints send corrections only after receiving a position; check the GGA position source.")
158 warning: true
159 visible: root._connected && root._ggaSource === ""
160 && (root._stats.dataStale || root._stats.messagesReceived === 0)
161 }
162
163 GPSNoteLabel {
164 text: root._securityWarning
165 warning: true
166 visible: root._connected && root._securityWarning !== ""
167 }
168}