diff --git a/src/AutoPilotPlugins/APM/APMPowerComponent.cc b/src/AutoPilotPlugins/APM/APMPowerComponent.cc index d7e6f371a586eaffbaa1d148f4ce4454f18d6ea5..8922559a80965ad35bee23096192fba79564ae52 100644 --- a/src/AutoPilotPlugins/APM/APMPowerComponent.cc +++ b/src/AutoPilotPlugins/APM/APMPowerComponent.cc @@ -34,25 +34,6 @@ QString APMPowerComponent::iconResource(void) const return QStringLiteral("/qmlimages/PowerComponentIcon.png"); } -bool APMPowerComponent::requiresSetup(void) const -{ - return true; -} - -bool APMPowerComponent::setupComplete(void) const -{ - return _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, QStringLiteral("BATT_CAPACITY"))->rawValue().toInt() != 0; -} - -QStringList APMPowerComponent::setupCompleteChangedTriggerList(void) const -{ - QStringList list; - - list << QStringLiteral("BATT_CAPACITY"); - - return list; -} - QUrl APMPowerComponent::setupSource(void) const { return QUrl::fromUserInput(QStringLiteral("qrc:/qml/APMPowerComponent.qml")); diff --git a/src/AutoPilotPlugins/APM/APMPowerComponent.h b/src/AutoPilotPlugins/APM/APMPowerComponent.h index e033041fba18f84c2c1040b34305e90a61e030dd..7dbfe5d7bd48b8d206f782381d5493e51fa80bc7 100644 --- a/src/AutoPilotPlugins/APM/APMPowerComponent.h +++ b/src/AutoPilotPlugins/APM/APMPowerComponent.h @@ -21,14 +21,14 @@ public: APMPowerComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); // Overrides from VehicleComponent - QStringList setupCompleteChangedTriggerList(void) const override; + QStringList setupCompleteChangedTriggerList(void) const override { return QStringList(); } // Virtuals from VehicleComponent QString name (void) const override; QString description (void) const override; QString iconResource (void) const override; - bool requiresSetup (void) const override; - bool setupComplete (void) const override; + bool requiresSetup (void) const override { return false; } + bool setupComplete (void) const override { return true; } QUrl setupSource (void) const override; QUrl summaryQmlSource (void) const override; bool allowSetupWhileArmed (void) const override { return true; } diff --git a/src/AutoPilotPlugins/APM/APMPowerComponent.qml b/src/AutoPilotPlugins/APM/APMPowerComponent.qml index 8552e8c1e71b5bd751a4383e1d05bdab173616d9..6812a0e2db12d8dd343ea0191274540997e8ec58 100644 --- a/src/AutoPilotPlugins/APM/APMPowerComponent.qml +++ b/src/AutoPilotPlugins/APM/APMPowerComponent.qml @@ -36,15 +36,65 @@ SetupPage { width: availableWidth spacing: _margins - property bool _batt2ParamsAvailable: controller.parameterExists(-1, "BATT2_FS_LOW_ACT") - property bool _batt2MonitorAvailable: controller.parameterExists(-1, "BATT2_MONITOR") + property Fact _batt1Monitor: controller.getParameterFact(-1, "BATT_MONITOR") property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) + property bool _batt2MonitorAvailable: controller.parameterExists(-1, "BATT2_MONITOR") + property bool _batt1MonitorEnabled: _batt1Monitor.rawValue !== 0 + property bool _batt2MonitorEnabled: _batt2MonitorAvailable && _batt2Monitor.rawValue !== 0 + property bool _batt1ParamsAvailable: controller.parameterExists(-1, "BATT_CAPACITY") + property bool _batt2ParamsAvailable: controller.parameterExists(-1, "BATT2_CAPACITY") + + property string _restartRequired: qsTr("Requires vehicle reboot") QGCPalette { id: ggcPal; colorGroupEnabled: true } - // Battery 1 settings + // Battery1 Monitor settings only - used when only monitor param is available Column { spacing: _margins / 2 + visible: !_batt1MonitorEnabled || !_batt1ParamsAvailable + + QGCLabel { + text: qsTr("Battery 1") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + width: batt1Column.x + batt1Column.width + _margins + height: batt1Column.y + batt1Column.height + _margins + color: ggcPal.windowShade + + ColumnLayout { + id: batt1Column + anchors.margins: _margins + anchors.top: parent.top + anchors.left: parent.left + spacing: ScreenTools.defaultFontPixelWidth + + RowLayout { + id: batt1MonitorRow + spacing: ScreenTools.defaultFontPixelWidth + + QGCLabel { text: qsTr("Battery1 monitor:") } + FactComboBox { + id: monitor1Combo + fact: _batt1Monitor + indexModel: false + } + } + + QGCLabel { + text: _restartRequired + visible: _batt1MonitorEnabled && !_batt1ParamsAvailable + } + } + } + } + + // Battery 1 settings + Column { + id: _batt1FullSettings + spacing: _margins / 2 + visible: _batt1MonitorEnabled && _batt1ParamsAvailable QGCLabel { text: qsTr("Battery 1") @@ -61,25 +111,25 @@ SetupPage { anchors.margins: _margins anchors.top: parent.top anchors.left: parent.left - sourceComponent: powerSetupComponent - - property Fact armVoltMin: controller.getParameterFact(-1, "r.ARMING_VOLT_MIN") - property Fact battAmpPerVolt: controller.getParameterFact(-1, "r.BATT_AMP_PERVLT") - property Fact battCapacity: controller.getParameterFact(-1, "BATT_CAPACITY") - property Fact battCurrPin: controller.getParameterFact(-1, "BATT_CURR_PIN") - property Fact battMonitor: controller.getParameterFact(-1, "BATT_MONITOR") - property Fact battVoltMult: controller.getParameterFact(-1, "BATT_VOLT_MULT") - property Fact battVoltPin: controller.getParameterFact(-1, "BATT_VOLT_PIN") + sourceComponent: _batt1FullSettings.visible ? powerSetupComponent : undefined + + property Fact armVoltMin: controller.getParameterFact(-1, "r.ARMING_VOLT_MIN", false /* reportMissing */) + property Fact battAmpPerVolt: controller.getParameterFact(-1, "r.BATT_AMP_PERVLT", false /* reportMissing */) + property Fact battCapacity: controller.getParameterFact(-1, "BATT_CAPACITY", false /* reportMissing */) + property Fact battCurrPin: controller.getParameterFact(-1, "BATT_CURR_PIN", false /* reportMissing */) + property Fact battMonitor: controller.getParameterFact(-1, "BATT_MONITOR", false /* reportMissing */) + property Fact battVoltMult: controller.getParameterFact(-1, "BATT_VOLT_MULT", false /* reportMissing */) + property Fact battVoltPin: controller.getParameterFact(-1, "BATT_VOLT_PIN", false /* reportMissing */) property Fact vehicleVoltage: controller.vehicle.battery.voltage property Fact vehicleCurrent: controller.vehicle.battery.current } } } - // Batter2 Monitor settings only - used when only monitor param is available + // Battery2 Monitor settings only - used when only monitor param is available Column { spacing: _margins / 2 - visible: _batt2MonitorAvailable && !_batt2ParamsAvailable + visible: !_batt2MonitorEnabled || !_batt2ParamsAvailable QGCLabel { text: qsTr("Battery 2") @@ -87,23 +137,32 @@ SetupPage { } Rectangle { - width: batt2MonitorRow.x + batt2MonitorRow.width + _margins - height: batt2MonitorRow.y + batt2MonitorRow.height + _margins + width: batt2Column.x + batt2Column.width + _margins + height: batt2Column.y + batt2Column.height + _margins color: ggcPal.windowShade - RowLayout { - id: batt2MonitorRow + ColumnLayout { + id: batt2Column anchors.margins: _margins anchors.top: parent.top anchors.left: parent.left spacing: ScreenTools.defaultFontPixelWidth - visible: _batt2MonitorAvailable && !_batt2ParamsAvailable - QGCLabel { text: qsTr("Battery2 monitor:") } - FactComboBox { - id: monitorCombo - fact: _batt2Monitor - indexModel: false + RowLayout { + id: batt2MonitorRow + spacing: ScreenTools.defaultFontPixelWidth + + QGCLabel { text: qsTr("Battery2 monitor:") } + FactComboBox { + id: monitor2Combo + fact: _batt2Monitor + indexModel: false + } + } + + QGCLabel { + text: _restartRequired + visible: _batt2MonitorEnabled && !_batt2ParamsAvailable } } } @@ -111,8 +170,9 @@ SetupPage { // Battery 2 settings - Used when full params are available Column { - spacing: _margins / 2 - visible: _batt2ParamsAvailable + id: batt2FullSettings + spacing: _margins / 2 + visible: _batt2MonitorEnabled && _batt2ParamsAvailable QGCLabel { text: qsTr("Battery 2") @@ -129,7 +189,7 @@ SetupPage { anchors.margins: _margins anchors.top: parent.top anchors.left: parent.left - sourceComponent: _batt2ParamsAvailable ? powerSetupComponent : undefined + sourceComponent: batt2FullSettings.visible ? powerSetupComponent : undefined property Fact armVoltMin: controller.getParameterFact(-1, "r.ARMING_VOLT2_MIN", false /* reportMissing */) property Fact battAmpPerVolt: controller.getParameterFact(-1, "r.BATT2_AMP_PERVLT", false /* reportMissing */) diff --git a/src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml b/src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml index ab23561769b0914cc8f6c917628989b70d3f35c5..642dc15b588642573b09117feb043db917024106 100644 --- a/src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml +++ b/src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml @@ -7,7 +7,6 @@ * ****************************************************************************/ - import QtQuick 2.3 import QtQuick.Controls 1.2 @@ -24,37 +23,40 @@ FactPanel { QGCPalette { id: qgcPal; colorGroupEnabled: enabled } FactPanelController { id: controller; factPanel: panel } + property Fact _batt1Monitor: controller.getParameterFact(-1, "BATT_MONITOR") + property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) property bool _batt2MonitorAvailable: controller.parameterExists(-1, "BATT2_MONITOR") - property bool _batt2CapacityAvailable: controller.parameterExists(-1, "BATT2_CAPACITY") + property bool _batt1MonitorEnabled: _batt1Monitor.rawValue !== 0 + property bool _batt2MonitorEnabled: _batt2MonitorAvailable && _batt2Monitor.rawValue !== 0 - property Fact _battCapacity: controller.getParameterFact(-1, "BATT_CAPACITY") + property Fact _battCapacity: controller.getParameterFact(-1, "BATT_CAPACITY", false /* reportMissing */) property Fact _batt2Capacity: controller.getParameterFact(-1, "BATT2_CAPACITY", false /* reportMissing */) - property Fact _battMonitor: controller.getParameterFact(-1, "BATT_MONITOR") - property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) + property bool _battCapacityAvailable: controller.parameterExists(-1, "BATT_CAPACITY") Column { anchors.fill: parent VehicleSummaryRow { - labelText: qsTr("Battery monitor") - valueText: _battMonitor.enumStringValue + labelText: qsTr("Batt1 monitor") + valueText: _batt1Monitor.enumStringValue } VehicleSummaryRow { - labelText: qsTr("Battery capacity") - valueText: _battCapacity.valueString + " " + _battCapacity.units + labelText: qsTr("Batt1 capacity") + valueText: _batt1MonitorEnabled ? _battCapacity.valueString + " " + _battCapacity.units : "" + visible: _batt1MonitorEnabled } VehicleSummaryRow { - labelText: qsTr("Battery2 monitor") + labelText: qsTr("Batt2 monitor") valueText: _batt2MonitorAvailable ? _batt2Monitor.enumStringValue : "" visible: _batt2MonitorAvailable } VehicleSummaryRow { - labelText: qsTr("Battery2 capacity") - valueText: _batt2CapacityAvailable ? _batt2Capacity.valueString + " " + _battCapacity.units : "" - visible: _batt2CapacityAvailable + labelText: qsTr("Batt2 capacity") + valueText: _batt2MonitorEnabled ? _batt2Capacity.valueString + " " + _batt2Capacity.units : "" + visible: _batt2MonitorEnabled } } } diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml index fdcf50ce3542c8c1eb811d6645a01dd0f62ff491..aa83712f9dfb7a1dab40fd8b5e86dac123e356bf 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml @@ -36,20 +36,21 @@ SetupPage { QGCPalette { id: ggcPal; colorGroupEnabled: true } property Fact _failsafeGCSEnable: controller.getParameterFact(-1, "FS_GCS_ENABLE") - property Fact _failsafeBattLowAct: controller.getParameterFact(-1, "r.BATT_FS_LOW_ACT") - property Fact _failsafeBattMah: controller.getParameterFact(-1, "r.BATT_LOW_MAH") - property Fact _failsafeBattVoltage: controller.getParameterFact(-1, "r.BATT_LOW_VOLT") + property Fact _failsafeBattLowAct: controller.getParameterFact(-1, "r.BATT_FS_LOW_ACT", false /* reportMissing */) + property Fact _failsafeBattMah: controller.getParameterFact(-1, "r.BATT_LOW_MAH", false /* reportMissing */) + property Fact _failsafeBattVoltage: controller.getParameterFact(-1, "r.BATT_LOW_VOLT", false /* reportMissing */) property Fact _failsafeThrEnable: controller.getParameterFact(-1, "FS_THR_ENABLE") property Fact _failsafeThrValue: controller.getParameterFact(-1, "FS_THR_VALUE") - property bool _failsafeBattCritActAvailable: controller.parameterExists(-1, "BATT_FS_CRT_ACT") - property bool _failsafeBatt2LowActAvailable: controller.parameterExists(-1, "BATT2_FS_LOW_ACT") - property bool _failsafeBatt2CritActAvailable: controller.parameterExists(-1, "BATT2_FS_CRT_ACT") + property Fact _batt1Monitor: controller.getParameterFact(-1, "BATT_MONITOR") + property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) property bool _batt2MonitorAvailable: controller.parameterExists(-1, "BATT2_MONITOR") + property bool _batt1MonitorEnabled: _batt2MonitorAvailable ? _batt2Monitor.rawValue !== 0 : false property bool _batt2MonitorEnabled: _batt2MonitorAvailable ? _batt2Monitor.rawValue !== 0 : false + property bool _batt1ParamsAvailable: controller.parameterExists(-1, "BATT_CAPACITY") + property bool _batt2ParamsAvailable: controller.parameterExists(-1, "BATT2_CAPACITY") property Fact _failsafeBattCritAct: controller.getParameterFact(-1, "BATT_FS_CRT_ACT", false /* reportMissing */) - property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) property Fact _failsafeBatt2LowAct: controller.getParameterFact(-1, "BATT2_FS_LOW_ACT", false /* reportMissing */) property Fact _failsafeBatt2CritAct: controller.getParameterFact(-1, "BATT2_FS_CRT_ACT", false /* reportMissing */) property Fact _failsafeBatt2Mah: controller.getParameterFact(-1, "BATT2_LOW_MAH", false /* reportMissing */) @@ -78,9 +79,10 @@ SetupPage { Column { spacing: _margins / 2 + visible: _batt1MonitorEnabled && _batt1ParamsAvailable QGCLabel { - text: qsTr("Battery Failsafe Triggers") + text: qsTr("Battery1 Failsafe Triggers") font.family: ScreenTools.demiboldFontFamily } @@ -147,7 +149,7 @@ SetupPage { Column { spacing: _margins / 2 - visible: _batt2MonitorEnabled && _failsafeBatt2LowActAvailable + visible: _batt2MonitorEnabled && _batt2ParamsAvailable QGCLabel { text: qsTr("Battery2 Failsafe Triggers") diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSummaryCopter.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSummaryCopter.qml index a08b9c082dd33c1f1befea2414d3c91b3e6578a7..03c2ec5c647f61ef294a9dce7c0b478c3c22ca48 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSummaryCopter.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSummaryCopter.qml @@ -14,63 +14,63 @@ FactPanel { QGCPalette { id: qgcPal; colorGroupEnabled: enabled } FactPanelController { id: controller; factPanel: panel } - property Fact _failsafeBattLowAct: controller.getParameterFact(-1, "r.BATT_FS_LOW_ACT") - property Fact _failsafeThrEnable: controller.getParameterFact(-1, "FS_THR_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 _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") + property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") + property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") - property Fact _rtlAltFact: controller.getParameterFact(-1, "RTL_ALT") - property Fact _rtlLoitTimeFact: controller.getParameterFact(-1, "RTL_LOIT_TIME") - property Fact _rtlAltFinalFact: controller.getParameterFact(-1, "RTL_ALT_FINAL") - property Fact _landSpeedFact: controller.getParameterFact(-1, "LAND_SPEED") + property Fact _rtlAltFact: controller.getParameterFact(-1, "RTL_ALT") - property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") + property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") - property bool _failsafeBattCritActAvailable: controller.parameterExists(-1, "BATT_FS_CRT_ACT") - property bool _failsafeBatt2LowActAvailable: controller.parameterExists(-1, "BATT2_FS_LOW_ACT") - property bool _failsafeBatt2CritActAvailable: controller.parameterExists(-1, "BATT2_FS_CRT_ACT") + property Fact _batt1Monitor: controller.getParameterFact(-1, "BATT_MONITOR") + property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) + property bool _batt2MonitorAvailable: controller.parameterExists(-1, "BATT2_MONITOR") + property bool _batt1MonitorEnabled: _batt1Monitor.rawValue !== 0 + property bool _batt2MonitorEnabled: _batt2MonitorAvailable && _batt2Monitor.rawValue !== 0 - property Fact _failsafeBattCritAct: controller.getParameterFact(-1, "BATT_FS_CRT_ACT", false /* reportMissing */) - property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) - property Fact _failsafeBatt2LowAct: controller.getParameterFact(-1, "BATT2_FS_LOW_ACT", false /* reportMissing */) - property Fact _failsafeBatt2CritAct: controller.getParameterFact(-1, "BATT2_FS_CRT_ACT", false /* reportMissing */) + property Fact _batt1FSLowAct: controller.getParameterFact(-1, "r.BATT_FS_LOW_ACT", false /* reportMissing */) + property Fact _batt1FSCritAct: controller.getParameterFact(-1, "BATT_FS_CRT_ACT", false /* reportMissing */) + property Fact _batt2FSLowAct: controller.getParameterFact(-1, "BATT2_FS_LOW_ACT", false /* reportMissing */) + property Fact _batt2FSCritAct: controller.getParameterFact(-1, "BATT2_FS_CRT_ACT", false /* reportMissing */) + property bool _batt1FSCritActAvailable: controller.parameterExists(-1, "BATT_FS_CRT_ACT") Column { anchors.fill: parent VehicleSummaryRow { labelText: qsTr("Arming Checks:") - valueText: _armingCheck.value & 1 ? qsTr("Enabled") : qsTr("Some disabled") + valueText: _armingCheck.value & 1 ? qsTr("Enabled") : qsTr("Some disabled") } VehicleSummaryRow { labelText: qsTr("Throttle failsafe:") - valueText: _failsafeBattLowAct.enumStringValue + valueText: _failsafeThrEnable.enumStringValue } VehicleSummaryRow { - labelText: qsTr("Batt low failsafe:") - valueText: _failsafeBattLowAct.enumStringValue + labelText: qsTr("Batt1 low failsafe:") + valueText: _batt1MonitorEnabled ? _batt1FSLowAct.enumStringValue : "" + visible: _batt1MonitorEnabled } VehicleSummaryRow { - labelText: qsTr("Batt critical failsafe:") - valueText: _failsafeBattCritActAvailable ? _failsafeBattCritAct.enumStringValue : "" - visible: _failsafeBattCritActAvailable + labelText: qsTr("Batt1 critical failsafe:") + valueText: _batt1FSCritActAvailable ? _batt1FSCritAct.enumStringValue : "" + visible: _batt1FSCritActAvailable } VehicleSummaryRow { - labelText: qsTr("Batt2 low failsafe:") - valueText: _failsafeBatt2LowActAvailable ? _failsafeBatt2LowAct.enumStringValue : "" - visible: _failsafeBatt2LowActAvailable + labelText: qsTr("Batt2 low failsafe:") + valueText: _batt2MonitorEnabled ? _batt2FSLowAct.enumStringValue : "" + visible: _batt2MonitorEnabled } VehicleSummaryRow { - labelText: qsTr("Batt2 critical failsafe:") - valueText: _failsafeBatt2CritActAvailable ? _failsafeBatt2CritAct.enumStringValue : "" - visible: _failsafeBatt2CritActAvailable + labelText: qsTr("Batt2 critical failsafe:") + valueText: _batt2MonitorEnabled ? _batt2FSCritAct.enumStringValue : "" + visible: _batt2MonitorEnabled } VehicleSummaryRow { @@ -94,20 +94,5 @@ FactPanel { labelText: qsTr("RTL min alt:") valueText: _rtlAltFact.value == 0 ? qsTr("current") : _rtlAltFact.valueString + " " + _rtlAltFact.units } - - VehicleSummaryRow { - labelText: qsTr("RTL loiter time:") - valueText: _rtlLoitTimeFact.valueString + " " + _rtlLoitTimeFact.units - } - - VehicleSummaryRow { - labelText: qsTr("RTL final alt:") - valueText: _rtlAltFinalFact.value == 0 ? qsTr("Land") : _rtlAltFinalFact.valueString + " " + _rtlAltFinalFact.units - } - - VehicleSummaryRow { - labelText: qsTr("Descent speed:") - valueText: _landSpeedFact.valueString + " " + _landSpeedFact.units - } } }