SafetyComponent.qml 10.8 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
4

Don Gagne's avatar
Don Gagne committed
5
import QGroundControl.FactSystem 1.0
6
import QGroundControl.FactControls 1.0
7
import QGroundControl.Palette 1.0
Don Gagne's avatar
Don Gagne committed
8
import QGroundControl.Controls 1.0
Don Gagne's avatar
Don Gagne committed
9 10

Rectangle {
11
    QGCPalette { id: palette; colorGroupEnabled: true }
Don Gagne's avatar
Don Gagne committed
12

13
    width: 600
14
    height: 600
Don Gagne's avatar
Don Gagne committed
15
    color: palette.window
Don Gagne's avatar
Don Gagne committed
16 17 18 19 20 21 22 23 24 25

    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
26 27

    Column {
28
        anchors.fill: parent
Don Gagne's avatar
Don Gagne committed
29 30 31 32 33 34 35 36

        QGCLabel {
            text: "SAFETY CONFIG"
            font.pointSize: 20
        }

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

37 38
        //-----------------------------------------------------------------
        //-- Return Home Triggers
Don Gagne's avatar
Don Gagne committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

        QGCLabel { text: "Triggers For Return Home"; color: palette.text; font.pointSize: 20 }

        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 {
                        id: rcLossField
64
                        fact: Fact { name: "COM_RC_LOSS_T" }
Don Gagne's avatar
Don Gagne committed
65 66
                        showUnits: true
                    }
67
                }
Don Gagne's avatar
Don Gagne committed
68 69 70 71

                Row {
                    spacing: 10
                    FactCheckBox {
72
                        id: telemetryTimeoutCheckbox
73
                        fact: Fact { name: "COM_DL_LOSS_EN" }
Don Gagne's avatar
Don Gagne committed
74 75 76 77 78 79 80 81 82
                        checkedValue: 1
                        uncheckedValue: 0
                        text: "Telemetry Signal Timeout"
                        anchors.baseline: telemetryLossField.baseline
                        width: firstColumnWidth
                    }
                    QGCLabel { text: "Return Home after"; anchors.baseline: telemetryLossField.baseline }
                    FactTextField {
                        id: telemetryLossField
83
                        fact: Fact { name: "COM_DL_LOSS_T" }
Don Gagne's avatar
Don Gagne committed
84
                        showUnits: true
85
                        enabled: telemetryTimeoutCheckbox.checked
Don Gagne's avatar
Don Gagne committed
86
                    }
87
                }
Don Gagne's avatar
Don Gagne committed
88 89 90

                // Bottom margin
                Item { height: 1; width: 10 }
91
            }
92
        }
Don Gagne's avatar
Don Gagne committed
93 94 95

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

96
        //-----------------------------------------------------------------
Don Gagne's avatar
Don Gagne committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
        //-- Return Home Settings

        QGCLabel { text: "Return Home Settings"; font.pointSize: 20 }

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

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

            Column {
                id: settingsColumn
                width: parent.width
                anchors.margins: shadedMargin
                anchors.left: parent.left

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

                // This item is the holder for the climb alt and loiter seconds fields
                Item {
                    width: parent.width
                    height: climbAltitudeColumn.height

                    Column {
                        id: climbAltitudeColumn
                        spacing: controlVerticalSpacing

                        QGCLabel { text: "Climb to altitude of" }
                        FactTextField {
                            id: climbField
128
                            fact: Fact { name: "RTL_RETURN_ALT" }
Don Gagne's avatar
Don Gagne committed
129 130
                            showUnits: true
                        }
131
                    }
Don Gagne's avatar
Don Gagne committed
132 133 134 135 136 137 138 139


                    Column {
                        x: flightGraphic.width - 200
                        spacing: controlVerticalSpacing

                        QGCCheckBox {
                            id: homeLoiterCheckbox
140 141
                            property Fact fact: Fact { name: "RTL_LAND_DELAY" }

Don Gagne's avatar
Don Gagne committed
142 143 144 145 146 147 148
                            checked: fact.value > 0
                            text: "Loiter at Home altitude for"
                            onClicked: {
                                fact.value = checked ? 60 : -1
                            }
                        }
                        FactTextField {
149
                            fact: Fact { name: "RTL_LAND_DELAY" }
Don Gagne's avatar
Don Gagne committed
150 151
                            showUnits: true
                            enabled: homeLoiterCheckbox.checked == true
152 153 154
                        }
                    }
                }
Don Gagne's avatar
Don Gagne committed
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254

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

                // This row holds the flight graphic and the home loiter alt column
                Row {
                    width: parent.width
                    spacing: 20

                    // Flight graphic
                    Item {
                        id: flightGraphic
                        width: parent.width - loiterAltitudeColumnWidth
                        height: 200 // controls the height of the flight graphic

                        Rectangle {
                            x: planeWidth / 2
                            height: planeImage.y - 5
                            width: flightLineWidth
                            color: palette.button
                        }
                        Rectangle {
                            x: planeWidth / 2
                            height: flightLineWidth
                            width: parent.width - x
                            color: palette.button
                        }
                        Rectangle {
                            x: parent.width - flightLineWidth
                            height: parent.height - homeWidth - arrowToHomeSpacing
                            width: flightLineWidth
                            color: palette.button
                        }

                        QGCColoredImage {
                            id: planeImage
                            y: parent.height - planeWidth - 40
                            source: "/qml/SafetyComponentPlane.png"
                            fillMode: Image.PreserveAspectFit
                            width: planeWidth
                            height: planeWidth
                            smooth: true
                            color: palette.button
                        }

                        QGCColoredImage {
                            x: planeWidth + 70
                            y: parent.height - height - 20
                            width: 80
                            height: parent.height / 2
                            source: "/qml/SafetyComponentTree.png"
                            fillMode: Image.Stretch
                            smooth: true
                            color: palette.windowShadeDark
                        }

                        QGCColoredImage {
                            x: planeWidth + 15
                            y: parent.height - height
                            width: 100
                            height: parent.height * .75
                            source: "/qml/SafetyComponentTree.png"
                            fillMode: Image.Stretch
                            smooth: true
                            color: palette.button
                        }

                        QGCColoredImage {
                            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
                        }

                        QGCColoredImage {
                            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
                        }
                    }

                    Column {
                        spacing: controlVerticalSpacing

                        QGCLabel {
                            text: "Home loiter altitude";
                            color: palette.text;
                            enabled: homeLoiterCheckbox.checked == true
                        }
                        FactTextField {
                            id: descendField;
255
                            fact: Fact { name: "RTL_DESCEND_ALT" }
Don Gagne's avatar
Don Gagne committed
256 257 258 259
                            enabled: homeLoiterCheckbox.checked == true
                            showUnits: true
                        }
                    }
260
                }
Don Gagne's avatar
Don Gagne committed
261 262

                Item { height: shadedMargin; width: 10 } // bottom margin
263 264 265
            }
        }

Don Gagne's avatar
Don Gagne committed
266
        QGCLabel {
267
            property Fact fact: Fact { name: "NAV_RCL_OBC" }
268
            width: parent.width
269
            font.pointSize: 14
270
            text: "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply.";
271
            visible: fact.value != 0
272 273
            wrapMode: Text.Wrap
        }
Don Gagne's avatar
Don Gagne committed
274
        QGCLabel {
275
            property Fact fact: Fact { name: "NAV_DLL_OBC" }
276
            width: parent.width
277
            font.pointSize: 14
278
            text: "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply.";
279
            visible: fact.value != 0
280 281
            wrapMode: Text.Wrap
        }
Don Gagne's avatar
Don Gagne committed
282 283
    }
}