diff --git a/VectoCommon/VectoCommon/Utils/VectoMath.cs b/VectoCommon/VectoCommon/Utils/VectoMath.cs index 5e2960b8286443a56a83cb46c37dc6376dc4cc3c..46c6642a64ab518ff54042c2346946d33fcf41e5 100644 --- a/VectoCommon/VectoCommon/Utils/VectoMath.cs +++ b/VectoCommon/VectoCommon/Utils/VectoMath.cs @@ -148,11 +148,13 @@ namespace TUGraz.VectoCommon.Utils [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T Min<T>(T c1, T c2) where T : IComparable { - if (c1 == null) + if (c1 == null) { return c2; + } - if (c2 == null) + if (c2 == null) { return c1; + } return c1.CompareTo(c2) <= 0 ? c1 : c2; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index dcdc0316d42f547a9aecf90921cd0cb60e279ba9..aebe8290fb02172543a72516767eee5b3576d9c7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -264,7 +264,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // return RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun); //} if (TorqueConverter != null) { - TorqueConverter.Locked(CurrentState.InTorque, CurrentState.InAngularVelocity, CurrentState.InTorque, CurrentState.InAngularVelocity); + TorqueConverter.Locked(CurrentState.InTorque, CurrentState.InAngularVelocity, CurrentState.InTorque, + CurrentState.InAngularVelocity); } var response = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity); response.GearboxPowerRequest = outTorque * avgOutAngularVelocity; @@ -339,14 +340,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (GearboxType.AutomaticTransmission()) { disengagedResponse = EngineIdleRequest(absTime, dt); } else { - disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), - outAngularVelocity * ModelData.Gears[NextGear.Gear].Ratio); + disengagedResponse = NextGear.Gear > 0 + ? NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), + outAngularVelocity * ModelData.Gears[NextGear.Gear].Ratio) + : EngineIdleRequest(absTime, dt); } if (TorqueConverter != null) { - if (DataBus.VehicleStopped) - TorqueConverter.Locked(0.SI<NewtonMeter>(), disengagedResponse.EngineSpeed, CurrentState.InTorque, outAngularVelocity); - else - TorqueConverter.Locked(CurrentState.InTorque, disengagedResponse.EngineSpeed, CurrentState.InTorque, disengagedResponse.EngineSpeed); + if (DataBus.VehicleStopped) { + TorqueConverter.Locked(0.SI<NewtonMeter>(), disengagedResponse.EngineSpeed, CurrentState.InTorque, + outAngularVelocity); + } else { + TorqueConverter.Locked(CurrentState.InTorque, disengagedResponse.EngineSpeed, CurrentState.InTorque, + disengagedResponse.EngineSpeed); + } } disengagedResponse.GearboxPowerRequest = outTorque * avgOutAngularVelocity; CurrentState.SetState(0.SI<NewtonMeter>(), disengagedResponse.EngineSpeed, 0.SI<NewtonMeter>(), outAngularVelocity); @@ -419,14 +425,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region ICluchInfo - public override GearInfo NextGear { + public override GearInfo NextGear + { get { if (Disengaged == null) { return new GearInfo(Gear, !TorqueConverterActive ?? true); } var future = DataBus.LookAhead(ModelData.TractionInterruption * 5); - var nextGear = 1u; - var torqueConverterLocked = true; + var nextGear = 0u; + var torqueConverterLocked = false; foreach (var entry in future) { if (entry.VehicleTargetSpeed != null && entry.VehicleTargetSpeed.IsEqual(0)) { // vehicle is stopped, no next gear, engine should go to idle @@ -447,7 +454,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public override Second TractionInterruption { + public override Second TractionInterruption + { get { if (Disengaged == null) { return ModelData.TractionInterruption; @@ -514,7 +522,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new System.NotImplementedException(); } - public override GearInfo NextGear { + public override GearInfo NextGear + { get { throw new System.NotImplementedException(); } } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 34a659e73d410f3a132c60665d3bee1d6df7af99..f9a48c918fd5cfbe5c2c0ca7df4a0aedffaa83b6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -64,7 +64,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Second LastDownshift { get; private set; } - public override GearInfo NextGear { + public override GearInfo NextGear + { get { return _strategy.NextGear; } } @@ -179,10 +180,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _engageTime = absTime + dt; } - var engineSpeedNorm = (outAngularVelocity - DataBus.EngineIdleSpeed) / - (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed); - if (DataBus.DriverBehavior == DrivingBehavior.Braking && DataBus.BrakePower.IsGreater(0) && - engineSpeedNorm < Constants.SimulationSettings.ClutchClosingSpeedNorm && + if (DataBus.DriverBehavior == DrivingBehavior.Braking && DataBus.BrakePower.IsGreater(0) && outTorque < 0 && DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ClutchDisengageWhenHaltingSpeed)) { _engageTime = absTime + dt; Disengaged = true;