Skip to content
SafetyComponent.qml 12.6 KiB
Newer Older
/*=====================================================================

 QGroundControl Open Source Ground Control Station

 (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

 This file is part of the QGROUNDCONTROL project

 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

 ======================================================================*/

dogmaphobic's avatar
dogmaphobic committed
import QtQuick 2.5
Don Gagne's avatar
Don Gagne committed
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
dogmaphobic's avatar
dogmaphobic committed
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
Don Gagne's avatar
Don Gagne committed
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
Don Gagne's avatar
Don Gagne committed
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
QGCView {
    id:                 _safetyView
    viewPanel:          panel
    anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
    FactPanelController { id: controller; factPanel: panel }
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
    QGCPalette { id: palette; colorGroupEnabled: enabled }
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
    property real firstColumnWidth:     ScreenTools.defaultFontPixelWidth * 28
    property real secondColumnWidth:    ScreenTools.defaultFontPixelWidth * 25

    QGCViewPanel {
        id:             panel
        anchors.fill:   parent

        Flickable {
            clip:               true
            anchors.fill:       parent
            contentHeight:      safetyColumn.height
            contentWidth:       parent.width
            boundsBehavior:     Flickable.StopAtBounds
            flickableDirection: Flickable.VerticalFlick

            Column {
                id:     safetyColumn
                width:  _safetyView.width

                //-----------------------------------------------------------------
                //-- Return Home Triggers

                QGCLabel { text: "Triggers For Return Home"; font.pixelSize: ScreenTools.mediumFontPixelSize; }

                Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer

                Rectangle {
                    width:  parent.width
                    height: triggerColumn.height + ScreenTools.defaultFontPixelHeight
                    color:  palette.windowShade
                    Column {
                        id:                 triggerColumn
                        width:              parent.width
                        spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
                        anchors.left:       parent.left
                        Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
                        Row {
                            spacing:                ScreenTools.defaultFontPixelWidth
                            QGCLabel {
                                text:               "RC Transmitter Signal Loss"
                                width:              firstColumnWidth
                                anchors.verticalCenter: parent.verticalCenter
                            }
                            QGCLabel {
                                text:               "Return Home after"
                                width:              secondColumnWidth
                                anchors.verticalCenter: parent.verticalCenter
                            }
Don Gagne's avatar
Don Gagne committed
                            FactTextField {
dogmaphobic's avatar
dogmaphobic committed
                                id:                 rcLossField
                                fact:               controller.getParameterFact(-1, "COM_RC_LOSS_T")
                                showUnits:          true
                                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
                            }
Don Gagne's avatar
Don Gagne committed
                        }
dogmaphobic's avatar
dogmaphobic committed
                        Row {
                            spacing:                ScreenTools.defaultFontPixelWidth
                            FactCheckBox {
                                id:                 telemetryTimeoutCheckbox
                                width:              firstColumnWidth
                                fact:               controller.getParameterFact(-1, "COM_DL_LOSS_EN")
                                checkedValue:       1
                                uncheckedValue:     0
                                text:               "Telemetry Signal Timeout"
                                anchors.verticalCenter: parent.verticalCenter
                            }
                            QGCLabel {
                                text:               "Return Home after"
                                width:              secondColumnWidth
                                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
                            }
Don Gagne's avatar
Don Gagne committed
                            FactTextField {
dogmaphobic's avatar
dogmaphobic committed
                                id:                 telemetryLossField
                                fact:               controller.getParameterFact(-1, "COM_DL_LOSS_T")
                                showUnits:          true
                                enabled:            telemetryTimeoutCheckbox.checked
                                anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
                            }
dogmaphobic's avatar
dogmaphobic committed
                        Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
dogmaphobic's avatar
dogmaphobic committed
                }
dogmaphobic's avatar
dogmaphobic committed
                Item { height: ScreenTools.defaultFontPixelHeight; width: 1 } // spacer
dogmaphobic's avatar
dogmaphobic committed
                //-----------------------------------------------------------------
                //-- Return Home Settings
dogmaphobic's avatar
dogmaphobic committed
                QGCLabel { text: "Return Home Settings"; font.pixelSize: ScreenTools.mediumFontPixelSize; }
dogmaphobic's avatar
dogmaphobic committed
                Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
dogmaphobic's avatar
dogmaphobic committed
                Rectangle {
                    width:  parent.width
                    height: settingsRow.height
                    color:  palette.windowShade
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
                    Row {
                        id:                 settingsRow
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
                        anchors.left:       parent.left
                        spacing:            ScreenTools.defaultFontPixelWidth
                        Item {
                            width:          firstColumnWidth
                            height:         firstColumnWidth * 0.65
                            Image {
                                id:             icon
                                width:          parent.width
                                height:         parent.width * 0.5
                                mipmap:         true
                                fillMode:       Image.PreserveAspectFit
                                visible:        false
                                source:         "/qmlimages/ReturnToHomeAltitude.svg"
                                anchors.verticalCenter: parent.verticalCenter
                                anchors.horizontalCenter: parent.horizontalCenter
Don Gagne's avatar
Don Gagne committed
                            }
dogmaphobic's avatar
dogmaphobic committed
                            ColorOverlay {
                                id:             iconOverlay
                                anchors.fill:   icon
                                source:         icon
                                color:          palette.button
Don Gagne's avatar
Don Gagne committed
                            }
dogmaphobic's avatar
dogmaphobic committed
                            anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
                        }
Don Gagne's avatar
Don Gagne committed
                        Column {
dogmaphobic's avatar
dogmaphobic committed
                            width:              parent.width - firstColumnWidth
                            spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.verticalCenter: parent.verticalCenter
                            Item { height: ScreenTools.defaultFontPixelHeight * 0.5; width: 1 } // spacer
                            Row {
                                spacing:        ScreenTools.defaultFontPixelWidth
                                QGCLabel {
                                    text:       "Climb to altitude of"
                                    width:      secondColumnWidth
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                                FactTextField {
                                    id:         climbField
                                    fact:       controller.getParameterFact(-1, "RTL_RETURN_ALT")
                                    showUnits:  true
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                            }
                            Row {
                                spacing:        ScreenTools.defaultFontPixelWidth
                                QGCCheckBox {
                                    id:         homeLoiterCheckbox
                                    width:      secondColumnWidth
                                    checked:    fact.value > 0
                                    text:       "Loiter at Home altitude for"
                                    anchors.verticalCenter: parent.verticalCenter
                                    property Fact fact: controller.getParameterFact(-1, "RTL_LAND_DELAY")
                                    onClicked: {
                                        fact.value = checked ? 60 : -1
                                    }
                                }
                                FactTextField {
                                    id:         landDelayField
                                    fact:       controller.getParameterFact(-1, "RTL_LAND_DELAY")
                                    showUnits:  true
                                    enabled:    homeLoiterCheckbox.checked === true
                                    anchors.verticalCenter: parent.verticalCenter
                                }
Don Gagne's avatar
Don Gagne committed
                            }
dogmaphobic's avatar
dogmaphobic committed
                            Row {
                                spacing:    ScreenTools.defaultFontPixelWidth
                                QGCLabel {
                                    text:       "Home loiter altitude";
                                    color:      palette.text;
                                    enabled:    homeLoiterCheckbox.checked === true
                                    width:      secondColumnWidth
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                                FactTextField {
                                    id:         descendField;
                                    fact:       controller.getParameterFact(-1, "RTL_DESCEND_ALT")
                                    enabled:    homeLoiterCheckbox.checked === true
                                    showUnits:  true
                                    anchors.verticalCenter: parent.verticalCenter
                                }
Don Gagne's avatar
Don Gagne committed
                            }
dogmaphobic's avatar
dogmaphobic committed
                            Item { height: ScreenTools.defaultFontPixelHeight; width: 1 } // spacer
Don Gagne's avatar
Don Gagne committed
                }
dogmaphobic's avatar
dogmaphobic committed
                QGCLabel {
                    width:          parent.width
                    font.pixelSize: ScreenTools.mediumFontPixelSize
                    text:           "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply.";
                    visible:        fact.value !== 0
                    wrapMode:       Text.Wrap
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
                    property Fact fact: controller.getParameterFact(-1, "NAV_RCL_OBC")
                }
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
                QGCLabel {
                    width:          parent.width
                    font.pixelSize: ScreenTools.mediumFontPixelSize
                    text:           "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply.";
                    visible:        fact.value !== 0
                    wrapMode:       Text.Wrap
Don Gagne's avatar
Don Gagne committed

dogmaphobic's avatar
dogmaphobic committed
                    property Fact fact: controller.getParameterFact(-1, "NAV_DLL_OBC")
                }
Don Gagne's avatar
Don Gagne committed
            }
dogmaphobic's avatar
dogmaphobic committed
    }