diff --git a/VectoCore/Configuration/Constants.cs b/VectoCore/Configuration/Constants.cs index 076772cc9b3a15316639a5a87a02614f0c7554ed..d7c6e3c120730a266f4c2bf0f1f5d0090a24952e 100644 --- a/VectoCore/Configuration/Constants.cs +++ b/VectoCore/Configuration/Constants.cs @@ -72,11 +72,6 @@ namespace TUGraz.VectoCore.Configuration public static Meter DriverActionDistanceTolerance = 0.25.SI<Meter>(); - /// <summary> - /// The initial search interval for the breaking power search in the driver. - /// </summary> - public static readonly Watt BreakingPowerInitialSearchInterval = 20.SI().Kilo.Watt.Cast<Watt>(); - /// <summary> /// The initial search interval for the operating point search in the driver. /// </summary> diff --git a/VectoCore/Models/Simulation/IVectoRun.cs b/VectoCore/Models/Simulation/IVectoRun.cs index dc6171fd0f471aa0cb85857816bf768aa1e0bc0f..f14714fdbfade715cbec59989fc9d9e029c245ee 100644 --- a/VectoCore/Models/Simulation/IVectoRun.cs +++ b/VectoCore/Models/Simulation/IVectoRun.cs @@ -10,6 +10,8 @@ namespace TUGraz.VectoCore.Models.Simulation /// </summary> void Run(); + string Name { get; } + /// <summary> /// Return the vehicle container. /// </summary> diff --git a/VectoCore/Models/Simulation/Impl/DistanceRun.cs b/VectoCore/Models/Simulation/Impl/DistanceRun.cs index 971248cedf10480cc8d78f91d5f7c01a673d52fb..a4b7695ac4b36ea1e9564bd3264561e834cfce40 100644 --- a/VectoCore/Models/Simulation/Impl/DistanceRun.cs +++ b/VectoCore/Models/Simulation/Impl/DistanceRun.cs @@ -9,8 +9,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { public class DistanceRun : VectoRun { - public string Name { get; protected set; } - public DistanceRun(string name, IVehicleContainer container) : base(container) { Name = name; diff --git a/VectoCore/Models/Simulation/Impl/VectoRun.cs b/VectoCore/Models/Simulation/Impl/VectoRun.cs index ca4e0d5c182d80955afe3d5cdad2675cb43ce4db..29e3d8bf3c01076129951694f0d89ee026597056 100644 --- a/VectoCore/Models/Simulation/Impl/VectoRun.cs +++ b/VectoCore/Models/Simulation/Impl/VectoRun.cs @@ -12,6 +12,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl /// </summary> public abstract class VectoRun : LoggingObject, IVectoRun { + public string Name { get; protected set; } + protected Second AbsTime = 0.SI<Second>(); protected Second dt = 1.SI<Second>(); protected SummaryFileWriter SumWriter { get; set; } @@ -49,16 +51,16 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } while (response is ResponseSuccess); } catch (VectoSimulationException vse) { Container.FinishSimulation(); - throw new VectoSimulationException("absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4}", vse, AbsTime, - Container.Distance, dt, Container.VehicleSpeed, Container.Gear, vse.Message); + throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", vse, + AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, vse.Message, Name); } catch (VectoException ve) { Container.FinishSimulation(); - throw new VectoSimulationException("absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4}", ve, AbsTime, - Container.Distance, dt, Container.VehicleSpeed, Container.Gear, ve.Message); + throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", ve, + AbsTime, Container.Distance, dt, Container.VehicleSpeed, Container.Gear, ve.Message, Name); } catch (Exception e) { Container.FinishSimulation(); - throw new VectoSimulationException("absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4}", e, AbsTime, - Container.Distance, dt, Container.VehicleSpeed, Container.Gear, e.Message); + throw new VectoSimulationException("{6} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", e, AbsTime, + Container.Distance, dt, Container.VehicleSpeed, Container.Gear, e.Message, Name); } Container.FinishSimulation(); Log.Info("VectoJob finished."); diff --git a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index e49344a5e635bc5bf7a6f5d968909d47a712b4db..492cb064d90f2a0c5519a1c81c577fb1509dc2c7 100644 --- a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -267,7 +267,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public Meter CycleStartDistance { - get { return Road.CycleStartDistance; } + get { return Road == null ? 0.SI<Meter>() : Road.CycleStartDistance; } } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 7f1a20eb9fceb0b0b9e0e2bc54223d40fc532a47..46600df4d820884a219e565642c932de275b5ffa 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -17,6 +17,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public class DefaultDriverStrategy : LoggingObject, IDriverStrategy { + protected DrivingBehaviorEntry NextDrivingAction; + public enum DrivingMode { DrivingModeDrive, @@ -40,43 +42,40 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Request(Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient) { - DrivingBehaviorEntry nextAction = null; - switch (CurrentDrivingMode) { - case DrivingMode.DrivingModeDrive: - var currentDistance = Driver.DataBus.Distance; - nextAction = GetNextDrivingAction(currentDistance); - if (nextAction != null) { - if (currentDistance.IsEqual(nextAction.ActionDistance, - Constants.SimulationSettings.DriverActionDistanceTolerance)) { - CurrentDrivingMode = DrivingMode.DrivingModeBrake; - DrivingModes[CurrentDrivingMode].ResetMode(); - Log.Debug("Switching to DrivingMode BRAKE"); - - BrakeTrigger = nextAction; - break; - } - if ((currentDistance + ds).IsGreater(nextAction.ActionDistance)) { - Log.Debug("Current simulation interval exceeds next action distance at {0}. reducing maxDistance to {1}", - nextAction.ActionDistance, nextAction.ActionDistance - currentDistance); - return new ResponseDrivingCycleDistanceExceeded() { - Source = this, - MaxDistance = nextAction.ActionDistance - currentDistance - }; - } - } - break; - case DrivingMode.DrivingModeBrake: - if (Driver.DataBus.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance)) { - CurrentDrivingMode = DrivingMode.DrivingModeDrive; + if (CurrentDrivingMode == DrivingMode.DrivingModeBrake) { + if (Driver.DataBus.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance)) { + CurrentDrivingMode = DrivingMode.DrivingModeDrive; + NextDrivingAction = null; + DrivingModes[CurrentDrivingMode].ResetMode(); + Log.Debug("Switching to DrivingMode DRIVE"); + } + } + if (CurrentDrivingMode == DrivingMode.DrivingModeDrive) { + var currentDistance = Driver.DataBus.Distance; + UpdateDrivingAction(currentDistance); + if (NextDrivingAction != null) { + if (currentDistance.IsEqual(NextDrivingAction.ActionDistance, + Constants.SimulationSettings.DriverActionDistanceTolerance)) { + CurrentDrivingMode = DrivingMode.DrivingModeBrake; DrivingModes[CurrentDrivingMode].ResetMode(); - Log.Debug("Switching to DrivingMode DRIVE"); + Log.Debug("Switching to DrivingMode BRAKE"); + + BrakeTrigger = NextDrivingAction; + //break; + } else if ((currentDistance + ds).IsGreater(NextDrivingAction.ActionDistance)) { + Log.Debug("Current simulation interval exceeds next action distance at {0}. reducing maxDistance to {1}", + NextDrivingAction.ActionDistance, NextDrivingAction.ActionDistance - currentDistance); + return new ResponseDrivingCycleDistanceExceeded() { + Source = this, + MaxDistance = NextDrivingAction.ActionDistance - currentDistance + }; } - break; + } } var retVal = DrivingModes[CurrentDrivingMode].Request(absTime, ds, targetVelocity, gradient); - if (nextAction == null || !(retVal is ResponseSuccess)) { + if (NextDrivingAction == null || !(retVal is ResponseSuccess)) { return retVal; } @@ -89,46 +88,94 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // if the speed at the end of the simulation interval is below the next target speed // we are fine (no need to brake right now) var v2 = Driver.DataBus.VehicleSpeed + retVal.Acceleration * retVal.SimulationInterval; - if (v2 <= nextAction.NextTargetSpeed) { + if (v2 <= NextDrivingAction.NextTargetSpeed) { return retVal; } Meter newds; - switch (nextAction.Action) { + switch (NextDrivingAction.Action) { case DrivingBehavior.Coasting: - var coastingDistance = Formulas.DecelerationDistance(v2, nextAction.NextTargetSpeed, + var coastingDistance = Formulas.DecelerationDistance(v2, NextDrivingAction.NextTargetSpeed, Driver.DriverData.LookAheadCoasting.Deceleration); // if the distance at the end of the simulation interval is smaller than the new ActionDistance // we are safe - go ahead... - if ((Driver.DataBus.Distance + ds).IsSmallerOrEqual(nextAction.TriggerDistance - coastingDistance, + if ((Driver.DataBus.Distance + ds).IsSmallerOrEqual(NextDrivingAction.TriggerDistance - coastingDistance, Constants.SimulationSettings.DriverActionDistanceTolerance)) { return retVal; } - newds = EstimateAccelerationDistanceBeforeBrake(retVal, nextAction); + newds = EstimateAccelerationDistanceBeforeBrake(retVal, NextDrivingAction); break; case DrivingBehavior.Braking: var brakingDistance = Driver.DriverData.AccelerationCurve.ComputeAccelerationDistance(v2, - nextAction.NextTargetSpeed); - if ((Driver.DataBus.Distance + ds).IsSmaller(nextAction.TriggerDistance - brakingDistance)) { + NextDrivingAction.NextTargetSpeed); + if ((Driver.DataBus.Distance + ds).IsSmaller(NextDrivingAction.TriggerDistance - brakingDistance)) { return retVal; } - newds = (nextAction.TriggerDistance - brakingDistance) - Driver.DataBus.Distance; + newds = (NextDrivingAction.TriggerDistance - brakingDistance) - Driver.DataBus.Distance; break; default: return retVal; } - if (ds.IsEqual(newds, 1e-3.SI<Meter>())) { + if (newds.IsEqual(0, 1e-3) || ds.IsEqual(newds, 1e-3.SI<Meter>())) { return retVal; } - Log.Debug("Exceeding next ActionDistance at {0}. Reducing max Distance to {1}", nextAction.ActionDistance, newds); + Log.Debug("Exceeding next ActionDistance at {0}. Reducing max Distance to {1}", NextDrivingAction.ActionDistance, + newds); return new ResponseDrivingCycleDistanceExceeded() { Source = this, MaxDistance = newds, }; } + private void UpdateDrivingAction(Meter currentDistance) + { + var nextAction = GetNextDrivingAction(currentDistance); + if (NextDrivingAction == null) { + if (nextAction != null) { + // take the new action + NextDrivingAction = nextAction; + } + } else { + // update action distance for current 'next action' + if (Driver.DataBus.VehicleSpeed > NextDrivingAction.NextTargetSpeed) { + switch (NextDrivingAction.Action) { + case DrivingBehavior.Coasting: + var coastingDistance = Formulas.DecelerationDistance(Driver.DataBus.VehicleSpeed, + NextDrivingAction.NextTargetSpeed, + Driver.DriverData.LookAheadCoasting.Deceleration); + NextDrivingAction.ActionDistance = NextDrivingAction.TriggerDistance - coastingDistance; + break; + case DrivingBehavior.Braking: + var brakingDistance = Driver.ComputeDecelerationDistance(NextDrivingAction.NextTargetSpeed); + NextDrivingAction.ActionDistance = NextDrivingAction.TriggerDistance - brakingDistance; + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + if (nextAction != null) { + if (nextAction.HasEqualTrigger(NextDrivingAction)) { + // if the action changes and the vehicle has not yet exceeded the action distance => update the action + // otherwise do nothing, NextDrivingAction's action distance has already been updated + if (nextAction.Action != NextDrivingAction.Action && nextAction.ActionDistance > currentDistance) { + NextDrivingAction = nextAction; + } + } else { + // hmm, we've got a new action that is closer to what we got before? + if (nextAction.ActionDistance < NextDrivingAction.ActionDistance) { + NextDrivingAction = nextAction; + } + } + } else { + NextDrivingAction = null; + } + } + Log.Debug("Next Driving Action: {0}", NextDrivingAction); + } + public IResponse Request(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient) { @@ -178,8 +225,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ? entry.VehicleTargetSpeed + Driver.DriverData.OverSpeedEcoRoll.OverSpeed : entry.VehicleTargetSpeed; if (nextTargetSpeed < currentSpeed) { + // TODO @@@quam currentSpeed ? targetSpeed? nextTargetSpeed? if (!Driver.DriverData.LookAheadCoasting.Enabled || - entry.VehicleTargetSpeed < Driver.DriverData.LookAheadCoasting.MinSpeed) { + currentSpeed < Driver.DriverData.LookAheadCoasting.MinSpeed) { var brakingDistance = Driver.ComputeDecelerationDistance(nextTargetSpeed); Log.Debug("adding 'Braking' starting at distance {0}. brakingDistance: {1}, triggerDistance: {2}", entry.Distance - brakingDistance, brakingDistance, entry.Distance); @@ -408,7 +456,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }). Case<ResponseOverload>(r => { // limiting deceleration while coast may result in an overload => issue brakes to decelerate with driver's max deceleration - response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); + if (DataBus.ClutchClosed(absTime)) { + response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); + } else { + response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); + } //Phase = BrakingPhase.Brake; }). Case<ResponseGearShift>(r => { @@ -461,5 +513,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public MeterPerSecond NextTargetSpeed; public Meter TriggerDistance; public Meter ActionDistance; + + public bool HasEqualTrigger(DrivingBehaviorEntry other) + { + return TriggerDistance.IsEqual(other.TriggerDistance) && NextTargetSpeed.IsEqual(other.NextTargetSpeed); + } + + public override string ToString() + { + return string.Format("action: {0} @ {1}. trigger: {2} targetSpeed: {3}", Action, ActionDistance, TriggerDistance, + NextTargetSpeed); + } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index f32fc8e0dca155930ffbd6b00cccec9b68f0a3bd..0aa2dc841f2c6a1d7068cdda2b090b925090b35e 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -189,6 +189,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return cycleIterator.RightSample.Distance; } } while (cycleIterator.RightSample.Distance < PreviousState.Distance + ds && cycleIterator.MoveNext()); + if (cycleIterator.LastEntry) { + return cycleIterator.RightSample.Distance; + } return null; } diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 1616ce94117f6ed41c8ce6ce726566e7d403bda2..eb8118aa528a33ab89c464b74ca2c703cb7a997c 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -478,8 +478,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var debug = new List<dynamic>(); // only used while testing - var searchInterval = Constants.SimulationSettings.BreakingPowerInitialSearchInterval; - var operatingPoint = new OperatingPoint() { SimulationDistance = ds, Acceleration = acceleration }; Watt origDelta = null; initialResponse.Switch(). @@ -491,6 +489,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new UnexpectedResponseException("cannot use response for searching braking power!", r); }); + // braking power is in the range of the exceeding delta. set searching range to 2/3 so that + // the target point is approximately in the center of the second interval + var searchInterval = origDelta.Abs() * 2 / 3; + debug.Add(new { brakePower = 0.SI<Watt>(), searchInterval, delta = origDelta, operatingPoint }); var brakePower = searchInterval * -origDelta.Sign(); diff --git a/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTestTruck.cs b/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTestTruck.cs index 7d68a0ba7968631a3f7f7fbdb9e0f744ff3a54b0..4731983b2c1c99bc60041a702ff45279f7cffc54 100644 --- a/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTestTruck.cs +++ b/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTestTruck.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NLog; using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy { @@ -706,6 +707,23 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy @"..\..\TestData\Integration\DriverStrategy\Vecto2.2\40t Truck\40t_Long_Haul_Truck_Cycle_Drive_stop_85_stop_85_level.vmod"); } + [TestMethod] + public void Truck_Accelerate_48_52_beforeStop_lefel() + { + var data = new string[] { + // <s>,<v>,<grad>,<stop> + " 0, 49.9, -5, 0", + "200, 52, -5, 0", + "300, 0, -5, 2", + }; + + var cycle = SimpleDrivingCycles.CreateCycleData(data); + Truck40tPowerTrain.CreateEngineeringRun(cycle, "Truck_DriverStrategy_Accelerate_48_52_beforeStop_level.vmod", + 7500.SI<Kilogram>(), 19000.SI<Kilogram>()).Run(); + + //GraphWriter.Write("Truck_DriverStrategy_Accelerate_48_52_beforeStop_level.vmod"); + } + #endregion #region AccelerateOverspeed @@ -836,8 +854,8 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy var cycleData = new string[] { // <s>,<v>,<grad>,<stop> " 0, 60, -1.4, 0", - "198, 60, -1.7, 0", - "200, 0, -1.7, 4", + "298, 60, -1.7, 0", + "300, 0, -1.7, 4", }; var cycle = SimpleDrivingCycles.CreateCycleData(cycleData); diff --git a/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCoreTest/Models/Simulation/AuxTests.cs index d9cd836bd5b68fb228ef4cb7cd6beed342cf576e..0e022023bfecdef387921ba4457a994c77815bb8 100644 --- a/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -31,7 +31,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var container = new VehicleContainer(dataWriter, deco); var data = DrivingCycleDataReader.ReadFromFileDistanceBased(@"TestData\Cycles\LongHaul_short.vdri"); - + var mockcycle = new MockDrivingCycle(container, data); var port = new MockTnOutPort(); var aux = new Auxiliary(container); diff --git a/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs b/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs index 467c740219df90c8c1f1ac54123479e02cf3b9bc..20b14da6ce2ea4b5ad4a1b2410d532c16954f04a 100644 --- a/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs +++ b/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs @@ -179,11 +179,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent absTime += response.SimulationInterval; - var exceeded = (ResponseDrivingCycleDistanceExceeded)cycle.OutPort().Request(absTime, 300.SI<Meter>()); - Assert.AreEqual(16, exceeded.MaxDistance.Value(), Tolerance); - Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance); - Assert.AreEqual(0.0284160694958265, driver.LastRequest.Gradient.Value(), 1E-12); - Assert.AreEqual(2 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance); + var exceeded = (ResponseDrivingCycleDistanceExceeded)cycle.OutPort().Request(absTime, 1000.SI<Meter>()); + Assert.AreEqual(811, exceeded.MaxDistance.Value(), Tolerance); AssertHelper.Exception<VectoSimulationException>(() => { container.CommitSimulationStep(absTime, exceeded.SimulationInterval); @@ -193,8 +190,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent response = cycle.OutPort().Request(absTime, exceeded.MaxDistance); Assert.AreEqual(5.SI<MeterPerSecond>().Value(), driver.LastRequest.TargetVelocity.Value(), Tolerance); - Assert.AreEqual(0.0284160694958265, driver.LastRequest.Gradient.Value(), 1E-12); - Assert.AreEqual(18 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance); + Assert.AreEqual(0.020140043264606885, driver.LastRequest.Gradient.Value(), 1E-12); + Assert.AreEqual(813 + startDistance, cycle.CurrentState.Distance.Value(), Tolerance); container.CommitSimulationStep(absTime, response.SimulationInterval); diff --git a/VectoCoreTest/Utils/GraphWriter.cs b/VectoCoreTest/Utils/GraphWriter.cs index a5daa407f5be3efd8a543fccb0014af32df54bfe..807f8c47ac961c8a35bd425651a26f68bcfd9d83 100644 --- a/VectoCoreTest/Utils/GraphWriter.cs +++ b/VectoCoreTest/Utils/GraphWriter.cs @@ -120,7 +120,6 @@ namespace TUGraz.VectoCore.Tests.Utils IsDockedInsideChartArea = false, DockedToChartArea = yfield.ToString(), Font = new Font("Verdana", 14), - }; chart.Legends.Add(legend); diff --git a/VectoCoreTest/Utils/MockAuxiliaryDemand.cs b/VectoCoreTest/Utils/MockAuxiliaryDemand.cs index b193adf3c54732c7d6d7683bff23a01d73de9e13..be93826a2034e534091f1c6f552a83cbfa1686b7 100644 --- a/VectoCoreTest/Utils/MockAuxiliaryDemand.cs +++ b/VectoCoreTest/Utils/MockAuxiliaryDemand.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using TUGraz.VectoCore.Models.Simulation; @@ -19,13 +20,13 @@ namespace TUGraz.VectoCore.Tests.Utils if (data != null) { _left = data.Entries.GetEnumerator(); _right = data.Entries.GetEnumerator(); - _left.MoveNext(); - _right.MoveNext(); - _right.MoveNext(); } else { _left = Enumerable.Empty<DrivingCycleData.DrivingCycleEntry>().GetEnumerator(); _right = Enumerable.Empty<DrivingCycleData.DrivingCycleEntry>().GetEnumerator(); } + _left.MoveNext(); + _right.MoveNext(); + _right.MoveNext(); } @@ -39,7 +40,13 @@ namespace TUGraz.VectoCore.Tests.Utils }; } - protected override void DoWriteModalResults(IModalDataWriter writer) {} + protected override void DoWriteModalResults(IModalDataWriter writer) + { + writer[ModalResultField.dist] = 0.SI<Meter>(); + writer[ModalResultField.v_targ] = 0.KMPHtoMeterPerSecond(); + writer[ModalResultField.grad] = 0.SI<Scalar>(); + writer[ModalResultField.altitude] = 0.SI<Meter>(); + } protected override void DoCommitSimulationStep() { @@ -49,7 +56,7 @@ namespace TUGraz.VectoCore.Tests.Utils public Meter CycleStartDistance { - get { return _left.Current.Distance; } + get { return 0.SI<Meter>(); } } public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance)