SafetyComponent.qml 25.1 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


11 12
import QtQuick                  2.3
import QtQuick.Controls         1.2
13
import QtQuick.Controls.Styles  1.4
14
import QtQuick.Layouts          1.2
Don Gagne's avatar
Don Gagne committed
15
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
        Item {
31
            width:  Math.max(availableWidth, outerGrid.width)
32
            height: _hitlAvailable ? (lastRect.y + lastRect.height) : (otherLastRect.y + otherLastRect.height)
Don Gagne's avatar
Don Gagne committed
33

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

39 40
            readonly property string hitlParam: "SYS_HITL"

41
            property real _margins:         ScreenTools.defaultFontPixelHeight
42
            property real _editFieldWidth:  ScreenTools.defaultFontPixelWidth * 20
Don Gagne's avatar
Don Gagne committed
43 44
            property real _imageWidth:      ScreenTools.defaultFontPixelWidth * 15
            property real _imageHeight:     ScreenTools.defaultFontPixelHeight * 3
Don Gagne's avatar
Don Gagne committed
45

46
            property Fact _enableLogging:   controller.getParameterFact(-1, "SDLOG_MODE")
47 48 49 50 51 52 53 54 55
            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)
56 57
            property bool _hitlAvailable:   controller.parameterExists(-1, hitlParam)
            property Fact _hitlEnabled:     controller.getParameterFact(-1, hitlParam, false)
dogmaphobic's avatar
dogmaphobic committed
58

59
            ExclusiveGroup { id: homeLoiterGroup }
Don Gagne's avatar
Don Gagne committed
60

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
            Rectangle {
                x:      lowBattGrid.x + outerGrid.x - _margins
                y:      lowBattGrid.y + outerGrid.y - _margins
                width:  lowBattGrid.width + (_margins * 2)
                height: lowBattGrid.height + (_margins * 2)
                color:  qgcPal.windowShade
            }

            Rectangle {
                x:      rcLossGrid.x + outerGrid.x - _margins
                y:      rcLossGrid.y + outerGrid.y - _margins
                width:  rcLossGrid.width + (_margins * 2)
                height: rcLossGrid.height + (_margins * 2)
                color:  qgcPal.windowShade
            }

            Rectangle {
                x:      dataLinkLossGrid.x + outerGrid.x - _margins
                y:      dataLinkLossGrid.y + outerGrid.y - _margins
                width:  dataLinkLossGrid.width + (_margins * 2)
                height: dataLinkLossGrid.height + (_margins * 2)
                color:  qgcPal.windowShade
            }

            Rectangle {
                x:      geoFenceGrid.x + outerGrid.x - _margins
                y:      geoFenceGrid.y + outerGrid.y - _margins
                width:  geoFenceGrid.width + (_margins * 2)
                height: geoFenceGrid.height + (_margins * 2)
                color:  qgcPal.windowShade
            }

            Rectangle {
                x:      returnHomeGrid.x + outerGrid.x - _margins
                y:      returnHomeGrid.y + outerGrid.y - _margins
                width:  returnHomeGrid.width + (_margins * 2)
                height: returnHomeGrid.height + (_margins * 2)
                color:  qgcPal.windowShade
            }

            Rectangle {
                x:      landModeGrid.x + outerGrid.x - _margins
                y:      landModeGrid.y + outerGrid.y - _margins
                width:  landModeGrid.width + (_margins * 2)
                height: landModeGrid.height + (_margins * 2)
                color:  qgcPal.windowShade
            }

109 110 111 112 113 114 115 116 117
            Rectangle {
                id:     otherLastRect
                x:      loggingGrid.x + outerGrid.x - _margins
                y:      loggingGrid.y + outerGrid.y - _margins
                width:  loggingGrid.width + (_margins * 2)
                height: loggingGrid.height + (_margins * 2)
                color:  qgcPal.windowShade
            }

118 119 120 121 122 123 124 125 126 127
            Rectangle {
                id:         lastRect
                x:          hitlGrid.x + outerGrid.x - _margins
                y:          hitlGrid.y + outerGrid.y - _margins
                width:      hitlGrid.width + (_margins * 2)
                height:     hitlGrid.height + (_margins * 2)
                color:      qgcPal.windowShade
                visible:    _hitlAvailable
            }

