diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 61febfe04e2865a4c4543040cb9e297f94f07a91..6ba0325173d1c17920107da4d3287fbdedf0ea65 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -181,9 +181,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var avgEngineSpeed = (PreviousState.EngineSpeed + angularVelocity) / 2.0; - var engineSpeedLimit = GetEngineSpeedLimit(); + var engineSpeedLimit = GetEngineSpeedLimit(absTime); if (!dryRun && avgEngineSpeed.IsGreater(engineSpeedLimit, Constants.SimulationSettings.LineSearchTolerance)) { - return new ResponseEngineSpeedTooHigh() { DeltaEngineSpeed = avgEngineSpeed - engineSpeedLimit }; + return new ResponseEngineSpeedTooHigh() { + DeltaEngineSpeed = avgEngineSpeed - engineSpeedLimit, + Source = this, + EngineSpeed = angularVelocity + }; } var fullDragTorque = ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryTorque(avgEngineSpeed); @@ -293,12 +297,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - protected virtual PerSecond GetEngineSpeedLimit() + protected virtual PerSecond GetEngineSpeedLimit(Second absTime) { - return DataBus.Gear == 0 + return DataBus.Gear == 0 || !DataBus.ClutchClosed(absTime) ? ModelData.FullLoadCurves[0].N95hSpeed - : VectoMath.Min(DataBus.GetGearData(DataBus.Gear).MaxSpeed, - ModelData.FullLoadCurves[0].N95hSpeed); + : VectoMath.Min(DataBus.GetGearData(DataBus.Gear).MaxSpeed, ModelData.FullLoadCurves[0].N95hSpeed); } public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs index 9837ac690fae6f9fe70274b97260d0db795003ba..e577fef15fac6b162d763255e8a34243ff553db8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs @@ -110,7 +110,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return requestedEngineTorque; } - protected override PerSecond GetEngineSpeedLimit() + protected override PerSecond GetEngineSpeedLimit(Second absTime) { return ModelData.FullLoadCurves[0].N95hSpeed; }