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 @@ ...@@ -11,5 +11,12 @@
"shortDescription": "Enables or disables low battery handling measures.", "shortDescription": "Enables or disables low battery handling measures.",
"type": "bool", "type": "bool",
"defaultValue": true "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") ...@@ -10,3 +10,4 @@ DECLARE_SETTINGGROUP(Wima, "Wima")
DECLARE_SETTINGSFACT(WimaSettings, lowBatteryThreshold) DECLARE_SETTINGSFACT(WimaSettings, lowBatteryThreshold)
DECLARE_SETTINGSFACT(WimaSettings, enableLowBatteryHandling) DECLARE_SETTINGSFACT(WimaSettings, enableLowBatteryHandling)
DECLARE_SETTINGSFACT(WimaSettings, minimalRemainingMissionTime)
...@@ -12,4 +12,5 @@ public: ...@@ -12,4 +12,5 @@ public:
DEFINE_SETTINGFACT(lowBatteryThreshold) DEFINE_SETTINGFACT(lowBatteryThreshold)
DEFINE_SETTINGFACT(enableLowBatteryHandling) DEFINE_SETTINGFACT(enableLowBatteryHandling)
DEFINE_SETTINGFACT(minimalRemainingMissionTime)
}; };
...@@ -922,8 +922,9 @@ void WimaController::checkBatteryLevel() ...@@ -922,8 +922,9 @@ void WimaController::checkBatteryLevel()
WimaSettings* wimaSettings = qgcApp()->toolbox()->settingsManager()->wimaSettings(); WimaSettings* wimaSettings = qgcApp()->toolbox()->settingsManager()->wimaSettings();
int batteryThreshold = wimaSettings->lowBatteryThreshold()->rawValue().toInt(); int batteryThreshold = wimaSettings->lowBatteryThreshold()->rawValue().toInt();
bool enabled = _enableWimaController.rawValue().toBool(); 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) { if (managerVehicle != nullptr && enabled == true) {
Fact *battery1percentRemaining = managerVehicle->battery1FactGroup()->getFact(VehicleBatteryFactGroup::_percentRemainingFactName); Fact *battery1percentRemaining = managerVehicle->battery1FactGroup()->getFact(VehicleBatteryFactGroup::_percentRemainingFactName);
...@@ -934,9 +935,15 @@ void WimaController::checkBatteryLevel() ...@@ -934,9 +935,15 @@ void WimaController::checkBatteryLevel()
&& battery2percentRemaining->rawValue().toDouble() < batteryThreshold) { && battery2percentRemaining->rawValue().toDouble() < batteryThreshold) {
_setVehicleHasLowBattery(true); _setVehicleHasLowBattery(true);
if (!_lowBatteryHandlingTriggered) { if (!_lowBatteryHandlingTriggered) {
if (_missionController->remainingTime() <= minTime) {
_lowBatteryHandlingTriggered = true;
}
else {
QString errorString; QString errorString;
attemptCounter++; attemptCounter++;
if (_checkSmartRTLPreCondition(errorString) == true) { if (_checkSmartRTLPreCondition(errorString) == true) {
managerVehicle->pauseVehicle(); managerVehicle->pauseVehicle();
if (_calcReturnPath(errorString)) { if (_calcReturnPath(errorString)) {
_lowBatteryHandlingTriggered = true; _lowBatteryHandlingTriggered = true;
...@@ -955,6 +962,7 @@ void WimaController::checkBatteryLevel() ...@@ -955,6 +962,7 @@ void WimaController::checkBatteryLevel()
} }
} }
} }
}
else { else {
_setVehicleHasLowBattery(false); _setVehicleHasLowBattery(false);
_lowBatteryHandlingTriggered = false; _lowBatteryHandlingTriggered = false;
......
...@@ -959,10 +959,19 @@ QGCView { ...@@ -959,10 +959,19 @@ QGCView {
} }
FactCheckBox { FactCheckBox {
text: "Enable low battery handling" text: "Enable low Battery handling"
fact: QGroundControl.settingsManager.wimaSettings.enableLowBatteryHandling fact: QGroundControl.settingsManager.wimaSettings.enableLowBatteryHandling
Layout.columnSpan: 2 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