QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RemoteIDIndicator.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7//-------------------------------------------------------------------------
8//-- Remote ID Indicator
9Item {
10 id: control
11 width: remoteIDIcon.width * 1.1
12 anchors.top: parent.top
13 anchors.bottom: parent.bottom
14
15 property bool showIndicator: remoteIDManager.available
16
17 property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
18 property var remoteIDManager: activeVehicle ? activeVehicle.remoteIDManager : null
19
20 property bool gpsFlag: activeVehicle && remoteIDManager ? remoteIDManager.gcsGPSGood : false
21 property bool basicIDFlag: activeVehicle && remoteIDManager ? remoteIDManager.basicIDGood : false
22 property bool armFlag: activeVehicle && remoteIDManager ? remoteIDManager.armStatusGood : false
23 property bool commsFlag: activeVehicle && remoteIDManager ? remoteIDManager.commsGood : false
24 property bool emergencyDeclared: activeVehicle && remoteIDManager ? remoteIDManager.emergencyDeclared : false
25 property bool operatorIDFlag: activeVehicle && remoteIDManager ? remoteIDManager.operatorIDGood : false
26 property int remoteIDState: getRemoteIDState()
27
28 property int regionOperation: QGroundControl.settingsManager.remoteIDSettings.region.value
29
30 enum RIDState {
31 HEALTHY,
32 WARNING,
33 ERROR,
34 UNAVAILABLE
35 }
36
37 enum RegionOperation {
38 FAA,
39 EU
40 }
41
42 function getRidColor() {
43 switch (remoteIDState) {
44 case RemoteIDIndicator.RIDState.HEALTHY:
45 return qgcPal.colorGreen
46 break
47 case RemoteIDIndicator.RIDState.WARNING:
48 return qgcPal.colorYellow
49 break
50 case RemoteIDIndicator.RIDState.ERROR:
51 return qgcPal.colorRed
52 break
53 case RemoteIDIndicator.RIDState.UNAVAILABLE:
54 return qgcPal.colorGrey
55 break
56 default:
57 return qgcPal.colorGrey
58 }
59 }
60
61 function getRemoteIDState() {
62 if (!activeVehicle) {
63 return RemoteIDIndicator.RIDState.UNAVAILABLE
64 }
65 // We need to have comms and arm healthy to even be in any other state other than ERROR
66 if (!commsFlag || !armFlag || emergencyDeclared) {
67 return RemoteIDIndicator.RIDState.ERROR
68 }
69 if (!gpsFlag || !basicIDFlag) {
70 return RemoteIDIndicator.RIDState.WARNING
71 }
72 if (regionOperation == RemoteIDIndicator.RegionOperation.EU || QGroundControl.settingsManager.remoteIDSettings.sendOperatorID.value) {
73 if (!operatorIDFlag) {
74 return RemoteIDIndicator.RIDState.WARNING
75 }
76 }
77 return RemoteIDIndicator.RIDState.HEALTHY
78 }
79
80 function goToSettings() {
81 if (mainWindow.allowViewSwitch()) {
82 globals.commingFromRIDIndicator = true
83 mainWindow.showSettingsTool()
84 }
85 }
86
87 QGCPalette { id: qgcPal }
88
89 QGCColoredImage {
90 id: remoteIDIcon
91 width: height
92 anchors.top: parent.top
93 anchors.bottom: parent.bottom
94 source: "/qmlimages/RidIconMan.svg"
95 color: getRidColor()
96 fillMode: Image.PreserveAspectFit
97 sourceSize.height: height
98
99 QGCColoredImage {
100 width: height
101 anchors.fill: parent
102 sourceSize.height: height
103 source: "/qmlimages/RidIconText.svg"
104 fillMode: Image.PreserveAspectFit
105 color: qgcPal.text
106 }
107 }
108
109 MouseArea {
110 anchors.fill: parent
111 onClicked: mainWindow.showIndicatorDrawer(indicatorPage, control)
112 }
113
114 Component {
115 id: indicatorPage
116
117 RemoteIDIndicatorPage { }
118 }
119}