QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SafetyComponentSummary.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.FactControls
7import QGroundControl.Controls
8
9Item {
10 implicitWidth: mainLayout.implicitWidth
11 implicitHeight: mainLayout.implicitHeight
12 width: parent.width // grows when Loader is wider than implicitWidth
13
14 FactPanelController { id: controller; }
15
16 property Fact _returnAltFact: controller.getParameterFact(-1, "RTL_RETURN_ALT")
17 property Fact _descendAltFact: controller.getParameterFact(-1, "RTL_DESCEND_ALT")
18 property Fact _commRCLossFact: controller.getParameterFact(-1, "COM_RC_LOSS_T")
19 property Fact _lowBattAction: controller.getParameterFact(-1, "COM_LOW_BAT_ACT")
20 property Fact _rcLossAction: controller.getParameterFact(-1, "NAV_RCL_ACT")
21 property Fact _dataLossAction: controller.getParameterFact(-1, "NAV_DLL_ACT")
22 property Fact _rtlLandDelayFact: controller.getParameterFact(-1, "RTL_LAND_DELAY")
23 property int _rtlLandDelayValue: _rtlLandDelayFact ? _rtlLandDelayFact.value : 0
24 property var _lowBattParts: _lowBattAction ? _lowBattAction.enumStringValue.split(",") : []
25
26 function _cleanBehavior(str) {
27 if (!str) {
28 return ""
29 }
30 let cleaned = str.replace(/at\s+(critical|emergency)\s+level/gi, "").trim()
31 if (cleaned === "") {
32 return str.trim()
33 }
34 return cleaned.charAt(0).toUpperCase() + cleaned.slice(1)
35 }
36
37 ColumnLayout {
38 id: mainLayout
39 width: parent.width
40 spacing: 0
41
42 VehicleSummaryRow {
43 labelText: qsTr("Low Battery Failsafe")
44 valueText: _lowBattParts.length > 1 ? "" : (_lowBattAction ? _lowBattAction.enumStringValue : "")
45 }
46
47 VehicleSummaryRow {
48 visible: _lowBattParts.length > 1
49 labelText: " " + qsTr("Critical Level")
50 valueText: _lowBattParts.length > 0 ? _cleanBehavior(_lowBattParts[0]) : ""
51 }
52
53 VehicleSummaryRow {
54 visible: _lowBattParts.length > 1
55 labelText: " " + qsTr("Emergency Level")
56 valueText: _lowBattParts.length > 1 ? _cleanBehavior(_lowBattParts[1]) : ""
57 }
58
59 VehicleSummaryRow {
60 labelText: qsTr("RC/Joystick Loss Failsafe")
61 valueText: _rcLossAction ? _rcLossAction.enumStringValue : ""
62 }
63
64 VehicleSummaryRow {
65 labelText: qsTr("RC/Joystick Loss Timeout")
66 valueText: _commRCLossFact ? _commRCLossFact.valueString + " " + _commRCLossFact.units : ""
67 }
68
69 VehicleSummaryRow {
70 labelText: qsTr("Data Link Loss Failsafe")
71 valueText: _dataLossAction ? _dataLossAction.enumStringValue : ""
72 }
73
74 VehicleSummaryRow {
75 labelText: qsTr("RTL Climb To")
76 valueText: _returnAltFact ? _returnAltFact.valueString + " " + _returnAltFact.units : ""
77 }
78
79 VehicleSummaryRow {
80 labelText: qsTr("RTL, Then")
81 valueText: _rtlLandDelayValue === 0 ?
82 qsTr("Land immediately") :
83 (_rtlLandDelayValue < 0 ?
84 qsTr("Loiter and do not land") :
85 qsTr("Loiter and land after specified time"))
86
87 }
88
89 VehicleSummaryRow {
90 labelText: qsTr("Loiter Alt")
91 valueText: _descendAltFact ? _descendAltFact.valueString + " " + _descendAltFact.units : ""
92 visible: _descendAltFact && _rtlLandDelayValue !== 0
93 }
94
95 VehicleSummaryRow {
96 labelText: qsTr("Land Delay")
97 valueText: _rtlLandDelayFact ? _rtlLandDelayValue + " " + _rtlLandDelayFact.units : ""
98 visible: _rtlLandDelayValue > 0
99 }
100 }
101}