diff --git a/VectoCommon/VectoCommon/Models/GearshiftPosition.cs b/VectoCommon/VectoCommon/Models/GearshiftPosition.cs index 20e5f8f8d6ec867d6034e7319946b3127dcf1fc3..c4c246034edd985839a79e30a15fccd5137597fb 100644 --- a/VectoCommon/VectoCommon/Models/GearshiftPosition.cs +++ b/VectoCommon/VectoCommon/Models/GearshiftPosition.cs @@ -72,7 +72,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return false; } - return p2.TorqueConverterLocked.Value && !p1.TorqueConverterLocked.Value; + return p2.TorqueConverterLocked.Value && !p1.TorqueConverterLocked.Value; } @@ -82,79 +82,51 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - public class GearList :IEnumerable<GearshiftPosition> + public class GearList : IEnumerable<GearshiftPosition> { protected GearshiftPosition[] Entries; - public GearList(GearshiftPosition[] gearList) - { - Entries = gearList; - } - - public bool HasPredecessor(GearshiftPosition cur) - { - var idx = Array.IndexOf(Entries, cur); - return idx > 0; - } - + public GearList(GearshiftPosition[] gearList) => Entries = gearList; + public bool HasPredecessor(GearshiftPosition cur) => cur.Gear != 0 && cur != Entries[0]; + public GearshiftPosition Predecessor(GearshiftPosition cur) { var idx = Array.IndexOf(Entries, cur); - return idx <= 0 ? null : Entries[idx - 1]; } - public bool HasSuccessor(GearshiftPosition cur) - { - var idx = Array.IndexOf(Entries, cur); - return idx < Entries.Length - 1; - } + public bool HasSuccessor(GearshiftPosition cur) => cur.Gear != 0 && cur != Entries[Entries.Length-1]; public GearshiftPosition Successor(GearshiftPosition cur) { var idx = Array.IndexOf(Entries, cur); - return idx < 0 || idx >= Entries.Length - 1 ? null : Entries[idx + 1]; } public GearshiftPosition Successor(GearshiftPosition cur, uint numUp) { var idx = Array.IndexOf(Entries, cur); - if (idx < 0) { return null; } - var next = idx + numUp; - return next >= Entries.Length ? Entries.Last() : Entries[next]; } public GearshiftPosition Predecessor(GearshiftPosition cur, uint numDown) { var idx = Array.IndexOf(Entries, cur); - if (idx < 0) { return null; } - var next = idx - numDown; - return next < 0 ? Entries.First() : Entries[next]; } - public IEnumerator<GearshiftPosition> GetEnumerator() - { - foreach (var entry in Entries) { - yield return entry; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + public IEnumerator<GearshiftPosition> GetEnumerator() => Entries.AsEnumerable().GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public int Distance(GearshiftPosition from, GearshiftPosition to) { diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs index 6621ad879f9b4d28118ef2339f9f930c9641c5d6..0995064cb8fd55e555a1938c7a9fbb85352e68dc 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs @@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus MeterPerSquareSecond DriverAcceleration { get; } PCCStates PCCState { get; } - - } + MeterPerSecond NextBrakeTriggerSpeed { get; } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 9f3e56225924003bc7b74c65dd12e3f372a7ac7a..0a179ae85a7b0c8c29b425a04f0cbbbe9bd79a80 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -1459,6 +1459,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); public PCCStates PCCState => PCCStates.OutsideSegment; + public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); #endregion } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs index 53c114f18cc84536f0277ad48d1cedd4b3067707..73b382beeb21e3eaa85a8dae4f3399d642ba313a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs @@ -49,5 +49,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent void WriteModalResults(IModalDataContainer container); void CommitSimulationStep(); + + DrivingBehaviorEntry BrakeTrigger { get; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 009c0de5f1ae0fca9608dbddfd55f1a8fc80eb42..2702d21465bd4654a58518ac1704e1a28c53bd36 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -132,7 +132,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected IDataBus DataBus => Driver?.DataBus; - protected internal DrivingBehaviorEntry BrakeTrigger { get; set; } + public DrivingBehaviorEntry BrakeTrigger { get; protected internal set; } public IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient) { @@ -855,9 +855,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public class DriverModeDrive : AbstractDriverMode { - protected override IResponse DoHandleRequest( - Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, - bool prohibitOverspeed = false) + protected override IResponse DoHandleRequest(Second absTime, Meter ds, MeterPerSecond targetVelocity, + Radian gradient, bool prohibitOverspeed = false) { var debug = new DebugData(); @@ -874,8 +873,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } for (var i = 0; i < 3; i++) { - var retVal = HandleRequestEngaged( - absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocity, debug); + var retVal = HandleRequestEngaged(absTime, ds, targetVelocity, gradient, prohibitOverspeed, + velocity, debug); if (retVal != null) { return retVal; } @@ -889,15 +888,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } if (!(response is ResponseSuccess) && DataBus.ClutchInfo.ClutchClosed(absTime)) { - response = HandleRequestEngaged( - absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocity, debug); + response = HandleRequestEngaged(absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocity, debug); } return response; } - private IResponse HandleRequestDisengaged( - Second absTime, Meter ds, Radian gradient, MeterPerSecond velocity, + private IResponse HandleRequestDisengaged(Second absTime, Meter ds, Radian gradient, MeterPerSecond velocity, DebugData debug) { if (DataBus.VehicleInfo.VehicleSpeed.IsSmallerOrEqual(0.SI<MeterPerSecond>())) { @@ -914,18 +911,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var response = Driver.DrivingActionRoll(absTime, ds, velocity, gradient); - debug.Add(new { action = "ClutchOpen -> Roll", response }); + debug.Add(new { a = "[HRD-0] ClutchOpen -> Roll", response }); switch (response) { case ResponseUnderload _ when DataBus.ClutchInfo.ClutchClosed(absTime): response = HandleRequestEngaged(absTime, ds, velocity, gradient, false, velocity, debug); break; case ResponseUnderload _ when !DataBus.ClutchInfo.ClutchClosed(absTime): response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, response); - debug.Add(new { action = "Roll:Underload -> Brake", response }); + debug.Add(new { a = "[HRD-1] Roll:Underload -> Brake", response }); break; case ResponseSpeedLimitExceeded _: response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); - debug.Add(new { action = "Roll:SpeedLimitExceeded -> Brake", response }); + debug.Add(new { a = "[HRD-2] Roll:SpeedLimitExceeded -> Brake", response }); break; } return response; @@ -936,8 +933,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl bool prohibitOverspeed, MeterPerSecond velocityWithOverspeed, DebugData debug) { // drive along - var first = FirstAccelerateOrCoast( - absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocityWithOverspeed, debug); + var first = FirstAccelerateOrCoast(absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocityWithOverspeed, debug); var second = first; switch (first) { @@ -945,11 +941,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.ClutchInfo.ClutchClosed(absTime)) { //TODO mk20210616 the whole statement could be de-nested to switch-pattern matching (with "where") if this first "if" would not be here. var debugResponse = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); + debug.Add(new { a = "[HRE-0] (Underload&Overspeed)->Roll", second }); } if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0) && DriverStrategy.IsOverspeedAllowed(targetVelocity, prohibitOverspeed)) { second = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "first:(Underload & Overspeed)-> Coast", second }); + debug.Add(new { a = "[HRE-1] (Underload&Overspeed)->Coast", second }); second = HandleCoastAfterUnderloadWithOverspeed(absTime, ds, gradient, velocityWithOverspeed, debug, second); } else { // overrideAction: in case of hybrids with an AT gearbox after an underload we search for braking power because the torque converter @@ -967,7 +964,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : (DrivingAction?)null; second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient, overrideAction: overrideAction); - debug.Add(new { action = "first:(Underload & !Overspeed) -> Brake", second }); + debug.Add(new { a = "[HRE-2] (Underload&!Overspeed)->Brake", second }); } break; case ResponseEngineSpeedTooHigh _: @@ -975,7 +972,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl break; case ResponseSpeedLimitExceeded _: second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "SpeedLimitExceeded -> Brake", second }); + debug.Add(new { a = "[HRE-3] SpeedLimitExceeded->Brake", second }); break; } @@ -988,36 +985,40 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl switch (second) { case ResponseGearShift _: third = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "second: GearShift -> Roll", third }); + debug.Add(new { a = "[HRE-4] second: GearShift -> Roll", third }); switch (third) { + case ResponseOverload _: + third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); + debug.Add(new { a = "[HRE-5] third:Overload -> try again Coast", third }); + break; case ResponseUnderload _: - // overload may happen if driver limits acceleration when rolling downhill + // underload may happen if driver limits acceleration when rolling downhill third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "third:Underload -> Brake", third }); + debug.Add(new { a = "[HRE-6] third:Underload -> Brake", third }); break; case ResponseSpeedLimitExceeded _: third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "third:SpeedLimitExceeded -> Brake", third }); + debug.Add(new { a = "[HRE-7] third:SpeedLimitExceeded -> Brake", third }); break; } break; case ResponseOverload _ when DataBus.VehicleInfo.VehicleSpeed.IsGreater(0): third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "second:Overload -> Coast", third }); + debug.Add(new { a = "[HRE-8] second:Overload -> Coast", third }); switch (third) { case ResponseGearShift _: third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "third:GearShift -> try again Coast", third }); + debug.Add(new { a = "[HRE-9] third:GearShift -> try again Coast", third }); break; case ResponseSpeedLimitExceeded _: if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.GearboxInfo.Gear.IsLockedGear()) { third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed + 1.KMPHtoMeterPerSecond(), gradient); - debug.Add(new { action = "third:Overload (AT, Converter gear) -> Coast", third }); + debug.Add(new { a = "[HRE-10] third:Overload (AT, Converter gear) -> Coast", third }); } else { third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "third:SpeedLimitExceeded -> Brake", third }); + debug.Add(new { a = "[HRE-11] third:SpeedLimitExceeded -> Brake", third }); } break; @@ -1028,35 +1029,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return third; } - private IResponse HandleCoastAfterUnderloadWithOverspeed( - Second absTime, Meter ds, Radian gradient, + private IResponse HandleCoastAfterUnderloadWithOverspeed(Second absTime, Meter ds, Radian gradient, MeterPerSecond velocity, DebugData debug, IResponse second) { if (second is ResponseUnderload || second is ResponseSpeedLimitExceeded) { second = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); - debug.Add( - new { - action = "second:(Underload|SpeedLimitExceeded) -> Brake", - second - }); + debug.Add(new { a = "[HCAUWO-0] second:(Underload|SpeedLimitExceeded) -> Brake", second }); } if (second is ResponseEngineSpeedTooHigh) { second = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, second); - debug.Add( - new { - action = "second:(EngineSpeedTooHigh|SpeedLimitExceeded) -> Brake with reduced acceleration", - second - }); + debug.Add(new { a = "[HCAUWO-1] second:(EngineSpeedTooHigh|SpeedLimitExceeded) -> Brake with reduced acceleration", second }); } return second; } - private IResponse FirstAccelerateOrCoast( - Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, + private IResponse FirstAccelerateOrCoast(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, bool prohibitOverspeed, MeterPerSecond velocityWithOverspeed, DebugData debug) { if (DriverStrategy.pccState == PCCStates.UseCase1 || DriverStrategy.pccState == PCCStates.UseCase2) { var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); + debug.Add(new { a = "[FAOC-0] Coast", response }); if (response is ResponseSuccess) { return response; } @@ -1068,27 +1060,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //we are driving in overspeed (VehicleSpeed >= targetVelocity) var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "Coast", response }); + debug.Add(new { a = "[FAOC-1] Coast", response }); if (response is ResponseSuccess && response.Driver.Acceleration < 0 && response.Vehicle.VehicleSpeed <= targetVelocity) { //do accelerate action if we would come below targetVelocity due to coasting response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); - debug.Add(new { action = "Accelerate(Success && Acc<0 && VehSpeed <= targetVelocity)", response }); + debug.Add(new { a = "[FAOC-2] Accelerate(Success && Acc<0 && VehSpeed <= targetVelocity)", response }); } if (response is ResponseOverload && DataBus.PowertrainInfo.HasCombustionEngine && !DataBus.EngineInfo.EngineOn) { response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); - debug.Add(new { action = "Accelerate(Overload && ICE off)", response }); + debug.Add(new { a = "[FAOC-3] Accelerate(Overload && ICE off)", response }); } if (response is ResponseOverload && !DataBus.PowertrainInfo.HasCombustionEngine) { response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); - debug.Add(new { action = "Accelerate(Overload && BEV)", response }); + debug.Add(new { a = "[FAOC-4] Accelerate(Overload && BEV)", response }); } if (response is ResponseOverload) { response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); - debug.Add(new { action = "Accelerate(Overload)", response }); + debug.Add(new { a = "[FAOC-5] Accelerate(Overload)", response }); } return response; } else { @@ -1096,11 +1088,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && DataBus.GearboxInfo.DisengageGearbox) { var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); - debug.Add(new { action = "Coast", response }); + debug.Add(new { a = "[FAOC-6] Coast", response }); return response; } else { var response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); - debug.Add(new { action = "Accelerate", response }); + debug.Add(new { a = "[FAOC-7] Accelerate", response }); return response; } } @@ -1222,22 +1214,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Meter brakingDistance, Meter currentDistance) { IResponse response; - Log.Debug( - "Phase: BRAKE. breaking distance: {0} start braking @ {1}", brakingDistance, + var debug = new DebugData(); + + Log.Debug("Phase: BRAKE. breaking distance: {0} start braking @ {1}", brakingDistance, DriverStrategy.BrakeTrigger.BrakingStartDistance); + if (DriverStrategy.BrakeTrigger.BrakingStartDistance.IsSmaller( - currentDistance, - Constants.SimulationSettings.DriverActionDistanceTolerance / 2)) { - Log.Info( - "Expected Braking Deceleration could not be reached! {0}", + currentDistance, Constants.SimulationSettings.DriverActionDistanceTolerance / 2)) { + Log.Info("Expected Braking Deceleration could not be reached! {0}", DriverStrategy.BrakeTrigger.BrakingStartDistance - currentDistance); } - var targetDistance = DataBus.VehicleInfo.VehicleSpeed < Constants.SimulationSettings.MinVelocityForCoast - ? DriverStrategy.BrakeTrigger.TriggerDistance - : null; + + Meter targetDistance = null; + if (DataBus.VehicleInfo.VehicleSpeed < Constants.SimulationSettings.MinVelocityForCoast) { + targetDistance = DriverStrategy.BrakeTrigger.TriggerDistance; + } + if (targetDistance == null && DriverStrategy.BrakeTrigger.NextTargetSpeed.IsEqual(0.SI<MeterPerSecond>())) { targetDistance = DriverStrategy.BrakeTrigger.TriggerDistance - DefaultDriverStrategy.BrakingSafetyMargin; } + Driver.DriverBehavior = DrivingBehavior.Braking; if (DataBus.VehicleInfo.VehicleSpeed.IsEqual(0) && DriverStrategy.BrakeTrigger.NextTargetSpeed.IsEqual(0)) { @@ -1248,61 +1244,74 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } response = Driver.DrivingActionAccelerate(absTime, ds, 1.KMPHtoMeterPerSecond(), gradient); + debug.Add(new { a = "[DB-] Accelerate", response }); + if (response is ResponseUnderload) { - response = Driver.DrivingActionBrake( - absTime, ds, 1.KMPHtoMeterPerSecond(), gradient, response, overrideAction: DrivingAction.Accelerate); + response = Driver.DrivingActionBrake(absTime, ds, 1.KMPHtoMeterPerSecond(), gradient, response, + overrideAction: DrivingAction.Accelerate); + debug.Add(new { a = "[DB-2] Brake", response }); } } else { - response = Driver.DrivingActionBrake( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, + response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); + debug.Add(new { a = "[DB-3] Brake", response }); } - if ((DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.HybridControllerInfo != null) && response == null) { + if ((DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.HybridControllerInfo != null) + && response == null) { for (var i = 0; i < 3 && response == null; i++) { DataBus.Brakes.BrakePower = 0.SI<Watt>(); - response = Driver.DrivingActionBrake( - absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, + response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); + debug.Add(new { a = "[DB-4] Brake", response }); } if (response == null) { throw new VectoException("No valid operating point found"); } } - switch (response) { case ResponseOverload r: Log.Info("Brake -> Got OverloadResponse during brake action - desired deceleration could not be reached! response: {0}", r); if (!DataBus.ClutchInfo.ClutchClosed(absTime)) { Log.Info("Brake -> Overload -> Clutch is open - Trying roll action"); response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); - if (response is ResponseSpeedLimitExceeded) + debug.Add(new { a = "[DB-5] Roll", response }); + if (response is ResponseSpeedLimitExceeded) { response = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient); + debug.Add(new { a = "[DB-6] Brake", response }); + } } else { Log.Info("Brake -> Overload -> Clutch is closed - Trying brake action again"); DataBus.Brakes.BrakePower = 0.SI<Watt>(); DataBus.HybridControllerCtl?.RepeatDrivingAction(absTime); response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); + debug.Add(new { a = "[DB-7] Brake", response }); if (response is ResponseOverload) { Log.Info("Brake -> Overload -> 2nd Brake -> Overload -> Trying accelerate action"); var gear = DataBus.GearboxInfo.Gear; - response = DataBus.GearboxInfo.GearEngaged(absTime) - ? Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient) - : Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); + if (DataBus.GearboxInfo.GearEngaged(absTime)) { + response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + debug.Add(new { a = "[DB-8] Accelerate", response }); + } else { + response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); + debug.Add(new { a = "[DB-9] Roll", response }); + } switch (response) { case ResponseGearShift _: - Log.Info("Brake -> Overload -> 2nd Brake -> Accelerate -> Got GearShift response, performing roll action"); + Log.Info("Brake -> Overload -> 2nd Brake -> Accelerate or Roll -> Got GearShift response, performing roll action"); response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + debug.Add(new { a = "[DB-12] Roll", response }); break; case ResponseUnderload _: if (gear.Gear != DataBus.GearboxInfo.Gear.Gear) { // AT Gearbox switched gears, shift losses are no longer applied, try once more... response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + debug.Add(new { a = "[DB-13] Accelerate", response }); } break; } @@ -1316,9 +1325,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DataBus.Brakes.BrakePower = 0.SI<Watt>(); response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); + debug.Add(new { a = "[DB-14] Brake", response }); if (response is ResponseOverload) { Log.Info("Brake -> Gearshift -> Overload -> trying roll action (no gear engaged)"); response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); + debug.Add(new { a = "[DB-15] Roll", response }); } break; } @@ -1327,9 +1338,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private IResponse DoCoast(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, Meter currentDistance) { - IResponse response; Driver.DriverBehavior = DrivingBehavior.Coasting; - response = DataBus.ClutchInfo.ClutchClosed(absTime) + var response = DataBus.ClutchInfo.ClutchClosed(absTime) ? Driver.DrivingActionCoast(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleInfo.VehicleSpeed), gradient) : Driver.DrivingActionRoll(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleInfo.VehicleSpeed), gradient); switch (response) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index af795aa3bb2184328df7d0fb3f4d56ea213d0c40..64cb50dc9c49c473a2aa9ca2902b5579cb972ef4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -40,7 +40,6 @@ using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.Impl; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils; using DriverData = TUGraz.VectoCore.Models.SimulationComponent.Data.DriverData; @@ -213,7 +212,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var limitedOperatingPoint = nextOperatingPoint; - if (!(retVal is ResponseEngineSpeedTooHigh || DataBus.ClutchInfo.ClutchClosed(absTime))) { + if (!DataBus.ClutchInfo.ClutchClosed(absTime)) { limitedOperatingPoint = LimitAccelerationByDriverModel(nextOperatingPoint, LimitationMode.LimitDecelerationDriver); Log.Debug("Found operating point for Drive/Accelerate. dt: {0}, acceleration: {1}", @@ -250,7 +249,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl nextOperatingPoint.Acceleration, gradient, false); if (retVal is ResponseFailTimeInterval rt) // occurs only with AT gearboxes - extend time interval after gearshift! - retVal = new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT }; + retVal = new ResponseDrivingCycleDistanceExceeded(this) { + MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT + }; } else { if (absTime > 0 && DataBus.VehicleInfo.VehicleStopped) { Log.Info( @@ -362,7 +363,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var tcLocked = DataBus.GearboxInfo.TCLocked; var retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, false); var gearChanged = !(DataBus.GearboxInfo.Gear == gear && DataBus.GearboxInfo.TCLocked == tcLocked); - if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() + && gearChanged + && (retVal is ResponseOverload || retVal is ResponseUnderload)) { Log.Debug("Gear changed after a valid operating point was found - re-try coasting!"); retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, false); } @@ -480,7 +483,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var applyLimit = rollAction || tcOperatingPointSet; var limitedOperatingPoint = LimitAccelerationByDriverModel(searchedOperatingPoint, - applyLimit ? LimitationMode.NoLimitation : LimitationMode.LimitDecelerationDriver); + applyLimit ? LimitationMode.LimitDecelerationDriver : LimitationMode.NoLimitation); // compute speed at the end of the simulation interval. if it exceeds the limit -> return var v2 = DataBus.VehicleInfo.VehicleSpeed + @@ -585,7 +588,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var t = (Tuple<Tuple<TorqueConverterOperatingPoint, NewtonMeter>, NewtonMeter, NewtonMeter>)tOp; return GetTCDelta(t.Item1, t.Item2, t.Item3); }, - evaluateFunction: engSpeed => { return EstimateTCOpPoint(operatingPoint, dryRunResp, engSpeed, tcInfo); }, + evaluateFunction: engSpeed => EstimateTCOpPoint(operatingPoint, dryRunResp, engSpeed, tcInfo), criterion: tOp => { var t = (Tuple<Tuple<TorqueConverterOperatingPoint, NewtonMeter>, NewtonMeter, NewtonMeter>)tOp; return GetTCDelta(t.Item1, t.Item2, t.Item3).Value(); @@ -684,13 +687,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var tqDiff = 0.SI<NewtonMeter>(); if (tqOp.Item2.IsSmaller(dragTorque)) { tqDiff = tqOp.Item2 - dragTorque; - } if (tqOp.Item2.IsGreater(maxTorque)) { tqDiff = tqOp.Item2 - maxTorque; } - return ((tqDiff.Value() * tqDiff.Value()) + (deltaSpeed.Value() * deltaSpeed.Value())).SI<NewtonMeter>(); + return (tqDiff.Value() * tqDiff.Value() + deltaSpeed.Value() * deltaSpeed.Value()).SI<NewtonMeter>(); } @@ -729,7 +731,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl case ResponseUnderload _: break; // will be handled in SearchBrakingPower case ResponseEngineSpeedTooHigh r: - Log.Debug("Engine speeed was too high, search for appropriate acceleration first."); + Log.Debug("Engine speed was too high, search for appropriate acceleration first."); operatingPoint = SearchOperatingPoint(absTime, ds, gradient, point.Acceleration, response); break; // will be handled in SearchBrakingPower case ResponseGearShift _: @@ -794,7 +796,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, false); var gearChanged = !(DataBus.GearboxInfo.Gear == gear && DataBus.GearboxInfo.TCLocked == tcLocked); - if ((DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.HybridControllerInfo != null) && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) { + if ((DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.HybridControllerInfo != null) + && gearChanged + && (retVal is ResponseOverload || retVal is ResponseUnderload)) { Log.Debug("Gear changed after a valid operating point was found - braking is no longer applicable due to overload"); return null; } @@ -937,10 +941,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (tmp.Acceleration.IsGreater(acceleration)) { var operatingPoint = ComputeTimeInterval(tmp.Acceleration, ds); if (!ds.IsEqual(operatingPoint.SimulationDistance)) { - Log.Error( - "Unexpected Condition: Distance has been adjusted from {0} to {1}, currentVelocity: {2} acceleration: {3}, targetVelocity: {4}", - operatingPoint.SimulationDistance, ds, DataBus.VehicleInfo.VehicleSpeed, operatingPoint.Acceleration, - nextTargetSpeed); + Log.Error("Unexpected Condition: Distance has been adjusted from {0} to {1}, currentVelocity: {2} acceleration: {3}, targetVelocity: {4}", + operatingPoint.SimulationDistance, ds, DataBus.VehicleInfo.VehicleSpeed, + operatingPoint.Acceleration, nextTargetSpeed); throw new VectoSimulationException("Simulation distance unexpectedly adjusted! {0} -> {1}", ds, operatingPoint.SimulationDistance); } @@ -954,9 +957,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var operatingPoint = new OperatingPoint(op); // if we should brake with the max. deceleration and the deceleration changes within the current interval, take the larger deceleration... - if ( - operatingPoint.Acceleration.IsEqual( - DriverData.AccelerationCurve.Lookup(DataBus.VehicleInfo.VehicleSpeed).Deceleration)) { + if (operatingPoint.Acceleration.IsEqual(DriverData.AccelerationCurve.Lookup(DataBus.VehicleInfo.VehicleSpeed).Deceleration)) { var v2 = DataBus.VehicleInfo.VehicleSpeed + operatingPoint.Acceleration * operatingPoint.SimulationInterval; var nextAcceleration = DriverData.AccelerationCurve.Lookup(v2).Deceleration; var tmp = ComputeTimeInterval(VectoMath.Min(operatingPoint.Acceleration, nextAcceleration), @@ -975,38 +976,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // ================================================ - /// <summary> - /// - /// </summary> - /// <param name="operatingPoint"></param> - /// <param name="limits"></param> - /// <returns></returns> - private OperatingPoint LimitAccelerationByDriverModel(OperatingPoint operatingPoint, - LimitationMode limits) + private OperatingPoint LimitAccelerationByDriverModel(OperatingPoint operatingPoint, LimitationMode limits) { var limitApplied = false; var retVal = new OperatingPoint(operatingPoint); - var originalAcceleration = retVal.Acceleration; - //if (((limits & LimitationMode.LimitDecelerationLookahead) != 0) && - // retVal.Acceleration < DriverData.LookAheadCoasting.Deceleration) { - // retVal.Acceleration = DriverData.LookAheadCoasting.Deceleration; - // limitApplied = true; - //} + var accelerationLimits = DriverData.AccelerationCurve.Lookup(DataBus.VehicleInfo.VehicleSpeed); - //if (retVal.Acceleration > accelerationLimits.Acceleration) { + if (limits != LimitationMode.NoLimitation && operatingPoint.Acceleration > accelerationLimits.Acceleration) { retVal.Acceleration = accelerationLimits.Acceleration; limitApplied = true; } - if (((limits & LimitationMode.LimitDecelerationDriver) != 0) && - retVal.Acceleration < accelerationLimits.Deceleration) { + + if ((limits & LimitationMode.LimitDecelerationDriver) != 0 + && retVal.Acceleration < accelerationLimits.Deceleration) { retVal.Acceleration = accelerationLimits.Deceleration; limitApplied = true; } + if (limitApplied) { retVal.SimulationInterval = - ComputeTimeInterval(retVal.Acceleration, retVal.SimulationDistance) - .SimulationInterval; + ComputeTimeInterval(retVal.Acceleration, retVal.SimulationDistance).SimulationInterval; Log.Debug("Limiting acceleration from {0} to {1}, dt: {2}", operatingPoint.Acceleration, retVal.Acceleration, retVal.SimulationInterval); } @@ -1053,7 +1043,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl deltaPower.Abs() * (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() ? 0.5 : 1), getYValue: result => { var response = (ResponseDryRun)result; - return DataBus.ClutchInfo.ClutchClosed(absTime) && DataBus.GearboxInfo.GearEngaged(absTime) ? response.DeltaDragLoad : response.Gearbox.PowerRequest; + return DataBus.ClutchInfo.ClutchClosed(absTime) + && DataBus.GearboxInfo.GearEngaged(absTime) ? response.DeltaDragLoad : response.Gearbox.PowerRequest; }, evaluateFunction: x => { DataBus.Brakes.BrakePower = x; @@ -1191,19 +1182,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }, criterion: response => { var r = (ResponseDryRun)response; - if (searchEngineSpeed) { - return (r.DeltaEngineSpeed + 1.RPMtoRad()).Value(); - } - delta = actionRoll - ? r.Gearbox.PowerRequest - : (coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad); - return delta.Value(); + if (searchEngineSpeed) return (r.DeltaEngineSpeed + 1.RPMtoRad()).Value(); + if (actionRoll) return r.Gearbox.PowerRequest.Value(); + if (coastingOrRoll) return r.DeltaDragLoad.Value(); + return r.DeltaFullLoad.Value(); }, abortCriterion: (response, cnt) => { var r = (ResponseDryRun)response; - if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && - r.DeltaDragLoad.Value().IsSmallerOrEqual(-double.MaxValue / 20) && coastingOrRoll && !actionRoll ) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() + && r.DeltaDragLoad.Value().IsSmallerOrEqual(-double.MaxValue / 20) + && coastingOrRoll + && !actionRoll) { nanCount++; } if (nanCount > 10) { @@ -1212,23 +1202,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return r != null && !actionRoll && !allowDistanceDecrease && !ds.IsEqual(r.Driver.OperatingPoint.SimulationDistance); }, searcher: this); - return ComputeTimeInterval(retVal.Acceleration, retVal.SimulationDistance); + return ComputeTimeInterval(retVal.Acceleration, retVal.SimulationDistance); } catch (VectoException ve) { switch (ve) { case VectoSearchFailedException _: case VectoSearchAbortedException _: - + // search aborted, try to go ahead with the last acceleration if (!searchEngineSpeed && !actionRoll && !coastingOrRoll) { var nanCount1 = 0; try { retVal.Acceleration = SearchAlgorithm.Search(acceleration, delta, Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating, - getYValue: response => { - var r = (ResponseDryRun)response; - - return (r.DeltaFullLoad); - }, + getYValue: response => ((ResponseDryRun)response).DeltaFullLoad, evaluateFunction: acc => { // calculate new time interval only when vehiclespeed and acceleration are != 0 @@ -1271,8 +1257,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl abortCriterion: (response, cnt) => { var r = (ResponseDryRun)response; - if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && - r.DeltaDragLoad.Value().IsSmallerOrEqual(-double.MaxValue / 20) && coastingOrRoll && !actionRoll) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() + && r.DeltaDragLoad.Value().IsSmallerOrEqual(-double.MaxValue / 20) + && coastingOrRoll + && !actionRoll) { nanCount1++; } @@ -1307,40 +1295,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return null; } - private static Watt GetOrigDelta(IResponse initialResponse, bool coastingOrRoll, bool actionRoll) - { - Watt origDelta = null; + private static Watt GetOrigDelta(IResponse initialResponse, bool coastingOrRoll, bool actionRoll) { if (actionRoll) { switch (initialResponse) { - case ResponseDryRun r: - origDelta = r.Gearbox.PowerRequest; - break; - case ResponseOverload r: - origDelta = r.Delta; - break; - case ResponseFailTimeInterval r: - origDelta = r.Gearbox.PowerRequest; - break; - default: - throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", initialResponse); - } - } else { - switch (initialResponse) { - case ResponseOverload r: - origDelta = r.Delta; - break; - case ResponseEngineSpeedTooHigh r: - // search operating point in drive action after overload - origDelta = r.DeltaEngineSpeed * 1.SI<NewtonMeter>(); - break; - case ResponseDryRun r: - origDelta = coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad; - break; - default: - throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", initialResponse); + case ResponseDryRun r: return r.Gearbox.PowerRequest; + case ResponseOverload r: return r.Delta; + case ResponseFailTimeInterval r: return r.Gearbox.PowerRequest; + default: throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", initialResponse); } } - return origDelta; + + switch (initialResponse) { + case ResponseOverload r: return r.Delta; + case ResponseEngineSpeedTooHigh r: return r.DeltaEngineSpeed * 1.SI<NewtonMeter>(); + case ResponseDryRun r: return coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad; + default: throw new UnexpectedResponseException("SearchOperatingPoint: Unknown response type.", initialResponse); + } } /// <summary> @@ -1388,10 +1358,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // this case should not happen, acceleration has been computed such that the target speed // can be reached within ds. - Log.Error( - "Unexpected Condition: Distance has been adjusted from {0} to {1}, currentVelocity: {2} acceleration: {3}, targetVelocity: {4}", + Log.Error("Unexpected Condition: Distance has been adjusted from {0} to {1}, currentVelocity: {2} acceleration: {3}, targetVelocity: {4}", retVal.SimulationDistance, ds, currentSpeed, CurrentState.Acceleration, targetVelocity); - throw new VectoSimulationException("Simulation distance unexpectedly adjusted! {0} -> {1}", ds, + throw new VectoSimulationException("Simulation distance unexpectedly adjusted! {0} -> {1}", ds, retVal.SimulationDistance); } @@ -1401,10 +1370,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> /// <param name="targetSpeed"></param> /// <returns></returns> - public Meter ComputeDecelerationDistance(MeterPerSecond targetSpeed) - { - return DriverData.AccelerationCurve.ComputeDecelerationDistance(DataBus.VehicleInfo.VehicleSpeed, targetSpeed); - } + public Meter ComputeDecelerationDistance(MeterPerSecond targetSpeed) => + DriverData.AccelerationCurve.ComputeDecelerationDistance(DataBus.VehicleInfo.VehicleSpeed, targetSpeed); /// <summary> /// Computes the time interval for driving the given distance ds with the vehicle's current speed and the given acceleration. @@ -1414,10 +1381,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <param name="acceleration"></param> /// <param name="ds"></param> /// <returns>Operating point (a, ds, dt)</returns> - private OperatingPoint ComputeTimeInterval(MeterPerSquareSecond acceleration, Meter ds) - { - return VectoMath.ComputeTimeInterval(DataBus.VehicleInfo.VehicleSpeed, acceleration, DataBus.MileageCounter.Distance, ds); - } + private OperatingPoint ComputeTimeInterval(MeterPerSquareSecond acceleration, Meter ds) => + VectoMath.ComputeTimeInterval(DataBus.VehicleInfo.VehicleSpeed, acceleration, DataBus.MileageCounter.Distance, ds); /// <summary> /// simulate a certain time interval where the vehicle is stopped. @@ -1456,7 +1421,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { container[ModalResultField.acc] = CurrentState.Acceleration; container.SetDataValue("DriverAction", (int)DrivingAction); - DriverStrategy.WriteModalResults(container); } @@ -1476,7 +1440,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public class DriverState { - // ReSharper disable once InconsistentNaming public Second dt; public MeterPerSquareSecond Acceleration; public IResponse Response; @@ -1493,6 +1456,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public DrivingBehavior DriverBehavior { get; set; } public MeterPerSquareSecond DriverAcceleration { get; protected set; } + public PCCStates PCCState => DriverStrategy.PCCState; + + public MeterPerSecond NextBrakeTriggerSpeed => DriverStrategy.BrakeTrigger.NextTargetSpeed; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index b2eedc4832d860f7b7fcc8ab4a806e12fb567c55..ed4a81f1f7feb69534f24f723c431ce117226336 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -479,10 +479,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { Disengaged = false; var lastGear = Gear; - Gear = DataBus.VehicleInfo.VehicleStopped - ? _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity) - : _strategy.Engage(absTime, dt, outTorque, - VectoMath.Min(PreviousState.OutAngularVelocity, outAngularVelocity)); + if (DataBus.VehicleInfo.VehicleStopped) { + Gear = _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity); + } else { + Gear = _strategy.Engage(absTime, dt, outTorque, VectoMath.Min(PreviousState.OutAngularVelocity, outAngularVelocity)); + } + if (!DataBus.VehicleInfo.VehicleStopped) { if (Gear > lastGear) { LastUpshift = absTime; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs index 069781313de40b1d8b0123d2cd3ec4232e7415e6..0cbdfc9083114ec85080ce27da0db0bee6f4b064 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs @@ -11,11 +11,9 @@ using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; -using TUGraz.VectoCore.Models.SimulationComponent.Strategies; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils; @@ -62,14 +60,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _electricMotorCtl[pos] = new ElectricMotorController(this, motorData); } - //public ResponseDryRun RequestDryRun(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, HybridStrategyResponse strategySettings) - //{ - // ApplyStrategySettings(strategySettings); - // var retVal = NextComponent.Request(absTime, dt, outTorque, outAngularVelocity, true); - - // return retVal as ResponseDryRun; - //} - private void ApplyStrategySettings(HybridStrategyResponse strategySettings) { Gearbox.SwitchToNeutral = strategySettings.GearboxInNeutral; @@ -78,17 +68,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (DataBus.VehicleInfo.VehicleStopped && strategySettings.NextGear.Gear != 0) { _shiftStrategy.SetNextGear(strategySettings.NextGear); } - //if (strategySettings.ShiftRequired) { - // _shiftStrategy.SetNextGear(strategySettings.NextGear); - //} } SimpleComponentState IHybridController.PreviousState => PreviousState; - public virtual IElectricMotorControl ElectricMotorControl(PowertrainPosition pos) - { - return _electricMotorCtl[pos]; - } + public virtual IElectricMotorControl ElectricMotorControl(PowertrainPosition pos) => _electricMotorCtl[pos]; public virtual IShiftStrategy ShiftStrategy => _shiftStrategy; @@ -96,10 +80,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool GearboxEngaged => CurrentStrategySettings.GearboxEngaged; - public PerSecond ElectricMotorSpeed(PowertrainPosition pos) - { - return CurrentStrategySettings.MechanicalAssistPower[pos].Item1; - } + public PerSecond ElectricMotorSpeed(PowertrainPosition pos) => CurrentStrategySettings.MechanicalAssistPower[pos].Item1; public Second SimulationInterval => CurrentStrategySettings.SimulationInterval; @@ -119,8 +100,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retry = false; var strategyResponse = Strategy.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); - if (strategyResponse is HybridStrategyLimitedResponse) { - var ovl = strategyResponse as HybridStrategyLimitedResponse; + if (strategyResponse is HybridStrategyLimitedResponse ovl) { if (dryRun) { return new ResponseDryRun(this) { DeltaDragLoad = ovl.Delta, @@ -168,8 +148,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentStrategySettings = strategySettings; retVal = NextComponent.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); DebugData.Add(new { - DrivingAction = DataBus.DriverInfo.DrivingAction, StrategySettings = strategySettings, - Response = retVal, DryRun = dryRun + DrivingAction = DataBus.DriverInfo.DrivingAction, + StrategySettings = strategySettings, + Response = retVal, + DryRun = dryRun }); if (!dryRun && strategySettings.CombustionEngineOn && retVal is ResponseSuccess && @@ -181,18 +163,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl continue; } - var gear = DataBus.GearboxInfo.Gear; - var maxSpeed = VectoMath.Min(DataBus.GearboxInfo.GetGearData(gear.Gear).MaxSpeed, - DataBus.EngineInfo.EngineN95hSpeed); - if (!dryRun && retVal is ResponseSuccess && DataBus.GearboxInfo.GearEngaged(absTime) && retVal.Gearbox.InputSpeed.IsGreater(maxSpeed)) { - Strategy.AllowEmergencyShift = true; - retryCount++; - retry = true; - Strategy.OperatingpointChangedDuringRequest(absTime, dt, outTorque, outAngularVelocity, false, retVal); - continue; - } - - if (!dryRun && strategySettings.CombustionEngineOn && retVal is ResponseEngineSpeedTooHigh && !strategySettings.ProhibitGearshift) { + var gear = DataBus.GearboxInfo.Gear; + var maxSpeed = VectoMath.Min(DataBus.GearboxInfo.GetGearData(gear.Gear).MaxSpeed, + DataBus.EngineInfo.EngineN95hSpeed); + if (!dryRun && retVal is ResponseSuccess && DataBus.GearboxInfo.GearEngaged(absTime) && retVal.Gearbox.InputSpeed.IsGreater(maxSpeed)) { + Strategy.AllowEmergencyShift = true; + retryCount++; + retry = true; + Strategy.OperatingpointChangedDuringRequest(absTime, dt, outTorque, outAngularVelocity, false, retVal); + continue; + } + + if (!dryRun && strategySettings.CombustionEngineOn && retVal is ResponseEngineSpeedTooHigh && !strategySettings.ProhibitGearshift) { retryCount++; retry = true; Strategy.AllowEmergencyShift = true; @@ -236,7 +218,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl PreviousState.StrategyResponse = strategyResponse as HybridStrategyResponse; _electricMotorTorque = PreviousState.StrategyResponse.MechanicalAssistPower; var retVal = NextComponent.Initialize(outTorque, outAngularVelocity); - SelectedGear =DataBus.GearboxInfo.Gear; + SelectedGear = DataBus.GearboxInfo.Gear; return retVal; } @@ -255,12 +237,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } private NewtonMeter MechanicalAssistPower(PowertrainPosition pos, Second absTime, Second dt, - NewtonMeter outTorque, PerSecond prevOutAngularVelocity, PerSecond currOutAngularVelocity, bool dryRun) - { - return _electricMotorTorque[pos]?.Item2; - - //return CurrentState.StrategyResponse.MechanicalAssistPower[pos]; - } + NewtonMeter outTorque, PerSecond prevOutAngularVelocity, PerSecond currOutAngularVelocity, bool dryRun) => + _electricMotorTorque[pos]?.Item2; public GearshiftPosition NextGear => CurrentState.StrategyResponse.NextGear; @@ -381,7 +359,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)) { return InitStartGear(absTime, outTorque, outAngularVelocity); } - + foreach (var entry in GearList.Reverse()) { var gear = entry; //for (var gear = (uint)GearboxModelData.Gears.Count; gear > 1; gear--) { @@ -442,7 +420,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (_runData != null && _runData.HybridStrategyParameters.MaxPropulsionTorque?.GetVECTOValueOrDefault(gear) != null) { var tqRequest = response.Gearbox.InputTorque; var maxTorque = _runData.HybridStrategyParameters.MaxPropulsionTorque[gear].FullLoadDriveTorque(response.Gearbox.InputSpeed); - reserve = 1 - VectoMath.Min(response.Engine.TorqueOutDemand / fullLoadPower, tqRequest / maxTorque); + reserve = 1 - VectoMath.Min(response.Engine.TorqueOutDemand / fullLoadPower, tqRequest / maxTorque); } if (response.Engine.EngineSpeed > DataBus.EngineInfo.EngineIdleSpeed && @@ -458,18 +436,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } - protected virtual bool SpeedTooLowForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) - { - return (outAngularSpeed * GearboxModelData.Gears[gear.Gear].Ratio).IsSmaller(DataBus.EngineInfo.EngineIdleSpeed); - } + protected virtual bool SpeedTooLowForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) => + (outAngularSpeed * GearboxModelData.Gears[gear.Gear].Ratio).IsSmaller(DataBus.EngineInfo.EngineIdleSpeed); - protected virtual bool SpeedTooHighForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) - { - return - (outAngularSpeed * GearboxModelData.Gears[gear.Gear].Ratio).IsGreaterOrEqual(VectoMath.Min( - GearboxModelData.Gears[gear.Gear].MaxSpeed, - DataBus.EngineInfo.EngineN95hSpeed)); - } + protected virtual bool SpeedTooHighForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) => + (outAngularSpeed * GearboxModelData.Gears[gear.Gear].Ratio).IsGreaterOrEqual( + VectoMath.Min(GearboxModelData.Gears[gear.Gear].MaxSpeed, DataBus.EngineInfo.EngineN95hSpeed)); public override GearshiftPosition Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { @@ -514,24 +486,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override IGearbox Gearbox { get => _gearbox; - set - { - var myGearbox = value as Gearbox; - if (myGearbox == null) { - throw new VectoException("This shift strategy can't handle gearbox of type {0}", - value.GetType()); - } - - _gearbox = myGearbox; - } + set => _gearbox = value as Gearbox ?? throw new VectoException("This shift strategy can't handle gearbox of type {0}", value.GetType()); } public override GearshiftPosition NextGear => _nextGear; - public void SetNextGear(GearshiftPosition nextGear) - { - _nextGear = nextGear; - } + public void SetNextGear(GearshiftPosition nextGear) => _nextGear = nextGear; } @@ -542,21 +502,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected new ATGearbox _gearbox; public HybridCtlATShiftStrategy(HybridController hybridController, IVehicleContainer container) : base( - hybridController, container) { } + hybridController, container) + { } public override IGearbox Gearbox { get => _gearbox; - set - { - var myGearbox = value as ATGearbox; - if (myGearbox == null) { - throw new VectoException("This shift strategy can't handle gearbox of type {0}", - value.GetType()); - } - - _gearbox = myGearbox; - } + set => _gearbox = value as ATGearbox ?? throw new VectoException("This shift strategy can't handle gearbox of type {0}", value.GetType()); } public override GearshiftPosition InitGear(Second absTime, Second dt, NewtonMeter torque, PerSecond outAngularVelocity) @@ -585,30 +537,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return Gears.First(); } - protected override bool DoCheckShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, - NewtonMeter inTorque, PerSecond inAngularVelocity, GearshiftPosition gear, Second lastShiftTime, - IResponse response) - { - return false; - } - - //public override GearshiftPosition Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) - //{ - // if (_nextGear.AbsTime != null && _nextGear.AbsTime.IsEqual(absTime)) { - // //_gearbox.Gear = _nextGear.Gear; - // _gearbox.Disengaged = _nextGear.Disengaged; - // _nextGear.AbsTime = null; - // return _nextGear.Gear; - // } - - // _nextGear.AbsTime = null; - // return _gearbox.Gear; - //} + protected override bool DoCheckShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, + PerSecond outAngularVelocity, NewtonMeter inTorque, PerSecond inAngularVelocity, GearshiftPosition gear, + Second lastShiftTime, IResponse response) => + false; - public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) - { + public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) => throw new NotImplementedException("AT Shift Strategy does not support disengaging."); - } protected override bool SpeedTooLowForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) { @@ -617,7 +552,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } return base.SpeedTooLowForEngine(gear, outAngularSpeed); - //(outAngularSpeed * GearboxModelData.Gears[gear.Gear].Ratio).IsSmaller(DataBus.EngineInfo.EngineIdleSpeed); } protected override bool SpeedTooHighForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) @@ -627,12 +561,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } return base.SpeedTooHighForEngine(gear, outAngularSpeed); - //(outAngularSpeed * GearboxModelData.Gears[gear.Gear].Ratio).IsGreaterOrEqual(VectoMath.Min( - // GearboxModelData.Gears[gear.Gear].MaxSpeed, - // DataBus.EngineInfo.EngineN95hSpeed)); } - } - } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index 22c140fce2d05af5ea80f7c4cf5c97a6351cddc3..8e59dce75588cd02952fe1c3648dcba4bd2700a3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -385,8 +385,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public DrivingAction DrivingAction => DrivingAction.Accelerate; public MeterPerSquareSecond DriverAcceleration { get; protected set; } + public PCCStates PCCState => PCCStates.OutsideSegment; + public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + public Meter Distance => CurrentState.Distance; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs index e2b3ddc9f0adbca3428dee4cdfc62bdd8a9f9b0f..ceb710a1179768407f5c4c398d069acc70737a49 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs @@ -152,6 +152,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); public PCCStates PCCState => PCCStates.OutsideSegment; + public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); #endregion } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs index 006869c8d8f4608a34ed35d8f7864ac8a01a613c..b50f7d7e463308645f0d49080b280db24bd2c79d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs @@ -33,6 +33,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public MeterPerSquareSecond DriverAcceleration => 0.SI<MeterPerSquareSecond>(); public PCCStates PCCState => PCCStates.OutsideSegment; + public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); #endregion } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs index 1994691105ddba51fb234b695feb4a143e5d7995..d4bd2bd90c15c6372664e1a45a6f8677b72c8531 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/HybridStrategy.cs @@ -47,7 +47,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies protected override IResponse RequestDryRun(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, GearshiftPosition nextGear, HybridStrategyResponse cfg) { - TestPowertrain.Gearbox.Gear = DataBus.VehicleInfo.VehicleStopped ? Controller.ShiftStrategy.NextGear : PreviousState.GearboxEngaged ? DataBus.GearboxInfo.Gear : Controller.ShiftStrategy.NextGear; + if (DataBus.VehicleInfo.VehicleStopped) { + TestPowertrain.Gearbox.Gear = Controller.ShiftStrategy.NextGear; + } + else if (PreviousState.GearboxEngaged) { + TestPowertrain.Gearbox.Gear = DataBus.GearboxInfo.Gear; + } else { + TestPowertrain.Gearbox.Gear = Controller.ShiftStrategy.NextGear; + } + TestPowertrain.Gearbox.Disengaged = !nextGear.Engaged; TestPowertrain.Gearbox.DisengageGearbox = !nextGear.Engaged; TestPowertrain.Container.VehiclePort.Initialize(DataBus.VehicleInfo.VehicleSpeed, DataBus.DrivingCycleInfo.RoadGradient ?? 0.SI<Radian>()); @@ -602,13 +610,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies public virtual IHybridStrategyResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) { - var nextGear = DataBus.VehicleInfo.VehicleStopped - ? Controller.ShiftStrategy.NextGear - : !DataBus.GearboxInfo.GearEngaged(absTime) - ? Controller.ShiftStrategy.NextGear - : PreviousState.GearboxEngaged - ? DataBus.GearboxInfo.Gear - : Controller.ShiftStrategy.NextGear; + GearshiftPosition nextGear; + if (DataBus.VehicleInfo.VehicleStopped) { + nextGear = Controller.ShiftStrategy.NextGear; + } + else if (!DataBus.GearboxInfo.GearEngaged(absTime)) { + nextGear = Controller.ShiftStrategy.NextGear; + } + else if (PreviousState.GearboxEngaged) { + nextGear = DataBus.GearboxInfo.Gear; + } else { + nextGear = Controller.ShiftStrategy.NextGear; + } + if (DataBus.DriverInfo.DrivingAction == DrivingAction.Accelerate && StrategyParameters.MaxPropulsionTorque?.GetVECTOValueOrDefault(nextGear) != null && DataBus.GearboxInfo.TCLocked) { var emOff = new HybridStrategyResponse { @@ -1037,7 +1051,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies if (ElectricMotorCanPropellDuringTractionInterruption || DataBus.GearboxInfo.GearEngaged(absTime)) { - if (vehiclespeedBelowThreshold && (emPos == PowertrainPosition.HybridP2 || emPos == PowertrainPosition.HybridP1)) { + if (vehiclespeedBelowThreshold && emPos.IsOneOf(PowertrainPosition.HybridP2, PowertrainPosition.HybridP1)) { if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { var firstgear = ResponseEmOff; firstgear.Gear = GearList.First(); @@ -1083,7 +1097,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies var endSpeed = DataBus.VehicleInfo.VehicleSpeed + DataBus.DriverInfo.DriverAcceleration * ModelData.GearboxData.TractionInterruption; if (engineSpeedTooLow && DataBus.GearboxInfo.GearboxType.ManualTransmission() && - endSpeed.IsSmallerOrEqual(ModelData.GearboxData.DisengageWhenHaltingSpeed, 0.1.KMPHtoMeterPerSecond())) { + endSpeed.IsSmallerOrEqual(disengageSpeedThreshold, 0.1.KMPHtoMeterPerSecond())) { var response = ResponseEmOff; response.Gear = new GearshiftPosition(0); response.Setting.GearboxEngaged = false; @@ -1340,18 +1354,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { return firstResponse.Engine.EngineOn ? firstResponse.Engine.EngineSpeed.IsSmaller(ModelData.EngineData.IdleSpeed) - : firstResponse.Gearbox.InputSpeed?.IsSmaller(ModelData.EngineData.IdleSpeed) ?? - false; + : (firstResponse.Gearbox.InputSpeed?.IsSmaller(ModelData.EngineData.IdleSpeed) ?? false); } return firstResponse.Clutch.OutputSpeed.IsSmaller(ModelData.EngineData.IdleSpeed); // firstResponse.Gearbox.InputSpeed.IsSmaller(ModelData.EngineData.IdleSpeed)); } private GearshiftPosition FindBestGearForBraking(GearshiftPosition nextGear, IResponse firstResponse) { - var endSpeed = DataBus.VehicleInfo.VehicleSpeed + + var endSpeed = DataBus.VehicleInfo.VehicleSpeed + DataBus.DriverInfo.DriverAcceleration * ModelData.GearboxData.TractionInterruption; - if (DataBus.GearboxInfo.GearboxType.ManualTransmission() && - endSpeed.IsSmallerOrEqual(ModelData.GearboxData.DisengageWhenHaltingSpeed, 0.1.KMPHtoMeterPerSecond())) { + + // 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) + && endSpeed.IsSmallerOrEqual(ModelData.GearboxData.DisengageWhenHaltingSpeed, 0.1.KMPHtoMeterPerSecond())) { return new GearshiftPosition(0); } @@ -1732,7 +1748,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies // ICE is off, selected solution has a too low or too high engine speed - keep ICE off retVal.CombustionEngineOn = false; } - if (best.IgnoreReason.EngineSpeedTooLow() && !DataBus.EngineInfo.EngineOn && DataBus.VehicleInfo.VehicleSpeed.IsGreater(ModelData.GearshiftParameters.StartSpeed)) { + if (best.IgnoreReason.EngineSpeedTooLow() && !DataBus.EngineInfo.EngineOn + && DataBus.VehicleInfo.VehicleSpeed.IsGreater(ModelData.GearshiftParameters.StartSpeed)) { // ICE is off, selected solution has a too low or too high engine speed - keep ICE off retVal.CombustionEngineOn = false; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs index be68a2a1b5127385fffbc037540fd796c6ac73c8..bb876d51366a5361b32a22d93fda98059e165df5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs @@ -221,6 +221,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies public MeterPerSquareSecond DriverAcceleration => realContainer?.DriverInfo.DriverAcceleration; public PCCStates PCCState => PCCStates.OutsideSegment; + public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); #endregion #region Overrides of VectoSimulationComponent diff --git a/VectoCore/VectoCoreTest/Utils/MockDriver.cs b/VectoCore/VectoCoreTest/Utils/MockDriver.cs index 27ff91a02f291c83ed83fe97aa27af347b092efa..14db237ec6d19c32e534b0a73de4d5d4e13486f2 100644 --- a/VectoCore/VectoCoreTest/Utils/MockDriver.cs +++ b/VectoCore/VectoCoreTest/Utils/MockDriver.cs @@ -124,5 +124,6 @@ namespace TUGraz.VectoCore.Tests.Utils public MeterPerSquareSecond DriverAcceleration { get; set; } public PCCStates PCCState => PCCStates.OutsideSegment; + public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index b327caafe996a12209ac663446793648eca1a8af..54b0580661a7a5ebf6b8e35c8b34976eebc24649 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -236,6 +236,7 @@ namespace TUGraz.VectoCore.Tests.Utils public MeterPerSquareSecond DriverAcceleration { get; set; } public PCCStates PCCState => PCCStates.OutsideSegment; + public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); public CycleData CycleData { get; set; }