SafetyComponent.qml 14.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*=====================================================================

 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
24
import QtQuick 2.5
Don Gagne's avatar
Don Gagne committed
25 26
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
dogmaphobic's avatar
dogmaphobic committed
27 28
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
29

Don Gagne's avatar
Don Gagne committed
30
import QGroundControl.FactSystem 1.0
31
import QGroundControl.FactControls 1.0
32
import QGroundControl.Palette 1.0
Don Gagne's avatar
Don Gagne committed
33
import QGroundControl.Controls 1.0
34
import QGroundControl.ScreenTools 1.0
Don Gagne's avatar
Don Gagne committed
35

Don Gagne's avatar
Don Gagne committed
36

dogmaphobic's avatar
dogmaphobic committed
37
QGCView {
Don Gagne's avatar
Don Gagne committed
38 39 40
    id:             _safetyView
    viewPanel:      panel
    anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
41

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

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

Don Gagne's avatar
Don Gagne committed
46 47
    property real _margins: ScreenTools.defaultFontPixelHeight

Don Gagne's avatar
Don Gagne committed
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")
dogmaphobic's avatar
dogmaphobic committed
52 53 54 55 56

    QGCViewPanel {
        id:             panel
        anchors.fill:   parent

Don Gagne's avatar
Don Gagne committed
57
        QGCFlickable {
dogmaphobic's avatar
dogmaphobic committed
58 59
            clip:               true
            anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
60
            contentHeight:      screenBottom.y + screenBottom.height
dogmaphobic's avatar
dogmaphobic committed
61 62 63
            contentWidth:       parent.width
            flickableDirection: Flickable.VerticalFlick

Don Gagne's avatar
Don Gagne committed
64 65
            QGCLabel {
                id:             triggerLabel
66
                text:           qsTr("Triggers For Return Home")
Don Gagne's avatar
Don Gagne committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80
                font.weight:    Font.DemiBold
            }

            Rectangle {
                id:                     triggerSettings
                anchors.topMargin:      _margins / 2
                anchors.rightMargin:    _margins
                anchors.left:           parent.left
                anchors.top:            triggerLabel.bottom
                anchors.bottom:         geoFenceSettings.bottom
                width:                  telemetryLossField.x + telemetryLossField.width + (_margins * 2)
                color:                  palette.windowShade

                QGCLabel {
81
                    text:               qsTr("RC Transmitter Signal Loss: Return Home after")
Don Gagne's avatar
Don Gagne committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.baseline:   rcLossField.baseline
                }

                FactTextField {
                    id:                 rcLossField
                    anchors.topMargin:  _margins
                    anchors.top:        parent.top
                    anchors.left:       telemetryLossField.left
                    fact:               controller.getParameterFact(-1, "COM_RC_LOSS_T")
                    showUnits:          true
                }

                FactCheckBox {
                    id:                 telemetryTimeoutCheckbox
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.baseline:   telemetryLossField.baseline
                    fact:               controller.getParameterFact(-1, "COM_DL_LOSS_EN")
                    checkedValue:       1
                    uncheckedValue:     0
104
                    text:               qsTr("Telemetry Signal Timeout: Return Home after")
dogmaphobic's avatar
dogmaphobic committed
105
                }
Don Gagne's avatar
Don Gagne committed
106

Don Gagne's avatar
Don Gagne committed
107 108 109 110 111 112 113 114 115
                FactTextField {
                    id:                 telemetryLossField
                    anchors.leftMargin: _margins
                    anchors.topMargin:  _margins / 2
                    anchors.left:       telemetryTimeoutCheckbox.right
                    anchors.top:        rcLossField.bottom
                    fact:               controller.getParameterFact(-1, "COM_DL_LOSS_T")
                    showUnits:          true
                    enabled:            telemetryTimeoutCheckbox.checked
Don Gagne's avatar
Don Gagne committed
116
                }
Don Gagne's avatar
Don Gagne committed
117 118 119 120 121 122 123
            } // Rectangle - Trigger settings

            QGCLabel {
                id:                 geoFenceLabel
                anchors.leftMargin: _margins
                anchors.left:       triggerSettings.right
                anchors.top:        parent.top
124
                text:               qsTr("GeoFence")
Don Gagne's avatar
Don Gagne committed
125 126 127 128 129 130 131 132 133 134 135
                font.weight:        Font.DemiBold
            }

            Rectangle {
                id:                 geoFenceSettings
                anchors.topMargin:  _margins / 2
                anchors.left:       geoFenceLabel.left
                anchors.top:        geoFenceLabel.bottom
                width:              fenceActionCombo.x + fenceActionCombo.width + _margins
                height:             fenceAltMaxField.y + fenceAltMaxField.height + _margins
                color:              palette.windowShade
136

dogmaphobic's avatar
dogmaphobic committed
137
                QGCLabel {
Don Gagne's avatar
Don Gagne committed
138 139 140 141
                    id:                 fenceActionLabel
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.baseline:   fenceActionCombo.baseline
142
                    text:               qsTr("Action on breach:")
Don Gagne's avatar
Don Gagne committed
143
                }
Don Gagne's avatar
Don Gagne committed
144

Don Gagne's avatar
Don Gagne committed
145 146 147 148 149 150
                FactComboBox {
                    id:                 fenceActionCombo
                    anchors.margins:    _margins
                    anchors.left:       fenceActionLabel.right
                    anchors.top:        parent.top
                    width:              fenceAltMaxField.width
151
                    model:              [ qsTr("None"), qsTr("Warning"), qsTr("Loiter"), qsTr("Return Home"), qsTr("Flight termination") ]
Don Gagne's avatar
Don Gagne committed
152 153 154 155 156 157 158
                    fact:               _fenceAction
                }

                QGCCheckBox {
                    id:                 fenceRadiusCheckBox
                    anchors.left:       fenceActionLabel.left
                    anchors.baseline:   fenceRadiusField.baseline
159
                    text:               qsTr("Max radius:")
Don Gagne's avatar
Don Gagne committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
                    checked:            _fenceRadius.value >= 0

                    onClicked: _fenceRadius.value = checked ? 100 : -1
                }

                FactTextField {
                    id:                 fenceRadiusField
                    anchors.topMargin:  _margins
                    anchors.left:       fenceActionCombo.left
                    anchors.top:        fenceActionCombo.bottom
                    showUnits:          true
                    fact:               _fenceRadius
                    enabled:            fenceRadiusCheckBox.checked
                }

                QGCCheckBox {
                    id:                 fenceAltMaxCheckBox
                    anchors.left:       fenceActionLabel.left
                    anchors.baseline:   fenceAltMaxField.baseline
179
                    text:               qsTr("Max altitude:")
Don Gagne's avatar
Don Gagne committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
                    checked:            _fenceAlt.value >= 0

                    onClicked: _fenceAlt.value = checked ? 100 : -1
                }

                FactTextField {
                    id:                 fenceAltMaxField
                    anchors.topMargin:  _margins / 2
                    anchors.left:       fenceActionCombo.left
                    anchors.top:        fenceRadiusField.bottom
                    showUnits:          true
                    fact:               _fenceAlt
                    enabled:            fenceAltMaxCheckBox.checked
                }
            } // Rectangle - GeoFence Settings

            QGCLabel {
                id:                 rtlLabel
                anchors.topMargin:  _margins
                anchors.top:        triggerSettings.bottom
200
                text:               qsTr("Return Home Settings")
Don Gagne's avatar
Don Gagne committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
                font.weight:        Font.DemiBold
            }

            Rectangle {
                id:                 rtlSettings
                anchors.topMargin:  _margins / 2
                anchors.left:       parent.left
                anchors.top:        rtlLabel.bottom
                width:              landDelayField.x + landDelayField.width + _margins
                height:             descendField.y + descendField.height + _margins
                color:              palette.windowShade

                Image {
                    id:                 icon
                    anchors.margins:    _margins
                    anchors.left:       parent.left
                    anchors.top:        parent.top
                    height:             ScreenTools.defaultFontPixelWidth * 10
                    width:              ScreenTools.defaultFontPixelWidth * 20
                    mipmap:             true
                    fillMode:           Image.PreserveAspectFit
                    visible:            false
                    source:             "/qmlimages/ReturnToHomeAltitude.svg"
                }

                ColorOverlay {
                    anchors.fill:   icon
                    source:         icon
                    color:          palette.text
                }

                QGCLabel {
                    id:                 climbLabel
                    anchors.margins:    _margins
                    anchors.left:       icon.right
                    anchors.baseline:   climbField.baseline
237
                    text:               qsTr("Climb to altitude of")
Don Gagne's avatar
Don Gagne committed
238 239 240 241 242 243 244 245 246 247 248
                }

                FactTextField {
                    id:                 climbField
                    anchors.topMargin:  _margins
                    anchors.top:        parent.top
                    anchors.left:       landDelayField.left
                    fact:               controller.getParameterFact(-1, "RTL_RETURN_ALT")
                    showUnits:          true
                }

Don Gagne's avatar
Don Gagne committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
                QGCLabel {
                    id:                 returnHomeLabel
                    anchors.topMargin:  _margins
                    anchors.top:        climbField.bottom
                    anchors.left:       climbLabel.left
                    text:               "Return Home, then:"
                }

                ExclusiveGroup { id: homeLoiterGroup }

                QGCRadioButton {
                    id:                 homeLoiterNoLandRadio
                    anchors.topMargin:  _margins
                    anchors.top:        returnHomeLabel.bottom
                    anchors.left:       climbLabel.left
                    checked:            _rtlLandDelay.value < 0
                    exclusiveGroup:     homeLoiterGroup
                    text:               "Loiter at Home altitude, do not land"

                    onClicked: _rtlLandDelay.value = -1
                }

                QGCRadioButton {
                    id:                 homeLoiterLandRadio
Don Gagne's avatar
Don Gagne committed
273 274
                    anchors.baseline:   landDelayField.baseline
                    anchors.left:       climbLabel.left
Don Gagne's avatar
Don Gagne committed
275 276
                    checked:            _rtlLandDelay.value >= 0
                    exclusiveGroup:     homeLoiterGroup
277
                    text:               qsTr("Loiter at Home altitude for")
Don Gagne's avatar
Don Gagne committed
278
                    onClicked: _rtlLandDelay.value = 60
Don Gagne's avatar
Don Gagne committed
279 280 281 282 283
                }

                FactTextField {
                    id:                 landDelayField
                    anchors.margins:    _margins
Don Gagne's avatar
Don Gagne committed
284 285
                    anchors.left:       homeLoiterLandRadio.right
                    anchors.top:        homeLoiterNoLandRadio.bottom
Don Gagne's avatar
Don Gagne committed
286 287
                    fact:               controller.getParameterFact(-1, "RTL_LAND_DELAY")
                    showUnits:          true
Don Gagne's avatar
Don Gagne committed
288
                    enabled:            homeLoiterLandRadio.checked === true
dogmaphobic's avatar
dogmaphobic committed
289
                }
Don Gagne's avatar
Don Gagne committed
290

dogmaphobic's avatar
dogmaphobic committed
291
                QGCLabel {
292
                    text:               qsTr("Home loiter altitude")
Don Gagne's avatar
Don Gagne committed
293 294 295
                    anchors.baseline:   descendField.baseline
                    anchors.left:       climbLabel.left
                    color:              palette.text
Don Gagne's avatar
Don Gagne committed
296
                    enabled:            homeLoiterLandRadio.checked === true
Don Gagne's avatar
Don Gagne committed
297
                }
Don Gagne's avatar
Don Gagne committed
298

Don Gagne's avatar
Don Gagne committed
299 300 301 302 303 304
                FactTextField {
                    id:                 descendField
                    anchors.topMargin:  _margins
                    anchors.left:       landDelayField.left
                    anchors.top:        landDelayField.bottom
                    fact:               controller.getParameterFact(-1, "RTL_DESCEND_ALT")
Don Gagne's avatar
Don Gagne committed
305
                    enabled:            homeLoiterLandRadio.checked === true
Don Gagne's avatar
Don Gagne committed
306
                    showUnits:          true
dogmaphobic's avatar
dogmaphobic committed
307
                }
Don Gagne's avatar
Don Gagne committed
308
            }
Don Gagne's avatar
Don Gagne committed
309 310

            QGCLabel {
Don Gagne's avatar
Don Gagne committed
311 312 313 314 315 316
                id:                 navRclObc
                anchors.topMargin:  _margins
                anchors.top:        rtlSettings.bottom
                anchors.left:       parent.left
                anchors.right:      parent.right
                font.pixelSize:     ScreenTools.mediumFontPixelSize
317
                text:               qsTr("Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply.")
Don Gagne's avatar
Don Gagne committed
318 319
                visible:            fact.value !== 0
                wrapMode:           Text.Wrap
Don Gagne's avatar
Don Gagne committed
320 321 322 323 324

                property Fact fact: controller.getParameterFact(-1, "NAV_RCL_OBC")
            }

            QGCLabel {
Don Gagne's avatar
Don Gagne committed
325 326 327 328 329 330
                id:                 navDllObc
                anchors.topMargin:  _margins / 2
                anchors.top:        navRclObc.bottom
                anchors.left:       parent.left
                anchors.right:      parent.right
                font.pixelSize:     ScreenTools.mediumFontPixelSize
331
                text:               qsTr("Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply.")
Don Gagne's avatar
Don Gagne committed
332 333
                visible:            fact.value !== 0
                wrapMode:           Text.Wrap
Don Gagne's avatar
Don Gagne committed
334 335 336

                property Fact fact: controller.getParameterFact(-1, "NAV_DLL_OBC")
            }
Don Gagne's avatar
Don Gagne committed
337 338 339 340 341 342 343

            Item {
                id:             screenBottom
                anchors.top:    navDllObc.bottom
                width:          1
                height:         1
            }
Don Gagne's avatar
Don Gagne committed
344
        } // QGCFlickable
Don Gagne's avatar
Don Gagne committed
345 346
    } // QGCViewPanel
} // QGCView