128 129 130 131
            GridLayout {
                id:         outerGrid
                columns:    3
                anchors.horizontalCenter:   parent.horizontalCenter
132

133
                QGCLabel {
134 135
                    text:               qsTr("Low Battery Failsafe Trigger")
                    Layout.columnSpan:  3
136
                }
137 138 139 140 141 142 143 144 145 146

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                Item { width: _margins; height: 1 }

                GridLayout {
                    id:         lowBattGrid
                    columns:    3

                    Image {
Don Gagne's avatar
Don Gagne committed
147 148 149 150
                        mipmap:                 true
                        fillMode:               Image.PreserveAspectFit
                        source:                 qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/LowBatteryLight.svg" : "/qmlimages/LowBattery.svg"
                        Layout.rowSpan:         4
Don Gagne's avatar
Don Gagne committed
151 152 153 154
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
                        width:                  _imageWidth
                        height:                 _imageHeight
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
                    }

                    QGCLabel {
                        text:               qsTr("Failsafe Action:")
                        Layout.fillWidth:   true
                    }
                    FactComboBox {
                        fact:                   _lowBattAction
                        indexModel:             false
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCLabel {
                        text:               qsTr("Battery Warn Level:")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "BAT_LOW_THR")
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCLabel {
                        text:               qsTr("Battery Failsafe Level:")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "BAT_CRIT_THR")
                        Layout.minimumWidth:    _editFieldWidth
183
                    }
Don Gagne's avatar
Don Gagne committed
184 185 186 187 188 189 190 191 192

                    QGCLabel {
                        text:               qsTr("Battery Emergency Level:")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "BAT_EMERGEN_THR")
                        Layout.minimumWidth:    _editFieldWidth
                    }
193
                }
194 195 196

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

197
                QGCLabel {
198 199
                    text:               qsTr("RC Loss Failsafe Trigger")
                    Layout.columnSpan: 3
200
                }
201 202 203 204 205 206 207 208 209 210 211 212

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                Item { width: _margins; height: 1 }

                GridLayout {
                    id:         rcLossGrid
                    columns:    3

                    Image {
                        mipmap:             true
                        fillMode:           Image.PreserveAspectFit
DonLakeFlyer's avatar
DonLakeFlyer committed
213
                        source:             qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/RCLossLight.svg" : "/qmlimages/RCLoss.svg"
214
                        Layout.rowSpan:     3
Don Gagne's avatar
Don Gagne committed
215 216 217 218
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
                        width:                  _imageWidth
                        height:                 _imageHeight
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
                    }

                    QGCLabel {
                        text:               qsTr("Failsafe Action:")
                        Layout.fillWidth:   true
                    }
                    FactComboBox {
                        fact:                   _rcLossAction
                        indexModel:             false
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCLabel {
                        text:               qsTr("RC Loss Timeout:")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "COM_RC_LOSS_T")
                        Layout.minimumWidth:    _editFieldWidth
238 239
                    }
                }
240 241 242

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

243
                QGCLabel {
244 245
                    text:               qsTr("Data Link Loss Failsafe Trigger")
                    Layout.columnSpan: 3
246
                }
247 248 249 250 251 252 253 254 255 256 257 258

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                Item { width: _margins; height: 1 }

                GridLayout {
                    id:         dataLinkLossGrid
                    columns:    3

                    Image {
                        mipmap:             true
                        fillMode:           Image.PreserveAspectFit
DonLakeFlyer's avatar
DonLakeFlyer committed
259
                        source:             qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/DatalinkLossLight.svg" : "/qmlimages/DatalinkLoss.svg"
260
                        Layout.rowSpan:     3
Don Gagne's avatar
Don Gagne committed
261 262 263 264
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
                        width:                  _imageWidth
                        height:                 _imageHeight
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
                    }

                    QGCLabel {
                        text:               qsTr("Failsafe Action:")
                        Layout.fillWidth:   true
                    }
                    FactComboBox {
                        fact:                   _dlLossAction
                        indexModel:             false
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCLabel {
                        text:               qsTr("Data Link Loss Timeout:")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "COM_DL_LOSS_T")
                        Layout.minimumWidth:    _editFieldWidth
284 285
                    }
                }
286 287 288

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

289
                QGCLabel {
290 291
                    text:               qsTr("Geofence Failsafe Trigger")
                    Layout.columnSpan:  3
292
                }
