diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index eb7cf50d429438e06a620502ccb2e203624a7c1c..67098dff44dd93f7697f2314914082ac8c1ab680 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -751,8 +751,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl IEPTO epto = null; if (data.PTO?.PTOCycle != null) { var pevPTOController = GetPEV_SHEVIdleController(data.PTO, container); - cycle.IdleController = pevPTOController; - var eptoAux = new EPTO(pevPTOController); + if (cycle != null) { + cycle.IdleController = pevPTOController; + } + var eptoAux = new EPTO(pevPTOController, container); + container.AddComponent(eptoAux); elAux.AddAuxiliary(eptoAux); epto = eptoAux; } @@ -1612,6 +1615,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl .AddComponent(new Brakes(container)); var pos = data.ElectricMachinesData.First(x => x.Item1 != PowertrainPosition.GEN).Item1; + AddElectricAuxiliaries(data, container, es, null); switch (pos) { case PowertrainPosition.BatteryElectricE4: //-->Engine E4 @@ -1659,6 +1663,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl default: throw new ArgumentOutOfRangeException(nameof(pos), pos, "Invalid engine powertrain position for simple serial hybrid vehicles."); + + } } @@ -1706,6 +1712,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl .AddComponent(GetRetarder(RetarderType.AxlegearInputRetarder, data.Retarder, container)) .AddComponent(gearbox) .AddComponent(em); + + AddElectricAuxiliaries(data, container, es, null); } /// <summary> @@ -1725,7 +1733,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl GetElectricMachine(PowertrainPosition.GEN, data.ElectricMachinesData, container, es, ctl) .AddComponent(ice); - + //AddElectricAuxiliaries(data, container,es, null); new ATClutchInfo(container); new DummyGearboxInfo(container, new GearshiftPosition(0)); } @@ -1876,6 +1884,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl .AddComponent(data.GearboxData is null ? null : GetSimpleGearbox(container, data)) .AddComponent(GetElectricMachine(data.ElectricMachinesData.First(x => x.Item1 != PowertrainPosition.GEN).Item1, data.ElectricMachinesData, container, es, new SimpleElectricMotorControl())); + AddElectricAuxiliaries(data, container, es, null); if (data.AxleGearData == null) { new DummyAxleGearInfo(container); // necessary for certain IEPC configurations } @@ -2247,7 +2256,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public PerSecond EngineRatedSpeed { get; } public PerSecond EngineN95hSpeed { get; } public PerSecond EngineN80hSpeed { get; } - public bool EngineOn { get; } + public bool EngineOn { get; private set; } #endregion @@ -2257,7 +2266,16 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #endregion - protected override bool DoUpdateFrom(object other) => false; + protected override bool DoUpdateFrom(object other) + { + if (other is IEngineInfo info) { + EngineOn = info.EngineOn; + return true; + } else { + return false; + } + + } } public class SimpleElectricMotorControl : IElectricMotorControl diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs index 7364aa19f8cb18eb4a5decde660d1a72754bc327..82821560ad7dcf8b1843b23f6847de32eccb8d11 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs @@ -113,8 +113,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl consideredAuxiliaries = consideredAuxiliaries?.Where(aux => !auxiliarieIgnoredDuringVehicleStop.Contains(aux.Key)); } - if (DataBus.PowertrainInfo.HasCombustionEngine && !DataBus.EngineInfo.EngineOn) { - consideredAuxiliaries = consideredAuxiliaries?.Where(aux => !auxiliarieIgnoredDuringVehicleStop.Contains(aux.Key)); + if (!DataBus.EngineInfo.EngineOn) { + consideredAuxiliaries = consideredAuxiliaries?.Where(aux => !auxiliariesIgnoredWhenICEIsOff.Contains(aux.Key)); } if (consideredAuxiliaries == null) { @@ -166,7 +166,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #endregion - protected override bool DoUpdateFrom(object other) => false; + protected override bool DoUpdateFrom(object other) + { + //if (other is ElectricAuxiliaries eAux) { + + // var updateableConsumers = this._electricConsumers.OfType<IUpdateable>(); + // var updateableConsumersSource = d._electricConsumers.OfType<IUpdateable>(); + // System.Diagnostics.Debug.Assert(updateableConsumers.Count() <= 1 + // && updateableConsumersSource.Count() <= 1, + // "Only 1 updateable subcomponent supported"); + + + + + + + + + // return true; + //} else { + // return false; + //} + return false; + } } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index e440b96a276380d785760e64e8f08d1d8eceddf0..1c95fccf2242baf39722d5ece56e2967dcfbee7c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -28,7 +28,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool DeRatingActive { get; protected internal set; } - public bool EmOff => PreviousState.EMTorque == null ? true : false; + public bool EmOff => PreviousState.EMTorque == null || PreviousState.EMTorque.IsEqual(0) ? true : false; public BusAuxiliariesAdapter BusAux { protected get; set; } @@ -154,6 +154,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun, double ratio) { + var gear = DataBus.GearboxInfo?.Gear ?? new GearshiftPosition(1); if (gear.Gear == 0) { gear = new GearshiftPosition(1); @@ -601,6 +602,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (other is ElectricMotor e && Position == e.Position) { ThermalBuffer = e.ThermalBuffer; DeRatingActive = e.DeRatingActive; + PreviousState = e.PreviousState.Clone(); + CurrentState = e.CurrentState.Clone(); return true; }