diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs index 71887650bc8095af1d4b5b47d578098d65db12b8..1e3031ae115c949a9704cffc5472e06d27df004d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DriverData.cs @@ -29,49 +29,49 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.ComponentModel.DataAnnotations; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.Models.Declaration; - -namespace TUGraz.VectoCore.Models.SimulationComponent.Data -{ - public class DriverData - { - [Required, ValidateObject] public OverSpeedEcoRollData OverSpeedEcoRoll; - - [Required, ValidateObject] public LACData LookAheadCoasting; - - [Required, ValidateObject] public AccelerationCurveData AccelerationCurve; - - public static DriverMode ParseDriverMode(string mode) - { - return mode.Replace("-", "").ParseEnum<DriverMode>(); - } - - public class OverSpeedEcoRollData - { - public DriverMode Mode; - - [Required, SIRange(0, 120 / Constants.MeterPerSecondToKMH)] public MeterPerSecond MinSpeed; - - [Required, SIRange(0, 50 / Constants.MeterPerSecondToKMH)] public MeterPerSecond OverSpeed; - - [Required, SIRange(0, 50 / Constants.MeterPerSecondToKMH)] public MeterPerSecond UnderSpeed; - } - - public class LACData - { - public bool Enabled; - - //public MeterPerSquareSecond Deceleration; - - [Required, SIRange(0, 120 / Constants.MeterPerSecondToKMH)] public MeterPerSecond MinSpeed; - - [Required, Range(0, 20)] public double LookAheadDistanceFactor; - - [Required, ValidateObject] public LACDecisionFactor LookAheadDecisionFactor; - } - } +using System.ComponentModel.DataAnnotations; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Models.Declaration; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Data +{ + public class DriverData + { + [Required, ValidateObject] public OverSpeedEcoRollData OverSpeedEcoRoll; + + [Required, ValidateObject] public LACData LookAheadCoasting; + + [Required, ValidateObject] public AccelerationCurveData AccelerationCurve; + + public static DriverMode ParseDriverMode(string mode) + { + return mode.Replace("-", "").ParseEnum<DriverMode>(); + } + + public class OverSpeedEcoRollData + { + public DriverMode Mode; + + [Required, SIRange(0, 120 / Constants.MeterPerSecondToKMH)] public MeterPerSecond MinSpeed; + + [Required, SIRange(0, 50 / Constants.MeterPerSecondToKMH)] public MeterPerSecond OverSpeed; + + [Required, SIRange(0, 50 / Constants.MeterPerSecondToKMH)] public MeterPerSecond UnderSpeed; + } + + public class LACData + { + public bool Enabled; + + //public MeterPerSquareSecond Deceleration; + + [Required, SIRange(0, 120 / Constants.MeterPerSecondToKMH)] public MeterPerSecond MinSpeed; + + [Required, Range(0, 20)] public double LookAheadDistanceFactor; + + [Required, ValidateObject] public LACDecisionFactor LookAheadDecisionFactor; + } + } } \ 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 99dbc193ff197f1da00916a2fc3ada8b3556264a..4ca611871051c3f26d46030911e3a9c430c0ef5f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - var retVal = DrivingModes[CurrentDrivingMode].Request(absTime, ds, targetVelocity, gradient); + var retVal = DrivingModes[CurrentDrivingMode].Request(absTime, ds, VectoMath.Min(Driver.DataBus.MaxVehicleSpeed, targetVelocity), gradient); return retVal; } @@ -118,7 +118,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { Driver.DriverBehavior = DrivingBehavior.Halted; CurrentDrivingMode = DrivingMode.DrivingModeDrive; - return Driver.DrivingActionHalt(absTime, dt, targetVelocity, gradient); + return Driver.DrivingActionHalt(absTime, dt, VectoMath.Min(Driver.DataBus.MaxVehicleSpeed, targetVelocity), gradient); } private void UpdateDrivingAction(Meter currentDistance, Meter ds) @@ -289,8 +289,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (prohibitOverspeed) { return false; } - return Driver.DriverData.OverSpeedEcoRoll.Mode == DriverMode.Overspeed && - velocity > Driver.DriverData.OverSpeedEcoRoll.MinSpeed; + return Driver.DriverData.OverSpeedEcoRoll.Mode == DriverMode.Overspeed + && velocity > Driver.DriverData.OverSpeedEcoRoll.MinSpeed + && (velocity + Driver.DriverData.OverSpeedEcoRoll.OverSpeed) < (Driver.DataBus.MaxVehicleSpeed ?? 500.KMPHtoMeterPerSecond()); } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs index 4aae8a546732f45ba6f97b5536a9dd103febb2d7..d35405a8e6c6b44ae8bf0bc6a4a12788e277aa87 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs @@ -230,7 +230,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation fullLoad.Columns.Add("drag torque"); fullLoad.Columns.Add("PT1"); fullLoad.Rows.Add("0", "5000", "-5000", "0"); - fullLoad.Rows.Add("3000", "5000", "-5000", "0"); + fullLoad.Rows.Add("2000", "5000", "-5000", "0"); + fullLoad.Rows.Add("3000", "0", "-5000", "0"); var fullLoadCurve = FullLoadCurveReader.Create(fullLoad); var data = new VectoRunData { @@ -297,7 +298,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation fullLoad.Columns.Add("drag torque"); fullLoad.Columns.Add("PT1"); fullLoad.Rows.Add("0", "5000", "-5000", "0"); - fullLoad.Rows.Add("3000", "5000", "-5000", "0"); + fullLoad.Rows.Add("2000", "5000", "-5000", "0"); + fullLoad.Rows.Add("3000", "0", "-5000", "0"); var fullLoadCurve = FullLoadCurveReader.Create(fullLoad); var data = new VectoRunData { diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs index 4552c62b98c695904fafe70b0225e7c86f405ed6..7bb253f3ff4963eff8784c1de9d1f20fac061719 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs @@ -30,6 +30,7 @@ */ using System.Collections.Generic; +using System.IO; using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -61,6 +62,13 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public const string AccelerationFile = @"TestData\Components\Coach.vacc"; public const double Tolerance = 0.001; + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + } + + [TestCase] public void DriverCoastingTest() {