From e44808b9be0de47eaa819953cf7c0810ef3ad8e8 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 4 Apr 2022 14:15:29 +0200
Subject: [PATCH] serial hybrid: fix testcases - check if gearbox data exists
 (only for S2)

---
 .../SimulationComponent/Strategies/SerialHybridStrategy.cs   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/SerialHybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/SerialHybridStrategy.cs
index 2949a0d18f..6dc5415022 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/SerialHybridStrategy.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/SerialHybridStrategy.cs
@@ -510,7 +510,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
 				return null;
 			}
 
-			if (DataBus.VehicleInfo.VehicleSpeed.IsSmallerOrEqual(ModelData.GearboxData.DisengageWhenHaltingSpeed) && emOutTorque.IsSmaller(0)) {
+			if (ModelData.GearboxData != null && DataBus.VehicleInfo.VehicleSpeed.IsSmallerOrEqual(ModelData.GearboxData.DisengageWhenHaltingSpeed) && emOutTorque.IsSmaller(0)) {
 				return null;
 			}
 
@@ -572,7 +572,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
 	GenSetOperatingPoint maxPowerGenset, Second dt)
 		{
 			var reqBatteryPower = maxPowerGenset.ElectricPower + drivetrainDemand.ElectricPowerDemand;
-			if (DataBus.BatteryInfo.StateOfCharge.IsEqual(StrategyParameters.MinSoC, 0.01) && reqBatteryPower < 0 && drivetrainDemand.ElectricPowerDemand < drivetrainDemand.Response.ElectricSystem.MaxPowerDrive) {
+			if (DataBus.BatteryInfo.StateOfCharge.IsEqual(StrategyParameters.MinSoC, 0.01) && reqBatteryPower < 0 &&
+				drivetrainDemand.ElectricPowerDemand < drivetrainDemand.Response.ElectricSystem.MaxPowerDrive) {
 				return StateMachineState.Acc_S3;
 			}
 
-- 
GitLab