diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs index 6347aa578e303da255657f1f346ece96b3bf6ea5..a99137445b37e3a7ccb9e4b755a1d08bf3f434d7 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -84,6 +84,8 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus IHybridControllerCtl HybridControllerCtl { get; } IAngledriveInfo AngledriveInfo { get; } + + bool IsTestPowertrain { get; } } public interface IPowertainInfo diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index d736257cbfcca0d63dff3fa7d6d3b532d3dcb41c..97773891bf372ec2e2b624c1c87fb7c710da4428 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -78,6 +78,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public virtual ITorqueConverterControl TorqueConverterCtl { get; private set; } + public virtual bool IsTestPowertrain + { + get { return false; } + } internal ISimulationOutPort Cycle; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs index 83841e2169192c997af6a7775d15b73e19327dd7..bf6ef7e401733830f8742026bdc155343526774e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs @@ -71,7 +71,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - if (!dryRun && BrakePower < 0) { + if (!dryRun && !DataBus.IsTestPowertrain && BrakePower < 0) { throw new VectoSimulationException("Negative Braking Power is not allowed! P_br: {0}", BrakePower); } CurrentState.SetState(outTorque + brakeTorque, outAngularVelocity, outTorque, outAngularVelocity); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index 8b9b00129fbfa24e8637f4e644d238c53f4e21f6..7cb8d8a0d6fd3345f0a099f8e62a65b473533ef5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -29,8 +29,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected internal Joule ThermalBuffer = 0.SI<Joule>(); protected internal bool DeRatingActive = false; - private bool IsTestPowertrain; - public Joule OverloadBuffer { get; } public NewtonMeter ContinuousTorque { get; } @@ -43,8 +41,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Position = position; container.AddComponent(this); // We have to do this again because in the base class the position is unknown! - IsTestPowertrain = container is SimplePowertrainContainer; - ContinuousTorque = ModelData.ContinuousPower / ModelData.ContinuousPowerSpeed; var contElPwr = ModelData.EfficiencyMap.LookupElectricPower(ModelData.ContinuousPowerSpeed, -ContinuousTorque).ElectricalPower ?? @@ -161,7 +157,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var emTorque = emTorqueDt == null ? null : ConvertDrivetrainTorqueToEm(emTorqueDt); var emOff = emTorqueDt == null; - if (!dryRun && !IsTestPowertrain && emTorqueDt != null && ((emTorque).IsSmaller(maxDriveTorqueEm ?? 0.SI<NewtonMeter>(), 1e-3) || + if (!dryRun && !DataBus.IsTestPowertrain && emTorqueDt != null && ((emTorque).IsSmaller(maxDriveTorqueEm ?? 0.SI<NewtonMeter>(), 1e-3) || (emTorque).IsGreater(maxRecuperationTorqueEm ?? 0.SI<NewtonMeter>(), 1e-3))) { // check if provided EM torque (drivetrain) is valid) if ((!avgDtSpeed.IsEqual(DataBus.HybridControllerInfo.ElectricMotorSpeed(Position)) || @@ -237,7 +233,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var electricSupplyResponse = ElectricPower.Request(absTime, dt, electricPower, dryRun); - if (!dryRun && !IsTestPowertrain && !emOff && !(electricSupplyResponse is ElectricSystemResponseSuccess)) { + if (!dryRun && !DataBus.IsTestPowertrain && !emOff && !(electricSupplyResponse is ElectricSystemResponseSuccess)) { if ( !avgEmSpeed.IsEqual(DataBus.HybridControllerInfo.ElectricMotorSpeed(Position))) { return new ResponseInvalidOperatingPoint(this); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs index c7b1285f75d07a12b70f7f9f8661bed1cca9b50a..ca523806819f30ff811089970def1f36f500c9dd 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs @@ -32,6 +32,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public override IDriverInfo DriverInfo { get { return base.DriverInfo ?? this; } } + public override bool IsTestPowertrain + { + get { return true; } + } + #region Implementation of IDriverInfo public DrivingBehavior DriverBehavior diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index 98a7a730f81f6431b67cc0da79d6ab9a3685763b..5b0c38cf68cdd6b292b82be522b88c1365fd4348 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -167,6 +167,10 @@ namespace TUGraz.VectoCore.Tests.Utils public IHybridControllerInfo HybridControllerInfo { get; } public IHybridControllerCtl HybridControllerCtl { get; } public IAngledriveInfo AngledriveInfo { get; } + public bool IsTestPowertrain + { + get { return false; } + } public Watt GearboxLoss() {