From af4e4b591f0f4e5f5385793f0f2980b7ec45f5b9 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 7 Feb 2019 10:29:27 +0100
Subject: [PATCH] Driver: in case of overload or Underload response and gear
 changed abort braking action

---
 .../VectoCore/Models/SimulationComponent/Impl/Driver.cs      | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
index 70ee78fb30..2f2a94e8fa 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
@@ -235,6 +235,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 							// search again for operating point, transmission may have shifted inbetween
 							nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration,
 								response);
+							if (nextOperatingPoint == null) {
+								throw new VectoException("DrivingActionAccelerate: Failed to find operating point after Overload");
+							}
 							DriverAcceleration = nextOperatingPoint.Acceleration;
 							retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval,
 								nextOperatingPoint.Acceleration, gradient);
@@ -564,7 +567,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration,
 				gradient);
 			var gearChanged = !(DataBus.Gear == gear && DataBus.TCLocked == tcLocked);
-			if (DataBus.GearboxType.AutomaticTransmission() && gearChanged && retVal is ResponseOverload) {
+			if (DataBus.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) {
 				Log.Debug("Gear changed after a valid operating point was found - braking is no longer applicable due to overload"); 
 				return null;
 			}
-- 
GitLab