From 99535f8f521fe32f24e1a3a7a36fcbeb13fcb5be Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Tue, 7 Jul 2020 10:21:53 +0200 Subject: [PATCH] Make P4 Testcases work --- .../SimulationComponent/Strategies/HybridStrategy.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs index 1f97bce7da..35b0f90a07 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs @@ -229,7 +229,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } if ((DataBus.DriverInfo.DrivingAction == DrivingAction.Accelerate || DataBus.DriverInfo.DrivingAction == DrivingAction.Brake) && allUnderload) { if (ElectricMotorCanPropellDuringTractionInterruption || DataBus.GearboxInfo.GearEngaged(absTime)) { - best = eval.MaxBy(x => x.Setting.MechanicalAssistPower.Sum(e => e.Value ?? 0.SI<NewtonMeter>())); + var filtered = eval.Where(x => !x.IgnoreReason.InvalidEngineSpeed()).OrderBy(x => currentGear - x.Gear).ToArray(); + if (!filtered.Any()) { + filtered = eval.OrderBy(x => currentGear - x.Gear).ToArray(); + } + best = filtered.MaxBy( + x => x.Setting.MechanicalAssistPower.Sum(e => e.Value ?? 0.SI<NewtonMeter>())); } } if (DataBus.DriverInfo.DrivingAction == DrivingAction.Brake && dryRun) { -- GitLab