From 99d161edd4f2188bf7ffc13ba652ea7c5b9095e2 Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Fri, 7 Oct 2016 16:01:10 -0700 Subject: [PATCH 1/8] Add safety component for Sub firmware. --- qgroundcontrol.qrc | 2 + src/AutoPilotPlugins/APM/APMSafetyComponent.cc | 6 + src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml | 385 +++++++++++++++++++++ .../APM/APMSafetyComponentSummarySub.qml | 123 +++++++ 4 files changed, 516 insertions(+) create mode 100644 src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml create mode 100644 src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 5a9a2a3..68ba7f0 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -149,9 +149,11 @@ src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml src/AutoPilotPlugins/APM/APMSafetyComponentPlane.qml src/AutoPilotPlugins/APM/APMSafetyComponentRover.qml + src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml src/AutoPilotPlugins/APM/APMSafetyComponentSummaryCopter.qml src/AutoPilotPlugins/APM/APMSafetyComponentSummaryPlane.qml src/AutoPilotPlugins/APM/APMSafetyComponentSummaryRover.qml + src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml src/AutoPilotPlugins/PX4/CameraComponent.qml src/AutoPilotPlugins/PX4/CameraComponentSummary.qml diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponent.cc b/src/AutoPilotPlugins/APM/APMSafetyComponent.cc index d97d522..39caad7 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponent.cc +++ b/src/AutoPilotPlugins/APM/APMSafetyComponent.cc @@ -69,6 +69,9 @@ QUrl APMSafetyComponent::setupSource(void) const case MAV_TYPE_TRICOPTER: qmlFile = QStringLiteral("qrc:/qml/APMSafetyComponentCopter.qml"); break; + case MAV_TYPE_SUBMARINE: + qmlFile = QStringLiteral("qrc:/qml/APMSafetyComponentSub.qml"); + break; case MAV_TYPE_GROUND_ROVER: qmlFile = QStringLiteral("qrc:/qml/APMSafetyComponentRover.qml"); break; @@ -96,6 +99,9 @@ QUrl APMSafetyComponent::summaryQmlSource(void) const case MAV_TYPE_TRICOPTER: qmlFile = QStringLiteral("qrc:/qml/APMSafetyComponentSummaryCopter.qml"); break; + case MAV_TYPE_SUBMARINE: + qmlFile = QStringLiteral("qrc:/qml/APMSafetyComponentSummarySub.qml"); + break; case MAV_TYPE_GROUND_ROVER: qmlFile = QStringLiteral("qrc:/qml/APMSafetyComponentSummaryRover.qml"); break; diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml new file mode 100644 index 0000000..6582c5d --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml @@ -0,0 +1,385 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 +import QtGraphicalEffects 1.0 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 + +QGCView { + id: _safetyView + viewPanel: panel + anchors.fill: parent + + FactPanelController { id: controller; factPanel: panel } + + QGCPalette { id: ggcPal; colorGroupEnabled: enabled } + + property Fact _failsafeGCSEnable: controller.getParameterFact(-1, "FS_GCS_ENABLE") + property Fact _failsafeBattEnable: controller.getParameterFact(-1, "FS_BATT_ENABLE") + property Fact _failsafeBattMah: controller.getParameterFact(-1, "FS_BATT_MAH") + property Fact _failsafeBattVoltage: controller.getParameterFact(-1, "FS_BATT_VOLTAGE") + property Fact _failsafeThrEnable: controller.getParameterFact(-1, "FS_THR_ENABLE") + property Fact _failsafeThrValue: controller.getParameterFact(-1, "FS_THR_VALUE") + + property Fact _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") + property Fact _fenceAltMax: controller.getParameterFact(-1, "FENCE_ALT_MAX") + property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") + property Fact _fenceMargin: controller.getParameterFact(-1, "FENCE_MARGIN") + property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") + + property Fact _leakPin: controller.getParameterFact(-1, "WD_1_PIN") + property Fact _leakLogic: controller.getParameterFact(-1, "WD_1_DEFAULT") + + property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") + + property real _margins: ScreenTools.defaultFontPixelHeight + property bool _showIcon: !ScreenTools.isTinyScreen + + ExclusiveGroup { id: fenceActionRadioGroup } + + QGCViewPanel { + id: panel + anchors.fill: parent + + QGCFlickable { + clip: true + anchors.fill: parent + contentHeight: flowLayout.height + contentWidth: flowLayout.width + + Flow { + id: flowLayout + width: panel.width // parent.width doesn't work for some reason + spacing: _margins + + Column { + spacing: _margins / 2 + + QGCLabel { + id: failsafeLabel + text: qsTr("Failsafe Triggers") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + id: failsafeSettings + width: throttleEnableCombo.x + throttleEnableCombo.width + _margins + height: mahField.y + mahField.height + _margins + color: ggcPal.windowShade + + QGCLabel { + id: gcsEnableLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: gcsEnableCombo.baseline + text: qsTr("Ground Station failsafe:") + } + + FactComboBox { + id: gcsEnableCombo + anchors.topMargin: _margins + anchors.leftMargin: _margins + anchors.left: gcsEnableLabel.right + anchors.top: parent.top + width: voltageField.width + fact: _failsafeGCSEnable + indexModel: false + } + + QGCLabel { + id: throttleEnableLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: throttleEnableCombo.baseline + text: qsTr("Throttle failsafe:") + } + + QGCComboBox { + id: throttleEnableCombo + anchors.topMargin: _margins + anchors.left: gcsEnableCombo.left + anchors.top: gcsEnableCombo.bottom + width: voltageField.width + model: [qsTr("Disabled"), qsTr("Always RTL"), + qsTr("Continue with Mission in Auto Mode"), qsTr("Always Land")] + currentIndex: _failsafeThrEnable.value + + onActivated: _failsafeThrEnable.value = index + } + + QGCLabel { + id: throttlePWMLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: throttlePWMField.baseline + text: qsTr("PWM threshold:") + } + + FactTextField { + id: throttlePWMField + anchors.topMargin: _margins / 2 + anchors.left: gcsEnableCombo.left + anchors.top: throttleEnableCombo.bottom + fact: _failsafeThrValue + showUnits: true + } + + QGCLabel { + id: batteryEnableLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: batteryEnableCombo.baseline + text: qsTr("Battery failsafe:") + } + + QGCComboBox { + id: batteryEnableCombo + anchors.topMargin: _margins + anchors.left: gcsEnableCombo.left + anchors.top: throttlePWMField.bottom + width: voltageField.width + model: [qsTr("Disabled"), qsTr("Land"), qsTr("Return to Launch")] + currentIndex: _failsafeBattEnable.value + + onActivated: _failsafeBattEnable.value = index + } + + QGCCheckBox { + id: voltageLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: voltageField.baseline + text: qsTr("Voltage threshold:") + checked: _failsafeBattVoltage.value != 0 + + onClicked: _failsafeBattVoltage.value = checked ? 10.5 : 0 + } + + FactTextField { + id: voltageField + anchors.topMargin: _margins / 2 + anchors.left: gcsEnableCombo.left + anchors.top: batteryEnableCombo.bottom + fact: _failsafeBattVoltage + showUnits: true + } + + QGCCheckBox { + id: mahLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: mahField.baseline + text: qsTr("MAH threshold:") + checked: _failsafeBattMah.value != 0 + + onClicked: _failsafeBattMah.value = checked ? 600 : 0 + } + + FactTextField { + id: mahField + anchors.topMargin: _margins / 2 + anchors.left: gcsEnableCombo.left + anchors.top: voltageField.bottom + fact: _failsafeBattMah + showUnits: true + } + } // Rectangle - Failsafe Settings + } // Column - Failsafe Settings + + Column { + spacing: _margins / 2 + + QGCLabel { + id: geoFenceLabel + text: qsTr("GeoFence") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + id: geoFenceSettings + width: fenceAltMaxField.x + fenceAltMaxField.width + _margins + height: fenceAltMaxField.y + fenceAltMaxField.height + _margins + color: ggcPal.windowShade + + QGCCheckBox { + id: altitudeGeo + enabled: false + anchors.margins: _margins + anchors.left: parent.left + anchors.top: parent.top + text: qsTr("Depth GeoFence enabled") + checked: _fenceEnable.value != 0 && _fenceType.value & 1 + + onClicked: { + if (checked) { + if (_fenceEnable.value == 1) { + _fenceType.value |= 1 + } else { + _fenceEnable.value = 1 + _fenceType.value = 1 + } + } else { + _fenceEnable.value = 0 + _fenceType.value = 0 + } + } + } + + QGCRadioButton { + id: geoReportRadio + enabled: false + anchors.margins: _margins + anchors.left: parent.left + anchors.top: altitudeGeo.bottom + text: qsTr("Report only") + exclusiveGroup: fenceActionRadioGroup + checked: _fenceAction.value == 0 + + onClicked: _fenceAction.value = 0 + } + + QGCRadioButton { + id: geoRTLRadio + enabled: false + anchors.topMargin: _margins / 2 + anchors.left: altitudeGeo.left + anchors.top: geoReportRadio.bottom + text: qsTr("RTL or Land") + exclusiveGroup: fenceActionRadioGroup + checked: _fenceAction.value == 1 + + onClicked: _fenceAction.value = 1 + } + + QGCLabel { + id: fenceAltMaxLabel + enabled: false + anchors.left: altitudeGeo.left + anchors.baseline: fenceAltMaxField.baseline + text: qsTr("Max depth:") + } + + FactTextField { + id: fenceAltMaxField + enabled: false + anchors.topMargin: _margins / 2 + anchors.leftMargin: _margins + anchors.left: fenceAltMaxLabel.right + anchors.top: geoRTLRadio.bottom + fact: _fenceAltMax + showUnits: true + } + } // Rectangle - GeoFence Settings + } // Column - GeoFence Settings + + Column { + spacing: _margins / 2 + + QGCLabel { + id: leakDetectorLabel + text: qsTr("Leak Detector") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + id: leakDetectorSettings + width: leakLogicCombo.x + leakLogicCombo.width + _margins + height: leakLogicCombo.y + leakLogicCombo.height + _margins + color: ggcPal.windowShade + + QGCLabel { + id: leakPinLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.top: parent.top + text: qsTr("Pin:") + } + + FactComboBox { + id: leakPinCombo + anchors.margins: _margins + anchors.left: leakLogicLabel.right + anchors.baseline: leakPinLabel.baseline + width: voltageField.width + fact: _leakPin + indexModel: false + } + + QGCLabel { + id: leakLogicLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.top: leakPinLabel.bottom + text: qsTr("Logic:") + } + + FactComboBox { + id: leakLogicCombo + anchors.margins: _margins + anchors.left: leakLogicLabel.right + anchors.baseline: leakLogicLabel.baseline + width: voltageField.width + fact: _leakLogic + indexModel: false + } + } // Rectangle - Leak Detector Settings + } // Column - Leak Detector Settings + + Column { + spacing: _margins / 2 + + QGCLabel { + text: qsTr("Arming Checks") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + width: flowLayout.width + height: armingCheckInnerColumn.height + (_margins * 2) + color: ggcPal.windowShade + + Column { + id: armingCheckInnerColumn + anchors.margins: _margins + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + spacing: _margins + + FactBitmask { + id: armingCheckBitmask + anchors.left: parent.left + anchors.right: parent.right + firstEntryIsAll: true + fact: _armingCheck + } + + QGCLabel { + id: armingCheckWarning + anchors.left: parent.left + anchors.right: parent.right + wrapMode: Text.WordWrap + color: qgcPal.warningText + text: qsTr("Warning: Turning off arming checks can lead to loss of Vehicle control.") + visible: _armingCheck.value != 1 + } + } + } // Rectangle - Arming checks + } // Column - Arming Checks + } // Flow + } // QGCFlickable + } // QGCViewPanel +} // QGCView diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml new file mode 100644 index 0000000..d97e032 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml @@ -0,0 +1,123 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 + +FactPanel { + id: panel + anchors.fill: parent + color: qgcPal.windowShadeDark + + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + FactPanelController { id: controller; factPanel: panel } + + property Fact _failsafeBattEnable: controller.getParameterFact(-1, "FS_BATT_ENABLE") + property Fact _failsafeThrEnable: controller.getParameterFact(-1, "FS_THR_ENABLE") + + property Fact _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") + property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") + property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") + + property Fact _leakPin: controller.getParameterFact(-1, "WD_1_PIN") + + property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") + + property string _failsafeBattEnableText + property string _failsafeThrEnableText + + Component.onCompleted: { + setFailsafeBattEnableText() + setFailsafeThrEnableText() + } + + Connections { + target: _failsafeBattEnable + + onValueChanged: setFailsafeBattEnableText() + } + + Connections { + target: _failsafeThrEnable + + onValueChanged: setFailsafeThrEnableText() + } + + function setFailsafeThrEnableText() { + switch (_failsafeThrEnable.value) { + case 0: + _failsafeThrEnableText = qsTr("Disabled") + break + case 1: + _failsafeThrEnableText = qsTr("Always RTL") + break + case 2: + _failsafeThrEnableText = qsTr("Continue with Mission in Auto Mode") + break + case 3: + _failsafeThrEnableText = qsTr("Always Land") + break + default: + _failsafeThrEnableText = qsTr("Unknown") + } + } + + function setFailsafeBattEnableText() { + switch (_failsafeBattEnable.value) { + case 0: + _failsafeBattEnableText = qsTr("Disabled") + break + case 1: + _failsafeBattEnableText = qsTr("Land") + break + case 2: + _failsafeBattEnableText = qsTr("Return to Launch") + break + default: + _failsafeThrEnableText = qsTr("Unknown") + } + } + + Column { + anchors.fill: parent + + VehicleSummaryRow { + labelText: qsTr("Arming Checks:") + valueText: _armingCheck.value & 1 ? qsTr("Enabled") : qsTr("Some disabled") + } + + VehicleSummaryRow { + labelText: qsTr("Throttle failsafe:") + valueText: _failsafeThrEnableText + } + + VehicleSummaryRow { + labelText: qsTr("Battery failsafe:") + valueText: _failsafeBattEnableText + } + + VehicleSummaryRow { + labelText: qsTr("Leak Detector:") + valueText: _leakPin.value > 0 ? qsTr("Enabled") : qsTr("Disabled") + } + + VehicleSummaryRow { + labelText: qsTr("GeoFence:") + valueText: _fenceEnable.value == 0 || _fenceType == 0 ? + qsTr("Disabled") : + (_fenceType.value == 1 ? + qsTr("Altitude") : + (_fenceType.value == 2 ? qsTr("Circle") : qsTr("Altitude,Circle"))) + } + + VehicleSummaryRow { + labelText: qsTr("GeoFence:") + valueText: _fenceAction.value == 0 ? + qsTr("Report only") : + (_fenceAction.value == 1 ? qsTr("RTL or Land") : qsTr("Unknown")) + visible: _fenceEnable.value != 0 + } + } +} From adc0c94133c2f35f030d0b9fe6edff96c745828f Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Sun, 9 Oct 2016 18:22:52 -0700 Subject: [PATCH 2/8] Add lights settings component for Sub. --- qgcresources.qrc | 1 + qgroundcontrol.pro | 2 + qgroundcontrol.qrc | 2 + src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc | 8 + src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h | 3 + src/AutoPilotPlugins/APM/APMLightsComponent.cc | 76 ++++++++ src/AutoPilotPlugins/APM/APMLightsComponent.h | 40 +++++ src/AutoPilotPlugins/APM/APMLightsComponent.qml | 197 +++++++++++++++++++++ .../APM/APMLightsComponentSummary.qml | 101 +++++++++++ .../APM/Images/LightsComponentIcon.png | Bin 0 -> 2132 bytes 10 files changed, 430 insertions(+) create mode 100644 src/AutoPilotPlugins/APM/APMLightsComponent.cc create mode 100644 src/AutoPilotPlugins/APM/APMLightsComponent.h create mode 100644 src/AutoPilotPlugins/APM/APMLightsComponent.qml create mode 100644 src/AutoPilotPlugins/APM/APMLightsComponentSummary.qml create mode 100644 src/AutoPilotPlugins/APM/Images/LightsComponentIcon.png diff --git a/qgcresources.qrc b/qgcresources.qrc index 23b8afa..70f2a65 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -57,6 +57,7 @@ src/AnalyzeView/GeoTagIcon.png src/AutoPilotPlugins/PX4/Images/LandMode.svg src/AutoPilotPlugins/PX4/Images/LandModeCopter.svg + src/AutoPilotPlugins/APM/Images/LightsComponentIcon.png src/AnalyzeView/LogDownloadIcon.png src/AutoPilotPlugins/PX4/Images/LowBattery.svg src/AutoPilotPlugins/PX4/Images/LowBatteryLight.svg diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 28bb362..9dfad86 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -667,6 +667,7 @@ HEADERS+= \ src/AutoPilotPlugins/APM/APMAirframeComponentController.h \ src/AutoPilotPlugins/APM/APMAirframeComponentAirframes.h \ src/AutoPilotPlugins/APM/APMCameraComponent.h \ + src/AutoPilotPlugins/APM/APMLightsComponent.h \ src/AutoPilotPlugins/APM/APMCompassCal.h \ src/AutoPilotPlugins/APM/APMFlightModesComponent.h \ src/AutoPilotPlugins/APM/APMFlightModesComponentController.h \ @@ -730,6 +731,7 @@ SOURCES += \ src/AutoPilotPlugins/APM/APMAirframeComponent.cc \ src/AutoPilotPlugins/APM/APMAirframeComponentController.cc \ src/AutoPilotPlugins/APM/APMCameraComponent.cc \ + src/AutoPilotPlugins/APM/APMLightsComponent.cc \ src/AutoPilotPlugins/APM/APMCompassCal.cc \ src/AutoPilotPlugins/APM/APMFlightModesComponent.cc \ src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 68ba7f0..69dd1d0 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -143,6 +143,8 @@ src/AutoPilotPlugins/APM/APMNotSupported.qml src/AutoPilotPlugins/APM/APMCameraComponent.qml src/AutoPilotPlugins/APM/APMCameraComponentSummary.qml + src/AutoPilotPlugins/APM/APMLightsComponent.qml + src/AutoPilotPlugins/APM/APMLightsComponentSummary.qml src/AutoPilotPlugins/APM/APMPowerComponent.qml src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml src/AutoPilotPlugins/APM/APMRadioComponentSummary.qml diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc index ece082b..9b8b702 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc @@ -27,6 +27,7 @@ #include "APMPowerComponent.h" #include "MotorComponent.h" #include "APMCameraComponent.h" +#include "APMLightsComponent.h" #include "ESP8266Component.h" /// This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_ARDUPILOT type. @@ -35,6 +36,7 @@ APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent) , _incorrectParameterVersion(false) , _airframeComponent(NULL) , _cameraComponent(NULL) + , _lightsComponent(NULL) , _flightModesComponent(NULL) , _powerComponent(NULL) #if 0 @@ -104,6 +106,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) _cameraComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_cameraComponent)); + if (_vehicle->sub()) { + _lightsComponent = new APMLightsComponent(_vehicle, this); + _lightsComponent->setupTriggerSignals(); + _components.append(QVariant::fromValue((VehicleComponent*)_lightsComponent)); + } + //-- Is there an ESP8266 Connected? if(_vehicle->parameterManager()->parameterExists(MAV_COMP_ID_UDP_BRIDGE, "SW_VER")) { _esp8266Component = new ESP8266Component(_vehicle, this); diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h index 62ffbdf..6bd6031 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h @@ -24,6 +24,7 @@ class APMSensorsComponent; class APMPowerComponent; class MotorComponent; class APMCameraComponent; +class APMLightsComponent; class ESP8266Component; /// This is the APM specific implementation of the AutoPilot class. @@ -40,6 +41,7 @@ public: APMAirframeComponent* airframeComponent (void) const { return _airframeComponent; } APMCameraComponent* cameraComponent (void) const { return _cameraComponent; } + APMLightsComponent* lightsComponent (void) const { return _lightsComponent; } APMFlightModesComponent* flightModesComponent(void) const { return _flightModesComponent; } APMPowerComponent* powerComponent (void) const { return _powerComponent; } #if 0 @@ -58,6 +60,7 @@ private: APMAirframeComponent* _airframeComponent; APMCameraComponent* _cameraComponent; + APMLightsComponent* _lightsComponent; APMFlightModesComponent* _flightModesComponent; APMPowerComponent* _powerComponent; #if 0 diff --git a/src/AutoPilotPlugins/APM/APMLightsComponent.cc b/src/AutoPilotPlugins/APM/APMLightsComponent.cc new file mode 100644 index 0000000..8896dd0 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMLightsComponent.cc @@ -0,0 +1,76 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +/// @file +/// @author Don Gagne +/// @author Rustom Jehangir + +#include "APMLightsComponent.h" +#include "QGCQmlWidgetHolder.h" +#include "APMAutoPilotPlugin.h" +#include "APMAirframeComponent.h" + +APMLightsComponent::APMLightsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) + : VehicleComponent(vehicle, autopilot, parent) + , _name(tr("Lights")) +{ +} + +QString APMLightsComponent::name(void) const +{ + return _name; +} + +QString APMLightsComponent::description(void) const +{ + return tr("The Lights Component is used to setup lights settings."); +} + +QString APMLightsComponent::iconResource(void) const +{ + return QStringLiteral("/qmlimages/LightsComponentIcon.png"); +} + +bool APMLightsComponent::requiresSetup(void) const +{ + return false; +} + +bool APMLightsComponent::setupComplete(void) const +{ + return true; +} + +QStringList APMLightsComponent::setupCompleteChangedTriggerList(void) const +{ + return QStringList(); +} + +QUrl APMLightsComponent::setupSource(void) const +{ + return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMLightsComponent.qml")); +} + +QUrl APMLightsComponent::summaryQmlSource(void) const +{ + return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMLightsComponentSummary.qml")); +} + +QString APMLightsComponent::prerequisiteSetup(void) const +{ + APMAutoPilotPlugin* plugin = dynamic_cast(_autopilot); + Q_ASSERT(plugin); + + if (!plugin->airframeComponent()->setupComplete()) { + return plugin->airframeComponent()->name(); + } + + return QString(); +} diff --git a/src/AutoPilotPlugins/APM/APMLightsComponent.h b/src/AutoPilotPlugins/APM/APMLightsComponent.h new file mode 100644 index 0000000..0369aae --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMLightsComponent.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +#ifndef APMLightsComponent_H +#define APMLightsComponent_H + +#include "VehicleComponent.h" + +class APMLightsComponent : public VehicleComponent +{ + Q_OBJECT + +public: + APMLightsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); + + // Virtuals from VehicleComponent + QStringList setupCompleteChangedTriggerList(void) const final; + + // Virtuals from VehicleComponent + QString name(void) const final; + QString description(void) const final; + QString iconResource(void) const final; + bool requiresSetup(void) const final; + bool setupComplete(void) const final; + QUrl setupSource(void) const final; + QUrl summaryQmlSource(void) const final; + QString prerequisiteSetup(void) const final; + +private: + const QString _name; +}; + +#endif diff --git a/src/AutoPilotPlugins/APM/APMLightsComponent.qml b/src/AutoPilotPlugins/APM/APMLightsComponent.qml new file mode 100644 index 0000000..db0e99a --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMLightsComponent.qml @@ -0,0 +1,197 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 + +QGCView { + id: _lightsView + viewPanel: panel + anchors.fill: parent + + FactPanelController { id: controller; factPanel: panel } + + QGCPalette { id: palette; colorGroupEnabled: enabled } + + property Fact _rc5Function: controller.getParameterFact(-1, "RC5_FUNCTION") + property Fact _rc6Function: controller.getParameterFact(-1, "RC6_FUNCTION") + property Fact _rc7Function: controller.getParameterFact(-1, "RC7_FUNCTION") + property Fact _rc8Function: controller.getParameterFact(-1, "RC8_FUNCTION") + property Fact _rc9Function: controller.getParameterFact(-1, "RC9_FUNCTION") + property Fact _rc10Function: controller.getParameterFact(-1, "RC10_FUNCTION") + property Fact _rc11Function: controller.getParameterFact(-1, "RC11_FUNCTION") + property Fact _rc12Function: controller.getParameterFact(-1, "RC12_FUNCTION") + property Fact _rc13Function: controller.getParameterFact(-1, "RC13_FUNCTION") + property Fact _rc14Function: controller.getParameterFact(-1, "RC14_FUNCTION") + + readonly property real _margins: ScreenTools.defaultFontPixelHeight + readonly property int _rcFunctionDisabled: 0 + readonly property int _rcFunctionRCIN9: 59 + readonly property int _rcFunctionRCIN10: 60 + readonly property int _firstLightsOutChannel: 5 + readonly property int _lastLightsOutChannel: 14 + + Component.onCompleted: { + calcLightOutValues() + } + + /// Light output channels are stored in RC#_FUNCTION parameters. We need to loop through those + /// to find them and setup the ui accordindly. + function calcLightOutValues() { + lightsLoader.lights1OutIndex = 0 + lightsLoader.lights2OutIndex = 0 + for (var channel=_firstLightsOutChannel; channel<=_lastLightsOutChannel; channel++) { + var functionFact = controller.getParameterFact(-1, "RC" + channel + "_FUNCTION") + if (functionFact.value == _rcFunctionRCIN9) { + lightsLoader.lights1OutIndex = channel - 4 + } else if (functionFact.value == _rcFunctionRCIN10) { + lightsLoader.lights2OutIndex = channel - 4 + } + } + } + + function setRCFunction(channel, rcFunction) { + // First clear any previous settings for this function + for (var index=_firstLightsOutChannel; index<=_lastLightsOutChannel; index++) { + var functionFact = controller.getParameterFact(-1, "RC" + index + "_FUNCTION") + if (functionFact.value != _rcFunctionDisabled && functionFact.value == rcFunction) { + functionFact.value = _rcFunctionDisabled + } + } + + // Now set the function into the new channel + if (channel != 0) { + var functionFact = controller.getParameterFact(-1, "RC" + channel + "_FUNCTION") + functionFact.value = rcFunction + } + } + + // Whenever any RC#_FUNCTION parameters chagnes we need to go looking for light output channels again + Connections { target: _rc5Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc6Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc7Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc8Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc9Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc10Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc11Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc12Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc13Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc14Function; onValueChanged: calcLightOutValues() } + + ListModel { + id: lightsOutModel + ListElement { text: qsTr("Disabled"); value: 0 } + ListElement { text: qsTr("Channel 5"); value: 5 } + ListElement { text: qsTr("Channel 6"); value: 6 } + ListElement { text: qsTr("Channel 7"); value: 7 } + ListElement { text: qsTr("Channel 8"); value: 8 } + ListElement { text: qsTr("Channel 9"); value: 9 } + ListElement { text: qsTr("Channel 10"); value: 10 } + ListElement { text: qsTr("Channel 11"); value: 11 } + ListElement { text: qsTr("Channel 12"); value: 12 } + ListElement { text: qsTr("Channel 13"); value: 13 } + ListElement { text: qsTr("Channel 14"); value: 14 } + } + + Component { + id: lightSettings + + Item { + width: rectangle.x + rectangle.width + height: rectangle.y + rectangle.height + + QGCLabel { + id: settingsLabel + text: qsTr("Light Settings") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + id: rectangle + anchors.topMargin: _margins / 2 + anchors.top: settingsLabel.bottom + width: lights1Combo.x + lights1Combo.width + _margins + height: lights2Combo.y + lights2Combo.height + _margins + color: palette.windowShade + + QGCLabel { + id: lights1Label + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: lights1Combo.baseline + text: qsTr("Lights 1:") + } + + QGCComboBox { + id: lights1Combo + anchors.margins: _margins + anchors.top: parent.top + anchors.left: lights1Label.right + width: ScreenTools.defaultFontPixelWidth * 15 + model: lightsOutModel + currentIndex: lights1OutIndex + + onActivated: setRCFunction(lightsOutModel.get(index).value, lights1Function) + } + + QGCLabel { + id: lights2Label + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: lights2Combo.baseline + text: qsTr("Lights 2:") + } + + QGCComboBox { + id: lights2Combo + anchors.margins: _margins + anchors.top: lights1Combo.bottom + anchors.left: lights2Label.right + width: lights1Combo.width + model: lightsOutModel + currentIndex: lights2OutIndex + + onActivated: setRCFunction(lightsOutModel.get(index).value, lights2Function) + } + } // Rectangle + } // Item + } // Component - lightSettings + + QGCViewPanel { + id: panel + anchors.fill: parent + + QGCFlickable { + clip: true + anchors.fill: parent + contentWidth: lightsLoader.x + lightsLoader.width + contentHeight: lightsLoader.y + lightsLoader.height + + Loader { + id: lightsLoader + sourceComponent: lightSettings + + anchors.margins: _margins + anchors.top: parent.top + + property int lights1OutIndex: 0 + property int lights2OutIndex: 0 + property int lights1Function: _rcFunctionRCIN9 + property int lights2Function: _rcFunctionRCIN10 + } + } // Flickable + } // QGCViewPanel +} // QGCView diff --git a/src/AutoPilotPlugins/APM/APMLightsComponentSummary.qml b/src/AutoPilotPlugins/APM/APMLightsComponentSummary.qml new file mode 100644 index 0000000..3eb129d --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMLightsComponentSummary.qml @@ -0,0 +1,101 @@ +import QtQuick 2.5 +import QtQuick.Controls 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 + +FactPanel { + id: panel + anchors.fill: parent + color: qgcPal.windowShadeDark + + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + FactPanelController { id: controller; factPanel: panel } + + property Fact _rc5Function: controller.getParameterFact(-1, "RC5_FUNCTION") + property Fact _rc6Function: controller.getParameterFact(-1, "RC6_FUNCTION") + property Fact _rc7Function: controller.getParameterFact(-1, "RC7_FUNCTION") + property Fact _rc8Function: controller.getParameterFact(-1, "RC8_FUNCTION") + property Fact _rc9Function: controller.getParameterFact(-1, "RC9_FUNCTION") + property Fact _rc10Function: controller.getParameterFact(-1, "RC10_FUNCTION") + property Fact _rc11Function: controller.getParameterFact(-1, "RC11_FUNCTION") + property Fact _rc12Function: controller.getParameterFact(-1, "RC12_FUNCTION") + property Fact _rc13Function: controller.getParameterFact(-1, "RC13_FUNCTION") + property Fact _rc14Function: controller.getParameterFact(-1, "RC14_FUNCTION") + + readonly property int _rcFunctionRCIN9: 59 + readonly property int _rcFunctionRCIN10: 60 + readonly property int _firstLightsOutChannel: 5 + readonly property int _lastLightsOutChannel: 14 + + Component.onCompleted: { + calcLightOutValues() + } + + /// Light output channels are stored in RC#_FUNCTION parameters. We need to loop through those + /// to find them and setup the ui accordindly. + function calcLightOutValues() { + lightsLoader.lights1OutIndex = 0 + lightsLoader.lights2OutIndex = 0 + for (var channel=_firstLightsOutChannel; channel<=_lastLightsOutChannel; channel++) { + var functionFact = controller.getParameterFact(-1, "RC" + channel + "_FUNCTION") + if (functionFact.value == _rcFunctionRCIN9) { + lightsLoader.lights1OutIndex = channel - 4 + } else if (functionFact.value == _rcFunctionRCIN10) { + lightsLoader.lights2OutIndex = channel - 4 + } + } + } + + // Whenever any RC#_FUNCTION parameters chagnes we need to go looking for light output channels again + Connections { target: _rc5Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc6Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc7Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc8Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc9Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc10Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc11Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc12Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc13Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc14Function; onValueChanged: calcLightOutValues() } + + ListModel { + id: lightsOutModel + ListElement { text: qsTr("Disabled"); value: 0 } + ListElement { text: qsTr("Channel 5"); value: 5 } + ListElement { text: qsTr("Channel 6"); value: 6 } + ListElement { text: qsTr("Channel 7"); value: 7 } + ListElement { text: qsTr("Channel 8"); value: 8 } + ListElement { text: qsTr("Channel 9"); value: 9 } + ListElement { text: qsTr("Channel 10"); value: 10 } + ListElement { text: qsTr("Channel 11"); value: 11 } + ListElement { text: qsTr("Channel 12"); value: 12 } + ListElement { text: qsTr("Channel 13"); value: 13 } + ListElement { text: qsTr("Channel 14"); value: 14 } + } + + Loader { + id: lightsLoader + + property int lights1OutIndex: 0 + property int lights2OutIndex: 0 + property int lights1Function: _rcFunctionRCIN9 + property int lights2Function: _rcFunctionRCIN10 + } + + Column { + anchors.fill: parent + + VehicleSummaryRow { + labelText: qsTr("Lights Output 1:") + valueText: lightsOutModel.get(lightsLoader.lights1OutIndex).text + } + + VehicleSummaryRow { + labelText: qsTr("Lights Output 2:") + valueText: lightsOutModel.get(lightsLoader.lights2OutIndex).text + } + } +} diff --git a/src/AutoPilotPlugins/APM/Images/LightsComponentIcon.png b/src/AutoPilotPlugins/APM/Images/LightsComponentIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..71c05680207280e505ba40c6b3c0b04a852a9c43 GIT binary patch literal 2132 zcmZuyc~}zI76%;{aOo*oE|`GjSR^E+J`vo)v|OJVn&>DgDiy*56tqkYo3irdI_)Yg zUnvS`=2Bu3fZ8ps@S9d;kl$ZfGl5EXMpfIbXZ}47;gJn0DuN$Re*p?SM(KtCaPZmJHXQe z8%C$0$l>$@6cm@nP@n+-92culX%sdY#-$yOW?{K_#5V+1p|85p2-r6W`w$)x;OPU~ zNoP`ER;V4QZ3ufX3o#{uXAGUW|ogHj9 zjT}kwrI5qpaOnR={M9LLH6_-YNu?;bt}?Q>#G(Jk_XCeZuhRWD`rl{!&8rx$Jy=oc zkB71cZ$>ra0RUCRZi16v0I2=K{@cWTYa5oU51OiIbpd|M(NovUp(-CB!(Ge+BQ&@DOq=9@w(JQ3>{VFOLo|+%_V>8&hH!kv=3`q zP`6u6vT%%GcNb8Mi zC$H7oFc0W2(|EsiN=Lxby#6+XSgV~KT1t^;6hywQGb1J$>s`!FKB>z?CV(o9Hm0VP zIjCxYX6?BAEkJ_WbJ7)pYp$&L#ynsY;O)O$q}^BQJjqW#cGpkL;E{21xZ4Ixwd;>@jjC9N``*C{w7|GAZ|Qpa%>z9NxsS}P0dygG!P#D zs+#%4rOcHVBkig#8Cg6PNX-+C@-%I0iJ`4;pqa?9@q$?BrDxrtcI9t^dI%>6oaD55 z^vgCu#(YUn;`=bG$%*!^s_`?m*!oyvDctf-N27cL&3{uZrF{gML%VYx)b{D0B@f*5 zCm>%AQ#_i=tuxZqR+Q|z(s)%jr$uQ&CWwSfk7i|&0;fQWMoI4FEm=rW#n{)7(+-1} z%DZ@N*Q~mu;pn7hX?|7`4zy{vNejn=a5D2Xg>%i`?Fenp~{r{WC|vi7Tqod!LkG}Y-#H&7kQX zFpPnyu6Sz=v}|l-VMvnf-BNGih;bV}BtNEwRyjmP|2nAAm9msHx^rMX1Eq1#%9(!{ zKEK`ZWvfXbd@gpmGf?jOlryV8TDaIN3#$#ofA~23KwDUJ;$vaeW#6P_e{yhg`M#_o zZecDfv~M}s%;`4#DJF?38ha%DyjfuIl^77X#@c6i4%F&iS0UdeGnlMs+A4RK zX|yf?vst{Ng_ghl6uo}C1iS?78TvWp!z(+(hqKyZezRriLQLND@-$cdC}^bY;`7V0 zo}o7T@yo$vopHFD=QTS|9dSIdnKNLzWdixZtgpt^APO!BnYAj9&gf0DFDeW>BxN4u ztcjJpKkKP>j#mJ?FE{DQz3KlVScR?&aVfF&nbB_{nx_g9&7*V^bG$mso8#EX`}Gck z`crw_xg?5o%5c&q!H)mVN!L)#r6bysP3`Y&K(V^k_3=n^zrJ3;hn$EaRZ?XT+2@Oc km{@0q(kIU+DR literal 0 HcmV?d00001 From da45a4575419c0878f25e0bed30d770cfec3d377 Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Mon, 10 Oct 2016 15:00:00 -0700 Subject: [PATCH 3/8] Improve Sub safety page to match firmware capabilities --- src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml | 154 +++------------------ .../APM/APMSafetyComponentSummarySub.qml | 69 +++------ 2 files changed, 42 insertions(+), 181 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml index 6582c5d..a8ff1d1 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml @@ -28,11 +28,11 @@ QGCView { QGCPalette { id: ggcPal; colorGroupEnabled: enabled } property Fact _failsafeGCSEnable: controller.getParameterFact(-1, "FS_GCS_ENABLE") - property Fact _failsafeBattEnable: controller.getParameterFact(-1, "FS_BATT_ENABLE") - property Fact _failsafeBattMah: controller.getParameterFact(-1, "FS_BATT_MAH") - property Fact _failsafeBattVoltage: controller.getParameterFact(-1, "FS_BATT_VOLTAGE") - property Fact _failsafeThrEnable: controller.getParameterFact(-1, "FS_THR_ENABLE") - property Fact _failsafeThrValue: controller.getParameterFact(-1, "FS_THR_VALUE") + property Fact _failsafeLeakEnable: controller.getParameterFact(-1, "FS_LEAK_ENABLE") + property Fact _failsafePressureEnable: controller.getParameterFact(-1, "FS_PRESS_ENABLE") + property Fact _failsafePressureValue: controller.getParameterFact(-1, "FS_PRESS_MAX") + property Fact _failsafeTempEnable: controller.getParameterFact(-1, "FS_TEMP_ENABLE") + property Fact _failsafeTempValue: controller.getParameterFact(-1, "FS_TEMP_MAX") property Fact _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") property Fact _fenceAltMax: controller.getParameterFact(-1, "FENCE_ALT_MAX") @@ -70,14 +70,14 @@ QGCView { QGCLabel { id: failsafeLabel - text: qsTr("Failsafe Triggers") + text: qsTr("Failsafe Actions") font.family: ScreenTools.demiboldFontFamily } Rectangle { id: failsafeSettings - width: throttleEnableCombo.x + throttleEnableCombo.width + _margins - height: mahField.y + mahField.height + _margins + width: leakEnableCombo.x + leakEnableCombo.width + _margins + height: leakEnableCombo.y + leakEnableCombo.height + _margins color: ggcPal.windowShade QGCLabel { @@ -90,111 +90,30 @@ QGCView { FactComboBox { id: gcsEnableCombo - anchors.topMargin: _margins - anchors.leftMargin: _margins + anchors.margins: _margins anchors.left: gcsEnableLabel.right anchors.top: parent.top - width: voltageField.width + width: ScreenTools.defaultFontPixelWidth*15 fact: _failsafeGCSEnable indexModel: false } QGCLabel { - id: throttleEnableLabel + id: leakEnableLabel anchors.margins: _margins anchors.left: parent.left - anchors.baseline: throttleEnableCombo.baseline - text: qsTr("Throttle failsafe:") + anchors.baseline: leakEnableCombo.baseline + text: qsTr("Leak failsafe:") } - QGCComboBox { - id: throttleEnableCombo + FactComboBox { + id: leakEnableCombo anchors.topMargin: _margins anchors.left: gcsEnableCombo.left anchors.top: gcsEnableCombo.bottom - width: voltageField.width - model: [qsTr("Disabled"), qsTr("Always RTL"), - qsTr("Continue with Mission in Auto Mode"), qsTr("Always Land")] - currentIndex: _failsafeThrEnable.value - - onActivated: _failsafeThrEnable.value = index - } - - QGCLabel { - id: throttlePWMLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: throttlePWMField.baseline - text: qsTr("PWM threshold:") - } - - FactTextField { - id: throttlePWMField - anchors.topMargin: _margins / 2 - anchors.left: gcsEnableCombo.left - anchors.top: throttleEnableCombo.bottom - fact: _failsafeThrValue - showUnits: true - } - - QGCLabel { - id: batteryEnableLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: batteryEnableCombo.baseline - text: qsTr("Battery failsafe:") - } - - QGCComboBox { - id: batteryEnableCombo - anchors.topMargin: _margins - anchors.left: gcsEnableCombo.left - anchors.top: throttlePWMField.bottom - width: voltageField.width - model: [qsTr("Disabled"), qsTr("Land"), qsTr("Return to Launch")] - currentIndex: _failsafeBattEnable.value - - onActivated: _failsafeBattEnable.value = index - } - - QGCCheckBox { - id: voltageLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: voltageField.baseline - text: qsTr("Voltage threshold:") - checked: _failsafeBattVoltage.value != 0 - - onClicked: _failsafeBattVoltage.value = checked ? 10.5 : 0 - } - - FactTextField { - id: voltageField - anchors.topMargin: _margins / 2 - anchors.left: gcsEnableCombo.left - anchors.top: batteryEnableCombo.bottom - fact: _failsafeBattVoltage - showUnits: true - } - - QGCCheckBox { - id: mahLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: mahField.baseline - text: qsTr("MAH threshold:") - checked: _failsafeBattMah.value != 0 - - onClicked: _failsafeBattMah.value = checked ? 600 : 0 - } - - FactTextField { - id: mahField - anchors.topMargin: _margins / 2 - anchors.left: gcsEnableCombo.left - anchors.top: voltageField.bottom - fact: _failsafeBattMah - showUnits: true + width: ScreenTools.defaultFontPixelWidth*15 + fact: _failsafeLeakEnable + indexModel: false } } // Rectangle - Failsafe Settings } // Column - Failsafe Settings @@ -216,11 +135,10 @@ QGCView { QGCCheckBox { id: altitudeGeo - enabled: false anchors.margins: _margins anchors.left: parent.left anchors.top: parent.top - text: qsTr("Depth GeoFence enabled") + text: qsTr("Depth GeoFence enabled\n(report only)") checked: _fenceEnable.value != 0 && _fenceType.value & 1 onClicked: { @@ -238,35 +156,8 @@ QGCView { } } - QGCRadioButton { - id: geoReportRadio - enabled: false - anchors.margins: _margins - anchors.left: parent.left - anchors.top: altitudeGeo.bottom - text: qsTr("Report only") - exclusiveGroup: fenceActionRadioGroup - checked: _fenceAction.value == 0 - - onClicked: _fenceAction.value = 0 - } - - QGCRadioButton { - id: geoRTLRadio - enabled: false - anchors.topMargin: _margins / 2 - anchors.left: altitudeGeo.left - anchors.top: geoReportRadio.bottom - text: qsTr("RTL or Land") - exclusiveGroup: fenceActionRadioGroup - checked: _fenceAction.value == 1 - - onClicked: _fenceAction.value = 1 - } - QGCLabel { id: fenceAltMaxLabel - enabled: false anchors.left: altitudeGeo.left anchors.baseline: fenceAltMaxField.baseline text: qsTr("Max depth:") @@ -274,11 +165,10 @@ QGCView { FactTextField { id: fenceAltMaxField - enabled: false anchors.topMargin: _margins / 2 anchors.leftMargin: _margins anchors.left: fenceAltMaxLabel.right - anchors.top: geoRTLRadio.bottom + anchors.top: altitudeGeo.bottom fact: _fenceAltMax showUnits: true } @@ -313,7 +203,7 @@ QGCView { anchors.margins: _margins anchors.left: leakLogicLabel.right anchors.baseline: leakPinLabel.baseline - width: voltageField.width + width: ScreenTools.defaultFontPixelWidth*15 fact: _leakPin indexModel: false } @@ -331,7 +221,7 @@ QGCView { anchors.margins: _margins anchors.left: leakLogicLabel.right anchors.baseline: leakLogicLabel.baseline - width: voltageField.width + width: ScreenTools.defaultFontPixelWidth*15 fact: _leakLogic indexModel: false } diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml index d97e032..a50f85a 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml @@ -14,69 +14,42 @@ FactPanel { QGCPalette { id: qgcPal; colorGroupEnabled: enabled } FactPanelController { id: controller; factPanel: panel } - property Fact _failsafeBattEnable: controller.getParameterFact(-1, "FS_BATT_ENABLE") - property Fact _failsafeThrEnable: controller.getParameterFact(-1, "FS_THR_ENABLE") + property Fact _failsafeGCSEnable: controller.getParameterFact(-1, "FS_GCS_ENABLE") + property Fact _failsafeLeakEnable: controller.getParameterFact(-1, "FS_LEAK_ENABLE") property Fact _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") - property Fact _leakPin: controller.getParameterFact(-1, "WD_1_PIN") + property Fact _leakPin: controller.getParameterFact(-1, "WD_1_PIN") property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") - property string _failsafeBattEnableText - property string _failsafeThrEnableText + property string _failsafeGCSEnableText Component.onCompleted: { - setFailsafeBattEnableText() - setFailsafeThrEnableText() + setFailsafeGCSEnableText() } Connections { - target: _failsafeBattEnable + target: _failsafeGCSEnable - onValueChanged: setFailsafeBattEnableText() + onValueChanged: setFailsafeGCSEnableText() } - Connections { - target: _failsafeThrEnable - - onValueChanged: setFailsafeThrEnableText() - } - - function setFailsafeThrEnableText() { - switch (_failsafeThrEnable.value) { - case 0: - _failsafeThrEnableText = qsTr("Disabled") - break - case 1: - _failsafeThrEnableText = qsTr("Always RTL") - break - case 2: - _failsafeThrEnableText = qsTr("Continue with Mission in Auto Mode") - break - case 3: - _failsafeThrEnableText = qsTr("Always Land") - break - default: - _failsafeThrEnableText = qsTr("Unknown") - } - } - - function setFailsafeBattEnableText() { - switch (_failsafeBattEnable.value) { + function setFailsafeGCSEnableText() { + switch (_failsafeGCSEnable.value) { case 0: - _failsafeBattEnableText = qsTr("Disabled") + _failsafeGCSEnableText = qsTr("Disabled") break case 1: - _failsafeBattEnableText = qsTr("Land") + _failsafeGCSEnableText = qsTr("Always RTL") break case 2: - _failsafeBattEnableText = qsTr("Return to Launch") + _failsafeGCSEnableText = qsTr("Continue with Mission in Auto Mode") break default: - _failsafeThrEnableText = qsTr("Unknown") + _failsafeGCSEnableText = qsTr("Unknown") } } @@ -89,13 +62,13 @@ FactPanel { } VehicleSummaryRow { - labelText: qsTr("Throttle failsafe:") - valueText: _failsafeThrEnableText + labelText: qsTr("GCS failsafe:") + valueText: _failsafeGCSEnableText } VehicleSummaryRow { - labelText: qsTr("Battery failsafe:") - valueText: _failsafeBattEnableText + labelText: qsTr("Leak failsafe:") + valueText: _failsafeLeakEnable.value ? qsTr("Enabled") : qsTr("Disabled") } VehicleSummaryRow { @@ -108,15 +81,13 @@ FactPanel { valueText: _fenceEnable.value == 0 || _fenceType == 0 ? qsTr("Disabled") : (_fenceType.value == 1 ? - qsTr("Altitude") : - (_fenceType.value == 2 ? qsTr("Circle") : qsTr("Altitude,Circle"))) + qsTr("Depth") : + (_fenceType.value == 2 ? qsTr("Circle") : qsTr("Depth,Circle"))) } VehicleSummaryRow { labelText: qsTr("GeoFence:") - valueText: _fenceAction.value == 0 ? - qsTr("Report only") : - (_fenceAction.value == 1 ? qsTr("RTL or Land") : qsTr("Unknown")) + valueText: qsTr("Report only") visible: _fenceEnable.value != 0 } } From 66adea1a4e2f6d43e27ccf90c79a5abea5be60c5 Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Mon, 10 Oct 2016 15:54:48 -0700 Subject: [PATCH 4/8] Update Sub safety for new leak detector parameter names --- src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml | 6 +++--- src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml index a8ff1d1..e07cc4d 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml @@ -40,8 +40,8 @@ QGCView { property Fact _fenceMargin: controller.getParameterFact(-1, "FENCE_MARGIN") property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") - property Fact _leakPin: controller.getParameterFact(-1, "WD_1_PIN") - property Fact _leakLogic: controller.getParameterFact(-1, "WD_1_DEFAULT") + property Fact _leakPin: controller.getParameterFact(-1, "LEAK1_PIN") + property Fact _leakLogic: controller.getParameterFact(-1, "LEAK1_LOGIC") property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") @@ -180,7 +180,7 @@ QGCView { QGCLabel { id: leakDetectorLabel - text: qsTr("Leak Detector") + text: qsTr("Leak detector") font.family: ScreenTools.demiboldFontFamily } diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml index a50f85a..7bab272 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml @@ -21,7 +21,7 @@ FactPanel { property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") - property Fact _leakPin: controller.getParameterFact(-1, "WD_1_PIN") + property Fact _leakPin: controller.getParameterFact(-1, "LEAK1_PIN") property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") @@ -72,7 +72,7 @@ FactPanel { } VehicleSummaryRow { - labelText: qsTr("Leak Detector:") + labelText: qsTr("Leak detector:") valueText: _leakPin.value > 0 ? qsTr("Enabled") : qsTr("Disabled") } From 1386aaa0f8a35bc65f50a4beaf1bc84e05bc9c45 Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Fri, 14 Oct 2016 10:33:20 -0700 Subject: [PATCH 5/8] Update lightsComponent to new SetupPage structure. --- src/AutoPilotPlugins/APM/APMLightsComponent.cc | 2 +- src/AutoPilotPlugins/APM/APMLightsComponent.qml | 307 ++++++++++++------------ 2 files changed, 151 insertions(+), 158 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMLightsComponent.cc b/src/AutoPilotPlugins/APM/APMLightsComponent.cc index 8896dd0..6c6d622 100644 --- a/src/AutoPilotPlugins/APM/APMLightsComponent.cc +++ b/src/AutoPilotPlugins/APM/APMLightsComponent.cc @@ -30,7 +30,7 @@ QString APMLightsComponent::name(void) const QString APMLightsComponent::description(void) const { - return tr("The Lights Component is used to setup lights settings."); + return tr("Lights setup is used to adjust light output channels."); } QString APMLightsComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/APM/APMLightsComponent.qml b/src/AutoPilotPlugins/APM/APMLightsComponent.qml index db0e99a..8b6effa 100644 --- a/src/AutoPilotPlugins/APM/APMLightsComponent.qml +++ b/src/AutoPilotPlugins/APM/APMLightsComponent.qml @@ -17,181 +17,174 @@ import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 -QGCView { - id: _lightsView - viewPanel: panel - anchors.fill: parent - - FactPanelController { id: controller; factPanel: panel } - - QGCPalette { id: palette; colorGroupEnabled: enabled } - - property Fact _rc5Function: controller.getParameterFact(-1, "RC5_FUNCTION") - property Fact _rc6Function: controller.getParameterFact(-1, "RC6_FUNCTION") - property Fact _rc7Function: controller.getParameterFact(-1, "RC7_FUNCTION") - property Fact _rc8Function: controller.getParameterFact(-1, "RC8_FUNCTION") - property Fact _rc9Function: controller.getParameterFact(-1, "RC9_FUNCTION") - property Fact _rc10Function: controller.getParameterFact(-1, "RC10_FUNCTION") - property Fact _rc11Function: controller.getParameterFact(-1, "RC11_FUNCTION") - property Fact _rc12Function: controller.getParameterFact(-1, "RC12_FUNCTION") - property Fact _rc13Function: controller.getParameterFact(-1, "RC13_FUNCTION") - property Fact _rc14Function: controller.getParameterFact(-1, "RC14_FUNCTION") - - readonly property real _margins: ScreenTools.defaultFontPixelHeight - readonly property int _rcFunctionDisabled: 0 - readonly property int _rcFunctionRCIN9: 59 - readonly property int _rcFunctionRCIN10: 60 - readonly property int _firstLightsOutChannel: 5 - readonly property int _lastLightsOutChannel: 14 - - Component.onCompleted: { - calcLightOutValues() - } - - /// Light output channels are stored in RC#_FUNCTION parameters. We need to loop through those - /// to find them and setup the ui accordindly. - function calcLightOutValues() { - lightsLoader.lights1OutIndex = 0 - lightsLoader.lights2OutIndex = 0 - for (var channel=_firstLightsOutChannel; channel<=_lastLightsOutChannel; channel++) { - var functionFact = controller.getParameterFact(-1, "RC" + channel + "_FUNCTION") - if (functionFact.value == _rcFunctionRCIN9) { - lightsLoader.lights1OutIndex = channel - 4 - } else if (functionFact.value == _rcFunctionRCIN10) { - lightsLoader.lights2OutIndex = channel - 4 - } - } - } - - function setRCFunction(channel, rcFunction) { - // First clear any previous settings for this function - for (var index=_firstLightsOutChannel; index<=_lastLightsOutChannel; index++) { - var functionFact = controller.getParameterFact(-1, "RC" + index + "_FUNCTION") - if (functionFact.value != _rcFunctionDisabled && functionFact.value == rcFunction) { - functionFact.value = _rcFunctionDisabled - } - } - - // Now set the function into the new channel - if (channel != 0) { - var functionFact = controller.getParameterFact(-1, "RC" + channel + "_FUNCTION") - functionFact.value = rcFunction - } - } - - // Whenever any RC#_FUNCTION parameters chagnes we need to go looking for light output channels again - Connections { target: _rc5Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc6Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc7Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc8Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc9Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc10Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc11Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc12Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc13Function; onValueChanged: calcLightOutValues() } - Connections { target: _rc14Function; onValueChanged: calcLightOutValues() } - - ListModel { - id: lightsOutModel - ListElement { text: qsTr("Disabled"); value: 0 } - ListElement { text: qsTr("Channel 5"); value: 5 } - ListElement { text: qsTr("Channel 6"); value: 6 } - ListElement { text: qsTr("Channel 7"); value: 7 } - ListElement { text: qsTr("Channel 8"); value: 8 } - ListElement { text: qsTr("Channel 9"); value: 9 } - ListElement { text: qsTr("Channel 10"); value: 10 } - ListElement { text: qsTr("Channel 11"); value: 11 } - ListElement { text: qsTr("Channel 12"); value: 12 } - ListElement { text: qsTr("Channel 13"); value: 13 } - ListElement { text: qsTr("Channel 14"); value: 14 } - } +SetupPage { + id: lightsPage + pageComponent: lightsPageComponent Component { - id: lightSettings - - Item { - width: rectangle.x + rectangle.width - height: rectangle.y + rectangle.height - - QGCLabel { - id: settingsLabel - text: qsTr("Light Settings") - font.family: ScreenTools.demiboldFontFamily + id: lightsPageComponent + + Column { + spacing: _margins + width: availableWidth + + FactPanelController { id: controller; factPanel: lightsPage.viewPanel } + + QGCPalette { id: palette; colorGroupEnabled: true } + + property Fact _rc5Function: controller.getParameterFact(-1, "RC5_FUNCTION") + property Fact _rc6Function: controller.getParameterFact(-1, "RC6_FUNCTION") + property Fact _rc7Function: controller.getParameterFact(-1, "RC7_FUNCTION") + property Fact _rc8Function: controller.getParameterFact(-1, "RC8_FUNCTION") + property Fact _rc9Function: controller.getParameterFact(-1, "RC9_FUNCTION") + property Fact _rc10Function: controller.getParameterFact(-1, "RC10_FUNCTION") + property Fact _rc11Function: controller.getParameterFact(-1, "RC11_FUNCTION") + property Fact _rc12Function: controller.getParameterFact(-1, "RC12_FUNCTION") + property Fact _rc13Function: controller.getParameterFact(-1, "RC13_FUNCTION") + property Fact _rc14Function: controller.getParameterFact(-1, "RC14_FUNCTION") + + readonly property real _margins: ScreenTools.defaultFontPixelHeight + readonly property int _rcFunctionDisabled: 0 + readonly property int _rcFunctionRCIN9: 59 + readonly property int _rcFunctionRCIN10: 60 + readonly property int _firstLightsOutChannel: 5 + readonly property int _lastLightsOutChannel: 14 + + Component.onCompleted: { + calcLightOutValues() } - Rectangle { - id: rectangle - anchors.topMargin: _margins / 2 - anchors.top: settingsLabel.bottom - width: lights1Combo.x + lights1Combo.width + _margins - height: lights2Combo.y + lights2Combo.height + _margins - color: palette.windowShade - - QGCLabel { - id: lights1Label - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: lights1Combo.baseline - text: qsTr("Lights 1:") - } - - QGCComboBox { - id: lights1Combo - anchors.margins: _margins - anchors.top: parent.top - anchors.left: lights1Label.right - width: ScreenTools.defaultFontPixelWidth * 15 - model: lightsOutModel - currentIndex: lights1OutIndex - - onActivated: setRCFunction(lightsOutModel.get(index).value, lights1Function) + /// Light output channels are stored in RC#_FUNCTION parameters. We need to loop through those + /// to find them and setup the ui accordindly. + function calcLightOutValues() { + lightsLoader.lights1OutIndex = 0 + lightsLoader.lights2OutIndex = 0 + for (var channel=_firstLightsOutChannel; channel<=_lastLightsOutChannel; channel++) { + var functionFact = controller.getParameterFact(-1, "RC" + channel + "_FUNCTION") + if (functionFact.value == _rcFunctionRCIN9) { + lightsLoader.lights1OutIndex = channel - 4 + } else if (functionFact.value == _rcFunctionRCIN10) { + lightsLoader.lights2OutIndex = channel - 4 + } } + } - QGCLabel { - id: lights2Label - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: lights2Combo.baseline - text: qsTr("Lights 2:") + function setRCFunction(channel, rcFunction) { + // First clear any previous settings for this function + for (var index=_firstLightsOutChannel; index<=_lastLightsOutChannel; index++) { + var functionFact = controller.getParameterFact(-1, "RC" + index + "_FUNCTION") + if (functionFact.value != _rcFunctionDisabled && functionFact.value == rcFunction) { + functionFact.value = _rcFunctionDisabled + } } - QGCComboBox { - id: lights2Combo - anchors.margins: _margins - anchors.top: lights1Combo.bottom - anchors.left: lights2Label.right - width: lights1Combo.width - model: lightsOutModel - currentIndex: lights2OutIndex - - onActivated: setRCFunction(lightsOutModel.get(index).value, lights2Function) + // Now set the function into the new channel + if (channel != 0) { + var functionFact = controller.getParameterFact(-1, "RC" + channel + "_FUNCTION") + functionFact.value = rcFunction } - } // Rectangle - } // Item - } // Component - lightSettings + } - QGCViewPanel { - id: panel - anchors.fill: parent + // Whenever any RC#_FUNCTION parameters chagnes we need to go looking for light output channels again + Connections { target: _rc5Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc6Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc7Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc8Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc9Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc10Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc11Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc12Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc13Function; onValueChanged: calcLightOutValues() } + Connections { target: _rc14Function; onValueChanged: calcLightOutValues() } + + ListModel { + id: lightsOutModel + ListElement { text: qsTr("Disabled"); value: 0 } + ListElement { text: qsTr("Channel 5"); value: 5 } + ListElement { text: qsTr("Channel 6"); value: 6 } + ListElement { text: qsTr("Channel 7"); value: 7 } + ListElement { text: qsTr("Channel 8"); value: 8 } + ListElement { text: qsTr("Channel 9"); value: 9 } + ListElement { text: qsTr("Channel 10"); value: 10 } + ListElement { text: qsTr("Channel 11"); value: 11 } + ListElement { text: qsTr("Channel 12"); value: 12 } + ListElement { text: qsTr("Channel 13"); value: 13 } + ListElement { text: qsTr("Channel 14"); value: 14 } + } - QGCFlickable { - clip: true - anchors.fill: parent - contentWidth: lightsLoader.x + lightsLoader.width - contentHeight: lightsLoader.y + lightsLoader.height + Component { + id: lightSettings + + Item { + width: rectangle.x + rectangle.width + height: rectangle.y + rectangle.height + + QGCLabel { + id: settingsLabel + text: qsTr("Light Settings") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + id: rectangle + anchors.topMargin: _margins / 2 + anchors.top: settingsLabel.bottom + width: lights1Combo.x + lights1Combo.width + _margins + height: lights2Combo.y + lights2Combo.height + _margins + color: palette.windowShade + + QGCLabel { + id: lights1Label + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: lights1Combo.baseline + text: qsTr("Lights 1:") + } + + QGCComboBox { + id: lights1Combo + anchors.margins: _margins + anchors.top: parent.top + anchors.left: lights1Label.right + width: ScreenTools.defaultFontPixelWidth * 15 + model: lightsOutModel + currentIndex: lights1OutIndex + + onActivated: setRCFunction(lightsOutModel.get(index).value, lights1Function) + } + + QGCLabel { + id: lights2Label + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: lights2Combo.baseline + text: qsTr("Lights 2:") + } + + QGCComboBox { + id: lights2Combo + anchors.margins: _margins + anchors.top: lights1Combo.bottom + anchors.left: lights2Label.right + width: lights1Combo.width + model: lightsOutModel + currentIndex: lights2OutIndex + + onActivated: setRCFunction(lightsOutModel.get(index).value, lights2Function) + } + } // Rectangle + } // Item + } // Component - lightSettings Loader { id: lightsLoader sourceComponent: lightSettings - anchors.margins: _margins - anchors.top: parent.top - property int lights1OutIndex: 0 property int lights2OutIndex: 0 property int lights1Function: _rcFunctionRCIN9 property int lights2Function: _rcFunctionRCIN10 } - } // Flickable - } // QGCViewPanel -} // QGCView + } // Column + } // Component +} // SetupPage From 5dffd405c1001ba641755b1c03a4cde173c19990 Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Fri, 14 Oct 2016 10:34:23 -0700 Subject: [PATCH 6/8] Update Sub's safetyComponent to use new SetupPage structure. --- src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml | 419 ++++++++++----------- 1 file changed, 205 insertions(+), 214 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml index e07cc4d..affae19 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml @@ -18,258 +18,249 @@ import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 -QGCView { - id: _safetyView - viewPanel: panel - anchors.fill: parent +SetupPage { + id: safetyPage + pageComponent: safetyPageComponent - FactPanelController { id: controller; factPanel: panel } + Component { + id: safetyPageComponent - QGCPalette { id: ggcPal; colorGroupEnabled: enabled } + Flow { + id: flowLayout + width: availableWidth + spacing: _margins - property Fact _failsafeGCSEnable: controller.getParameterFact(-1, "FS_GCS_ENABLE") - property Fact _failsafeLeakEnable: controller.getParameterFact(-1, "FS_LEAK_ENABLE") - property Fact _failsafePressureEnable: controller.getParameterFact(-1, "FS_PRESS_ENABLE") - property Fact _failsafePressureValue: controller.getParameterFact(-1, "FS_PRESS_MAX") - property Fact _failsafeTempEnable: controller.getParameterFact(-1, "FS_TEMP_ENABLE") - property Fact _failsafeTempValue: controller.getParameterFact(-1, "FS_TEMP_MAX") + FactPanelController { id: controller; factPanel: safetyPage.viewPanel } - property Fact _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") - property Fact _fenceAltMax: controller.getParameterFact(-1, "FENCE_ALT_MAX") - property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") - property Fact _fenceMargin: controller.getParameterFact(-1, "FENCE_MARGIN") - property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") + QGCPalette { id: ggcPal; colorGroupEnabled: true } - property Fact _leakPin: controller.getParameterFact(-1, "LEAK1_PIN") - property Fact _leakLogic: controller.getParameterFact(-1, "LEAK1_LOGIC") + property Fact _failsafeGCSEnable: controller.getParameterFact(-1, "FS_GCS_ENABLE") + property Fact _failsafeLeakEnable: controller.getParameterFact(-1, "FS_LEAK_ENABLE") + property Fact _failsafePressureEnable: controller.getParameterFact(-1, "FS_PRESS_ENABLE") + property Fact _failsafePressureValue: controller.getParameterFact(-1, "FS_PRESS_MAX") + property Fact _failsafeTempEnable: controller.getParameterFact(-1, "FS_TEMP_ENABLE") + property Fact _failsafeTempValue: controller.getParameterFact(-1, "FS_TEMP_MAX") - property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") + property Fact _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") + property Fact _fenceAltMax: controller.getParameterFact(-1, "FENCE_ALT_MAX") + property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") + property Fact _fenceMargin: controller.getParameterFact(-1, "FENCE_MARGIN") + property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") - property real _margins: ScreenTools.defaultFontPixelHeight - property bool _showIcon: !ScreenTools.isTinyScreen + property Fact _leakPin: controller.getParameterFact(-1, "LEAK1_PIN") + property Fact _leakLogic: controller.getParameterFact(-1, "LEAK1_LOGIC") - ExclusiveGroup { id: fenceActionRadioGroup } + property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") - QGCViewPanel { - id: panel - anchors.fill: parent + property real _margins: ScreenTools.defaultFontPixelHeight + property bool _showIcon: !ScreenTools.isTinyScreen - QGCFlickable { - clip: true - anchors.fill: parent - contentHeight: flowLayout.height - contentWidth: flowLayout.width + ExclusiveGroup { id: fenceActionRadioGroup } - Flow { - id: flowLayout - width: panel.width // parent.width doesn't work for some reason - spacing: _margins + Column { + spacing: _margins / 2 - Column { - spacing: _margins / 2 + QGCLabel { + id: failsafeLabel + text: qsTr("Failsafe Actions") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + id: failsafeSettings + width: leakEnableCombo.x + leakEnableCombo.width + _margins + height: leakEnableCombo.y + leakEnableCombo.height + _margins + color: ggcPal.windowShade QGCLabel { - id: failsafeLabel - text: qsTr("Failsafe Actions") - font.family: ScreenTools.demiboldFontFamily + id: gcsEnableLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: gcsEnableCombo.baseline + text: qsTr("Ground Station failsafe:") } - Rectangle { - id: failsafeSettings - width: leakEnableCombo.x + leakEnableCombo.width + _margins - height: leakEnableCombo.y + leakEnableCombo.height + _margins - color: ggcPal.windowShade - - QGCLabel { - id: gcsEnableLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: gcsEnableCombo.baseline - text: qsTr("Ground Station failsafe:") - } - - FactComboBox { - id: gcsEnableCombo - anchors.margins: _margins - anchors.left: gcsEnableLabel.right - anchors.top: parent.top - width: ScreenTools.defaultFontPixelWidth*15 - fact: _failsafeGCSEnable - indexModel: false - } - - QGCLabel { - id: leakEnableLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.baseline: leakEnableCombo.baseline - text: qsTr("Leak failsafe:") - } - - FactComboBox { - id: leakEnableCombo - anchors.topMargin: _margins - anchors.left: gcsEnableCombo.left - anchors.top: gcsEnableCombo.bottom - width: ScreenTools.defaultFontPixelWidth*15 - fact: _failsafeLeakEnable - indexModel: false - } - } // Rectangle - Failsafe Settings - } // Column - Failsafe Settings - - Column { - spacing: _margins / 2 + FactComboBox { + id: gcsEnableCombo + anchors.margins: _margins + anchors.left: gcsEnableLabel.right + anchors.top: parent.top + width: ScreenTools.defaultFontPixelWidth*15 + fact: _failsafeGCSEnable + indexModel: false + } QGCLabel { - id: geoFenceLabel - text: qsTr("GeoFence") - font.family: ScreenTools.demiboldFontFamily + id: leakEnableLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.baseline: leakEnableCombo.baseline + text: qsTr("Leak failsafe:") } - Rectangle { - id: geoFenceSettings - width: fenceAltMaxField.x + fenceAltMaxField.width + _margins - height: fenceAltMaxField.y + fenceAltMaxField.height + _margins - color: ggcPal.windowShade - - QGCCheckBox { - id: altitudeGeo - anchors.margins: _margins - anchors.left: parent.left - anchors.top: parent.top - text: qsTr("Depth GeoFence enabled\n(report only)") - checked: _fenceEnable.value != 0 && _fenceType.value & 1 - - onClicked: { - if (checked) { - if (_fenceEnable.value == 1) { - _fenceType.value |= 1 - } else { - _fenceEnable.value = 1 - _fenceType.value = 1 - } + FactComboBox { + id: leakEnableCombo + anchors.topMargin: _margins + anchors.left: gcsEnableCombo.left + anchors.top: gcsEnableCombo.bottom + width: ScreenTools.defaultFontPixelWidth*15 + fact: _failsafeLeakEnable + indexModel: false + } + } // Rectangle - Failsafe Settings + } // Column - Failsafe Settings + + Column { + spacing: _margins / 2 + + QGCLabel { + id: geoFenceLabel + text: qsTr("GeoFence") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + id: geoFenceSettings + width: fenceAltMaxField.x + fenceAltMaxField.width + _margins + height: fenceAltMaxField.y + fenceAltMaxField.height + _margins + color: ggcPal.windowShade + + QGCCheckBox { + id: altitudeGeo + anchors.margins: _margins + anchors.left: parent.left + anchors.top: parent.top + text: qsTr("Depth GeoFence enabled\n(report only)") + checked: _fenceEnable.value != 0 && _fenceType.value & 1 + + onClicked: { + if (checked) { + if (_fenceEnable.value == 1) { + _fenceType.value |= 1 } else { - _fenceEnable.value = 0 - _fenceType.value = 0 + _fenceEnable.value = 1 + _fenceType.value = 1 } + } else { + _fenceEnable.value = 0 + _fenceType.value = 0 } } - - QGCLabel { - id: fenceAltMaxLabel - anchors.left: altitudeGeo.left - anchors.baseline: fenceAltMaxField.baseline - text: qsTr("Max depth:") - } - - FactTextField { - id: fenceAltMaxField - anchors.topMargin: _margins / 2 - anchors.leftMargin: _margins - anchors.left: fenceAltMaxLabel.right - anchors.top: altitudeGeo.bottom - fact: _fenceAltMax - showUnits: true - } - } // Rectangle - GeoFence Settings - } // Column - GeoFence Settings - - Column { - spacing: _margins / 2 + } QGCLabel { - id: leakDetectorLabel - text: qsTr("Leak detector") - font.family: ScreenTools.demiboldFontFamily + id: fenceAltMaxLabel + anchors.left: altitudeGeo.left + anchors.baseline: fenceAltMaxField.baseline + text: qsTr("Max depth:") } - Rectangle { - id: leakDetectorSettings - width: leakLogicCombo.x + leakLogicCombo.width + _margins - height: leakLogicCombo.y + leakLogicCombo.height + _margins - color: ggcPal.windowShade + FactTextField { + id: fenceAltMaxField + anchors.topMargin: _margins / 2 + anchors.leftMargin: _margins + anchors.left: fenceAltMaxLabel.right + anchors.top: altitudeGeo.bottom + fact: _fenceAltMax + showUnits: true + } + } // Rectangle - GeoFence Settings + } // Column - GeoFence Settings - QGCLabel { - id: leakPinLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.top: parent.top - text: qsTr("Pin:") - } + Column { + spacing: _margins / 2 - FactComboBox { - id: leakPinCombo - anchors.margins: _margins - anchors.left: leakLogicLabel.right - anchors.baseline: leakPinLabel.baseline - width: ScreenTools.defaultFontPixelWidth*15 - fact: _leakPin - indexModel: false - } + QGCLabel { + id: leakDetectorLabel + text: qsTr("Leak detector") + font.family: ScreenTools.demiboldFontFamily + } - QGCLabel { - id: leakLogicLabel - anchors.margins: _margins - anchors.left: parent.left - anchors.top: leakPinLabel.bottom - text: qsTr("Logic:") - } + Rectangle { + id: leakDetectorSettings + width: leakLogicCombo.x + leakLogicCombo.width + _margins + height: leakLogicCombo.y + leakLogicCombo.height + _margins + color: ggcPal.windowShade - FactComboBox { - id: leakLogicCombo - anchors.margins: _margins - anchors.left: leakLogicLabel.right - anchors.baseline: leakLogicLabel.baseline - width: ScreenTools.defaultFontPixelWidth*15 - fact: _leakLogic - indexModel: false - } - } // Rectangle - Leak Detector Settings - } // Column - Leak Detector Settings + QGCLabel { + id: leakPinLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.top: parent.top + text: qsTr("Pin:") + } - Column { - spacing: _margins / 2 + FactComboBox { + id: leakPinCombo + anchors.margins: _margins + anchors.left: leakLogicLabel.right + anchors.baseline: leakPinLabel.baseline + width: ScreenTools.defaultFontPixelWidth*15 + fact: _leakPin + indexModel: false + } QGCLabel { - text: qsTr("Arming Checks") - font.family: ScreenTools.demiboldFontFamily + id: leakLogicLabel + anchors.margins: _margins + anchors.left: parent.left + anchors.top: leakPinLabel.bottom + text: qsTr("Logic:") } - Rectangle { - width: flowLayout.width - height: armingCheckInnerColumn.height + (_margins * 2) - color: ggcPal.windowShade - - Column { - id: armingCheckInnerColumn - anchors.margins: _margins - anchors.top: parent.top + FactComboBox { + id: leakLogicCombo + anchors.margins: _margins + anchors.left: leakLogicLabel.right + anchors.baseline: leakLogicLabel.baseline + width: ScreenTools.defaultFontPixelWidth*15 + fact: _leakLogic + indexModel: false + } + } // Rectangle - Leak Detector Settings + } // Column - Leak Detector Settings + + Column { + spacing: _margins / 2 + + QGCLabel { + text: qsTr("Arming Checks") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + width: flowLayout.width + height: armingCheckInnerColumn.height + (_margins * 2) + color: ggcPal.windowShade + + Column { + id: armingCheckInnerColumn + anchors.margins: _margins + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + spacing: _margins + + FactBitmask { + id: armingCheckBitmask anchors.left: parent.left anchors.right: parent.right - spacing: _margins - - FactBitmask { - id: armingCheckBitmask - anchors.left: parent.left - anchors.right: parent.right - firstEntryIsAll: true - fact: _armingCheck - } + firstEntryIsAll: true + fact: _armingCheck + } - QGCLabel { - id: armingCheckWarning - anchors.left: parent.left - anchors.right: parent.right - wrapMode: Text.WordWrap - color: qgcPal.warningText - text: qsTr("Warning: Turning off arming checks can lead to loss of Vehicle control.") - visible: _armingCheck.value != 1 - } + QGCLabel { + id: armingCheckWarning + anchors.left: parent.left + anchors.right: parent.right + wrapMode: Text.WordWrap + color: qgcPal.warningText + text: qsTr("Warning: Turning off arming checks can lead to loss of Vehicle control.") + visible: _armingCheck.value != 1 } - } // Rectangle - Arming checks - } // Column - Arming Checks - } // Flow - } // QGCFlickable - } // QGCViewPanel -} // QGCView + } + } // Rectangle - Arming checks + } // Column - Arming Checks + } // Flow + } // Component - safetyPageComponent +} // SetupView From 501faff45f4fcf10551d6ff1602ebbd5aec74137 Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Fri, 14 Oct 2016 10:35:12 -0700 Subject: [PATCH 7/8] Change safety page description for Sub only. --- src/AutoPilotPlugins/APM/APMSafetyComponent.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponent.cc b/src/AutoPilotPlugins/APM/APMSafetyComponent.cc index 39caad7..02da238 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponent.cc +++ b/src/AutoPilotPlugins/APM/APMSafetyComponent.cc @@ -29,7 +29,22 @@ QString APMSafetyComponent::name(void) const QString APMSafetyComponent::description(void) const { - return tr("Safety Setup is used to setup triggers for Return to Land as well as the settings for Return to Land itself."); + switch (_vehicle->vehicleType()) { + case MAV_TYPE_SUBMARINE: + return tr("Safety Setup is used to setup failsafe actions, geofence limits, leak detection, and arming checks."); + break; + case MAV_TYPE_GROUND_ROVER: + case MAV_TYPE_FIXED_WING: + case MAV_TYPE_QUADROTOR: + case MAV_TYPE_COAXIAL: + case MAV_TYPE_HELICOPTER: + case MAV_TYPE_HEXAROTOR: + case MAV_TYPE_OCTOROTOR: + case MAV_TYPE_TRICOPTER: + default: + return tr("Safety Setup is used to setup triggers for Return to Land as well as the settings for Return to Land itself."); + break; + } } QString APMSafetyComponent::iconResource(void) const From 66efcdfc8c7bed3b71a918d4cc66a7aa6d9abaaa Mon Sep 17 00:00:00 2001 From: Rustom Jehangir Date: Fri, 14 Oct 2016 10:38:47 -0700 Subject: [PATCH 8/8] Minor label text edit. --- src/AutoPilotPlugins/APM/APMLightsComponent.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AutoPilotPlugins/APM/APMLightsComponent.qml b/src/AutoPilotPlugins/APM/APMLightsComponent.qml index 8b6effa..42c76d1 100644 --- a/src/AutoPilotPlugins/APM/APMLightsComponent.qml +++ b/src/AutoPilotPlugins/APM/APMLightsComponent.qml @@ -121,7 +121,7 @@ SetupPage { QGCLabel { id: settingsLabel - text: qsTr("Light Settings") + text: qsTr("Light Output Channels") font.family: ScreenTools.demiboldFontFamily }