QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
EscIndicatorPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6import QGroundControl.FactControls
7
8ToolIndicatorPage {
9 id: control
10 showExpand: false
11
12 property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
13 property string na: qsTr("N/A", "No data to display")
14 property string valueNA: qsTr("–", "No data to display")
15
16 property var _escs: activeVehicle ? activeVehicle.escs : null
17 property int _onlineBitmask: _escs ? _escs.get(0).info.rawValue : 0
18
19 function _isMotorOnline(motorIndex) {
20 return (_onlineBitmask & (1 << motorIndex)) !== 0
21 }
22
23 function _isMotorHealthy(motorIndex) {
24 return _isMotorOnline(motorIndex) && _escs.get(motorIndex).failureFlags.rawValue === 0
25 }
26
27 contentComponent: Component {
28 ColumnLayout {
29 spacing: ScreenTools.defaultFontPixelHeight / 4
30
31 SettingsGroupLayout {
32 heading: qsTr("ESC Status Overview")
33
34 GridLayout {
35 Layout.fillWidth: true
36 columns: 1
37 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25
38 columnSpacing: ScreenTools.defaultFontPixelWidth * 2
39
40 LabelledLabel {
41 Layout.fillWidth: true
42 label: qsTr("Healthy Motors")
43 labelText: {
44 let healthyCount = 0
45 for (let i = 0; i < _escs.count; i++) {
46 if (_isMotorHealthy(i)) healthyCount++
47 }
48 return healthyCount + "/" + _escs.count
49 }
50 }
51
52 LabelledLabel {
53 Layout.fillWidth: true
54 label: qsTr("Total Errors")
55 labelText: {
56 let totalErrors = 0
57 for (let i = 0; i < _escs.count; i++) {
58 totalErrors += _escs.get(i).errorCount.rawValue
59 }
60 return totalErrors.toString()
61 }
62 }
63 }
64 }
65
66 Repeater {
67 model: _escs
68
69 SettingsGroupLayout {
70 heading: qsTr("Motor %1 %2").arg(object.id.rawValue + 1).arg( _isThisMotorHealthy ? "" : qsTr("- OFFLINE"))
71 headingPointSize: ScreenTools.defaultFontPointSize * ScreenTools.smallFontPointRatio
72 outerBorderColor: _isThisMotorHealthy ? QGroundControl.globalPalette.colorGreen : QGroundControl.globalPalette.colorRed
73
74 property bool _isThisMotorHealthy: _isMotorHealthy(index)
75
76 GridLayout {
77 columns: 2
78 columnSpacing: ScreenTools.defaultFontPixelWidth * 2.5
79 flow: GridLayout.LeftToRight
80
81 LabelledFactLabel {
82 label: qsTr("RPM")
83 fact: object.rpm
84 }
85
86 LabelledLabel {
87 label: qsTr("Temp")
88 labelText: (object.temperature !== 32767 ? object.temperature.valueString : na) + " " + object.temperature.units
89 }
90
91 LabelledFactLabel {
92 label: qsTr("Voltage")
93 fact: object.voltage
94 }
95
96 LabelledFactLabel {
97 label: qsTr("Current")
98 fact: object.current
99 }
100
101 LabelledFactLabel {
102 label: qsTr("Errors")
103 fact: object.errorCount
104 }
105 }
106 }
107 }
108 }
109 }
110}