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