SafetyComponent.qml 30 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
9 10


Don Gagne's avatar
Don Gagne committed
11 12 13 14 15
import QtQuick                  2.5
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.2
import QtQuick.Layouts          1.2
import QtGraphicalEffects       1.0
16

Don Gagne's avatar
Don Gagne committed
17 18 19 20
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
Don Gagne's avatar
Don Gagne committed
21

Don Gagne's avatar
Don Gagne committed
22

23 24 25
SetupPage {
    id:             safetyPage
    pageComponent:  pageComponent
Don Gagne's avatar
Don Gagne committed
26

27 28
    Component {
        id: pageComponent
Don Gagne's avatar
Don Gagne committed
29

30 31 32
        Item {
            width:  Math.max(availableWidth, mainCol.width)
            height: mainCol.height
Don Gagne's avatar
Don Gagne committed
33

34 35 36 37 38 39 40 41
            FactPanelController {
                id:         controller
                factPanel:  safetyPage.viewPanel
            }

            property real _margins:         ScreenTools.defaultFontPixelHeight
            property real _middleRowWidth:  ScreenTools.defaultFontPixelWidth * 20
            property real _editFieldWidth:  ScreenTools.defaultFontPixelWidth * 14
Don Gagne's avatar
Don Gagne committed
42

43 44 45 46 47 48 49 50 51
            property Fact _fenceAction:     controller.getParameterFact(-1, "GF_ACTION")
            property Fact _fenceRadius:     controller.getParameterFact(-1, "GF_MAX_HOR_DIST")
            property Fact _fenceAlt:        controller.getParameterFact(-1, "GF_MAX_VER_DIST")
            property Fact _rtlLandDelay:    controller.getParameterFact(-1, "RTL_LAND_DELAY")
            property Fact _lowBattAction:   controller.getParameterFact(-1, "COM_LOW_BAT_ACT")
            property Fact _rcLossAction:    controller.getParameterFact(-1, "NAV_RCL_ACT")
            property Fact _dlLossAction:    controller.getParameterFact(-1, "NAV_DLL_ACT")
            property Fact _disarmLandDelay: controller.getParameterFact(-1, "COM_DISARM_LAND")
            property Fact _landSpeedMC:     controller.getParameterFact(-1, "MPC_LAND_SPEED", false)
dogmaphobic's avatar
dogmaphobic committed
52

53
            property bool _showIcons: !ScreenTools.isTinyScreen
Don Gagne's avatar
Don Gagne committed
54

55
            Column {
56 57
                id:                                     mainCol
                spacing:                                _margins
58
                anchors.horizontalCenter:               parent.horizontalCenter
59

60 61 62 63
                /*
                   **** Low Battery ****
                */
                Item { width: 1; height: _margins * 0.5; }
64
                QGCLabel {
65
                    text:                               qsTr("Low Battery Failsafe Trigger")
66
                    font.family:                        ScreenTools.demiboldFontFamily
67 68
                }
                Rectangle {
69
                    color:                              qgcPal.windowShade
70 71
                    width:                              rtlSettings.width
                    height:                             lowBattRow.height + _margins * 2
72
                    Row {
73 74 75 76 77 78 79
                        id:                             lowBattRow
                        spacing:                        _margins
                        anchors.verticalCenter:         parent.verticalCenter
                        Item { width: _margins * 0.5; height: 1; }
                        Image {
                            height:                     ScreenTools.defaultFontPixelWidth * 6
                            width:                      ScreenTools.defaultFontPixelWidth * 20
dogmaphobic's avatar
dogmaphobic committed
80
                            sourceSize.width:           width
81 82
                            mipmap:                     true
                            fillMode:                   Image.PreserveAspectFit
83
                            source:                     qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/LowBatteryLight.svg" : "/qmlimages/LowBattery.svg"
84
                            anchors.verticalCenter:     parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
85 86 87 88 89 90
                            visible:                    _showIcons
                        }
                        Item {
                            width:      _margins * 0.5
                            height:     1
                            visible:    _showIcons
91
                        }
92 93 94 95 96 97 98
                        Column {
                            spacing:                    _margins * 0.5
                            anchors.verticalCenter:     parent.verticalCenter
                            Row {
                                QGCLabel {
                                    anchors.baseline:   lowBattCombo.baseline
                                    width:              _middleRowWidth
99
                                    text:               qsTr("Failsafe Action:")
100 101 102 103 104
                                }
                                FactComboBox {
                                    id:                 lowBattCombo
                                    width:              _editFieldWidth
                                    fact:               _lowBattAction
105
                                    indexModel:         false
106 107 108 109 110 111
                                }
                            }
                            Row {
                                QGCLabel {
                                    anchors.baseline:   batLowLevelField.baseline
                                    width:              _middleRowWidth
112
                                    text:               qsTr("Battery Warn Level:")
113 114 115
                                }
                                FactTextField {
                                    id:                 batLowLevelField
116
                                    fact:               controller.getParameterFact(-1, "BAT_LOW_THR")
117 118 119 120
                                    showUnits:          true
                                    width:              _editFieldWidth
                                }
                            }
121 122
                            Row {
                                QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
123
                                    anchors.baseline:   batCritLevelField.baseline
124 125 126 127 128 129 130 131 132 133
                                    width:              _middleRowWidth
                                    text:               qsTr("Battery Failsafe Level:")
                                }
                                FactTextField {
                                    id:                 batCritLevelField
                                    fact:               controller.getParameterFact(-1, "BAT_CRIT_THR")
                                    showUnits:          true
                                    width:              _editFieldWidth
                                }
                            }
134
                        }
135 136 137 138 139 140
                    }
                }
                /*
                   **** RC Loss ****
                */
                QGCLabel {
141
                    text:                               qsTr("RC Loss Failsafe Trigger")
142
                    font.family:                        ScreenTools.demiboldFontFamily
143 144
                }
                Rectangle {
145
                    color:                              qgcPal.windowShade
146 147 148 149 150 151 152 153 154 155
                    width:                              rtlSettings.width
                    height:                             rcLossRow.height + _margins * 2
                    Row {
                        id:                             rcLossRow
                        spacing:                        _margins
                        anchors.verticalCenter:         parent.verticalCenter
                        Item { width: _margins * 0.5; height: 1; }
                        Image {
                            height:                     ScreenTools.defaultFontPixelWidth * 6
                            width:                      ScreenTools.defaultFontPixelWidth * 20
dogmaphobic's avatar
dogmaphobic committed
156
                            sourceSize.width:           width
157 158
                            mipmap:                     true
                            fillMode:                   Image.PreserveAspectFit
159
                            source:                     qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/RCLossLight.svg" : "/qmlimages/RCLoss.svg"
160
                            anchors.verticalCenter:     parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
161 162 163 164 165 166
                            visible:                    _showIcons
                        }
                        Item {
                            width:      _margins * 0.5
                            height:     1
                            visible:    _showIcons
167 168
                        }
                        Column {
169 170 171 172 173 174
                            spacing:                    _margins * 0.5
                            anchors.verticalCenter:     parent.verticalCenter
                            Row {
                                QGCLabel {
                                    anchors.baseline:   rcLossCombo.baseline
                                    width:              _middleRowWidth
175
                                    text:               qsTr("Failsafe Action:")
176 177 178 179 180
                                }
                                FactComboBox {
                                    id:                 rcLossCombo
                                    width:              _editFieldWidth
                                    fact:               _rcLossAction
181
                                    indexModel:         false
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
                                }
                            }
                            Row {
                                QGCLabel {
                                    anchors.baseline:   rcLossField.baseline
                                    width:              _middleRowWidth
                                    text:               qsTr("RC Loss Timeout:")
                                }
                                FactTextField {
                                    id:                 rcLossField
                                    fact:               controller.getParameterFact(-1, "COM_RC_LOSS_T")
                                    showUnits:          true
                                    width:              _editFieldWidth
                                }
                            }
197 198 199 200 201 202 203
                        }
                    }
                }
                /*
                   **** Data Link Loss ****
                */
                QGCLabel {
204
                    text:                               qsTr("Data Link Loss Failsafe Trigger")
205
                    font.family:                        ScreenTools.demiboldFontFamily
206 207
                }
                Rectangle {
208
                    color:                              qgcPal.windowShade
209 210 211 212 213 214 215 216 217 218
                    width:                              rtlSettings.width
                    height:                             dlLossRow.height + _margins * 2
                    Row {
                        id:                             dlLossRow
                        spacing:                        _margins
                        anchors.verticalCenter:         parent.verticalCenter
                        Item { width: _margins * 0.5; height: 1; }
                        Image {
                            height:                     ScreenTools.defaultFontPixelWidth * 6
                            width:                      ScreenTools.defaultFontPixelWidth * 20
dogmaphobic's avatar
dogmaphobic committed
219
                            sourceSize.width:           width
220 221
                            mipmap:                     true
                            fillMode:                   Image.PreserveAspectFit
222
                            source:                     qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/DatalinkLossLight.svg" : "/qmlimages/DatalinkLoss.svg"
223
                            anchors.verticalCenter:     parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
224 225 226 227 228 229
                            visible:                    _showIcons
                        }
                        Item {
                            width:      _margins * 0.5
                            height:     1
                            visible:    _showIcons
230 231 232 233
                        }
                        Column {
                            spacing:                    _margins * 0.5
                            anchors.verticalCenter:     parent.verticalCenter
234 235
                            Row {
                                QGCLabel {
236
                                    anchors.baseline:   dlLossCombo.baseline
237
                                    width:              _middleRowWidth
238
                                    text:               qsTr("Failsafe Action:")
239 240 241 242 243 244 245 246 247 248 249 250 251
                                }
                                FactComboBox {
                                    id:                 dlLossCombo
                                    width:              _editFieldWidth
                                    fact:               _dlLossAction
                                    indexModel:         false
                                }
                            }
                            Row {
                                QGCLabel {
                                    anchors.baseline:   dlLossField.baseline
                                    width:              _middleRowWidth
                                    text:               qsTr("Data Link Loss Timeout:")
252 253
                                }
                                FactTextField {
254 255
                                    id:                 dlLossField
                                    fact:               controller.getParameterFact(-1, "COM_DL_LOSS_T")
256
                                    showUnits:          true
257
                                    width:              _editFieldWidth
258 259 260 261 262 263 264 265 266
                                }
                            }
                        }
                    }
                }
                /*
                   **** Geofence ****
                */
                QGCLabel {
267
                    text:                               qsTr("Geofence Failsafe Trigger")
268
                    font.family:                        ScreenTools.demiboldFontFamily
269 270
                }
                Rectangle {
271
                    color:                              qgcPal.windowShade
272 273 274 275 276 277 278 279 280 281
                    width:                              rtlSettings.width
                    height:                             geofenceRow.height + _margins * 2
                    Row {
                        id:                             geofenceRow
                        spacing:                        _margins
                        anchors.verticalCenter:         parent.verticalCenter
                        Item { width: _margins * 0.5; height: 1; }
                        Image {
                            height:                     ScreenTools.defaultFontPixelWidth * 8
                            width:                      ScreenTools.defaultFontPixelWidth * 20
dogmaphobic's avatar
dogmaphobic committed
282
                            sourceSize.width:           width
283 284
                            mipmap:                     true
                            fillMode:                   Image.PreserveAspectFit
285
                            source:                     qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/GeoFenceLight.svg" : "/qmlimages/GeoFence.svg"
286
                            anchors.verticalCenter:     parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
287 288 289 290 291 292
                            visible:                    _showIcons
                        }
                        Item {
                            width:      _margins * 0.5
                            height:     1
                            visible:    _showIcons
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
                        }
                        Column {
                            spacing:                    _margins * 0.5
                            anchors.verticalCenter:     parent.verticalCenter
                            Row {
                                QGCLabel {
                                    id:                 fenceActionLabel
                                    anchors.baseline:   fenceActionCombo.baseline
                                    text:               qsTr("Action on breach:")
                                    width:              _middleRowWidth
                                }
                                FactComboBox {
                                    id:                 fenceActionCombo
                                    width:              _editFieldWidth
                                    fact:               _fenceAction
308
                                    indexModel:         false
309 310 311 312 313 314 315
                                }
                            }
                            Row {
                                QGCCheckBox {
                                    id:                 fenceRadiusCheckBox
                                    anchors.baseline:   fenceRadiusField.baseline
                                    text:               qsTr("Max radius:")
Don Gagne's avatar
Don Gagne committed
316 317
                                    checked:            _fenceRadius.value > 0
                                    onClicked:          _fenceRadius.value = checked ? 100 : 0
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
                                    width:              _middleRowWidth
                                }
                                FactTextField {
                                    id:                 fenceRadiusField
                                    showUnits:          true
                                    fact:               _fenceRadius
                                    enabled:            fenceRadiusCheckBox.checked
                                    width:              _editFieldWidth
                                }
                            }
                            Row {
                                QGCCheckBox {
                                    id:                 fenceAltMaxCheckBox
                                    anchors.baseline:   fenceAltMaxField.baseline
                                    text:               qsTr("Max altitude:")
Don Gagne's avatar
Don Gagne committed
333 334
                                    checked:            _fenceAlt.value > 0
                                    onClicked:          _fenceAlt.value = checked ? 100 : 0
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
                                    width:              _middleRowWidth
                                }
                                FactTextField {
                                    id:                 fenceAltMaxField
                                    showUnits:          true
                                    fact:               _fenceAlt
                                    enabled:            fenceAltMaxCheckBox.checked
                                    width:              _editFieldWidth
                                }
                            }
                        }
                    }
                }
                /*
                   **** Return Home Settings ****
                */
                QGCLabel {
                    id:                                 rtlLabel
                    text:                               qsTr("Return Home Settings")
354
                    font.family:                        ScreenTools.demiboldFontFamily
355 356 357
                }
                Rectangle {
                    id:                                 rtlSettings
358
                    color:                              qgcPal.windowShade
359 360 361 362 363 364 365 366 367
                    width:                              rtlRow.width  + _margins * 2
                    height:                             rtlRow.height + _margins * 2
                    Row {
                        id:                             rtlRow
                        spacing:                        _margins
                        anchors.verticalCenter:         parent.verticalCenter
                        Item { width: _margins * 0.5; height: 1; }
                        QGCColoredImage {
                            id:                         icon
368
                            color:                      qgcPal.text
369 370
                            height:                     ScreenTools.defaultFontPixelWidth * 10
                            width:                      ScreenTools.defaultFontPixelWidth * 20
dogmaphobic's avatar
dogmaphobic committed
371
                            sourceSize.width:           width
372 373
                            mipmap:                     true
                            fillMode:                   Image.PreserveAspectFit
374
                            source:                     controller.vehicle.fixedWing ? "/qmlimages/ReturnToHomeAltitude.svg" : "/qmlimages/ReturnToHomeAltitudeCopter.svg"
375
                            anchors.verticalCenter:     parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
376 377 378 379 380 381
                            visible:                    _showIcons
                        }
                        Item {
                            width:      _margins * 0.5
                            height:     1
                            visible:    _showIcons
382 383 384
                        }
                        Column {
                            spacing:                    _margins * 0.5
385 386 387 388
                            Row {
                                QGCLabel {
                                    id:                 climbLabel
                                    anchors.baseline:   climbField.baseline
389
                                    width:              _middleRowWidth
390 391 392 393 394 395
                                    text:               qsTr("Climb to altitude of:")
                                }
                                FactTextField {
                                    id:                 climbField
                                    fact:               controller.getParameterFact(-1, "RTL_RETURN_ALT")
                                    showUnits:          true
396
                                    width:              _editFieldWidth
397 398
                                }
                            }
399
                            Item { width: 1; height: _margins * 0.5; }
400
                            QGCLabel {
401 402
                                id:                     returnHomeLabel
                                text:                   "Return home, then:"
403 404
                            }
                            Row {
405
                                Item { height: 1; width: _margins; }
406 407 408 409
                                Column {
                                    spacing:            _margins * 0.5
                                    ExclusiveGroup { id: homeLoiterGroup }
                                    QGCRadioButton {
410 411 412 413 414
                                        id:             homeLandRadio
                                        checked:        _rtlLandDelay.value === 0
                                        exclusiveGroup: homeLoiterGroup
                                        text:           "Land immediately"
                                        onClicked:      _rtlLandDelay.value = 0
415 416
                                    }
                                    QGCRadioButton {
417 418 419 420 421
                                        id:             homeLoiterNoLandRadio
                                        checked:        _rtlLandDelay.value < 0
                                        exclusiveGroup: homeLoiterGroup
                                        text:           "Loiter and do not land"
                                        onClicked:      _rtlLandDelay.value = -1
422 423
                                    }
                                    QGCRadioButton {
424 425 426 427 428
                                        id:             homeLoiterLandRadio
                                        checked:        _rtlLandDelay.value > 0
                                        exclusiveGroup: homeLoiterGroup
                                        text:           qsTr("Loiter and land after specified time")
                                        onClicked:      _rtlLandDelay.value = 60
429 430 431
                                    }
                                }
                            }
432
                            Item { width: 1; height: _margins * 0.5; }
433 434 435
                            Row {
                                QGCLabel {
                                    text:               qsTr("Loiter Time")
436
                                    width:              _middleRowWidth
437
                                    anchors.baseline:   landDelayField.baseline
438
                                    color:              qgcPal.text
439 440 441 442 443 444 445
                                    enabled:            homeLoiterLandRadio.checked === true
                                }
                                FactTextField {
                                    id:                 landDelayField
                                    fact:               controller.getParameterFact(-1, "RTL_LAND_DELAY")
                                    showUnits:          true
                                    enabled:            homeLoiterLandRadio.checked === true
446
                                    width:              _editFieldWidth
447 448 449 450 451
                                }
                            }
                            Row {
                                QGCLabel {
                                    text:               qsTr("Loiter Altitude")
452
                                    width:              _middleRowWidth
453
                                    anchors.baseline:   descendField.baseline
454
                                    color:              qgcPal.text
455
                                    enabled:            homeLoiterLandRadio.checked === true || homeLoiterNoLandRadio.checked === true
456 457 458 459
                                }
                                FactTextField {
                                    id:                 descendField
                                    fact:               controller.getParameterFact(-1, "RTL_DESCEND_ALT")
460
                                    enabled:            homeLoiterLandRadio.checked === true || homeLoiterNoLandRadio.checked === true
461
                                    showUnits:          true
462
                                    width:              _editFieldWidth
463 464 465 466 467
                                }
                            }
                        }
                    }
                }
468 469 470
                /*
                   **** Land Mode Settings ****
                */
471
                QGCLabel {
472
                    text:                               qsTr("Land Mode Settings")
473
                    font.family:                        ScreenTools.demiboldFontFamily
474 475
                }
                Rectangle {
476
                    color:                              qgcPal.windowShade
477 478
                    width:                              rtlSettings.width
                    height:                             landModeRow.height + _margins * 2
479
                    Row {
480 481 482
                        id:                             landModeRow
                        spacing:                        _margins
                        anchors.verticalCenter:         parent.verticalCenter
483
                        Item {
484 485
                            width:                      _margins * 0.5
                            height:                     1
486 487
                        }
                        QGCColoredImage {
488
                            color:                      qgcPal.text
dogmaphobic's avatar
dogmaphobic committed
489
                            height:                     ScreenTools.defaultFontPixelWidth * 13
490
                            width:                      ScreenTools.defaultFontPixelWidth * 20
dogmaphobic's avatar
dogmaphobic committed
491
                            sourceSize.width:           width
492 493
                            mipmap:                     true
                            fillMode:                   Image.PreserveAspectFit
494
                            source:                     controller.vehicle.fixedWing ? "/qmlimages/LandMode.svg" : "/qmlimages/LandModeCopter.svg"
495
                            anchors.verticalCenter:     parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
496
                            visible:                    _showIcons
497 498
                        }
                        Item {
Don Gagne's avatar
Don Gagne committed
499 500 501
                            width:      _margins * 0.5
                            height:     1
                            visible:    _showIcons
502 503 504 505 506
                        }
                        Column {
                            spacing:                    _margins * 0.5
                            anchors.verticalCenter:     parent.verticalCenter
                            Row {
507
                                visible:                !controller.vehicle.fixedWing && (_landSpeedMC !== -1)
508 509
                                QGCLabel {
                                    anchors.baseline:   landVelField.baseline
510 511
                                    width:              _middleRowWidth
                                    text:               qsTr("Landing Velocity:")
512 513 514
                                }
                                FactTextField {
                                    id:                 landVelField
Lorenz Meier's avatar
Lorenz Meier committed
515
                                    fact:               _landSpeedMC
516
                                    showUnits:          true
517
                                    width:              _editFieldWidth
518 519 520
                                }
                            }
                            Row {
521 522
                                QGCCheckBox {
                                    id:                 disarmDelayCheckBox
523 524
                                    anchors.baseline:   disarmField.baseline
                                    text:               qsTr("Disarm After:")
525 526 527
                                    checked:            _disarmLandDelay.value > 0
                                    onClicked:          _disarmLandDelay.value = checked ? 2 : 0
                                    width:              _middleRowWidth
528 529 530 531
                                }
                                FactTextField {
                                    id:                 disarmField
                                    showUnits:          true
532 533
                                    fact:               _disarmLandDelay
                                    enabled:            disarmDelayCheckBox.checked
534
                                    width:              _editFieldWidth
535 536 537 538 539
                                }
                            }
                        }
                    }
                }
540
                Item { width: 1; height: _margins * 0.5; }
541 542 543 544
            } // Column
        } // Item
    } // Component
} // SetupPage
545