APMSafetyComponentSub.qml 18.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/


11 12
import QtQuick              2.3
import QtQuick.Controls     1.2
13 14
import QtGraphicalEffects   1.0

Jacob Walser's avatar
Jacob Walser committed
15
import QGroundControl               1.0
16 17 18 19 20 21
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0

22 23 24
SetupPage {
    id:                 safetyPage
    pageComponent:      safetyPageComponent
25

26 27
    Component {
        id: safetyPageComponent
28

29 30 31 32
        Flow {
            id:         flowLayout
            width:      availableWidth
            spacing:    _margins
33

34
            FactPanelController { id: controller; factPanel: safetyPage.viewPanel }
35

36
            QGCPalette { id: ggcPal; colorGroupEnabled: true }
37

Jacob Walser's avatar
Jacob Walser committed
38
            property var _activeVehicle:     QGroundControl.multiVehicleManager.activeVehicle
39
            property bool _firmware34:       _activeVehicle.versionCompare(3, 5, 0) < 0
Jacob Walser's avatar
Jacob Walser committed
40 41

            // Enable/Action parameters
42
            property Fact _failsafeBatteryEnable:     controller.getParameterFact(-1, "r.BATT_FS_LOW_ACT")
Jacob Walser's avatar
Jacob Walser committed
43 44 45
            property Fact _failsafeEKFEnable:         controller.getParameterFact(-1, "FS_EKF_ACTION")
            property Fact _failsafeGCSEnable:         controller.getParameterFact(-1, "FS_GCS_ENABLE")
            property Fact _failsafeLeakEnable:        controller.getParameterFact(-1, "FS_LEAK_ENABLE")
46
            property Fact _failsafePilotEnable:       _firmware34 ? null : controller.getParameterFact(-1, "FS_PILOT_INPUT")
Jacob Walser's avatar
Jacob Walser committed
47 48 49 50 51 52
            property Fact _failsafePressureEnable:    controller.getParameterFact(-1, "FS_PRESS_ENABLE")
            property Fact _failsafeTemperatureEnable: controller.getParameterFact(-1, "FS_TEMP_ENABLE")

            // Threshold parameters
            property Fact _failsafePressureThreshold:    controller.getParameterFact(-1, "FS_PRESS_MAX")
            property Fact _failsafeTemperatureThreshold: controller.getParameterFact(-1, "FS_TEMP_MAX")
53
            property Fact _failsafePilotTimeout:         _firmware34 ? null : controller.getParameterFact(-1, "FS_PILOT_TIMEOUT")
Jacob Walser's avatar
Jacob Walser committed
54 55 56
            property Fact _failsafeLeakPin:              controller.getParameterFact(-1, "LEAK1_PIN")
            property Fact _failsafeLeakLogic:            controller.getParameterFact(-1, "LEAK1_LOGIC")
            property Fact _failsafeEKFThreshold:         controller.getParameterFact(-1, "FS_EKF_THRESH")
57 58
            property Fact _failsafeBatteryVoltage:       controller.getParameterFact(-1, "r.BATT_LOW_VOLT")
            property Fact _failsafeBatteryCapacity:      controller.getParameterFact(-1, "r.BATT_LOW_MAH")
59

60
            property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK")
61

62 63
            property real _margins:     ScreenTools.defaultFontPixelHeight
            property bool _showIcon:    !ScreenTools.isTinyScreen
64

65
            ExclusiveGroup { id: fenceActionRadioGroup }
66

67 68
            Column {
                spacing: _margins / 2
69

70 71 72 73 74 75 76
                QGCLabel {
                    id:         failsafeLabel
                    text:       qsTr("Failsafe Actions")
                    font.family: ScreenTools.demiboldFontFamily
                }

                Rectangle {
Jacob Walser's avatar
Jacob Walser committed
77 78 79
                    id:     failsafeRectangle
                    width:  flowLayout.width
                    height: childrenRect.height + _margins
80
                    color:  ggcPal.windowShade
81

Jacob Walser's avatar
Jacob Walser committed
82 83 84 85 86 87 88 89 90 91 92 93 94
                    Column {
                        anchors.top: failsafeRectangle.top
                        anchors.left: failsafeRectangle.left
                        anchors.margins: _margins / 2
                        property var _labelWidth: ScreenTools.defaultFontPixelWidth * 15
                        property var _editWidth: ScreenTools.defaultFontPixelWidth * 20
                        id:     failsafeSettings
                        spacing: ScreenTools.defaultFontPixelHeight

                        Row {
                            spacing: _margins / 2

                            QGCLabel {
95 96 97 98 99
                                id:                     gcsEnableLabel
                                width:                  failsafeSettings._labelWidth
                                anchors.verticalCenter: gcsEnableCombo.verticalCenter
                                text:                   qsTr("GCS Heartbeat:")
                                wrapMode:               Text.Wrap
Jacob Walser's avatar
Jacob Walser committed
100
                            }
101

Jacob Walser's avatar
Jacob Walser committed
102 103 104 105 106 107 108
                            FactComboBox {
                                id:                 gcsEnableCombo
                                width:              failsafeSettings._editWidth
                                fact:               _failsafeGCSEnable
                                indexModel:         false
                            }
                        }
109

Jacob Walser's avatar
Jacob Walser committed
110 111
                        Row {
                            spacing: _margins / 2
112

Jacob Walser's avatar
Jacob Walser committed
113
                            QGCLabel {
114 115 116 117 118
                                id:                     leakEnableLabel
                                width:                  failsafeSettings._labelWidth
                                anchors.verticalCenter: leakEnableCombo.verticalCenter
                                text:                   qsTr("Leak:")
                                wrapMode:               Text.Wrap
Jacob Walser's avatar
Jacob Walser committed
119
                            }
120

Jacob Walser's avatar
Jacob Walser committed
121 122 123 124 125 126
                            FactComboBox {
                                id:                 leakEnableCombo
                                width:              failsafeSettings._editWidth
                                fact:               _failsafeLeakEnable
                                indexModel:         false
                            }
127

Jacob Walser's avatar
Jacob Walser committed
128
                            QGCLabel {
129
                                text:               qsTr( "Detector Pin:")
Jacob Walser's avatar
Jacob Walser committed
130 131 132 133
                                width:              failsafeSettings._labelWidth
                                visible:            leakEnableCombo.currentIndex != 0
                                anchors.baseline:   leakEnableCombo.baseline
                            }
134

Jacob Walser's avatar
Jacob Walser committed
135 136 137 138 139
                            FactComboBox {
                                width:              failsafeSettings._editWidth
                                visible:            leakEnableCombo.currentIndex != 0
                                anchors.baseline:   leakEnableCombo.baseline
                                fact:               _failsafeLeakPin
140
                                indexModel:         false
Jacob Walser's avatar
Jacob Walser committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154
                            }

                            QGCLabel {
                                text: "Logic when Dry:"
                                width:              failsafeSettings._labelWidth
                                visible:            leakEnableCombo.currentIndex != 0
                                anchors.baseline:   leakEnableCombo.baseline
                            }

                            FactComboBox {
                                width:              failsafeSettings._editWidth
                                visible:            leakEnableCombo.currentIndex != 0
                                anchors.baseline:   leakEnableCombo.baseline
                                fact:               _failsafeLeakLogic
155
                                indexModel:         false
156 157 158
                            }
                        }

Jacob Walser's avatar
Jacob Walser committed
159 160 161
                        Row {
                            spacing: _margins / 2
                            visible: !_firmware34
162

Jacob Walser's avatar
Jacob Walser committed
163
                            QGCLabel {
164 165 166 167 168
                                id:                     batteryEnableLabel
                                width:                  failsafeSettings._labelWidth
                                anchors.verticalCenter: batteryEnableCombo.verticalCenter
                                text:                   qsTr("Battery:")
                                wrapMode:               Text.Wrap
Jacob Walser's avatar
Jacob Walser committed
169
                            }
170

Jacob Walser's avatar
Jacob Walser committed
171 172 173 174 175 176
                            FactComboBox {
                                id:                 batteryEnableCombo
                                width:              failsafeSettings._editWidth
                                fact:               _failsafeBatteryEnable
                                indexModel:         false
                            }
177

Jacob Walser's avatar
Jacob Walser committed
178 179 180 181 182 183
                            QGCLabel {
                                text: "Voltage:"
                                width:              failsafeSettings._labelWidth
                                visible:            batteryEnableCombo.currentIndex != 0
                                anchors.baseline:   batteryEnableCombo.baseline
                            }
184

Jacob Walser's avatar
Jacob Walser committed
185 186 187 188 189 190
                            FactTextField {
                                width:              failsafeSettings._editWidth
                                visible:            batteryEnableCombo.currentIndex != 0
                                anchors.baseline:   batteryEnableCombo.baseline
                                fact:               _failsafeBatteryVoltage
                            }
191

Jacob Walser's avatar
Jacob Walser committed
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
                            QGCLabel {
                                text: "Remaining Capacity:"
                                width:              failsafeSettings._labelWidth
                                visible:            batteryEnableCombo.currentIndex != 0
                                anchors.baseline:   batteryEnableCombo.baseline
                            }

                            FactTextField {
                                width:              failsafeSettings._editWidth
                                visible:            batteryEnableCombo.currentIndex != 0
                                anchors.baseline:   batteryEnableCombo.baseline
                                fact:               _failsafeBatteryCapacity
                            }
                        }

                        Row {
                            spacing: _margins / 2
                            visible: !_firmware34

                            QGCLabel {
212 213 214 215 216
                                id:                     ekfEnableLabel
                                width:                  failsafeSettings._labelWidth
                                anchors.verticalCenter: ekfEnableCombo.verticalCenter
                                text:                   qsTr("EKF:")
                                wrapMode:               Text.Wrap
Jacob Walser's avatar
Jacob Walser committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
                            }

                            FactComboBox {
                                id:                 ekfEnableCombo
                                width:              failsafeSettings._editWidth
                                fact:               _failsafeEKFEnable
                                indexModel:         false
                            }

                            QGCLabel {
                                text: "Threshold:"
                                width:              failsafeSettings._labelWidth
                                visible:            ekfEnableCombo.currentIndex != 0
                                anchors.baseline:   ekfEnableCombo.baseline
                            }

                            FactTextField {
                                width:              failsafeSettings._editWidth
                                visible:            ekfEnableCombo.currentIndex != 0
                                anchors.baseline:   ekfEnableCombo.baseline
                                fact:               _failsafeEKFThreshold
                            }
                        }

                        Row {
                            spacing: _margins / 2
                            visible: !_firmware34

                            QGCLabel {
246 247 248 249 250
                                id:                     pilotEnableLabel
                                width:                  failsafeSettings._labelWidth
                                anchors.verticalCenter: pilotEnableCombo.verticalCenter
                                text:                   qsTr("Pilot Input:")
                                wrapMode:               Text.Wrap
Jacob Walser's avatar
Jacob Walser committed
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
                            }

                            FactComboBox {
                                id:                 pilotEnableCombo
                                width:              failsafeSettings._editWidth
                                fact:               _failsafePilotEnable
                                indexModel:         false
                            }

                            QGCLabel {
                                text: "Timeout:"
                                width:              failsafeSettings._labelWidth
                                visible:            pilotEnableCombo.currentIndex != 0
                                anchors.baseline:   pilotEnableCombo.baseline

                            }

                            FactTextField {
                                width:              failsafeSettings._editWidth
                                visible:            pilotEnableCombo.currentIndex != 0
                                anchors.baseline:   pilotEnableCombo.baseline
                                fact:               _failsafePilotTimeout
                            }
                        }

                        Row {
                            spacing: _margins / 2

                            QGCLabel {
280 281 282 283 284
                                id:                     temperatureEnableLabel
                                width:                  failsafeSettings._labelWidth
                                anchors.verticalCenter: temperatureEnableCombo.verticalCenter
                                text:                   qsTr("Internal Temperature:")
                                wrapMode:               Text.Wrap
Jacob Walser's avatar
Jacob Walser committed
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
                            }

                            FactComboBox {
                                id:                 temperatureEnableCombo
                                width:              failsafeSettings._editWidth
                                fact:               _failsafeTemperatureEnable
                                indexModel:         false
                            }

                            QGCLabel {
                                text: "Threshold:"
                                width:              failsafeSettings._labelWidth
                                visible:            temperatureEnableCombo.currentIndex != 0
                                anchors.baseline:   temperatureEnableCombo.baseline
                            }

                            FactTextField {
                                width:              failsafeSettings._editWidth
                                visible:            temperatureEnableCombo.currentIndex != 0
                                anchors.baseline:   temperatureEnableCombo.baseline
                                fact:               _failsafeTemperatureThreshold
                            }
                        }

                        Row {
                            spacing: _margins / 2

                            QGCLabel {
313 314 315 316 317
                                id:                     pressureEnableLabel
                                width:                  failsafeSettings._labelWidth
                                anchors.verticalCenter: pressureEnableCombo.verticalCenter
                                text:                   qsTr("Internal Pressure:")
                                wrapMode:               Text.Wrap
Jacob Walser's avatar
Jacob Walser committed
318 319 320 321 322 323 324 325 326 327
                            }

                            FactComboBox {
                                id:                 pressureEnableCombo
                                width:              failsafeSettings._editWidth
                                fact:               _failsafePressureEnable
                                indexModel:         false
                            }

                            QGCLabel {
328
                                text:               qsTr("Threshold:")
Jacob Walser's avatar
Jacob Walser committed
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
                                width:              failsafeSettings._labelWidth
                                visible:            pressureEnableCombo.currentIndex != 0
                                anchors.baseline:   pressureEnableCombo.baseline
                            }

                            FactTextField {
                                width:              failsafeSettings._editWidth
                                visible:            pressureEnableCombo.currentIndex != 0
                                anchors.baseline:   pressureEnableCombo.baseline
                                fact:               _failsafePressureThreshold
                            }
                        }
                    } // Column - Failsafe Settings
                }// Rectangle - Failsafe Settings
            } // Column - Failsafe Settings
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367

            Column {
                spacing: _margins / 2

                QGCLabel {
                    text:           qsTr("Arming Checks")
                    font.family:    ScreenTools.demiboldFontFamily
                }

                Rectangle {
                    width:  flowLayout.width
                    height: armingCheckInnerColumn.height + (_margins * 2)
                    color:  ggcPal.windowShade

                    Column {
                        id:                 armingCheckInnerColumn
                        anchors.margins:    _margins
                        anchors.top:        parent.top
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                        spacing: _margins

                        FactBitmask {
                            id:                 armingCheckBitmask
368 369
                            anchors.left:       parent.left
                            anchors.right:      parent.right
370 371 372
                            firstEntryIsAll:    true
                            fact:               _armingCheck
                        }
373

374 375 376 377 378 379 380 381
                        QGCLabel {
                            id:             armingCheckWarning
                            anchors.left:   parent.left
                            anchors.right:  parent.right
                            wrapMode:       Text.WordWrap
                            color:          qgcPal.warningText
                            text:            qsTr("Warning: Turning off arming checks can lead to loss of Vehicle control.")
                            visible:        _armingCheck.value != 1
382
                        }
383 384 385 386 387 388
                    }
                } // Rectangle - Arming checks
            } // Column - Arming Checks
        } // Flow
    } // Component - safetyPageComponent
} // SetupView