QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MockLink.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8Rectangle {
9 color: qgcPal.window
10 anchors.fill: parent
11
12 readonly property real _margins: ScreenTools.defaultFontPixelHeight
13
14 QGCPalette { id: qgcPal; colorGroupEnabled: true }
15
16 QGCFlickable {
17 anchors.fill: parent
18 contentWidth: column.width + (_margins * 2)
19 contentHeight: column.height + (_margins * 2)
20 clip: true
21
22 ColumnLayout {
23 id: column
24 anchors.margins: _margins
25 anchors.left: parent.left
26 anchors.top: parent.top
27 spacing: ScreenTools.defaultFontPixelHeight / 4
28
29 QGCCheckBox {
30 id: sendStatusText
31 text: qsTr("Send status text + voice")
32 }
33 QGCCheckBox {
34 id: enableCamera
35 text: qsTr("Enable camera")
36 }
37 QGCCheckBox {
38 id: enableGimbal
39 text: qsTr("Enable gimbal")
40 }
41 QGCCheckBox {
42 id: enableProximity
43 text: qsTr("Enable proximity sensors")
44 }
45 QGCCheckBox {
46 id: apmStartFreshParams
47 text: qsTr("Start with fresh firmware parameters (setup required)")
48 visible: vehicleTypeCombo.apmSelected
49
50 onVisibleChanged: {
51 if (!visible) {
52 checked = false
53 }
54 }
55 }
56 LabelledComboBox {
57 id: vehicleTypeCombo
58 label: qsTr("Vehicle Type")
59 Layout.fillWidth: true
60 model: _vehicleNames
61
62 readonly property var _vehicleEntries: {
63 let entries = []
64 if (QGroundControl.px4ProFirmwareSupported) {
65 entries.push({ key: "px4", name: qsTr("PX4 Vehicle") })
66 }
67 if (QGroundControl.apmFirmwareSupported) {
68 entries.push({ key: "apmCopter", name: qsTr("APM ArduCopter Vehicle") })
69 entries.push({ key: "apmPlane", name: qsTr("APM ArduPlane Vehicle") })
70 entries.push({ key: "apmSub", name: qsTr("APM ArduSub Vehicle") })
71 entries.push({ key: "apmRover", name: qsTr("APM ArduRover Vehicle") })
72 }
73 entries.push({ key: "generic", name: qsTr("Generic Vehicle") })
74 return entries
75 }
76 readonly property var _vehicleNames: _vehicleEntries.map(entry => entry.name)
77 // Entries are ordered supported firmwares first, Generic last resort
78 readonly property string selectedKey: currentIndex >= 0 ? _vehicleEntries[currentIndex].key : _vehicleEntries[0].key
79 readonly property bool apmSelected: selectedKey.startsWith("apm")
80 }
81 LabelledComboBox {
82 id: videoStreamTypeCombo
83 label: qsTr("Served Video Stream")
84 Layout.fillWidth: true
85 visible: enableCamera.checked
86 model: [
87 qsTr("Disabled"),
88 qsTr("RTP/UDP H.264"),
89 qsTr("RTP/UDP H.265"),
90 qsTr("RTSP (H.264)"),
91 qsTr("MPEG-TS (UDP)"),
92 qsTr("MPEG-TS (TCP)")
93 ]
94 }
95 QGCButton {
96 text: qsTr("Start MockLink")
97 Layout.fillWidth: true
98 onClicked: {
99 switch (vehicleTypeCombo.selectedKey) {
100 case "px4":
101 QGroundControl.startPX4MockLink(sendStatusText.checked, enableCamera.checked, enableGimbal.checked, enableProximity.checked, videoStreamTypeCombo.currentIndex)
102 break
103 case "apmCopter":
104 QGroundControl.startAPMArduCopterMockLink(sendStatusText.checked, enableCamera.checked, enableGimbal.checked, enableProximity.checked, apmStartFreshParams.checked, videoStreamTypeCombo.currentIndex)
105 break
106 case "apmPlane":
107 QGroundControl.startAPMArduPlaneMockLink(sendStatusText.checked, enableCamera.checked, enableGimbal.checked, enableProximity.checked, apmStartFreshParams.checked, videoStreamTypeCombo.currentIndex)
108 break
109 case "apmSub":
110 QGroundControl.startAPMArduSubMockLink(sendStatusText.checked, enableCamera.checked, enableGimbal.checked, enableProximity.checked, apmStartFreshParams.checked, videoStreamTypeCombo.currentIndex)
111 break
112 case "apmRover":
113 QGroundControl.startAPMArduRoverMockLink(sendStatusText.checked, enableCamera.checked, enableGimbal.checked, enableProximity.checked, apmStartFreshParams.checked, videoStreamTypeCombo.currentIndex)
114 break
115 default:
116 QGroundControl.startGenericMockLink(sendStatusText.checked, enableCamera.checked, enableGimbal.checked, enableProximity.checked, videoStreamTypeCombo.currentIndex)
117 break
118 }
119 }
120 }
121 QGCButton {
122 text: qsTr("Stop One MockLink")
123 Layout.fillWidth: true
124 onClicked: QGroundControl.stopOneMockLink()
125 }
126 }
127 }
128}