From afabd225e0514712fdc36f974cbab46260da329c Mon Sep 17 00:00:00 2001 From: Michael Krisper <michael.krisper@tugraz.at> Date: Wed, 31 Aug 2016 17:00:11 +0200 Subject: [PATCH] PTOController: Added Duration --- .../Impl/IdleControllerSwitcher.cs | 12 ++++++++++++ .../SimulationComponent/Impl/PTOCycleController.cs | 10 ++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs index ef0db2c630..65c640bc2d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/IdleControllerSwitcher.cs @@ -66,5 +66,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { _ptoController.CommitSimulationStep(null); } + + public Second Duration + { + get + { + if (_ptoController != null) + return _ptoController.Duration; + else { + return 0.SI<Second>(); + } + } + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs index 17d894ad92..c6799f61d9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs @@ -1,3 +1,4 @@ +using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -14,9 +15,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl set { NextComponent = value; } } + public readonly Second Duration; + protected Second IdleStart; - public PTOCycleController(DrivingCycleData cycle) : base(null, cycle) {} + public PTOCycleController(DrivingCycleData cycle) : base(null, cycle) + { + Duration = Data.Entries.Last().Time - Data.Entries.First().Time; + } public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) @@ -55,7 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (RightSample.Current == null) return null; - return RightSample.Current.Time; + return RightSample.Current.Time - LeftSample.Current.Time; } } } \ No newline at end of file -- GitLab