diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs index d388216f1d38c77a35ee95855299e591f6d98432..6b68a67eecaf45500613c33e49eed4cf2d181cc3 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -30,7 +30,6 @@ */ using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent; namespace TUGraz.VectoCore.Models.Simulation.DataBus diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs index 8b93a251faf9ef221165ea76b27ad8af00511e4a..74b952668c1e683cd3fad489c11609d0809f1b90 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs @@ -29,6 +29,8 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using TUGraz.VectoCommon.Utils; + namespace TUGraz.VectoCore.Models.Simulation.DataBus { public enum DrivingBehavior @@ -43,5 +45,6 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus public interface IDriverInfo { DrivingBehavior DriverBehavior { get; } + MeterPerSquareSecond DriverAcceleration { get; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index beec23dfcf8fa4730b36678b7b654ce1b82a3c3c..52fc806bac02127fdb3d89b0af07fc865963dcb7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -31,6 +31,7 @@ using System; using System.Linq; +using System.Windows.Forms.VisualStyles; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -62,6 +63,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DriverData = driverData; DriverStrategy = strategy; strategy.Driver = this; + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); } public IDriverDemandInPort InPort() @@ -146,6 +148,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var operatingPoint = ComputeAcceleration(ds, targetVelocity); IResponse retVal = null; + DriverAcceleration = operatingPoint.Acceleration; var response = previousResponse ?? NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); @@ -177,6 +180,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("Found operating point for Drive/Accelerate. dt: {0}, acceleration: {1}", limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration); + DriverAcceleration = limitedOperatingPoint.Acceleration; retVal = NextComponent.Request(absTime, limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration, gradient); retVal.Switch(). @@ -188,6 +192,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Info( "Operating point with limited acceleration resulted in an overload! trying again with original acceleration {0}", nextOperatingPoint.Acceleration); + DriverAcceleration = nextOperatingPoint.Acceleration; retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, nextOperatingPoint.Acceleration, gradient); retVal.Switch(). @@ -267,6 +272,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl bool rollAction) { var requestedOperatingPoint = ComputeAcceleration(ds, DataBus.VehicleSpeed); + DriverAcceleration = requestedOperatingPoint.Acceleration; var initialResponse = NextComponent.Request(absTime, requestedOperatingPoint.SimulationInterval, requestedOperatingPoint.Acceleration, gradient, dryRun: true); @@ -307,6 +313,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return new ResponseSpeedLimitExceeded() { Source = this }; } + DriverAcceleration = limitedOperatingPoint.Acceleration; var response = NextComponent.Request(absTime, limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration, gradient); @@ -377,6 +384,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } + DriverAcceleration = operatingPoint.Acceleration; var response = previousResponse ?? NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); @@ -425,6 +433,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return new ResponseOverload { Source = this }; } + DriverAcceleration = operatingPoint.Acceleration; retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); retVal.Switch(). @@ -502,6 +511,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl initialResponse.Switch(). Case<ResponseGearShift>(r => { IterationStatistics.Increment(this, "SearchBrakingPower"); + DriverAcceleration = operatingPoint.Acceleration; var nextResp = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, true); deltaPower = nextResp.GearboxPowerRequest; @@ -521,6 +531,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl operatingPoint = ComputeTimeInterval(operatingPoint.Acceleration, ds); IterationStatistics.Increment(this, "SearchBrakingPower"); + DriverAcceleration = operatingPoint.Acceleration; return NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient, true); }, @@ -581,6 +592,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal.SimulationDistance = tmp.SimulationDistance; } IterationStatistics.Increment(this, "SearchOperatingPoint"); + DriverAcceleration = acc; var response = NextComponent.Request(absTime, retVal.SimulationInterval, acc, gradient, true); response.OperatingPoint = retVal; return response; @@ -710,11 +722,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DataBus.VehicleSpeed); } + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); retVal.Switch(). - Case<ResponseGearShift>( - r => { retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); }); + Case<ResponseGearShift>(r => { + DriverAcceleration = 0.SI<MeterPerSquareSecond>(); + retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); + }); CurrentState.dt = dt; CurrentState.Acceleration = 0.SI<MeterPerSquareSecond>(); return retVal; @@ -755,5 +770,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } public DrivingBehavior DriverBehavior { get; set; } + + public MeterPerSquareSecond DriverAcceleration { get; protected set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 95d534a251891b46f1149b5ef9fd23fc5ad88367..05933df60da2b5e6d9b568f10afae35e55a06c88 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -313,6 +313,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl get { return DrivingBehavior.Driving; } } + public MeterPerSquareSecond DriverAcceleration + { + get { return 0.SI<MeterPerSquareSecond>(); } + } + #endregion } @@ -420,6 +425,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var deltaT = RightSample.Current.Time - LeftSample.Current.Time; var acceleration = deltaV / deltaT; var gradient = LeftSample.Current.RoadGradient; + DriverAcceleration = acceleration; DriverBehavior = acceleration < 0 ? DriverBehavior = DrivingBehavior.Braking : DriverBehavior = DrivingBehavior.Driving; @@ -592,6 +598,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public DrivingBehavior DriverBehavior { get; internal set; } + public MeterPerSquareSecond DriverAcceleration { get; protected set; } + public Meter Distance { get { return CurrentState.Distance; } diff --git a/VectoCore/VectoCoreTest/Utils/MockDriver.cs b/VectoCore/VectoCoreTest/Utils/MockDriver.cs index d0a0d1a76f8dc5a81fbc75b28fbb6467a78d9f9d..7315419a5d7d19092983f24c9fce9fa3961840be 100644 --- a/VectoCore/VectoCoreTest/Utils/MockDriver.cs +++ b/VectoCore/VectoCoreTest/Utils/MockDriver.cs @@ -117,5 +117,6 @@ namespace TUGraz.VectoCore.Tests.Utils public bool VehicleStopped { get; set; } public DrivingBehavior DriverBehavior { get; set; } + public MeterPerSquareSecond DriverAcceleration { get; set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index 92b6ab895c5acea5f4d16719c2e923ec24302852..c657a81350d34f0ab590384c03d2d2860b408ad7 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -137,7 +137,10 @@ namespace TUGraz.VectoCore.Tests.Utils } public bool VehicleStopped { get; set; } + public DrivingBehavior DriverBehavior { get; set; } + public MeterPerSquareSecond DriverAcceleration { get; set; } + public CycleData CycleData { get; set; } public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance)