5import QGroundControl.Controls
9 objectName: "toolbar_escIndicator"
10 anchors.top: parent.top
11 anchors.bottom: parent.bottom
12 width: escIndicatorRow.width
14 property bool showIndicator: _escs.count > 0
16 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
17 property var _escs: _activeVehicle ? _activeVehicle.escs : null
19 // ESC status properties derived from vehicle data
20 property int _motorCount: _escs && _escs.count > 0 ? _escs.get(0).count.rawValue : 0
21 property int _onlineBitmask: _escs && _escs.count > 0? _escs.get(0).info.rawValue : 0
23 property int _onlineMotorCount: _getOnlineMotorCount()
24 property bool _escHealthy: _getEscHealthStatus()
26 function _getOnlineMotorCount() {
27 if (_motorCount === 0) return 0;
30 let mask = _onlineBitmask;
32 // Count all set bits in the bitmask
41 function _getEscHealthStatus() {
42 // Health is good if all expected motors are online and have no failure flags
43 if (_onlineMotorCount !== _motorCount) return false
45 // Check failure flags for each motor (4 per group)
46 for (let index = 0; index < 4; index++) {
47 if ((_onlineBitmask & (1 << index)) !== 0) { // Motor is online
48 if (_escs.get(index).failureFlags > 0) { // Any failure flag set means unhealthy
57 function getEscStatusColor() {
58 return _escHealthy ? qgcPal.colorGreen : qgcPal.colorRed
61 QGCPalette { id: qgcPal }
65 anchors.top: parent.top
66 anchors.bottom: parent.bottom
67 spacing: ScreenTools.defaultFontPixelWidth / 2
72 anchors.top: parent.top
73 anchors.bottom: parent.bottom
74 source: "/qmlimages/EscIndicator.svg"
75 fillMode: Image.PreserveAspectFit
76 sourceSize.height: height
82 anchors.verticalCenter: parent.verticalCenter
86 anchors.horizontalCenter: parent.horizontalCenter
88 text: _onlineMotorCount.toString()
89 font.pointSize: ScreenTools.smallFontPointSize
93 color: getEscStatusColor()
94 text: _escHealthy ? qsTr("OK") : qsTr("ERR")
95 font.pointSize: ScreenTools.smallFontPointSize
102 onClicked: mainWindow.showIndicatorDrawer(escIndicatorPage, control)