From c5b29faadd8daaa1b385c83ceabdb3d02b78f233 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 7 Jun 2021 11:20:51 +0200
Subject: [PATCH] driver strategy: handle the case that another brake action
 gets more urgent during a coasting phase in a braking action (at the end of
 the interurban cycle)

---
 .../SimulationComponent/Impl/DefaultDriverStrategy.cs       | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs
index 04c979bd3a..3d9f71a01e 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs
@@ -214,12 +214,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			//}
 
 			if (CurrentDrivingMode == DrivingMode.DrivingModeBrake) {
+				var nextAction = GetNextDrivingAction(ds);
+				if (nextAction != null && !BrakeTrigger.HasEqualTrigger(nextAction) && nextAction.ActionDistance.IsSmallerOrEqual(BrakeTrigger.ActionDistance)) {
+					BrakeTrigger = nextAction;
+				}
 				if (Driver.DataBus.MileageCounter.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance, 1e-3.SI<Meter>())) {
 					CurrentDrivingMode = DrivingMode.DrivingModeDrive;
 					NextDrivingAction = null;
 					DrivingModes[CurrentDrivingMode].ResetMode();
 					Log.Debug("Switching to DrivingMode DRIVE");
 				}
+				
+
 			}
 			if (CurrentDrivingMode == DrivingMode.DrivingModeDrive) {
 				var currentDistance = Driver.DataBus.MileageCounter.Distance;
-- 
GitLab