diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs index b9e664ccd580786cdcb4b002e89bc4d09e53d52a..272932ed5a1b58923abc31bcb41f04378a3a7a7f 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 b0632a4e9a297167b2044d00efd2d6d252b784f2..93cc13c8c30c57543bf65fb83706423a65682ec7 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 }