MAVLinkInspectorPage.qml 12.9 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10 11 12 13
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

import QtQuick                      2.11
import QtQuick.Controls             2.4
import QtQuick.Layouts              1.11
import QtQuick.Dialogs              1.3
14
import QtQuick.Window               2.2
15
import QtCharts                     2.3
16 17 18 19 20 21 22

import QGroundControl               1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.ScreenTools   1.0

23 24 25
AnalyzePage {
    headerComponent:    headerComponent
    pageComponent:      pageComponent
26

27
    property var    curVehicle:         controller ? controller.activeVehicle : null
Gus Grubba's avatar
Gus Grubba committed
28
    property var    curMessage:         curVehicle && curVehicle.messages.count ? curVehicle.messages.get(curVehicle.selected) : null
29 30
    property int    curCompID:          0
    property real   maxButtonWidth:     0
31 32 33 34 35

    MAVLinkInspectorController {
        id: controller
    }

36 37 38
    Component {
        id:  headerComponent
        //-- Header
39
        RowLayout {
40 41 42
            id:                 header
            anchors.left:       parent.left
            anchors.right:      parent.right
43
            QGCLabel {
44
                text:           qsTr("Inspect real time MAVLink messages.")
45
            }
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
            RowLayout {
                Layout.alignment:   Qt.AlignRight
                visible:            curVehicle ? curVehicle.compIDsStr.length > 2 : false
                QGCLabel {
                    text:           qsTr("Component ID:")
                }
                QGCComboBox {
                    id:             cidCombo
                    model:          curVehicle ? curVehicle.compIDsStr : []
                    Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10
                    currentIndex:   0
                    onActivated: {
                        if(curVehicle && curVehicle.compIDsStr.length > 1) {
                            if(index < 1)
                                curCompID = 0
                            else
                                curCompID = curVehicle.compIDs[index - 1]
                        }
64 65 66 67
                    }
                }
            }
        }
68
    }
Gus Grubba's avatar
Gus Grubba committed
69

70 71
    Component {
        id:                         pageComponent
Gus Grubba's avatar
Gus Grubba committed
72
        Row {
73 74
            width:                  availableWidth
            height:                 availableHeight
75
            spacing:                ScreenTools.defaultFontPixelWidth
76 77 78
            //-- Messages (Buttons)
            QGCFlickable {
                id:                 buttonGrid
Gus Grubba's avatar
Gus Grubba committed
79
                flickableDirection: Flickable.VerticalFlick
80
                width:              maxButtonWidth
Gus Grubba's avatar
Gus Grubba committed
81
                height:             parent.height
82 83 84 85 86 87 88 89 90 91
                contentWidth:       width
                contentHeight:      buttonCol.height
                ColumnLayout {
                    id:             buttonCol
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        ScreenTools.defaultFontPixelHeight * 0.25
                    Repeater {
                        model:      curVehicle ? curVehicle.messages : []
                        delegate:   MAVLinkMessageButton {
Gus Grubba's avatar
Gus Grubba committed
92
                            text:       object.name + (object.fieldSelected ?  " *" : "")
93
                            compID:     object.cid
Gus Grubba's avatar
Gus Grubba committed
94
                            checked:    curVehicle ? (curVehicle.selected === index) : false
95 96 97
                            messageHz:  object.messageHz
                            visible:    curCompID === 0 || curCompID === compID
                            onClicked: {
Gus Grubba's avatar
Gus Grubba committed
98
                                curVehicle.selected = index
99 100 101
                            }
                            Layout.fillWidth: true
                        }
102
                    }
103 104
                }
            }
105 106 107
            //-- Message Data
            QGCFlickable {
                id:                 messageGrid
Gus Grubba's avatar
Gus Grubba committed
108
                visible:            curMessage !== null && (curCompID === 0 || curCompID === curMessage.cid)
Gus Grubba's avatar
Gus Grubba committed
109 110 111 112
                flickableDirection: Flickable.VerticalFlick
                width:              parent.width - buttonGrid.width - ScreenTools.defaultFontPixelWidth
                height:             parent.height
                contentWidth:       width
113
                contentHeight:      messageCol.height
Gus Grubba's avatar
Gus Grubba committed
114
                Column {
115
                    id:                 messageCol
Gus Grubba's avatar
Gus Grubba committed
116
                    width:              parent.width
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
                    spacing:            ScreenTools.defaultFontPixelHeight * 0.25
                    GridLayout {
                        columns:        2
                        columnSpacing:  ScreenTools.defaultFontPixelWidth
                        rowSpacing:     ScreenTools.defaultFontPixelHeight * 0.25
                        QGCLabel {
                            text:       qsTr("Message:")
                            Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20
                        }
                        QGCLabel {
                            color:      qgcPal.buttonHighlight
                            text:       curMessage ? curMessage.name + ' (' + curMessage.id + ') ' + curMessage.messageHz.toFixed(1) + 'Hz' : ""
                        }
                        QGCLabel {
                            text:       qsTr("Component:")
                        }
                        QGCLabel {
                            text:       curMessage ? curMessage.cid : ""
                        }
                        QGCLabel {
                            text:       qsTr("Count:")
                        }
                        QGCLabel {
                            text:       curMessage ? curMessage.count : ""
                        }
142
                    }
143
                    Item { height: ScreenTools.defaultFontPixelHeight; width: 1 }
144
                    //---------------------------------------------------------
145
                    GridLayout {
Gus Grubba's avatar
Gus Grubba committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
                        id:                 msgInfoGrid
                        columns:            5
                        columnSpacing:      ScreenTools.defaultFontPixelWidth  * 0.25
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.25
                        width:              parent.width
                        QGCLabel {
                            text:       qsTr("Name")
                        }
                        QGCLabel {
                            text:       qsTr("Value")
                        }
                        QGCLabel {
                            text:       qsTr("Type")
                        }
                        QGCLabel {
                            text:       qsTr("Plot 1")
                        }
                        QGCLabel {
                            text:       qsTr("Plot 2")
                        }

                        //---------------------------------------------------------
                        Rectangle {
                            Layout.columnSpan:  5
                            Layout.fillWidth:   true
                            height:             1
                            color:              qgcPal.text
                        }
                        //---------------------------------------------------------

176 177 178
                        Repeater {
                            model:      curMessage ? curMessage.fields : []
                            delegate:   QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
179
                                Layout.row:         index + 2
180 181 182 183 184 185 186 187
                                Layout.column:      0
                                Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20
                                text:               object.name
                            }
                        }
                        Repeater {
                            model:      curMessage ? curMessage.fields : []
                            delegate:   QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
188
                                Layout.row:         index + 2
189
                                Layout.column:      1
Gus Grubba's avatar
Gus Grubba committed
190 191
                                Layout.minimumWidth: msgInfoGrid.width * 0.25
                                Layout.maximumWidth: msgInfoGrid.width * 0.25
192
                                text:               object.value
Gus Grubba's avatar
Gus Grubba committed
193
                                elide:              Text.ElideRight
194 195 196 197 198
                            }
                        }
                        Repeater {
                            model:      curMessage ? curMessage.fields : []
                            delegate:   QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
199
                                Layout.row:         index + 2
200
                                Layout.column:      2
Gus Grubba's avatar
Gus Grubba committed
201
                                Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10
202
                                text:               object.type
Gus Grubba's avatar
Gus Grubba committed
203
                                elide:              Text.ElideRight
204 205
                            }
                        }
206 207 208
                        Repeater {
                            model:      curMessage ? curMessage.fields : []
                            delegate:   QGCCheckBox {
Gus Grubba's avatar
Gus Grubba committed
209
                                Layout.row:         index + 2
210
                                Layout.column:      3
Gus Grubba's avatar
Gus Grubba committed
211
                                Layout.alignment:   Qt.AlignHCenter
Gus Grubba's avatar
Gus Grubba committed
212 213 214 215 216 217 218 219 220 221 222 223 224
                                enabled: {
                                    if(checked)
                                        return true
                                    if(!object.selectable)
                                        return false
                                    if(object.series !== null)
                                        return false
                                    if(chart1.chartController !== null) {
                                        if(chart1.chartController.chartFields.length >= chart1.seriesColors.length)
                                            return false
                                    }
                                    return true;
                                }
225
                                checked:            object.series !== null && object.chartIndex === 0
226
                                onClicked: {
Gus Grubba's avatar
Gus Grubba committed
227 228 229 230
                                    if(checked) {
                                        chart1.addDimension(object)
                                    } else {
                                        chart1.delDimension(object)
231 232 233 234 235 236 237
                                    }
                                }
                            }
                        }
                        Repeater {
                            model:      curMessage ? curMessage.fields : []
                            delegate:   QGCCheckBox {
Gus Grubba's avatar
Gus Grubba committed
238
                                Layout.row:         index + 2
239
                                Layout.column:      4
Gus Grubba's avatar
Gus Grubba committed
240
                                Layout.alignment:   Qt.AlignHCenter
Gus Grubba's avatar
Gus Grubba committed
241 242 243 244 245 246 247 248 249 250 251 252 253
                                enabled: {
                                    if(checked)
                                        return true
                                    if(!object.selectable)
                                        return false
                                    if(object.series !== null)
                                        return false
                                    if(chart2.chartController !== null) {
                                        if(chart2.chartController.chartFields.length >= chart2.seriesColors.length)
                                            return false
                                    }
                                    return true;
                                }
254
                                checked:            object.series !== null && object.chartIndex === 1
255
                                onClicked: {
Gus Grubba's avatar
Gus Grubba committed
256 257 258 259
                                    if(checked) {
                                        chart2.addDimension(object)
                                    } else {
                                        chart2.delDimension(object)
260 261
                                    }
                                }
262 263
                            }
                        }
264
                    }
265
                    Item { height: ScreenTools.defaultFontPixelHeight * 0.25; width: 1 }
Gus Grubba's avatar
Gus Grubba committed
266 267 268
                    MAVLinkChart {
                        id:         chart1
                        height:     ScreenTools.defaultFontPixelHeight * 20
Gus Grubba's avatar
Gus Grubba committed
269
                        width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
270 271 272 273
                    }
                    MAVLinkChart {
                        id:         chart2
                        height:     ScreenTools.defaultFontPixelHeight * 20
Gus Grubba's avatar
Gus Grubba committed
274
                        width:      parent.width
275
                    }
276 277 278 279 280
                }
            }
        }
    }
}