From 7aec7c238475bc465927b6c67eca5359ad9ae916 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 21 Apr 2022 11:20:39 +0200
Subject: [PATCH] handle the case that there is no next braketrigger speed

---
 VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs | 2 +-
 .../Models/SimulationComponent/Strategies/HybridStrategy.cs   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
index 98e299d09d..2d70b00345 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs
@@ -1459,6 +1459,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 		public PCCStates PCCState => DriverStrategy.PCCState;
 
-		public MeterPerSecond NextBrakeTriggerSpeed => DriverStrategy.BrakeTrigger.NextTargetSpeed;
+		public MeterPerSecond NextBrakeTriggerSpeed => DriverStrategy.BrakeTrigger?.NextTargetSpeed;
 	}
 }
\ No newline at end of file
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs
index 94b61f8782..44d00dcfe8 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs
@@ -1053,7 +1053,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
 
 			// hint: only check for halting speed if vehicle is actually braking to halt.
 			var vehiclespeedBelowThreshold = DataBus.VehicleInfo.VehicleSpeed.IsSmaller(disengageSpeedThreshold) 
-											&& DataBus.DriverInfo.NextBrakeTriggerSpeed.IsEqual(0);
+											&& (DataBus.DriverInfo.NextBrakeTriggerSpeed?.IsEqual(0) ?? false); 
 
 			if (ElectricMotorCanPropellDuringTractionInterruption || DataBus.GearboxInfo.GearEngaged(absTime)) {
 
@@ -1378,7 +1378,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
 			
 			// only disengage if we are actually braking for halting (meaning: next brake trigger speed is 0).
 			if (DataBus.GearboxInfo.GearboxType.ManualTransmission() 
-				&& DataBus.DriverInfo.NextBrakeTriggerSpeed.IsEqual(0)
+				&& (DataBus.DriverInfo.NextBrakeTriggerSpeed?.IsEqual(0) ?? false)
 				&& endSpeed.IsSmallerOrEqual(ModelData.GearboxData.DisengageWhenHaltingSpeed, 0.1.KMPHtoMeterPerSecond())) {
 				return new GearshiftPosition(0);
 			}
-- 
GitLab