QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VibrationPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.FactControls
8import QGroundControl.Controls
9
10AnalyzePage {
11 id: vibrationPage
12 pageComponent: pageComponent
13 pageDescription: qsTr("Analyze vibration associated with your vehicle.")
14 allowPopout: true
15
16 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
17 property bool _available: !isNaN(_activeVehicle.vibration.xAxis.rawValue)
18 property real _margins: ScreenTools.defaultFontPixelWidth / 2
19 property real _barWidth: ScreenTools.defaultFontPixelWidth * 7
20 property real _barHeight: ScreenTools.defaultFontPixelHeight * 10
21 property real _xValue: _activeVehicle.vibration.xAxis.rawValue
22 property real _yValue: _activeVehicle.vibration.yAxis.rawValue
23 property real _zValue: _activeVehicle.vibration.zAxis.rawValue
24
25 readonly property real _barMinimum: 0.0
26 readonly property real _barMaximum: 90.0
27 readonly property real _barBadValue: 60.0
28 readonly property real _barMidValue: 30.0
29
30 QGCPalette { id:qgcPal; colorGroupEnabled: true }
31
32 Component {
33 id: pageComponent
34
35 Item {
36 width: childrenRect.width
37 height: childrenRect.height
38
39 RowLayout {
40 id: barRow
41 spacing: ScreenTools.defaultFontPixelWidth * 2
42
43 ColumnLayout {
44 Rectangle {
45 id: xBar
46 height: _barHeight
47 width: _barWidth
48 Layout.alignment: Qt.AlignHCenter
49 color: "transparent"
50 border.width: 1
51 border.color: qgcPal.text
52
53 Rectangle {
54 anchors.bottom: parent.bottom
55 width: parent.width
56 height: parent.height * (Math.min(_barMaximum, _xValue) / (_barMaximum - _barMinimum))
57 color: qgcPal.text
58 }
59
60 // Max vibe indication line at 60
61 Rectangle {
62 anchors.topMargin: parent.height * (1.0 - ((_barBadValue - _barMinimum) / (_barMaximum - _barMinimum)))
63 anchors.top: parent.top
64 anchors.left: parent.left
65 anchors.right: parent.right
66 width: parent.width
67 height: 1
68 color: "red"
69 }
70
71 // Mid vibe indication line at 30
72 Rectangle {
73 anchors.topMargin: parent.height * (1.0 - ((_barMidValue - _barMinimum) / (_barMaximum - _barMinimum)))
74 anchors.top: parent.top
75 anchors.left: parent.left
76 anchors.right: parent.right
77 width: parent.width
78 height: 1
79 color: "red"
80 }
81 }
82
83 QGCLabel {
84 Layout.alignment: Qt.AlignHCenter
85 text: qsTr("X (%1)").arg(_xValue.toFixed(0))
86 }
87 }
88
89 ColumnLayout {
90 Rectangle {
91 height: _barHeight
92 width: _barWidth
93 Layout.alignment: Qt.AlignHCenter
94 color: "transparent"
95 border.width: 1
96 border.color: qgcPal.text
97
98 Rectangle {
99 anchors.bottom: parent.bottom
100 width: parent.width
101 height: parent.height * (Math.min(_barMaximum, _yValue) / (_barMaximum - _barMinimum))
102 color: qgcPal.text
103 }
104
105 // Max vibe indication line at 60
106 Rectangle {
107 anchors.topMargin: parent.height * (1.0 - ((_barBadValue - _barMinimum) / (_barMaximum - _barMinimum)))
108 anchors.top: parent.top
109 anchors.left: parent.left
110 anchors.right: parent.right
111 width: parent.width
112 height: 1
113 color: "red"
114 }
115
116 // Mid vibe indication line at 30
117 Rectangle {
118 anchors.topMargin: parent.height * (1.0 - ((_barMidValue - _barMinimum) / (_barMaximum - _barMinimum)))
119 anchors.top: parent.top
120 anchors.left: parent.left
121 anchors.right: parent.right
122 width: parent.width
123 height: 1
124 color: "red"
125 }
126 }
127
128 QGCLabel {
129 Layout.alignment: Qt.AlignHCenter
130 text: qsTr("Y (%1)").arg(_yValue.toFixed(0))
131 }
132 }
133
134 ColumnLayout {
135 Rectangle {
136 height: _barHeight
137 width: _barWidth
138 Layout.alignment: Qt.AlignHCenter
139 color: "transparent"
140 border.width: 1
141 border.color: qgcPal.text
142
143 Rectangle {
144 anchors.bottom: parent.bottom
145 width: parent.width
146 height: parent.height * (Math.min(_barMaximum, _zValue) / (_barMaximum - _barMinimum))
147 color: qgcPal.text
148 }
149
150 // Max vibe indication line at 60
151 Rectangle {
152 anchors.topMargin: parent.height * (1.0 - ((_barBadValue - _barMinimum) / (_barMaximum - _barMinimum)))
153 anchors.top: parent.top
154 anchors.left: parent.left
155 anchors.right: parent.right
156 width: parent.width
157 height: 1
158 color: "red"
159 }
160
161 // Mid vibe indication line at 30
162 Rectangle {
163 anchors.topMargin: parent.height * (1.0 - ((_barMidValue - _barMinimum) / (_barMaximum - _barMinimum)))
164 anchors.top: parent.top
165 anchors.left: parent.left
166 anchors.right: parent.right
167 width: parent.width
168 height: 1
169 color: "red"
170 }
171 }
172
173 QGCLabel {
174 Layout.alignment: Qt.AlignHCenter
175 text: qsTr("Z (%1)").arg(_zValue.toFixed(0))
176 }
177 }
178 }
179
180 Column {
181 anchors.margins: ScreenTools.defaultFontPixelWidth
182 anchors.left: barRow.right
183
184 QGCLabel {
185 text: qsTr("Clip count")
186 }
187
188 QGCLabel {
189 text: qsTr("Accel 1: %1").arg(_activeVehicle.vibration.clipCount1.rawValue)
190 }
191
192 QGCLabel {
193 text: qsTr("Accel 2: %1").arg(_activeVehicle.vibration.clipCount2.rawValue)
194 }
195
196 QGCLabel {
197 text: qsTr("Accel 3: %1").arg(_activeVehicle.vibration.clipCount3.rawValue)
198 }
199 }
200
201 Rectangle {
202 anchors.fill: parent
203 color: qgcPal.window
204 opacity: 0.75
205 visible: !_available
206
207 QGCLabel {
208 anchors.fill: parent
209 horizontalAlignment: Text.AlignHCenter
210 verticalAlignment: Text.AlignVCenter
211 text: qsTr("Not Available")
212 }
213 }
214 }
215 }
216}