diff --git a/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/Models/Simulation/DataBus/IDataBus.cs index e5549e05378f62b67661e80fe3556d13eead1f91..39f00f8e768e7484ae8b6242697d3b9cb81bdc1c 100644 --- a/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -1,4 +1,5 @@ using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.DataBus { diff --git a/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs b/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs index ae113cce4e5a44aad44203ca5435f7c464da4ef1..938284fb97afee720ae3decacf57b0304bddc637 100644 --- a/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs +++ b/VectoCore/Models/Simulation/DataBus/IDriverInfo.cs @@ -1,7 +1,20 @@ +using TUGraz.VectoCore.Utils; + namespace TUGraz.VectoCore.Models.Simulation.DataBus { + public enum DrivingBehavior + { + Halted, + Accelerating, + Driving, + Coasting, + Braking, + } + public interface IDriverInfo { bool VehicleStopped { get; } + + DrivingBehavior DrivingBehavior { get; } } } \ No newline at end of file diff --git a/VectoCore/Models/Simulation/DataBus/IRoadLookAhead.cs b/VectoCore/Models/Simulation/DataBus/IRoadLookAhead.cs index 438dc0de58305d372a13f5c3af86ffe12293e286..04f1d1f8b06bdc07c1449155757b7d1aac0996d0 100644 --- a/VectoCore/Models/Simulation/DataBus/IRoadLookAhead.cs +++ b/VectoCore/Models/Simulation/DataBus/IRoadLookAhead.cs @@ -6,6 +6,8 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus { public interface IRoadLookAhead { + Meter CycleStartDistance { get; } + IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance); IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time); diff --git a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 5ef220c745a960406dd04c68e4e8c141e67f912d..944abb8c7c4bb8eb9ab26940e042d748cc669895 100644 --- a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -258,5 +258,15 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { get { return Driver.VehicleStopped; } } + + public DrivingBehavior DrivingBehavior + { + get { return Driver.DrivingBehavior; } + } + + public Meter CycleStartDistance + { + get { return Road.CycleStartDistance; } + } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/IDriverStrategy.cs b/VectoCore/Models/SimulationComponent/IDriverStrategy.cs index 222162ba95424cdc1af79f47dee682ea4ec706a5..8728f1603045fdea08cd3beb1ac0b6c3f70a9439 100644 --- a/VectoCore/Models/SimulationComponent/IDriverStrategy.cs +++ b/VectoCore/Models/SimulationComponent/IDriverStrategy.cs @@ -1,4 +1,6 @@ using TUGraz.VectoCore.Models.Connector.Ports; +using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent @@ -7,6 +9,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent { IDriverActions Driver { get; set; } + DrivingBehavior DriverBehavior { get; } + IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient); IResponse Request(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient); diff --git a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index b4ccfba14d42ed86fcdbfe291fdaf70a490f5d91..00653dce01878b94aed27dedd873ad440786eb02 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -200,6 +200,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CycleIntervalIterator.LeftSample.RoadGradient); } + public Meter CycleStartDistance + { + get { return Data.Entries.Count > 0 ? Data.Entries.First().Distance : 0.SI<Meter>(); } + } + #endregion protected IResponse ProcessResponse(IResponse response) diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 8573b2cc9ecc6e982673afa79354918afcd16608..1dfd6ed2b34196f31e4794f4c15e7e063289123b 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -827,6 +827,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl LimitDecelerationLookahead = 0x4 } + public DrivingBehavior DriverBehavior + { + get { return DriverStrategy.DriverBehavior; } + } + public bool VehicleStopped { get; protected set; } + + public DrivingBehavior DrivingBehavior + { + get { return DriverStrategy.DriverBehavior; } + } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/EngineOnlyDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/EngineOnlyDrivingCycle.cs index 397f38c4b45351030083b315ed549640042bc0c8..7f7016162042e10a0dc9a2205a621f5de882bd88 100644 --- a/VectoCore/Models/SimulationComponent/Impl/EngineOnlyDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/EngineOnlyDrivingCycle.cs @@ -75,6 +75,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return NextComponent.Initialize(Data.Entries[index].EngineTorque, Data.Entries[index].EngineSpeed); } + public Meter StartDistance + { + get { throw new NotImplementedException(); } + } + #endregion #region ITnInPort diff --git a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs index 1fa19a646fc91702baac7fd713e4862de02c5c14..49c2374a056e88e6416760d3a48a36b44210c3dc 100644 --- a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs @@ -69,6 +69,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new NotImplementedException(); } + public Meter StartDistance + { + get { return 0.SI<Meter>(); } + } + #endregion #region IDrivingCycleInPort diff --git a/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index 581d1a8bf86c1108edfb789b51c49b2fb17dd23d..1472ab894312eea87f5be8fc2b5eaae5ec5ce70f 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -77,7 +77,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient) { _previousState = new VehicleState { - Distance = 0.SI<Meter>(), + Distance = DataBus.CycleStartDistance, Velocity = vehicleSpeed, RollingResistance = RollingResistance(roadGradient), SlopeResistance = SlopeResistance(roadGradient) @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl + _previousState.SlopeResistance; _currentState = new VehicleState { - Distance = 0.SI<Meter>(), + Distance = DataBus.CycleStartDistance, Velocity = vehicleSpeed, AirDragResistance = _previousState.AirDragResistance, RollingResistance = _previousState.RollingResistance, diff --git a/VectoCoreTest/Utils/MockAuxiliaryDemand.cs b/VectoCoreTest/Utils/MockAuxiliaryDemand.cs index 08f4e274ade8310741478578aa679bad64fa23a2..b193adf3c54732c7d6d7683bff23a01d73de9e13 100644 --- a/VectoCoreTest/Utils/MockAuxiliaryDemand.cs +++ b/VectoCoreTest/Utils/MockAuxiliaryDemand.cs @@ -47,6 +47,11 @@ namespace TUGraz.VectoCore.Tests.Utils _right.MoveNext(); } + public Meter CycleStartDistance + { + get { return _left.Current.Distance; } + } + public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) { return new List<DrivingCycleData.DrivingCycleEntry>(); diff --git a/VectoCoreTest/Utils/MockDriver.cs b/VectoCoreTest/Utils/MockDriver.cs index 4fe7209ad379a6afa1b6366230efcf92b78ce569..971d6f394cb576e16bdd9c185c78e8308982e1be 100644 --- a/VectoCoreTest/Utils/MockDriver.cs +++ b/VectoCoreTest/Utils/MockDriver.cs @@ -80,6 +80,13 @@ namespace TUGraz.VectoCore.Tests.Utils public Radian Gradient; } + //public MeterPerSquareSecond DriverAcceleration { get; set; } + public bool VehicleStopped { get; set; } + + public DrivingBehavior DrivingBehavior + { + get { throw new NotImplementedException(); } + } } } \ No newline at end of file