QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
NTRIPConnectionStatus.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7ColumnLayout {
8 id: root
9
10 property var rtcmMavlink: null
11
12 property var _ntripMgr: QGroundControl.ntripManager
13 readonly property int _status: root._ntripMgr ? root._ntripMgr.connectionStatus : NTRIPManager.Disconnected
14 readonly property var _stats: root._ntripMgr ? root._ntripMgr.connectionStats : null
15 readonly property bool _connected: root._status === NTRIPManager.Connected
16 property bool _dataStale: root._stats ? root._stats.dataStale : false
17 property string _valueNA: qsTr("-.--")
18
19 readonly property real _dataWarningLimitBytes: 50 * 1024 * 1024 // 50 MB
20
21 function _formatDataSize(bytes) {
22 if (bytes < 1024) return bytes + " B"
23 if (bytes < 1048576) return (bytes / 1024).toFixed(1) + " KB"
24 return (bytes / 1048576).toFixed(1) + " MB"
25 }
26
27 function _formatDataRate(bytesPerSec) {
28 if (bytesPerSec < 1024) return bytesPerSec.toFixed(0) + " B/s"
29 return (bytesPerSec / 1024).toFixed(1) + " KB/s"
30 }
31
32 spacing: ScreenTools.defaultFontPixelHeight / 2
33 visible: root._status !== NTRIPManager.Disconnected
34
35 QGCPalette { id: qgcPal }
36
37 QGCLabel {
38 text: qsTr("Connected but no data received recently")
39 color: qgcPal.colorOrange
40 wrapMode: Text.WordWrap
41 font.pointSize: ScreenTools.smallFontPointSize
42 visible: root._dataStale && root._connected
43 Layout.fillWidth: true
44 }
45
46 LabelledLabel {
47 label: qsTr("Mountpoint")
48 labelText: QGroundControl.settingsManager.ntripSettings.ntripMountpoint.valueString
49 visible: QGroundControl.settingsManager.ntripSettings.ntripMountpoint.valueString !== ""
50 && root._connected
51 }
52
53 LabelledLabel {
54 label: qsTr("Messages")
55 labelText: root._stats ? root._stats.messagesReceived : ""
56 visible: root._connected
57 && root._stats && root._stats.messagesReceived > 0
58 }
59
60 ColumnLayout {
61 Layout.fillWidth: true
62 spacing: ScreenTools.defaultFontPixelHeight / 4
63 visible: root._connected
64 && root._stats && root._stats.messageCountsById.length > 0
65
66 QGCLabel {
67 text: qsTr("Message Types")
68 font.pointSize: ScreenTools.smallFontPointSize
69 color: qgcPal.colorGrey
70 }
71
72 Flow {
73 Layout.fillWidth: true
74 spacing: ScreenTools.defaultFontPixelWidth / 2
75
76 Repeater {
77 model: root._stats ? root._stats.messageCountsById : []
78
79 delegate: Rectangle {
80 id: chip
81 required property var modelData
82
83 readonly property string _idLabel: chip.modelData[0] === 0
84 ? qsTr("unknown")
85 : chip.modelData[0].toString()
86
87 implicitWidth: chipLabel.implicitWidth + ScreenTools.defaultFontPixelWidth * 1.2
88 implicitHeight: chipLabel.implicitHeight + ScreenTools.defaultFontPixelHeight * 0.3
89 radius: implicitHeight / 2
90 color: qgcPal.windowShade
91 border.color: qgcPal.groupBorder
92 border.width: 1
93
94 QGCLabel {
95 id: chipLabel
96 anchors.centerIn: parent
97 text: qsTr("%1 × %2").arg(chip._idLabel).arg(chip.modelData[1])
98 font.pointSize: ScreenTools.smallFontPointSize
99 }
100 }
101 }
102 }
103 }
104
105 LabelledLabel {
106 label: qsTr("Data Received")
107 labelText: root._stats ? (root._formatDataSize(root._stats.bytesReceived) + " ("
108 + root._formatDataRate(root._stats.dataRateBytesPerSec) + ")") : root._valueNA
109 visible: root._connected
110 && root._stats && root._stats.bytesReceived > 0
111 }
112
113 QGCLabel {
114 text: qsTr("Warning: Data usage: %1 — consider connection costs").arg(root._stats ? root._formatDataSize(root._stats.bytesReceived) : "")
115 wrapMode: Text.WordWrap
116 color: qgcPal.warningText
117 font.pointSize: ScreenTools.smallFontPointSize
118 visible: root._connected
119 && root._stats && root._stats.bytesReceived > root._dataWarningLimitBytes
120 Layout.fillWidth: true
121 }
122
123 LabelledLabel {
124 label: qsTr("To Vehicle")
125 labelText: root.rtcmMavlink ? (root._formatDataSize(root.rtcmMavlink.totalBytesSent) + " ("
126 + root.rtcmMavlink.bandwidthKBps.toFixed(1) + " KB/s)") : root._valueNA
127 visible: root._connected
128 && root.rtcmMavlink && root.rtcmMavlink.totalBytesSent > 0
129 }
130
131 LabelledLabel {
132 label: qsTr("GGA Source")
133 labelText: (root._ntripMgr ? root._ntripMgr.ggaSource : "")
134 visible: root._connected
135 && (root._ntripMgr ? root._ntripMgr.ggaSource : "")
136 }
137
138 QGCLabel {
139 text: root._ntripMgr ? root._ntripMgr.securityWarning : ""
140 wrapMode: Text.WordWrap
141 color: qgcPal.colorOrange
142 font.pointSize: ScreenTools.smallFontPointSize
143 visible: root._connected
144 && root._ntripMgr
145 && root._ntripMgr.securityWarning !== ""
146 Layout.fillWidth: true
147 }
148
149 QGCLabel {
150 text: (root._ntripMgr ? root._ntripMgr.statusMessage : "")
151 wrapMode: Text.WordWrap
152 color: qgcPal.colorRed
153 font.pointSize: ScreenTools.smallFontPointSize
154 visible: root._status === NTRIPManager.Error
155 && (root._ntripMgr ? root._ntripMgr.statusMessage : "") !== ""
156 Layout.fillWidth: true
157 }
158}