SafetyComponent.qml 12.6 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/>.

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

Don Gagne's avatar
Don Gagne committed
24 25 26
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
27

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

Don Gagne's avatar
Don Gagne committed
34 35
FactPanel {
    id:     panel
Don Gagne's avatar
Don Gagne committed
36

Don Gagne's avatar
Don Gagne committed
37 38
    QGCPalette { id: palette; colorGroupEnabled: true }
    FactPanelController { id: controller; factPanel: panel }
Don Gagne's avatar
Don Gagne committed
39 40 41 42 43 44 45 46 47 48

    property int flightLineWidth: 2             // width of lines for flight graphic
    property int loiterAltitudeColumnWidth: 180 // width of loiter altitude column
    property int shadedMargin: 20               // margin inset for shaded areas
    property int controlVerticalSpacing: 10     // vertical spacing between controls
    property int homeWidth: 50                  // width of home graphic
    property int planeWidth: 40                 // width of plane graphic
    property int arrowToHomeSpacing: 20         // space between down arrow and home graphic
    property int arrowWidth: 18                 // width for arrow graphic
    property int firstColumnWidth: 220          // Width of first column in return home triggers area
Don Gagne's avatar
Don Gagne committed
49 50

    Column {
51
        anchors.fill: parent
Don Gagne's avatar
Don Gagne committed
52 53 54

        QGCLabel {
            text: "SAFETY CONFIG"
Don Gagne's avatar
Don Gagne committed
55
            font.pointSize: ScreenTools.largeFontPointSize
Don Gagne's avatar
Don Gagne committed
56 57 58 59
        }

        Item { height: 20; width: 10 } // spacer

60 61
        //-----------------------------------------------------------------
        //-- Return Home Triggers
Don Gagne's avatar
Don Gagne committed
62

Don Gagne's avatar
Don Gagne committed
63
        QGCLabel { text: "Triggers For Return Home"; font.pointSize: ScreenTools.mediumFontPointSize; }
Don Gagne's avatar
Don Gagne committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

        Item { height: 10; width: 10 } // spacer

        Rectangle {
            width: parent.width
            height: triggerColumn.height
            color: palette.windowShade

            Column {
                id: triggerColumn
                spacing: controlVerticalSpacing
                anchors.margins: shadedMargin
                anchors.left: parent.left

                // Top margin
                Item { height: 1; width: 10 }

                Row {
                    spacing: 10
                    QGCLabel { text: "RC Transmitter Signal Loss"; width: firstColumnWidth; anchors.baseline: rcLossField.baseline }
                    QGCLabel { text: "Return Home after"; anchors.baseline: rcLossField.baseline }
                    FactTextField {
Don Gagne's avatar
Don Gagne committed
86 87 88
                        id:         rcLossField
                        fact:       controller.getParameterFact(-1, "COM_RC_LOSS_T")
                        showUnits:  true
Don Gagne's avatar
Don Gagne committed
89
                    }
90
                }
Don Gagne's avatar
Don Gagne committed
91 92 93 94

                Row {
                    spacing: 10
                    FactCheckBox {
Don Gagne's avatar
Don Gagne committed
95 96 97 98 99 100 101
                        id:                 telemetryTimeoutCheckbox
                        anchors.baseline:   telemetryLossField.baseline
                        width:              firstColumnWidth
                        fact:               controller.getParameterFact(-1, "COM_DL_LOSS_EN")
                        checkedValue:       1
                        uncheckedValue:     0
                        text:               "Telemetry Signal Timeout"
Don Gagne's avatar
Don Gagne committed
102 103 104
                    }
                    QGCLabel { text: "Return Home after"; anchors.baseline: telemetryLossField.baseline }
                    FactTextField {
Don Gagne's avatar
Don Gagne committed
105 106 107 108
                        id:         telemetryLossField
                        fact:       controller.getParameterFact(-1, "COM_DL_LOSS_T")
                        showUnits:  true
                        enabled:    telemetryTimeoutCheckbox.checked
Don Gagne's avatar
Don Gagne committed
109
                    }
110
                }
Don Gagne's avatar
Don Gagne committed
111 112 113

                // Bottom margin
                Item { height: 1; width: 10 }
114
            }
115
        }
Don Gagne's avatar
Don Gagne committed
116 117 118

        Item { height: 20; width: 10 }    // spacer

119
        //-----------------------------------------------------------------
Don Gagne's avatar
Don Gagne committed
120 121
        //-- Return Home Settings

Don Gagne's avatar
Don Gagne committed
122
        QGCLabel { text: "Return Home Settings"; font.pointSize: ScreenTools.mediumFontPointSize; }
Don Gagne's avatar
Don Gagne committed
123 124 125 126

        Item { height: 10; width: 10 } // spacer

        Rectangle {
Don Gagne's avatar
Don Gagne committed
127
            width:  parent.width
Don Gagne's avatar
Don Gagne committed
128
            height: settingsColumn.height
Don Gagne's avatar
Don Gagne committed
129
            color:  palette.windowShade
Don Gagne's avatar
Don Gagne committed
130 131

            Column {
Don Gagne's avatar
Don Gagne committed
132 133 134 135
                id:                 settingsColumn
                width:              parent.width
                anchors.margins:    shadedMargin
                anchors.left:       parent.left
Don Gagne's avatar
Don Gagne committed
136 137 138 139 140

                Item { height: shadedMargin; width: 10 } // top margin

                // This item is the holder for the climb alt and loiter seconds fields
                Item {
Don Gagne's avatar
Don Gagne committed
141
                    width:  parent.width
Don Gagne's avatar
Don Gagne committed
142 143 144
                    height: climbAltitudeColumn.height

                    Column {
Don Gagne's avatar
Don Gagne committed
145 146
                        id:         climbAltitudeColumn
                        spacing:    controlVerticalSpacing
Don Gagne's avatar
Don Gagne committed
147 148 149

                        QGCLabel { text: "Climb to altitude of" }
                        FactTextField {
Don Gagne's avatar
Don Gagne committed
150 151 152
                            id:         climbField
                            fact:       controller.getParameterFact(-1, "RTL_RETURN_ALT")
                            showUnits:  true
Don Gagne's avatar
Don Gagne committed
153
                        }
154
                    }
Don Gagne's avatar
Don Gagne committed
155 156 157


                    Column {
Don Gagne's avatar
Don Gagne committed
158 159
                        x:          flightGraphic.width - 200
                        spacing:    controlVerticalSpacing
Don Gagne's avatar
Don Gagne committed
160 161

                        QGCCheckBox {
Don Gagne's avatar
Don Gagne committed
162 163 164 165 166
                            id:         homeLoiterCheckbox
                            checked:    fact.value > 0
                            text:       "Loiter at Home altitude for"

                            property Fact fact: controller.getParameterFact(-1, "RTL_LAND_DELAY")
167

Don Gagne's avatar
Don Gagne committed
168 169 170 171
                            onClicked: {
                                fact.value = checked ? 60 : -1
                            }
                        }
Don Gagne's avatar
Don Gagne committed
172

Don Gagne's avatar
Don Gagne committed
173
                        FactTextField {
Don Gagne's avatar
Don Gagne committed
174 175 176
                            fact:       controller.getParameterFact(-1, "RTL_LAND_DELAY")
                            showUnits:  true
                            enabled:    homeLoiterCheckbox.checked == true
177 178 179
                        }
                    }
                }
Don Gagne's avatar
Don Gagne committed
180 181 182 183 184

                Item { height: 20; width: 10 }    // spacer

                // This row holds the flight graphic and the home loiter alt column
                Row {
Don Gagne's avatar
Don Gagne committed
185 186
                    width:      parent.width
                    spacing:    20
Don Gagne's avatar
Don Gagne committed
187 188 189

                    // Flight graphic
                    Item {
Don Gagne's avatar
Don Gagne committed
190 191
                        id:     flightGraphic
                        width:  parent.width - loiterAltitudeColumnWidth
Don Gagne's avatar
Don Gagne committed
192 193 194
                        height: 200 // controls the height of the flight graphic

                        Rectangle {
Don Gagne's avatar
Don Gagne committed
195
                            x:      planeWidth / 2
Don Gagne's avatar
Don Gagne committed
196
                            height: planeImage.y - 5
Don Gagne's avatar
Don Gagne committed
197 198
                            width:  flightLineWidth
                            color:  palette.button
Don Gagne's avatar
Don Gagne committed
199 200
                        }
                        Rectangle {
Don Gagne's avatar
Don Gagne committed
201
                            x:      planeWidth / 2
Don Gagne's avatar
Don Gagne committed
202
                            height: flightLineWidth
Don Gagne's avatar
Don Gagne committed
203 204
                            width:  parent.width - x
                            color:  palette.button
Don Gagne's avatar
Don Gagne committed
205 206
                        }
                        Rectangle {
Don Gagne's avatar
Don Gagne committed
207
                            x:      parent.width - flightLineWidth
Don Gagne's avatar
Don Gagne committed
208
                            height: parent.height - homeWidth - arrowToHomeSpacing
Don Gagne's avatar
Don Gagne committed
209 210
                            width:  flightLineWidth
                            color:  palette.button
Don Gagne's avatar
Don Gagne committed
211 212 213
                        }

                        QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
214 215 216 217 218 219 220 221
                            id:         planeImage
                            y:          parent.height - planeWidth - 40
                            source:     "/qml/SafetyComponentPlane.png"
                            fillMode:   Image.PreserveAspectFit
                            width:      planeWidth
                            height:     planeWidth
                            smooth:     true
                            color:      palette.button
Don Gagne's avatar
Don Gagne committed
222 223 224
                        }

                        QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
225 226 227 228 229 230 231 232
                            x:          planeWidth + 70
                            y:          parent.height - height - 20
                            width:      80
                            height:     parent.height / 2
                            source:     "/qml/SafetyComponentTree.svg"
                            fillMode:   Image.Stretch
                            smooth:     true
                            color:      palette.windowShadeDark
Don Gagne's avatar
Don Gagne committed
233 234 235
                        }

                        QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
236 237 238 239 240 241 242 243
                            x:          planeWidth + 15
                            y:          parent.height - height
                            width:      100
                            height:     parent.height * .75
                            source:     "/qml/SafetyComponentTree.svg"
                            fillMode:   Image.PreserveAspectFit
                            smooth:     true
                            color:      palette.button
Don Gagne's avatar
Don Gagne committed
244 245 246
                        }

                        QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
247 248 249 250 251 252 253 254
                            x:          parent.width - (arrowWidth/2) - 1
                            y:          parent.height - homeWidth - arrowToHomeSpacing - 2
                            source:     "/qml/SafetyComponentArrowDown.png"
                            fillMode:   Image.PreserveAspectFit
                            width:      arrowWidth
                            height:     arrowWidth
                            smooth:     true
                            color:      palette.button
Don Gagne's avatar
Don Gagne committed
255 256 257
                        }

                        QGCColoredImage {
Don Gagne's avatar
Don Gagne committed
258 259 260 261 262 263 264 265 266
                            id:         homeImage
                            x:          parent.width - (homeWidth / 2)
                            y:          parent.height - homeWidth
                            source:     "/qml/SafetyComponentHome.png"
                            fillMode:   Image.PreserveAspectFit
                            width:      homeWidth
                            height:     homeWidth
                            smooth:     true
                            color:  palette.button
Don Gagne's avatar
Don Gagne committed
267 268 269 270 271 272 273
                        }
                    }

                    Column {
                        spacing: controlVerticalSpacing

                        QGCLabel {
Don Gagne's avatar
Don Gagne committed
274 275 276
                            text:       "Home loiter altitude";
                            color:      palette.text;
                            enabled:    homeLoiterCheckbox.checked === true
Don Gagne's avatar
Don Gagne committed
277 278
                        }
                        FactTextField {
Don Gagne's avatar
Don Gagne committed
279 280 281 282
                            id:         descendField;
                            fact:       controller.getParameterFact(-1, "RTL_DESCEND_ALT")
                            enabled:    homeLoiterCheckbox.checked === true
                            showUnits:  true
Don Gagne's avatar
Don Gagne committed
283 284
                        }
                    }
285
                }
Don Gagne's avatar
Don Gagne committed
286 287

                Item { height: shadedMargin; width: 10 } // bottom margin
288 289 290
            }
        }

Don Gagne's avatar
Don Gagne committed
291
        QGCLabel {
Don Gagne's avatar
Don Gagne committed
292 293 294 295 296 297 298
            width:          parent.width
            font.pointSize: ScreenTools.mediumFontPointSize
            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

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

Don Gagne's avatar
Don Gagne committed
301
        QGCLabel {
Don Gagne's avatar
Don Gagne committed
302 303 304 305 306 307 308
            width:          parent.width
            font.pointSize: ScreenTools.mediumFontPointSize
            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

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