diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 00539ff9c3002d089f9cc3b6d705a0bec5134a58..02d0ed555b320581b21e1faa1e4129c43ec2a1df 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -865,6 +865,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var response = HandleRequestDisengaged(absTime, ds, gradient, velocityWithOverspeed, debug); + if (response is ResponseDrivingCycleDistanceExceeded) { + return response; + } if (!(response is ResponseSuccess) && DataBus.ClutchInfo.ClutchClosed(absTime)) { response = HandleRequestEngaged( absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocityWithOverspeed, debug); @@ -1100,7 +1103,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, bool prohibitOverspeed = false) { - if (DataBus.VehicleInfo.VehicleSpeed <= DriverStrategy.BrakeTrigger.NextTargetSpeed && !DataBus.VehicleInfo.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleSpeed.IsSmallerOrEqual(DriverStrategy.BrakeTrigger.NextTargetSpeed) && !DataBus.VehicleInfo.VehicleStopped) { var retVal = HandleTargetspeedReached(absTime, ds, targetVelocity, gradient); for (var i = 0; i < 3 && retVal == null; i++) { retVal = HandleTargetspeedReached(absTime, ds, targetVelocity, gradient); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 0d6b683abb6812b195353275df697156c9e808a5..905ffc56dfb3bc908843b01e38886cf7f3e3ab74 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -440,6 +440,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl searchedOperatingPoint = SetTCOperatingPointATGbxCoastOrRoll(absTime, gradient, requestedOperatingPoint, initialResponse as ResponseDryRun); } + if (searchedOperatingPoint == null) { + searchedOperatingPoint = SearchOperatingPoint( + absTime, requestedOperatingPoint.SimulationDistance, + gradient, + requestedOperatingPoint.Acceleration, initialResponse, coastingOrRoll: true, allowDistanceDecrease: true); + if (searchedOperatingPoint == null) { + throw new NotImplementedException(); + } + + if (searchedOperatingPoint.SimulationDistance.IsSmaller(ds)) { + return new ResponseDrivingCycleDistanceExceeded(this) { + MaxDistance = searchedOperatingPoint.SimulationDistance + }; + } + } + if (!ds.IsEqual(searchedOperatingPoint.SimulationDistance)) { // vehicle is at low speed, coasting would lead to stop before ds is reached: reduce simulated distance to stop distance. Log.Debug( @@ -1052,7 +1068,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } protected OperatingPoint SearchOperatingPoint(Second absTime, Meter ds, Radian gradient, - MeterPerSquareSecond acceleration, IResponse initialResponse, bool coastingOrRoll = false) + MeterPerSquareSecond acceleration, IResponse initialResponse, bool coastingOrRoll = false, bool allowDistanceDecrease = false) { IterationStatistics.Increment(this, "SearchOperatingPoint", 0); @@ -1124,7 +1140,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (nanCount > 10) { return true; } - return r != null && !actionRoll && !ds.IsEqual(r.Driver.OperatingPoint.SimulationDistance); + return r != null && !actionRoll && !allowDistanceDecrease && !ds.IsEqual(r.Driver.OperatingPoint.SimulationDistance); }); return ComputeTimeInterval(retVal.Acceleration, retVal.SimulationDistance); } catch (VectoSearchAbortedException) {