Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 656a2e49 authored by Harald Martini's avatar Harald Martini
Browse files

update epto in testpowertrain

parent 7013ba3b
No related branches found
No related tags found
No related merge requests found
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
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment