diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 4568a2d6bc642d2d04e05128307b47f2db4a502d..f226f0c8823574ebd7cd2ac3de7abdd9b3ecbf7a 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -772,20 +772,26 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl es.Connect(dcdc); var elAux = new ElectricAuxiliaries(container); - + + IEPTO epto = null; + if (data.PTO?.PTOCycle != null) + { + var pevPTOController = GetPEVIdleController(data.PTO, container); + cycle.IdleController = pevPTOController; + var eptoAux = new EPTO(pevPTOController); + elAux.AddAuxiliary(eptoAux); + epto = eptoAux; + } + elAux.AddAuxiliaries(data.Aux.Where(x => x.ConnectToREESS && x.ID != Constants.Auxiliaries.IDs.Cond)); if (data.Aux.Any(aux => aux.ID == Constants.Auxiliaries.IDs.Cond)) { - elAux.AddAuxiliary(new Conditioning(data.Aux.FirstOrDefault(aux => aux.ID == Constants.Auxiliaries.IDs.Cond))); + elAux.AddAuxiliary(new Conditioning(data.Aux.FirstOrDefault(aux => aux.ID == Constants.Auxiliaries.IDs.Cond), epto)); } dcdc.Connect(elAux); - if (data.PTO?.PTOCycle != null) { - var pevPTOController = GetPEVIdleController(data.PTO, container); - cycle.IdleController = pevPTOController; - elAux.AddAuxiliary(new EPTO(pevPTOController)); - } + dcdc.Initialize(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs index 294ca3afafad50f5de4e9cc818ffcb1f59a74f78..2216f1013fdc1cbb7b1059f36e9e1601f3561123 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/Conditioning.cs @@ -26,7 +26,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries public class Conditioning : IAuxDemand { - private readonly Watt electricPowerDemand; + private readonly Watt _electricPowerDemand; + private readonly IEPTO _epto; + + + private bool EPTOOn(IDataBus dataBus) + { + return _epto?.EPTOOn(dataBus) ?? false; + } #region Implementation of IAuxDemand @@ -34,7 +41,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries #endregion - public Conditioning(VectoRunData.AuxData condAuxData) + /// <summary> + /// + /// </summary> + /// <param name="condAuxData"></param> + /// <param name="eptoCycleController">needed in case an epto is present in the vehicle</param> + /// <exception cref="VectoException"></exception> + + public Conditioning(VectoRunData.AuxData condAuxData, IEPTO epto = null) { if (condAuxData.ID != Constants.Auxiliaries.IDs.Cond) { throw new VectoException($"Invalid {nameof(condAuxData)}: ID must be {Constants.Auxiliaries.IDs.Cond}"); @@ -43,23 +57,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries if (condAuxData.PowerDemandElectric == null) { throw new VectoException($"No electric powerdemand set for {condAuxData.ID}"); } - electricPowerDemand = condAuxData.PowerDemandElectric; + _electricPowerDemand = condAuxData.PowerDemandElectric; + _epto = epto; AuxID = condAuxData.ID; } - - - public Watt PowerDemand(IDataBus dataBus) { switch (dataBus.PowertrainInfo.VehicleArchitecutre) { case VectoSimulationJobType.BatteryElectricVehicle: case VectoSimulationJobType.SerialHybridVehicle: return GetPEV_SHEV_PowerDemand(dataBus); - case VectoSimulationJobType.ParallelHybridVehicle: return GetP_HEV_PowerDemand(dataBus); - case VectoSimulationJobType.EngineOnlySimulation: case VectoSimulationJobType.IEPC_E: case VectoSimulationJobType.IEPC_S: @@ -73,13 +83,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries public Watt GetPEV_SHEV_PowerDemand(IDataBus dataBus) { var elInfo = GetElectricMotorInfo(dataBus); - if (elInfo.EmOff) - { + if (!elInfo.EmOff || EPTOOn(dataBus)) { + return _electricPowerDemand; + } else { return 0.SI<Watt>(); } - else { - return electricPowerDemand; - } } public Watt GetP_HEV_PowerDemand(IDataBus dataBus) @@ -96,7 +104,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Auxiliaries xFactor = emPower.Abs() / (emPower.Abs() + icePower.Abs()); } - return electricPowerDemand * xFactor; + return _electricPowerDemand * xFactor; } private IElectricMotorInfo GetElectricMotorInfo(IDataBus dataBus) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs index 72ec7f7ad421eaf14b72e47944ce4b6dc5f40ea8..b9e664ccd580786cdcb4b002e89bc4d09e53d52a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EPTO.cs @@ -6,7 +6,12 @@ using Constants = TUGraz.VectoCore.Configuration.Constants; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class EPTO : IAuxDemand + public interface IEPTO + { + bool EPTOOn(IDataBus dataBus); + } + + public class EPTO : IAuxDemand, IEPTO { private readonly IPTOCycleController _ptoCycleController; @@ -18,7 +23,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IAuxDemand public Watt PowerDemand(IDataBus dataBus) { - if (dataBus.DrivingCycleInfo.PTOActive) { return _ptoCycleController.CycleData.LeftSample.PTOElectricalPowerDemand ?? 0.SI<Watt>(); } @@ -26,6 +30,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return 0.SI<Watt>(); } + public bool EPTOOn(IDataBus dataBus) + { + return !PowerDemand(dataBus).IsEqual(0); + } + public string AuxID => Constants.Auxiliaries.IDs.PTOConsumer;