From 656a2e491513f8a46d515b47e76f9bfbbdb9d32f Mon Sep 17 00:00:00 2001 From: "VKMTHD\\haraldmartini" <harald.martini@student.tugraz.at> Date: Thu, 16 Feb 2023 18:32:18 +0100 Subject: [PATCH] update epto in testpowertrain --- .../Models/SimulationComponent/Impl/EPTO.cs | 34 +++++++++++++++++-- .../Impl/PTOCycleController.cs | 29 +++++++++++++++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs index b9e664ccd5..272932ed5a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs @@ -1,7 +1,10 @@ using Microsoft.VisualBasic; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries; +using TUGraz.VectoCore.OutputData; using Constants = TUGraz.VectoCore.Configuration.Constants; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl @@ -11,12 +14,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl bool EPTOOn(IDataBus dataBus); } - public class EPTO : IAuxDemand, IEPTO + public class EPTO : VectoSimulationComponent, IAuxDemand, IEPTO, IUpdateable { private readonly IPTOCycleController _ptoCycleController; + private readonly IDataBus _dataBus; - public EPTO(IPTOCycleController cycleController) + public EPTO(IPTOCycleController cycleController, IVehicleContainer dataBus) : base(dataBus) { + _dataBus = dataBus; _ptoCycleController = cycleController; } @@ -39,5 +44,30 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public string AuxID => Constants.Auxiliaries.IDs.PTOConsumer; #endregion + + #region Implementation of IUpdateable + + protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) + { + + } + + protected override void DoCommitSimulationStep(Second time, Second simulationInterval) + { + + } + + protected override bool DoUpdateFrom(object other) + { + if (other is EPTO epto) { + if (this._ptoCycleController is IUpdateable updateablePtoCycle) { + return updateablePtoCycle.UpdateFrom(epto._ptoCycleController); + } + } + + return false; + } + + #endregion } } \ 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 b0632a4e9a..93cc13c8c3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs @@ -119,7 +119,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } - public class EPTOCycleController : IIdleControllerSwitcher + public class EPTOCycleController : IIdleControllerSwitcher, IUpdateable { internal readonly IDrivingCycleData Data; protected Second AbsTime { get; private set; } @@ -139,6 +139,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CycleIterator = new DrivingCycleEnumerator(Data); _ptoActive = false; AbsTime = 0.SI<Second>(); + } public CycleData CycleData @@ -188,6 +189,32 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } #endregion + + #region Implementation of IUpdateable + + public bool UpdateFrom(object other) + { + if (!DataBus.IsTestPowertrain) + { + throw new VectoException("Only components in a testpowertrain are allowed to be updated!"); + } + if (other is EPTOCycleController otherPtoCycle) { + Reset(); + while (this.CycleIterator.Current != otherPtoCycle.CycleIterator.Current) { + this.CycleIterator.MoveNext(); + } + + this._ptoActive = otherPtoCycle._ptoActive; + + return true; + } else { + return false; + } + + + } + + #endregion } -- GitLab