diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index d6bf3efdcfb8ffc5af3e9dbf24dc21ab41060b7f..448907ed6a76df6d4d07ce1ebadae0ed35034a31 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -237,7 +237,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.EngineTorque = VectoMath.Limit(totalTorqueDemand, minTorque, maxTorque); CurrentState.EnginePower = CurrentState.EngineTorque * avgEngineSpeed; - if (torqueOut.IsGreater(0.SI<NewtonMeter>()) && + if (totalTorqueDemand.IsGreater(0.SI<NewtonMeter>()) && (deltaFull * avgEngineSpeed).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { Log.Debug("requested engine power exceeds fullload power: delta: {0}", deltaFull); return new ResponseOverload { @@ -250,7 +250,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - if (torqueOut.IsSmaller(0.SI<NewtonMeter>()) && + if (totalTorqueDemand.IsSmaller(0.SI<NewtonMeter>()) && (deltaDrag * avgEngineSpeed).IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.LineSearchTolerance)) { Log.Debug("requested engine power is below drag power: delta: {0}", deltaDrag); return new ResponseUnderload { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 56972493d38cbad365e7737ade59f9f1d69f4d55..c578eacbb99bf2e43af52b4f244ec7a038a39b81 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -274,8 +274,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var currentSpeed = Driver.DataBus.VehicleSpeed; // distance until halt - var lookaheadDistance = Formulas.DecelerationDistance(currentSpeed, 0.SI<MeterPerSecond>(), - Driver.DriverData.LookAheadCoasting.Deceleration); + //var lookaheadDistance = Formulas.DecelerationDistance(currentSpeed, 0.SI<MeterPerSecond>(), + // Driver.DriverData.LookAheadCoasting.Deceleration); + var lookaheadDistance = (currentSpeed.Value() * 3.6 * 10).SI<Meter>(); + lookaheadDistance = VectoMath.Max(2 * ds, 1.2 * lookaheadDistance); var lookaheadData = Driver.DataBus.LookAhead(lookaheadDistance); @@ -287,8 +289,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : entry.VehicleTargetSpeed; if (nextTargetSpeed < currentSpeed) { var coastingDistance = ComputeCoastingDistance(currentSpeed, entry); - if (!Driver.DriverData.LookAheadCoasting.Enabled || - currentSpeed < Driver.DriverData.LookAheadCoasting.MinSpeed || + if ( /*!Driver.DriverData.LookAheadCoasting.Enabled || + currentSpeed < Driver.DriverData.LookAheadCoasting.MinSpeed || */ coastingDistance < 0) { var brakingDistance = Driver.ComputeDecelerationDistance(nextTargetSpeed) + BrakingSafetyMargin; Log.Debug( diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index a942b38e81f72bef2f1ee95ec3535f057aa04225..822d5223faa2a86163b587be203859c4b3e9d8fe 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -318,7 +318,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // compute speed at the end of the simulation interval. if it exceeds the limit -> return var v2 = DataBus.VehicleSpeed + limitedOperatingPoint.Acceleration * limitedOperatingPoint.SimulationInterval; - if (v2 > maxVelocity) { + if (v2 > maxVelocity && limitedOperatingPoint.Acceleration.IsGreaterOrEqual(0.SI<MeterPerSquareSecond>())) { Log.Debug("vehicle's velocity would exceed given max speed. v2: {0}, max speed: {1}", v2, maxVelocity); return new ResponseSpeedLimitExceeded() { Source = this }; } diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index c73b01af3dddf8a6fc90f3c53d8538d8b935269d..8b746b03f8be6c10fb85e1211603a3cef06ac0e3 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Globalization; using System.Linq; using System.Runtime.CompilerServices; using TUGraz.VectoCommon.Models; @@ -229,7 +230,11 @@ namespace TUGraz.VectoCore.OutputData _additionalColumns.Add(fieldName); Data.Columns.Add(fieldName); } - CurrentRow[fieldName] = value; + if (value is double) { + CurrentRow[fieldName] = string.Format(CultureInfo.InvariantCulture, "{0}", value); + } else { + CurrentRow[fieldName] = value; + } } public Dictionary<string, DataColumn> Auxiliaries { get; set; } diff --git a/VectoCore/VectoCoreTest/Integration/DriverStrategy/CoastingTests.cs b/VectoCore/VectoCoreTest/Integration/DriverStrategy/CoastingTests.cs index 219c5810c120b6ad8d0fe5597e589e27668a1967..e02b1eb2a723aee9b7fc78f6e7de8bfcd17b07bc 100644 --- a/VectoCore/VectoCoreTest/Integration/DriverStrategy/CoastingTests.cs +++ b/VectoCore/VectoCoreTest/Integration/DriverStrategy/CoastingTests.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using NUnit.Framework; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Simulation.Data; @@ -40,6 +41,11 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy TestCase(60, 35, 5.3), TestCase(50, 47.5, -2.1), TestCase(65, 62.5, -0.8), + TestCase(60, 50, 5.6), + TestCase(80, 40, 4.0), + TestCase(65, 60, 4.7), + TestCase(70, 62.5, 4.6), + TestCase(75, 65, 4.5), ] public void Truck_Coasting_Test(double v1, double v2, double slope) { @@ -47,9 +53,9 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy var cycle = new[] { // <s>,<v>,<grad>,<stop> - string.Format(" 0, {0}, {2}, 0", v1, v2, slope), - string.Format("1000, {1}, {2}, 0", v1, v2, slope), - string.Format("1100, {1}, {2}, 0", v1, v2, slope) + string.Format(CultureInfo.InvariantCulture, " 0, {0}, {2}, 0", v1, v2, slope), + string.Format(CultureInfo.InvariantCulture, "1000, {1}, {2}, 0", v1, v2, slope), + string.Format(CultureInfo.InvariantCulture, "1100, {1}, 0, 0", v1, v2, slope) }; System.IO.Directory.CreateDirectory(string.Format(@"Coast_{0}_{1}", v1, v2, slope)); var slopePrefix = "";