QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMLightsComponentSummary.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.FactControls
6import QGroundControl.Controls
7
8Item {
9 anchors.fill: parent
10
11 FactPanelController { id: controller; }
12
13 property Fact _rc5Function: controller.getParameterFact(-1, "SERVO5_FUNCTION")
14 property Fact _rc6Function: controller.getParameterFact(-1, "SERVO6_FUNCTION")
15 property Fact _rc7Function: controller.getParameterFact(-1, "SERVO7_FUNCTION")
16 property Fact _rc8Function: controller.getParameterFact(-1, "SERVO8_FUNCTION")
17 property Fact _rc9Function: controller.getParameterFact(-1, "SERVO9_FUNCTION")
18 property Fact _rc10Function: controller.getParameterFact(-1, "SERVO10_FUNCTION")
19 property Fact _rc11Function: controller.getParameterFact(-1, "SERVO11_FUNCTION")
20 property Fact _rc12Function: controller.getParameterFact(-1, "SERVO12_FUNCTION")
21 property Fact _rc13Function: controller.getParameterFact(-1, "SERVO13_FUNCTION")
22 property Fact _rc14Function: controller.getParameterFact(-1, "SERVO14_FUNCTION")
23
24 readonly property int _rcFunctionRCIN9: 59
25 readonly property int _rcFunctionRCIN10: 60
26 readonly property int _firstLightsOutChannel: 5
27 readonly property int _lastLightsOutChannel: 14
28
29 Component.onCompleted: {
30 calcLightOutValues()
31 }
32
33 /// Light output channels are stored in SERVO#_FUNCTION parameters. We need to loop through those
34 /// to find them and setup the ui accordindly.
35 function calcLightOutValues() {
36 lightsLoader.lights1OutIndex = 0
37 lightsLoader.lights2OutIndex = 0
38 for (var channel=_firstLightsOutChannel; channel<=_lastLightsOutChannel; channel++) {
39 var functionFact = controller.getParameterFact(-1, "SERVO" + channel + "_FUNCTION")
40 if (functionFact.value == _rcFunctionRCIN9) {
41 lightsLoader.lights1OutIndex = channel - 4
42 } else if (functionFact.value == _rcFunctionRCIN10) {
43 lightsLoader.lights2OutIndex = channel - 4
44 }
45 }
46 }
47
48 // Whenever any SERVO#_FUNCTION parameters chagnes we need to go looking for light output channels again
49 Connections { target: _rc5Function; onValueChanged: calcLightOutValues() }
50 Connections { target: _rc6Function; onValueChanged: calcLightOutValues() }
51 Connections { target: _rc7Function; onValueChanged: calcLightOutValues() }
52 Connections { target: _rc8Function; onValueChanged: calcLightOutValues() }
53 Connections { target: _rc9Function; onValueChanged: calcLightOutValues() }
54 Connections { target: _rc10Function; onValueChanged: calcLightOutValues() }
55 Connections { target: _rc11Function; onValueChanged: calcLightOutValues() }
56 Connections { target: _rc12Function; onValueChanged: calcLightOutValues() }
57 Connections { target: _rc13Function; onValueChanged: calcLightOutValues() }
58 Connections { target: _rc14Function; onValueChanged: calcLightOutValues() }
59
60 ListModel {
61 id: lightsOutModel
62 ListElement { text: qsTr("Disabled"); value: 0 }
63 ListElement { text: qsTr("Channel 5"); value: 5 }
64 ListElement { text: qsTr("Channel 6"); value: 6 }
65 ListElement { text: qsTr("Channel 7"); value: 7 }
66 ListElement { text: qsTr("Channel 8"); value: 8 }
67 ListElement { text: qsTr("Channel 9"); value: 9 }
68 ListElement { text: qsTr("Channel 10"); value: 10 }
69 ListElement { text: qsTr("Channel 11"); value: 11 }
70 ListElement { text: qsTr("Channel 12"); value: 12 }
71 ListElement { text: qsTr("Channel 13"); value: 13 }
72 ListElement { text: qsTr("Channel 14"); value: 14 }
73 }
74
75 Loader {
76 id: lightsLoader
77
78 property int lights1OutIndex: 0
79 property int lights2OutIndex: 0
80 property int lights1Function: _rcFunctionRCIN9
81 property int lights2Function: _rcFunctionRCIN10
82 }
83
84 Column {
85 anchors.fill: parent
86
87 VehicleSummaryRow {
88 labelText: qsTr("Lights Output 1")
89 valueText: lightsOutModel.get(lightsLoader.lights1OutIndex).text
90 }
91
92 VehicleSummaryRow {
93 labelText: qsTr("Lights Output 2")
94 valueText: lightsOutModel.get(lightsLoader.lights2OutIndex).text
95 }
96 }
97}