From 8feb85a757db9ff76f7fa464ab7955831842b39d Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Tue, 28 Feb 2017 14:32:05 +0100
Subject: [PATCH] handle consecutive overload responses with AT gearboxes due
 to gearshift between search braking power and actual request

---
 VECTO/Input Files/VectoJob.vb                      |  4 ++--
 .../Models/SimulationComponent/Impl/Driver.cs      | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb
index 69c8d15200..7efc024c87 100644
--- a/VECTO/Input Files/VectoJob.vb	
+++ b/VECTO/Input Files/VectoJob.vb	
@@ -231,8 +231,8 @@ Public Class VectoJob
 			Return New StartStopInputData With {
 				.Enabled = _startStop,
 				.MaxSpeed = StartStopMaxSpeed.KMPHtoMeterPerSecond(),
-				.MinTime = StartStopTime.SI (Of Second)(),
-				.Delay = StartStopDelay.SI (Of Second)()
+				.MinTime = StartStopTime.SI(Of Second)(),
+				.Delay = StartStopDelay.SI(Of Second)()
 				}
 		End Get
 	End Property
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
index a34ee73f77..fa19858e24 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
@@ -519,6 +519,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 							operatingPoint.Acceleration, gradient);
 					}
 				}).
+				Case<ResponseOverload>(r => {
+					if (DataBus.GearboxType.AutomaticTransmission()) {
+						// overload may happen because of gearshift between search and actual request, search again
+						DataBus.BrakePower = 0.SI<Watt>();
+						operatingPoint = SearchBrakingPower(absTime, operatingPoint.SimulationDistance, gradient,
+							operatingPoint.Acceleration, response);
+						DriverAcceleration = operatingPoint.Acceleration;
+						retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval,
+							operatingPoint.Acceleration, gradient);
+					} else {
+						throw new UnexpectedResponseException(
+							"DrivingAction Brake: request failed after braking power was found.", r);
+					}
+				}).
 				Default(
 					r => {
 						throw new UnexpectedResponseException(
-- 
GitLab