293 294 295 296 297 298 299 300 301 302 303 304

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                Item { width: _margins; height: 1 }

                GridLayout {
                    id:         geoFenceGrid
                    columns:    3

                    Image {
                        mipmap:             true
                        fillMode:           Image.PreserveAspectFit
DonLakeFlyer's avatar
DonLakeFlyer committed
305
                        source:             qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/GeoFenceLight.svg" : "/qmlimages/GeoFence.svg"
306
                        Layout.rowSpan:     3
Don Gagne's avatar
Don Gagne committed
307 308 309 310
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
                        width:                  _imageWidth
                        height:                 _imageHeight
311 312 313 314 315 316 317 318 319 320 321 322 323 324
                    }

                    QGCLabel {
                        text:               qsTr("Action on breach:")
                        Layout.fillWidth:   true
                    }
                    FactComboBox {
                        fact:                   _fenceAction
                        indexModel:             false
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCCheckBox {
                        id:                 fenceRadiusCheckBox
325
                        text:               qsTr("Max Radius:")
326 327 328 329 330 331 332 333 334 335 336 337
                        checked:            _fenceRadius.value > 0
                        onClicked:          _fenceRadius.value = checked ? 100 : 0
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   _fenceRadius
                        enabled:                fenceRadiusCheckBox.checked
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCCheckBox {
                        id:                 fenceAltMaxCheckBox
338
                        text:               qsTr("Max Altitude:")
339 340 341 342 343 344 345 346
                        checked:            _fenceAlt ? _fenceAlt.value > 0 : false
                        onClicked:          _fenceAlt.value = checked ? 100 : 0
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   _fenceAlt
                        enabled:                fenceAltMaxCheckBox.checked
                        Layout.minimumWidth:    _editFieldWidth
347 348
                    }
                }
349 350 351

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

352
                QGCLabel {
353 354
                    text:               qsTr("Return Home Settings")
                    Layout.columnSpan:  3
355
                }
356 357 358 359 360 361 362 363 364 365 366 367 368

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                Item { width: _margins; height: 1 }

                GridLayout {
                    id:         returnHomeGrid
                    columns:    3

                    QGCColoredImage {
                        color:                  qgcPal.text
                        mipmap:                 true
                        fillMode:               Image.PreserveAspectFit
DonLakeFlyer's avatar
DonLakeFlyer committed
369
                        source:                 controller.vehicle.fixedWing ? "/qmlimages/ReturnToHomeAltitude.svg" : "/qmlimages/ReturnToHomeAltitudeCopter.svg"
370
                        Layout.rowSpan:         7
Don Gagne's avatar
Don Gagne committed
371 372 373 374
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
                        width:                  _imageWidth
                        height:                 _imageHeight
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
                    }

                    QGCLabel {
                        text:               qsTr("Climb to altitude of:")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "RTL_RETURN_ALT")
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCLabel {
                        text:               qsTr("Return home, then:")
                        Layout.columnSpan:  2
                    }
390
                    Row {
391 392 393 394 395 396 397 398
                        Layout.columnSpan:  2
                        Item { width: ScreenTools.defaultFontPixelWidth; height: 1 }
                        QGCRadioButton {
                            id:                 homeLandRadio
                            checked:            _rtlLandDelay ? _rtlLandDelay.value === 0 : false
                            exclusiveGroup:     homeLoiterGroup
                            text:               qsTr("Land immediately")
                            onClicked:          _rtlLandDelay.value = 0
Don Gagne's avatar
Don Gagne committed
399
                        }
400 401 402 403 404 405 406 407 408 409
                    }
                    Row {
                        Layout.columnSpan:  2
                        Item { width: ScreenTools.defaultFontPixelWidth; height: 1 }
                        QGCRadioButton {
                            id:                 homeLoiterNoLandRadio
                            checked:            _rtlLandDelay ? _rtlLandDelay.value < 0 : false
                            exclusiveGroup:     homeLoiterGroup
                            text:               qsTr("Loiter and do not land")
                            onClicked:          _rtlLandDelay.value = -1
410
                        }
411 412 413 414 415 416 417 418 419 420
                    }
                    Row {
                        Layout.columnSpan:  2
                        Item { width: ScreenTools.defaultFontPixelWidth; height: 1 }
                        QGCRadioButton {
                            id:                 homeLoiterLandRadio
                            checked:            _rtlLandDelay ? _rtlLandDelay.value > 0 : false
                            exclusiveGroup:     homeLoiterGroup
                            text:               qsTr("Loiter and land after specified time")
                            onClicked:          _rtlLandDelay.value = 60
421 422
                        }
                    }
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442

                    QGCLabel {
                        text:               qsTr("Loiter Time")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "RTL_LAND_DELAY")
                        enabled:                homeLoiterLandRadio.checked === true
                        Layout.minimumWidth:    _editFieldWidth
                    }

                    QGCLabel {
                        text:               qsTr("Loiter Altitude")
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   controller.getParameterFact(-1, "RTL_DESCEND_ALT")
                        enabled:                homeLoiterLandRadio.checked === true || homeLoiterNoLandRadio.checked === true
                        Layout.minimumWidth:    _editFieldWidth
                    }
443
                }
444 445 446

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

447
                QGCLabel {
448 449
                    text:               qsTr("Land Mode Settings")
                    Layout.columnSpan:  3
450
                }
451 452 453 454 455 456 457 458 459 460 461 462 463

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                Item { width: _margins; height: 1 }

                GridLayout {
                    id:         landModeGrid
                    columns:    3

                    QGCColoredImage {
                        color:                  qgcPal.text
                        mipmap:                 true
                        fillMode:               Image.PreserveAspectFit
DonLakeFlyer's avatar
DonLakeFlyer committed
464
                        source:                 controller.vehicle.fixedWing ? "/qmlimages/LandMode.svg" : "/qmlimages/LandModeCopter.svg"
465
                        Layout.rowSpan:         landVelocityLabel.visible ? 2 : 1
Don Gagne's avatar
Don Gagne committed
466 467 468 469
                        width:                  _imageWidth
                        height:                 _imageHeight
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
470 471
                    }

472 473
                    QGCLabel {
                        id:                 landVelocityLabel
DonLakeFlyer's avatar
DonLakeFlyer committed
474
                        text:               qsTr("Landing Descent Rate:")
475 476 477
                        Layout.fillWidth:   true
                        visible:            controller.vehicle && !controller.vehicle.fixedWing
                    }
DonLakeFlyer's avatar
DonLakeFlyer committed
478
                    FactTextField {
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
                        fact:                   _landSpeedMC
                        Layout.minimumWidth:    _editFieldWidth
                        visible:                controller.vehicle && !controller.vehicle.fixedWing
                    }

                    QGCCheckBox {
                        id:                 disarmDelayCheckBox
                        text:               qsTr("Disarm After:")
                        checked:            _disarmLandDelay.value > 0
                        onClicked:          _disarmLandDelay.value = checked ? 2 : 0
                        Layout.fillWidth:   true
                    }
                    FactTextField {
                        fact:                   _disarmLandDelay
                        enabled:                disarmDelayCheckBox.checked
                        Layout.minimumWidth:    _editFieldWidth
                    }
                }
497

498 499 500
                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                QGCLabel {
501
                    text:               qsTr("Vehicle Telemetry Logging")
502 503 504 505 506 507 508 509
                    Layout.columnSpan:  3
                }

                Item { width: 1; height: _margins; Layout.columnSpan: 3 }

                Item { width: _margins; height: 1 }

                GridLayout {
510 511 512
                    id:                         loggingGrid
                    columns:                    4
                    columnSpacing:              ScreenTools.defaultFontPixelWidth * 4
513
                    Item {
514
                        Layout.fillWidth:       true
515 516 517 518 519 520 521 522 523 524 525
                    }
                    Image {
                        mipmap:                 true
                        fillMode:               Image.PreserveAspectFit
                        source:                 qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/no-logging-light.svg" : "/qmlimages/no-logging.svg"
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
                        width:                  _imageWidth
                        height:                 _imageHeight
                    }
                    QGCCheckBox {
526 527
                        text:                   qsTr("Enable telemetry logging to vehicle storage")
                        checkedState:           _enableLogging ? (_enableLogging.value >= 0 ? Qt.Checked : Qt.Unchecked) : Qt.Unchecked
528 529 530
                        Layout.minimumWidth:    _editFieldWidth
                        Layout.alignment:       Qt.AlignVCenter
                        onClicked:  {
531 532
                            if(_enableLogging) {
                                _enableLogging.value = checked ? 0 : -1
533 534 535 536 537 538 539 540
                            }
                        }
                    }
                    Item {
                        Layout.fillWidth:   true
                    }
                }

541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
                Item { width: 1; height: _margins; Layout.columnSpan: 3; visible: _hitlAvailable }

                QGCLabel {
                    text:               qsTr("Hardware in the Loop Simulation")
                    Layout.columnSpan:  3
                    visible:            _hitlAvailable
                }

                Item { width: 1; height: _margins; Layout.columnSpan: 3; visible: _hitlAvailable }

                Item { width: _margins; height: 1; visible: _hitlAvailable }

                GridLayout {
                    id:         hitlGrid
                    columns:    3
                    visible:    _hitlAvailable

                    Image {
559 560 561 562
                        mipmap:                 true
                        fillMode:               Image.PreserveAspectFit
                        source:                 qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/VehicleSummaryIcon.png" : "/qmlimages/VehicleSummaryIcon.png"
                        Layout.rowSpan:         3
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
                        Layout.maximumWidth:    _imageWidth
                        Layout.maximumHeight:   _imageHeight
                        width:                  _imageWidth
                        height:                 _imageHeight
                    }

                    QGCLabel {
                        text:               qsTr("HITL Enabled:")
                        Layout.fillWidth:   true
                    }
                    FactComboBox {
                        fact:                   _hitlEnabled
                        indexModel:             false
                        Layout.minimumWidth:    _editFieldWidth
                    }
                }
579

580 581 582 583
            }
        }
    }
}