Commit d8e92671 authored by Valentin Platzgummer's avatar Valentin Platzgummer

minimalRemainingMissionTime added to General Settings, and Low Battery...

minimalRemainingMissionTime added to General Settings, and Low Battery Handling on small minimalRemainingMissionTime function added
parent 8b25923f
This diff is collapsed.
......@@ -11,5 +11,12 @@
"shortDescription": "Enables or disables low battery handling measures.",
"type": "bool",
"defaultValue": true
},
{
"name": "minimalRemainingMissionTime",
"shortDescription": "If the remaining estimated mission time is lower than this value, low battery handling will not be triggered.",
"type": "uint64",
"units": "s",
"defaultValue": 60
}
]
......@@ -10,3 +10,4 @@ DECLARE_SETTINGGROUP(Wima, "Wima")
DECLARE_SETTINGSFACT(WimaSettings, lowBatteryThreshold)
DECLARE_SETTINGSFACT(WimaSettings, enableLowBatteryHandling)
DECLARE_SETTINGSFACT(WimaSettings, minimalRemainingMissionTime)
......@@ -12,4 +12,5 @@ public:
DEFINE_SETTINGFACT(lowBatteryThreshold)
DEFINE_SETTINGFACT(enableLowBatteryHandling)
DEFINE_SETTINGFACT(minimalRemainingMissionTime)
};
......@@ -918,12 +918,13 @@ void WimaController::updateAltitude()
void WimaController::checkBatteryLevel()
{
Vehicle *managerVehicle = masterController()->managerVehicle();
WimaSettings* wimaSettings = qgcApp()->toolbox()->settingsManager()->wimaSettings();
int batteryThreshold = wimaSettings->lowBatteryThreshold()->rawValue().toInt();
bool enabled = _enableWimaController.rawValue().toBool();
Vehicle *managerVehicle = masterController()->managerVehicle();
WimaSettings* wimaSettings = qgcApp()->toolbox()->settingsManager()->wimaSettings();
int batteryThreshold = wimaSettings->lowBatteryThreshold()->rawValue().toInt();
bool enabled = _enableWimaController.rawValue().toBool();
unsigned int minTime = wimaSettings->minimalRemainingMissionTime()->rawValue().toUInt();
static long attemptCounter = 0;
static short attemptCounter = 0;
if (managerVehicle != nullptr && enabled == true) {
Fact *battery1percentRemaining = managerVehicle->battery1FactGroup()->getFact(VehicleBatteryFactGroup::_percentRemainingFactName);
......@@ -934,25 +935,32 @@ void WimaController::checkBatteryLevel()
&& battery2percentRemaining->rawValue().toDouble() < batteryThreshold) {
_setVehicleHasLowBattery(true);
if (!_lowBatteryHandlingTriggered) {
QString errorString;
attemptCounter++;
if (_checkSmartRTLPreCondition(errorString) == true) {
managerVehicle->pauseVehicle();
if (_calcReturnPath(errorString)) {
if (_missionController->remainingTime() <= minTime) {
_lowBatteryHandlingTriggered = true;
}
else {
QString errorString;
attemptCounter++;
if (_checkSmartRTLPreCondition(errorString) == true) {
managerVehicle->pauseVehicle();
if (_calcReturnPath(errorString)) {
_lowBatteryHandlingTriggered = true;
attemptCounter = 0;
emit returnBatteryLowConfirmRequired();
} else {
if (attemptCounter > 3) {
qgcApp()->showMessage(tr("Battery level is low. Smart RTL not possible."));
qgcApp()->showMessage(errorString);
}
}
}
if (attemptCounter > 3) { // try 3 times, somtimes vehicle is outside joined area
_lowBatteryHandlingTriggered = true;
attemptCounter = 0;
emit returnBatteryLowConfirmRequired();
} else {
if (attemptCounter > 3) {
qgcApp()->showMessage(tr("Battery level is low. Smart RTL not possible."));
qgcApp()->showMessage(errorString);
}
}
}
if (attemptCounter > 3) { // try 3 times, somtimes vehicle is outside joined area
_lowBatteryHandlingTriggered = true;
attemptCounter = 0;
}
}
}
else {
......
......@@ -959,10 +959,19 @@ QGCView {
}
FactCheckBox {
text: "Enable low battery handling"
text: "Enable low Battery handling"
fact: QGroundControl.settingsManager.wimaSettings.enableLowBatteryHandling
Layout.columnSpan: 2
}
QGCLabel {
text: qsTr("Minimal remaining Mission Time")
visible: _userBrandImageIndoor.visible
}
FactTextField {
Layout.preferredWidth: _valueFieldWidth
fact: QGroundControl.settingsManager.wimaSettings.minimalRemainingMissionTime
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment