From 0eea8104116b5c7f48e8fe840d546c6d1a93e70b Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 13 Jun 2019 16:34:51 +0200
Subject: [PATCH] handle the case that a gearshift may occur for AT
 transmissions during coast action. if this is the case, perform coast action
 once more.

---
 .../Models/SimulationComponent/Impl/Driver.cs         | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
index 2f2a94e8fa..e81b35851d 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
@@ -352,7 +352,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			IterationStatistics.Increment(this, "Coast");
 			Log.Debug("DrivingAction Coast");
 
-			return CoastOrRollAction(absTime, ds, maxVelocity, gradient, false);
+			var gear = DataBus.Gear;
+			var tcLocked = DataBus.TCLocked;
+			var retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, false);
+			var gearChanged = !(DataBus.Gear == gear && DataBus.TCLocked == tcLocked);
+			if (DataBus.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) {
+				Log.Debug("Gear changed after a valid operating point was found - re-try coasting!");
+				retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, false);
+			}
+
+			return retVal;
 		}
 
 		/// <summary>
-- 
GitLab