1/****************************************************************************
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
8 ****************************************************************************/
14import QGroundControl.Controls
16//-------------------------------------------------------------------------
17//-- GPS Resilience Indicator
21 anchors.top: parent.top
22 anchors.bottom: parent.bottom
23 visible: showIndicator
25 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
26 property var _gpsAggregate: _activeVehicle ? _activeVehicle.gpsAggregate : null
28 property var qgcPal: QGroundControl.globalPalette
30 property bool showIndicator: _activeVehicle && _gpsAggregate && (
31 (_gpsAggregate.authenticationState.value > 0 && _gpsAggregate.authenticationState.value < 255) ||
32 (_gpsAggregate.spoofingState.value > 0 && _gpsAggregate.spoofingState.value < 255) ||
33 (_gpsAggregate.jammingState.value > 0 && _gpsAggregate.jammingState.value < 255)
36 // Authentication Icon (Outer/Bottom Layer)
39 width: parent.height * 0.95
40 height: parent.height * 0.95
41 anchors.centerIn: parent
42 source: "/qmlimages/GpsAuthentication.svg"
43 fillMode: Image.PreserveAspectFit
44 sourceSize.height: height
46 visible: _gpsAggregate && _gpsAggregate.authenticationState.value > 0 && _gpsAggregate.authenticationState.value < 255
49 // Interference Icon (Inner/Top Layer)
52 width: parent.height * 0.55
53 height: parent.height * 0.55
54 anchors.centerIn: parent
55 source: "/qmlimages/GpsInterference.svg"
56 fillMode: Image.PreserveAspectFit
57 sourceSize.height: height
59 visible: _gpsAggregate && (Math.max(_gpsAggregate.spoofingState.value, _gpsAggregate.jammingState.value) > 0) && (Math.max(_gpsAggregate.spoofingState.value, _gpsAggregate.jammingState.value) < 255)
62 function _authColor() {
63 if (!_gpsAggregate) return qgcPal.colorGrey;
64 switch (_gpsAggregate.authenticationState.value) {
65 case 1: return qgcPal.colorYellow; // Initializing
66 case 2: return qgcPal.colorRed; // Error
67 case 3: return qgcPal.colorGreen; // OK
68 default: return qgcPal.colorGrey; // Unknown or Disabled
72 function _interfColor() {
73 if (!_gpsAggregate) return qgcPal.colorGrey;
74 let maxState = Math.max(_gpsAggregate.spoofingState.value, _gpsAggregate.jammingState.value);
76 case 1: return qgcPal.colorGreen; // Not spoofed/jammed
77 case 2: return qgcPal.colorOrange; // Mitigated
78 case 3: return qgcPal.colorRed; // Detected
79 default: return qgcPal.colorGrey; // Unknown
85 onClicked: mainWindow.showIndicatorDrawer(resiliencePopup, control)
91 showExpand: expandedComponent ? true : false
92 contentComponent: resilienceContent
99 spacing: ScreenTools.defaultFontPixelHeight / 2
101 // Unified GPS Resilience Status
102 SettingsGroupLayout {
103 heading: qsTr("GPS Resilience Status")
107 label: qsTr("GPS Jamming")
108 labelText: _gpsAggregate ? (_gpsAggregate.jammingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
109 visible: _gpsAggregate && _gpsAggregate.jammingState.value > 0 && _gpsAggregate.jammingState.value < 255
113 label: qsTr("GPS Spoofing")
114 labelText: _gpsAggregate ? (_gpsAggregate.spoofingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
115 visible: _gpsAggregate && _gpsAggregate.spoofingState.value > 0 && _gpsAggregate.spoofingState.value < 255
119 label: qsTr("GPS Authentication")
120 labelText: _gpsAggregate ? (_gpsAggregate.authenticationState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
121 visible: _gpsAggregate && _gpsAggregate.authenticationState.value > 0 && _gpsAggregate.authenticationState.value < 255
126 SettingsGroupLayout {
127 heading: qsTr("GPS 1 Details")
129 visible: _activeVehicle && _activeVehicle.gps && (
130 (_activeVehicle.gps.jammingState.value > 0 && _activeVehicle.gps.jammingState.value < 255) ||
131 (_activeVehicle.gps.spoofingState.value > 0 && _activeVehicle.gps.spoofingState.value < 255) ||
132 (_activeVehicle.gps.authenticationState.value > 0 && _activeVehicle.gps.authenticationState.value < 255)
136 label: qsTr("Jamming")
137 labelText: (_activeVehicle && _activeVehicle.gps) ? (_activeVehicle.gps.jammingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
138 visible: _activeVehicle.gps.jammingState.value > 0 && _activeVehicle.gps.jammingState.value < 255
141 label: qsTr("Spoofing")
142 labelText: (_activeVehicle && _activeVehicle.gps) ? (_activeVehicle.gps.spoofingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
143 visible: _activeVehicle.gps.spoofingState.value > 0 && _activeVehicle.gps.spoofingState.value < 255
146 label: qsTr("Authentication")
147 labelText: (_activeVehicle && _activeVehicle.gps) ? (_activeVehicle.gps.authenticationState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
148 visible: _activeVehicle.gps.authenticationState.value > 0 && _activeVehicle.gps.authenticationState.value < 255
153 SettingsGroupLayout {
154 heading: qsTr("GPS 2 Details")
156 visible: _activeVehicle && _activeVehicle.gps2 && (
157 (_activeVehicle.gps2.jammingState.value > 0 && _activeVehicle.gps2.jammingState.value < 255) ||
158 (_activeVehicle.gps2.spoofingState.value > 0 && _activeVehicle.gps2.spoofingState.value < 255) ||
159 (_activeVehicle.gps2.authenticationState.value > 0 && _activeVehicle.gps2.authenticationState.value < 255)
163 label: qsTr("Jamming")
164 labelText: (_activeVehicle && _activeVehicle.gps2) ? (_activeVehicle.gps2.jammingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
165 visible: _activeVehicle.gps2.jammingState.value > 0 && _activeVehicle.gps2.jammingState.value < 255
168 label: qsTr("Spoofing")
169 labelText: (_activeVehicle && _activeVehicle.gps2) ? (_activeVehicle.gps2.spoofingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
170 visible: _activeVehicle.gps2.spoofingState.value > 0 && _activeVehicle.gps2.spoofingState.value < 255
173 label: qsTr("Authentication")
174 labelText: (_activeVehicle && _activeVehicle.gps2) ? (_activeVehicle.gps2.authenticationState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
175 visible: _activeVehicle.gps2.authenticationState.value > 0 && _activeVehicle.gps2.authenticationState.value < 255