Skip to content

Commit

Permalink
Merge pull request mavlink#6638 from DonLakeFlyer/ArduCopterMissingPa…
Browse files Browse the repository at this point in the history
…rams

ArduCopter: Deal with annoying missing params due to *_ENABLE settings
  • Loading branch information
DonLakeFlyer authored Jun 22, 2018
2 parents 0261ed1 + a2c0e0d commit cf765df
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 116 deletions.
19 changes: 0 additions & 19 deletions src/AutoPilotPlugins/APM/APMPowerComponent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
6 changes: 3 additions & 3 deletions src/AutoPilotPlugins/APM/APMPowerComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class APMPowerComponent : public VehicleComponent
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; }
Expand Down
114 changes: 87 additions & 27 deletions src/AutoPilotPlugins/APM/APMPowerComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -61,58 +111,68 @@ 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")
font.family: ScreenTools.demiboldFontFamily
}

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

// 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")
Expand All @@ -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 */)
Expand Down
28 changes: 15 additions & 13 deletions src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*
****************************************************************************/


import QtQuick 2.3
import QtQuick.Controls 1.2

Expand All @@ -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
}
}
}
20 changes: 11 additions & 9 deletions src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 */)
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -147,7 +149,7 @@ SetupPage {

Column {
spacing: _margins / 2
visible: _batt2MonitorEnabled && _failsafeBatt2LowActAvailable
visible: _batt2MonitorEnabled && _batt2ParamsAvailable

QGCLabel {
text: qsTr("Battery2 Failsafe Triggers")
Expand Down
Loading

0 comments on commit cf765df

Please sign in to comment.