diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index a2430f10218721d7b4fc8fe7504686662b1dd417..81cbc004fa465eb6c252875d5e84a821ad63332f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -217,7 +217,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private IResponse DriveTimeInterval(Second absTime, Second dt) { - CurrentState.AbsTime = PreviousState.AbsTime + dt; + CurrentState.AbsTime = absTime; CurrentState.WaitTime = PreviousState.WaitTime + dt; CurrentState.Gradient = ComputeGradient(0.SI<Meter>()); CurrentState.VehicleTargetSpeed = Left.VehicleTargetSpeed; @@ -250,6 +250,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal = NextComponent.Request(absTime, r.DeltaT, 0.SI<MeterPerSecond>(), CurrentState.Gradient); retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); }); + CurrentState.AbsTime = absTime; return retVal; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs index 8bd4a52d3f1c02fe7c33d51d59bf12bae42debd7..03ba010b74bad50031d612d17c0e9e12919e38bc 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs @@ -99,6 +99,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void Reset() { _currentCycleIndex = 0; + LastEntry = false; } public void Dispose() {} diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs index f5758152b42604191d65a823878794e92ce83ef2..a6a415cba37c18f50adc4a0fa706a14e62d60909 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs @@ -96,15 +96,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void CommitSimulationStep(IModalDataContainer container) { - _ptoController.CommitSimulationStep(container); + if (_currentController == _ptoController) { + _ptoController.CommitSimulationStep(container); + } } public Second Duration { get { - if (_ptoController != null) + if (_ptoController != null) { return _ptoController.Duration; + } return 0.SI<Second>(); } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs index 5ae1b9637b2f333929bd086c3a0252047016dee9..14c3754d1c45c692c4e5355c44b83551c52c6d7c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs @@ -88,7 +88,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Second GetNextCycleTime() { - if (CycleIterator.RightSample == null) { + if (CycleIterator.LastEntry && AbsTime.IsEqual(CycleIterator.RightSample.Time)) { return null; }