diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs index 2a7375c231c5ea8c72d3930b084c2a6556cad9c6..8d75c6b87dbdddafb78de2db05daf480e525bf75 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs @@ -59,7 +59,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric #region Implementation of IUpdateable - public bool UpdateFrom(object other) => false; + protected override bool DoUpdateFrom(object other) => false; #endregion } @@ -147,7 +147,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric #endregion #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is SimpleBattery b) { PreviousState = b.PreviousState.Clone(); SOC = b.SOC; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index f103c39708352d340db60a62193959efe939b93e..f1f7084bd143f5297278fd63bb6892a00a26a835 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -2200,6 +2200,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public bool CombustionEngineOn { get => false; set { } } #endregion + + protected override bool DoUpdateFrom(object other) => false; } public class SimpleElectricMotorControl : IElectricMotorControl @@ -2282,6 +2284,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); #endregion + + protected override bool DoUpdateFrom(object other) => false; } internal class EngineOnlyGearboxInfo : VectoSimulationComponent, IGearboxInfo @@ -2349,6 +2353,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public bool RequestAfterGearshift { get; set; } #endregion + + protected override bool DoUpdateFrom(object other) => false; } internal class ZeroMileageCounter : VectoSimulationComponent, IMileageCounter @@ -2377,6 +2383,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public Meter Distance => 0.SI<Meter>(); #endregion + + protected override bool DoUpdateFrom(object other) => false; } public class DummyVehicleInfo : VectoSimulationComponent, IVehicleInfo @@ -2432,5 +2440,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public MeterPerSecond MaxVehicleSpeed => throw new NotImplementedException(); #endregion + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/WHRCharger.cs b/VectoCore/VectoCore/Models/Simulation/Impl/WHRCharger.cs index 6ee398a33c537809c5005956f2c794792ff2400b..533a22dce50e4ed01e9cf145d8fa998ad0ea6e58 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/WHRCharger.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/WHRCharger.cs @@ -77,7 +77,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is WHRCharger c) { PreviousState = c.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs index 324aa905f869d4a08ba7c3b1e081e179a17556eb..36fbbd3b1af9ad392b655ddf7e2a0f25b211da45 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/DCDCConverter.cs @@ -146,7 +146,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent } #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is DCDCConverter d) { PreviousState = d.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs b/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs index 1e0bc2ecade0f659bea9038ba98e36c011cdfad0..530de303794632cbbc25aa2edfb37732d6127aff 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/ElectricSystem.cs @@ -150,7 +150,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is ElectricSystem s) { PreviousState = s.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/APTNGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/APTNGearbox.cs index fd345f22f0dd77198f9511164f5e76a4eb8157f8..e2b03d87e9818e1fd9e93eb79aeb6c4f8bc555d0 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/APTNGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/APTNGearbox.cs @@ -53,39 +53,5 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - protected internal override ResponseDryRun Initialize(Second absTime, GearshiftPosition gear, - NewtonMeter outTorque, PerSecond outAngularVelocity) - { - var oldGear = Gear; - Gear = gear; - var inAngularVelocity = outAngularVelocity * ModelData.Gears[gear.Gear].Ratio; - var torqueLossResult = ModelData.Gears[gear.Gear].LossMap.GetTorqueLoss(outAngularVelocity, outTorque); - CurrentState.TorqueLossResult = torqueLossResult; - var inTorque = outTorque / ModelData.Gears[gear.Gear].Ratio + torqueLossResult.Value; - - if (!inAngularVelocity.IsEqual(0)) { - var alpha = ModelData.Inertia.IsEqual(0) ? 0.SI<PerSquareSecond>() : outTorque / ModelData.Inertia; - var inertiaPowerLoss = Formulas.InertiaPower(inAngularVelocity, alpha, ModelData.Inertia, Constants.SimulationSettings.TargetTimeInterval); - inTorque += inertiaPowerLoss / inAngularVelocity; - } - - var response = NextComponent.Request(absTime, Constants.SimulationSettings.TargetTimeInterval, inTorque, inAngularVelocity, true); - - var eMotor = DataBus.ElectricMotorInfo(DataBus.PowertrainInfo.ElectricMotorPositions[0]); - var fullLoad = -eMotor.MaxPowerDrive(DataBus.BatteryInfo.InternalVoltage, inAngularVelocity, gear); - - Gear = oldGear; - return new ResponseDryRun(this, response) { - ElectricMotor = { PowerRequest = response.ElectricMotor.PowerRequest }, - Gearbox = { - PowerRequest = outTorque * outAngularVelocity, - InputSpeed = inAngularVelocity, - InputTorque = inTorque, - OutputTorque = outTorque, - OutputSpeed = outAngularVelocity, - }, - DeltaFullLoad = response.ElectricMotor.PowerRequest - fullLoad - }; - } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs index 59593d6bf4e052602745d3e60fd828ca677532cc..566475edad94c5d3f792c343a2634280fcb45a41 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs @@ -34,5 +34,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public Watt ClutchLosses => 0.SI<Watt>(); #endregion + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index 0ff958d56c87143be5a7846009106ac64c52e60b..c1a26ab1a8329f662790326869a28cd11d277507 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -591,7 +591,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) + protected override bool DoUpdateFrom(object other) { if (other is ATGearbox g) { PreviousState = g.PreviousState.Clone(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs index 4d50c43c3d4e53416effca7df1aca9b943370c5b..add7dc439a1dba0343983af95cfbffbeae16ce54 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Angledrive.cs @@ -61,5 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } public double Ratio => ModelData.Ratio; + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs index d69ef3935b0c42b4e66b931cab84cfb662578322..9f603d6637cedac7cc926fc217aab6ff500f4d1f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Auxiliaries/ElectricAuxiliaries.cs @@ -164,6 +164,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } #endregion + + protected override bool DoUpdateFrom(object other) => false; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs index d8a66e3599e6fa87e90480efac187c06d0b7f0e3..9d7ff8d92013ca8b7e494ba8bc4820121659cd74 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs @@ -87,7 +87,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is AxleGear g) { PreviousState = g.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs index 64907230104c2456904d139b03204898bcb30043..78440c8c380661ff90f01e1d8439c8b100bec948 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Battery.cs @@ -280,7 +280,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + #region Overrides of VectoSimulationComponent + + public override bool UpdateFrom(object other) + { + if (DataBus == null) { + // in case the battery is part of a battery system, the databus is null because we shall not write any data. + // allow updating the state, erroneous updates are covered by the batterysystem + return DoUpdateFrom(other); + } + return base.UpdateFrom(other); + } + + #endregion + + protected override bool DoUpdateFrom(object other) { if (other is Battery b) { PreviousState = b.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BatterySystem.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BatterySystem.cs index abd479fe01b31f9df6a95ecacbed5af098328836..4a50545c502841e361e1be7d948a4a955741b2d2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BatterySystem.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BatterySystem.cs @@ -393,7 +393,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is BatterySystem b) { PreviousState = b.PreviousState.Clone(); return Batteries.All(kv => kv.Value.UpdateFrom(b.Batteries[kv.Key])); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs index 738460f4cfca7fe491d39f8b86b90a5e81b61b09..9e7df2eef855274487f17b3b170b7311d61df896 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs @@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is Brakes b) { PreviousState = b.PreviousState.Clone(); BrakePower = b.BrakePower; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index 186e701e757c0050d3d665c834d92f0bf390d588..fe8c3b23d9edbae517229373eba38b513ba89bc1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -446,7 +446,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is BusAuxiliariesAdapter b) { PreviousState = b.PreviousState.Clone(); return ElectricStorage.UpdateFrom(b.ElectricStorage); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index 32640b8bae7f411b922721b7dd2ff22dadacb811..4e63db4f49918c46e77b1395a7d57d1ce73c26bc 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -256,7 +256,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public virtual bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is Clutch c) { PreviousState = c.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 1929d05093a6744c0e87237accb7fe8e35493840..cddf1f60dd2be8b3ca89c10229ae77e07bab28c0 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -540,6 +540,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } + protected override bool DoUpdateFrom(object other) => false; + #endregion /// <summary> diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index 100f857b49e00e860592c00f43f263ef11ec8f58..6819865184c412d210af3e28c54afa9e51d7181e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -557,6 +557,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #endregion + protected override bool DoUpdateFrom(object other) => false; + public class CycleGearboxState : GearboxState { public bool TorqueConverterActive; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleTorqueConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleTorqueConverter.cs index d2952ad79458b5686546cb57764c1ab4ef347ced..b07e37f4b19235cf286d2c582c2dc6dde0185d5d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleTorqueConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleTorqueConverter.cs @@ -101,5 +101,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { } #endregion + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 57f46260cfbe400e584d2e8e47ab448641dc7e21..0772429479d101abae548bcb687b24678a259277 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -590,7 +590,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is DistanceBasedDrivingCycle c) { PreviousState = c.PreviousState.Clone(); CycleIntervalIterator = c.CycleIntervalIterator; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 2d70b003450cc5d60cfee6cf0a2ef790e27ae6fd..a144bd086921701c838a7bcda9c856dbe748d042 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -1460,5 +1460,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public PCCStates PCCState => DriverStrategy.PCCState; public MeterPerSecond NextBrakeTriggerSpeed => DriverStrategy.BrakeTrigger?.NextTargetSpeed; + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyAxleGearInfo.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyAxleGearInfo.cs index 6c4729eec1dbb464501af28f292d09b0cf9fe5a8..88d52e93c415b54fccf85b1389a8422915b4cfe9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyAxleGearInfo.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyAxleGearInfo.cs @@ -26,5 +26,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public double Ratio => 1; #endregion + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs index 66cbd71d1c98257a598e418ece40099d758d9a03..61ff921d3054be6d5c717345312c238cf4e5886a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DummyGearboxInfo.cs @@ -70,5 +70,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool RequestAfterGearshift { get; set; } #endregion + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index 220dc2a2310e9c26ee10cda98fbb7c97b149126c..072b66c009da52271fc7004f107b8b0663839ec6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -595,7 +595,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is ElectricMotor e && Position == e.Position) { ThermalBuffer = e.ThermalBuffer; DeRatingActive = e.DeRatingActive; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricSystemDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricSystemDrivingCycle.cs index a8723c696a06586eaa3d48e060cc3fbab3e9e147..c77e5cfc1cec6cbdb3bf7dc5895b89b4debca5c7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricSystemDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricSystemDrivingCycle.cs @@ -132,5 +132,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { Data.Finish(); } + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs index f416d84a5cbf9396406fdd2169af88fe4da65d36..6f8c380ab8844a5ca7d249c06a1f22874edc7754 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs @@ -259,7 +259,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is EngineAuxiliary a) { PreviousState = a.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index dce15f19072a635e3389962f569766b57f7de85c..f7639657600ed376118ddfc09b74b9922b652604 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -135,64 +135,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override bool TCLocked => true; - protected internal virtual ResponseDryRun Initialize(Second absTime, GearshiftPosition gear, NewtonMeter outTorque, PerSecond outAngularVelocity) - { - var oldGear = Gear; - Gear = gear; - var inAngularVelocity = outAngularVelocity * ModelData.Gears[gear.Gear].Ratio; - var torqueLossResult = ModelData.Gears[gear.Gear].LossMap.GetTorqueLoss(outAngularVelocity, outTorque); - - CurrentState.TorqueLossResult = torqueLossResult; - var inTorque = outTorque / ModelData.Gears[gear.Gear].Ratio + torqueLossResult.Value; - - if (DataBus.PowertrainInfo.ElectricMotorPositions.Any(x => x.IsOneOf(PowertrainPosition.HybridP2, PowertrainPosition.HybridP2_5))) { - // if there is an electric motor after the transmission, initialize the EM first - NextComponent.Initialize(inTorque, inAngularVelocity); - } - - if (!inAngularVelocity.IsEqual(0)) { - var alpha = ModelData.Inertia.IsEqual(0) - ? 0.SI<PerSquareSecond>() - : outTorque / ModelData.Inertia; - - var inertiaPowerLoss = Formulas.InertiaPower(inAngularVelocity, alpha, ModelData.Inertia, - Constants.SimulationSettings.TargetTimeInterval); - inTorque += inertiaPowerLoss / inAngularVelocity; - } - - var response = NextComponent.Request(absTime, Constants.SimulationSettings.TargetTimeInterval, - inTorque, inAngularVelocity, true); - //NextComponent.Initialize(inTorque, inAngularVelocity); - //response.Switch(). - // Case<ResponseSuccess>(). - // Case<ResponseOverload>(). - // Case<ResponseUnderload>(). - // Default(r => { throw new UnexpectedResponseException("Gearbox.Initialize", r); }); - - var fullLoad = DataBus.EngineInfo.EngineStationaryFullPower(inAngularVelocity); - - Gear = oldGear; - return new ResponseDryRun(this) { - Engine = { - PowerRequest = response.Engine.PowerRequest, - EngineSpeed = response.Engine.EngineSpeed, - DynamicFullLoadPower = response.Engine.DynamicFullLoadPower, - TorqueOutDemand = response.Engine.TorqueOutDemand, - DynamicFullLoadTorque = response.Engine.DynamicFullLoadTorque - }, - Clutch = { - PowerRequest = response.Clutch.PowerRequest, - }, - Gearbox = { - PowerRequest = outTorque * outAngularVelocity, - InputSpeed = inAngularVelocity, - InputTorque = inTorque, - OutputTorque = outTorque, - OutputSpeed = outAngularVelocity, - }, - DeltaFullLoad = response.Engine.PowerRequest - fullLoad - }; - } /// <summary> /// Requests the Gearbox to deliver torque and angularVelocity @@ -580,7 +522,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is Gearbox g) { PreviousState = g.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs index 167bf5bf84821987d1e493cda36051d68ba85c36..0dde71041254d03ee3230460dc438f7d21e2082d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs @@ -11,10 +11,12 @@ using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Models.SimulationComponent.Impl.Shiftstrategies; +using TUGraz.VectoCore.Models.SimulationComponent.Strategies; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils; @@ -244,6 +246,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DebugData = new DebugData(); } + protected override bool DoUpdateFrom(object other) => false; + protected override void DoWriteModalResults( Second time, Second simulationInterval, IModalDataContainer container) @@ -307,6 +311,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected readonly GearList GearList; protected readonly VectoRunData _runData; + protected TestPowertrain<Gearbox> TestPowertrain; + public HybridCtlShiftStrategy(HybridController hybridController, IVehicleContainer container) : base( container) { @@ -334,6 +340,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl MaxStartGear = gear; break; } + + // create testcontainer + var testContainer = new SimplePowertrainContainer(_runData); + PowertrainBuilder.BuildSimpleHybridPowertrain(_runData, testContainer); + + TestPowertrain = new TestPowertrain<Gearbox>(testContainer, DataBus); } public override ShiftPolygon ComputeDeclarationShiftPolygon(GearboxType gearboxType, int i, @@ -378,10 +390,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl foreach (var entry in GearList.Reverse()) { var gear = entry; //for (var gear = (uint)GearboxModelData.Gears.Count; gear > 1; gear--) { - var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + if (_controller.CurrentStrategySettings != null) { + TestPowertrain.HybridController.ApplyStrategySettings(_controller.CurrentStrategySettings); + } + var response = TestPowertrain.Gearbox.Initialize(outTorque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, outTorque, outAngularVelocity, + true); var inAngularSpeed = outAngularVelocity * GearboxModelData.Gears[gear.Gear].Ratio; - var fullLoadPower = response.Engine.PowerRequest - response.DeltaFullLoad; + var fullLoadPower = DataBus.EngineInfo.EngineStationaryFullPower(response.Engine.EngineSpeed); var reserve = 1 - response.Engine.PowerRequest / fullLoadPower; var inTorque = response.Clutch.PowerRequest / inAngularSpeed; @@ -426,7 +448,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl continue; } - var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + //var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + if (_controller.CurrentStrategySettings != null) { + TestPowertrain.HybridController.ApplyStrategySettings(_controller.CurrentStrategySettings); + } + + var response = TestPowertrain.Gearbox.Initialize(outTorque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, outTorque, outAngularVelocity, + true); var fullLoadPower = response.Engine.DynamicFullLoadTorque; //EnginePowerRequest - response.DeltaFullLoad; @@ -599,8 +632,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } foreach (var gear in Gears.Reverse()) { - var response = _gearbox.Initialize(absTime, gear, torque, outAngularVelocity); + //var response = _gearbox.Initialize(absTime, gear, torque, outAngularVelocity); + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + if (_controller.CurrentStrategySettings != null) { + TestPowertrain.HybridController.ApplyStrategySettings(_controller.CurrentStrategySettings); + } + var response = TestPowertrain.Gearbox.Initialize(torque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, torque, outAngularVelocity, + true); if (response.Engine.EngineSpeed > DataBus.EngineInfo.EngineRatedSpeed || response.Engine.EngineSpeed < DataBus.EngineInfo.EngineIdleSpeed) { continue; } @@ -633,7 +676,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl continue; } - var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + //var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + if (_controller.CurrentStrategySettings != null) { + TestPowertrain.HybridController.ApplyStrategySettings(_controller.CurrentStrategySettings); + } + + var response = TestPowertrain.Gearbox.Initialize(outTorque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, outTorque, outAngularVelocity, + true); var fullLoadPower = response.Engine.DynamicFullLoadTorque; //EnginePowerRequest - response.DeltaFullLoad; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index a7a0f16b666e3aeed5aa961f2a438fa18ef1bfc7..bac76f36413474f983a7f45e4d82c470c8f05c14 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -391,6 +391,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl AdvanceState(); } + protected override bool DoUpdateFrom(object other) => false; + public double Progress => AbsTime == null ? 0 : AbsTime.Value() / Data.Entries.Last().Time.Value(); public CycleData CycleData => diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVGearbox.cs index 772ce783eeee00481780ddf3269408f3fae772f8..cc2209f43fc21cfdfe5c388b52e0970e99d9941b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVGearbox.cs @@ -11,41 +11,5 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public PEVGearbox(IVehicleContainer container, IShiftStrategy strategy) : base(container, strategy) { } - protected internal override ResponseDryRun Initialize(Second absTime, GearshiftPosition gear, NewtonMeter outTorque, PerSecond outAngularVelocity) - { - var oldGear = Gear; - Gear = gear; - var inAngularVelocity = outAngularVelocity * ModelData.Gears[gear.Gear].Ratio; - var torqueLossResult = ModelData.Gears[gear.Gear].LossMap.GetTorqueLoss(outAngularVelocity, outTorque); - CurrentState.TorqueLossResult = torqueLossResult; - var inTorque = outTorque / ModelData.Gears[gear.Gear].Ratio + torqueLossResult.Value; - - if (!inAngularVelocity.IsEqual(0)) { - var alpha = ModelData.Inertia.IsEqual(0) - ? 0.SI<PerSquareSecond>() - : outTorque / ModelData.Inertia; - - var inertiaPowerLoss = Formulas.InertiaPower(inAngularVelocity, alpha, ModelData.Inertia, - Constants.SimulationSettings.TargetTimeInterval); - inTorque += inertiaPowerLoss / inAngularVelocity; - } - - var response = - NextComponent.Request(absTime, Constants.SimulationSettings.TargetTimeInterval, inTorque, - inAngularVelocity, true); //NextComponent.Initialize(inTorque, inAngularVelocity); - - var fullLoad = -DataBus.ElectricMotorInfo(PowertrainPosition.BatteryElectricE2).MaxPowerDrive(DataBus.BatteryInfo.InternalVoltage, inAngularVelocity, Gear); - - Gear = oldGear; - return new ResponseDryRun(this, response) { - ElectricMotor = { - PowerRequest = response.ElectricMotor.PowerRequest - }, - Gearbox = { - PowerRequest = outTorque * outAngularVelocity, - }, - DeltaFullLoad = response.ElectricMotor.PowerRequest - fullLoad - }; - } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVPTO.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVPTO.cs index 930ba6d8131dba6fd5deb5613ca9ca6a4c25abc2..a0560cd8db3dacb2c03171cd09b028e8293d94fa 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVPTO.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVPTO.cs @@ -130,6 +130,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } + protected override bool DoUpdateFrom(object other) => false; + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index be196cbf4fb7d3f458d29278d006ad6289f50772..5f2df9758d0c7d0dac7554acd2aaa347eb3f5948 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -188,6 +188,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl AdvanceState(); } + protected override bool DoUpdateFrom(object other) => false; + #endregion public CycleData CycleData => diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs index 16d3959e7d58d6d9b85dfdcb2561ea3aa2c751ed..42c76bb1c13194f22680c98fe13251fb7f4aa1c0 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs @@ -106,5 +106,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } base.DoCommitSimulationStep(time, simulationInterval); } + + protected override bool DoUpdateFrom(object other) => false; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SerialHybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SerialHybridController.cs index e9571b1486adf47743d351e3a750265116553583..02b128dc519e3c1ca4a3bfa032f8b46174666ef2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SerialHybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SerialHybridController.cs @@ -183,6 +183,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DebugData = new DebugData(); } + protected override bool DoUpdateFrom(object other) => false; + public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { PreviousState.SetState(outTorque, outAngularVelocity, outTorque, outAngularVelocity); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/AMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/AMTShiftStrategy.cs index d20f4a2f9f1712ae825c3f844b1d3e24c830d6b7..4471dd5e060d83993e46d9b76f2d0cf786c56e81 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/AMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/AMTShiftStrategy.cs @@ -40,10 +40,12 @@ using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Models.SimulationComponent.Impl.Shiftstrategies; +using TUGraz.VectoCore.Models.SimulationComponent.Strategies; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { @@ -68,6 +70,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private GearshiftPosition DesiredGearRoadsweeping; private readonly IShiftPolygonCalculator _shiftPolygonCalculator; + protected TestPowertrain<Gearbox> TestPowertrain; + public AMTShiftStrategy(IVehicleContainer dataBus) : base(dataBus) { var runData = dataBus.RunData; @@ -95,6 +99,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl break; } } + + // create testcontainer + var testContainer = new SimplePowertrainContainer(runData); + PowertrainBuilder.BuildSimplePowertrain(runData, testContainer); + + TestPowertrain = new TestPowertrain<Gearbox>(testContainer, DataBus); } private bool SpeedTooLowForEngine(GearshiftPosition gear, PerSecond outAngularSpeed) @@ -143,10 +153,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl foreach (var gear in Gears.Reverse()) { var selected = gear; - var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + //var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + + var response = TestPowertrain.Gearbox.Initialize(outTorque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, outTorque, outAngularVelocity, + true); var inAngularSpeed = outAngularVelocity * GearboxModelData.Gears[gear.Gear].Ratio; - var fullLoadPower = response.Engine.PowerRequest - response.DeltaFullLoad; + var fullLoadPower = DataBus.EngineInfo.EngineStationaryFullPower(response.Engine.EngineSpeed); var reserve = 1 - response.Engine.PowerRequest / fullLoadPower; var inTorque = response.Clutch.PowerRequest / inAngularSpeed; @@ -184,7 +203,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl continue; } - var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + //var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + + var response = TestPowertrain.Gearbox.Initialize(outTorque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, outTorque, outAngularVelocity, + true); var fullLoadPower = response.Engine.DynamicFullLoadPower; //EnginePowerRequest - response.DeltaFullLoad; var reserve = 1 - response.Engine.PowerRequest / fullLoadPower; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/PEVAMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/PEVAMTShiftStrategy.cs index af4eb30b3a67bf04d5d3c6d89c66b4c829e665fa..a95252c997b1074663503aa3d628aed9fe3d08a1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/PEVAMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Shiftstrategies/PEVAMTShiftStrategy.cs @@ -5,6 +5,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; @@ -16,6 +17,7 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Models.SimulationComponent.Strategies; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils; @@ -89,14 +91,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Shiftstrategies protected bool DriveOffStandstill { get; set; } + protected TestPowertrain<Gearbox> TestPowertrain; + public PEVAMTShiftStrategy(IVehicleContainer dataBus) : this(dataBus, false) { if (dataBus.RunData.VehicleData == null) { return; } - - EMPos = dataBus.RunData.ElectricMachinesData.FirstOrDefault(x => x.Item1 == PowertrainPosition.BatteryElectricE2 || x.Item1 == PowertrainPosition.IEPC)?.Item1 ?? PowertrainPosition.HybridPositionNotSet; SetupVelocityDropPreprocessor(dataBus); @@ -136,6 +138,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Shiftstrategies DeRatedShiftpolygons = CalculateDeratedShiftLines(em, runData.GearboxData.InputData.Gears, runData.VehicleData.DynamicTyreRadius, runData.AxleGearData?.AxleGear.Ratio ?? 1.0, runData.GearboxData.Type); + + // create testcontainer + var testContainer = new SimplePowertrainContainer(runData); + PowertrainBuilder.BuildSimplePowertrainElectric(runData, testContainer); + + TestPowertrain = new TestPowertrain<Gearbox>(testContainer, DataBus); } protected void SetupVelocityDropPreprocessor(IVehicleContainer dataBus) @@ -669,10 +677,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Shiftstrategies var emCtl = emE2.Control; emE2.Control = new PEVInitControl(DataBus as IVehicleContainer); foreach (var gear in GearList.Reverse()) { - //for (var gear = (uint)GearboxModelData.Gears.Count; gear > 1; gear--) { - var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); - - var inAngularSpeed = outAngularVelocity * GearboxModelData.Gears[gear.Gear].Ratio; + //for (var gear = (uint)GearboxModelData.Gears.Count; gear > 1; gear--) { + //var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + + var response = TestPowertrain.Gearbox.Initialize(outTorque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, outTorque, outAngularVelocity, + true); + + var inAngularSpeed = outAngularVelocity * GearboxModelData.Gears[gear.Gear].Ratio; var inTorque = response.ElectricMotor.PowerRequest / inAngularSpeed; // if in shift curve and torque reserve is provided: return the current gear @@ -710,9 +726,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl.Shiftstrategies continue; } - var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + //var response = _gearbox.Initialize(absTime, gear, outTorque, outAngularVelocity); + TestPowertrain.UpdateComponents(); + TestPowertrain.Gearbox.Gear = gear; + TestPowertrain.Gearbox._nextGear = gear; + + var response = TestPowertrain.Gearbox.Initialize(outTorque, outAngularVelocity); + response = TestPowertrain.Gearbox.Request(absTime, + Constants.SimulationSettings.MeasuredSpeedTargetTimeInterval, outTorque, outAngularVelocity, + true); - var fullLoadPower = -(response.ElectricMotor.MaxDriveTorque * response.ElectricMotor.AngularVelocity); + var fullLoadPower = -(response.ElectricMotor.MaxDriveTorque * response.ElectricMotor.AngularVelocity); //.DynamicFullLoadPower; //EnginePowerRequest - response.DeltaFullLoad; var reserve = 1 - (response.ElectricMotor.TorqueRequestEmMap ?? 0.SI<NewtonMeter>()) / response.ElectricMotor.MaxDriveTorqueEM; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs index e294003b24e6bbed7eeffb352f5fd30c74f04f11..d07c8a79a629531e6bf1fd5ce415127ea8d93470 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs @@ -41,6 +41,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { // nothing to write - this is only used in test-container } + protected override bool DoUpdateFrom(object other) => false; + #endregion #region Implementation of ITnInProvider diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SingleSpeedGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SingleSpeedGearbox.cs index 9adda1a9a6d7a810f06a2f2a2d3d9a93caac4fd5..628ca68f24061393043d8bc5a0b97543af54edf2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SingleSpeedGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SingleSpeedGearbox.cs @@ -51,6 +51,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.T_IEPC_out] = CurrentState.OutTorque; } + protected override bool DoUpdateFrom(object other) => false; + #endregion #region Implementation of IGearboxInfo diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs index bd0aa3e00d4bf82bdd00556b0eab86401e3b57a1..1ee48a2dda7b8328e38958012828927aedaf6d1d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SuperCap.cs @@ -205,7 +205,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is SuperCap o) { PreviousState = o.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs index a623f26eedf2044e766d7e7c05c453880c21ea40..f7f36cc5d5f9ea04c677b534836b2f995b5a933b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs @@ -526,7 +526,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is TorqueConverter tc) { PreviousState = tc.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index 9a70a3d0db6a399a251d16486c4ce558cde3bda3..b526d5762a75f6d0e3e4abf85b2cd627a383ca05 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -286,7 +286,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is Vehicle v) { PreviousState = v.PreviousState.Clone(); MaxVehicleSpeed = v.MaxVehicleSpeed; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs index fa96f336de519ac769a24c0706f64a8097b3f752..97627d1ad8906b9a97ad3c5418ba4981efda683c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs @@ -101,7 +101,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) { if (other is Wheels w) { PreviousState = w.PreviousState.Clone(); return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs index e198f3a774097cf830318e2bfc940f4a71a842da..8fcefba0d8801f134f109730cf7e430a678d05db 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs @@ -92,9 +92,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } } - if (HybridController == null) { - throw new VectoException("Unknown HybridController in TestContainer: {0}", Container.HybridController?.GetType().FullName); - } + //if (HybridController == null) { + // throw new VectoException("Unknown HybridController in TestContainer: {0}", Container.HybridController?.GetType().FullName); + //} var busAux = container.RunData.BusAuxiliaries; if (busAux != null && busAux.ElectricalUserInputsConfig.ConnectESToREESS) { @@ -118,47 +118,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies public void UpdateComponents() => Container.UpdateComponents(RealContainer); } - public class MockBrakes : VectoSimulationComponent, IBrakes, IUpdateable - { - public MockBrakes(IVehicleContainer container) : base(container) - { - BrakePower = 0.SI<Watt>(); - } - - #region Overrides of VectoSimulationComponent - - protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) - { - - } - - protected override void DoCommitSimulationStep(Second time, Second simulationInterval) - { - - } - - #endregion - - #region Implementation of IBrakes - - public Watt BrakePower { get; set; } - - #endregion - - #region Implementation of IUpdateable - - public bool UpdateFrom(object other) { - if (other is IBrakes b) { - BrakePower = b.BrakePower; - return true; - } - - return false; - } - - #endregion - } - public class MockDrivingCycle : VectoSimulationComponent, IDrivingCycleInfo { private IDataBus realContainer; @@ -219,6 +178,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } + protected override bool DoUpdateFrom(object other) => false; + #endregion } @@ -255,6 +216,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies } + protected override bool DoUpdateFrom(object other) => false; + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs b/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs index 9e2874f554efc2aeb604ab301e790e249654dc86..fc7d97da6dad5e98bf68227cda85608dca526d1c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs @@ -30,6 +30,7 @@ */ using System; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Simulation; @@ -41,7 +42,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent /// <summary> /// Base class for all vecto simulation components. /// </summary> - public abstract class VectoSimulationComponent : LoggingObject + public abstract class VectoSimulationComponent : LoggingObject, IUpdateable { [NonSerialized] protected IDataBus DataBus; @@ -78,6 +79,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent /// <param name="time"></param> /// <param name="simulationInterval"></param> protected abstract void DoCommitSimulationStep(Second time, Second simulationInterval); + + public virtual bool UpdateFrom(object other) + { + if (!DataBus.IsTestPowertrain) { + throw new VectoException("Only components in a testpowertrain are allowed to be updated!"); + } + + return DoUpdateFrom(other); + } + + protected abstract bool DoUpdateFrom(object other); + } public abstract class StatefulVectoSimulationComponent<TStateType> : VectoSimulationComponent where TStateType : new() diff --git a/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs b/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs index b4137da9166964c3bc8f9daf4c9238e2b2e55fea..0a32bcf29f8e201440411ea3fc8710178e5f4f86 100644 --- a/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BatteryElectric/BatteryElectricTest.cs @@ -1186,6 +1186,8 @@ namespace TUGraz.VectoCore.Tests.Integration.BatteryElectric protected override void DoCommitSimulationStep(Second time, Second simulationInterval) { } + protected override bool DoUpdateFrom(object other) => false; + public PerSecond EngineSpeed { get; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs index 61ebd645060df5cc22713548d901acc0c11499aa..e5fb363a8e46e3012d349aabf9bf9f0e3f10bb52 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs @@ -226,5 +226,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public bool CombustionEngineOn { get; set; } #endregion + + protected override bool DoUpdateFrom(object other) => false; + } } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs index f51d0443de5e366a56a4d82829090a901a8252fe..629be28cca636baa23953690748a3d89dadff621 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs @@ -343,5 +343,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public MeterPerSecond MaxVehicleSpeed => throw new System.NotImplementedException(); #endregion + protected override bool DoUpdateFrom(object other) => false; + } } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs index e47c29e1c541aa9452ab8e9f295b0855d7f1a4e3..9eff10827adb73156c203a1c5d9669000021fe01 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs @@ -296,5 +296,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent } #endregion + + protected override bool DoUpdateFrom(object other) => false; + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs b/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs index 6ba0f3433b0ce5589fcde090ebec169ef3368fe5..756d5a3602b14d365c3999b9295e79dc06947311 100644 --- a/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs +++ b/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs @@ -113,5 +113,8 @@ namespace TUGraz.VectoCore.Tests.Utils public SpeedChangeEntry LastTargetspeedChange { get; set; } public void FinishSimulation() {} + + protected override bool DoUpdateFrom(object other) => false; + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockBrakes.cs b/VectoCore/VectoCoreTest/Utils/MockBrakes.cs index eba2ca40b3d624acc1d5e0c3fc28dde1ae9fcdde..a2d37a54145288454992e0d559ec19630fdd4774 100644 --- a/VectoCore/VectoCoreTest/Utils/MockBrakes.cs +++ b/VectoCore/VectoCoreTest/Utils/MockBrakes.cs @@ -51,7 +51,8 @@ namespace TUGraz.VectoCore.Tests.Utils #region Implementation of IUpdateable - public bool UpdateFrom(object other) { + protected override bool DoUpdateFrom(object other) + { if (other is IBrakes b) { BrakePower = b.BrakePower; return true; diff --git a/VectoCore/VectoCoreTest/Utils/MockComponent.cs b/VectoCore/VectoCoreTest/Utils/MockComponent.cs index 658107cb03e7fa0d8175b7e2a4cfcd50739485d5..821a4a55c676ae40e5e587a533bde76496e44311 100644 --- a/VectoCore/VectoCoreTest/Utils/MockComponent.cs +++ b/VectoCore/VectoCoreTest/Utils/MockComponent.cs @@ -58,5 +58,8 @@ namespace TUGraz.VectoCore.Tests.Utils { return new ResponseSuccess(this); } + + protected override bool DoUpdateFrom(object other) => false; + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockDriver.cs b/VectoCore/VectoCoreTest/Utils/MockDriver.cs index 14db237ec6d19c32e534b0a73de4d5d4e13486f2..e387785e4c503e0c6621f292b43b0a8b5d713440 100644 --- a/VectoCore/VectoCoreTest/Utils/MockDriver.cs +++ b/VectoCore/VectoCoreTest/Utils/MockDriver.cs @@ -125,5 +125,8 @@ namespace TUGraz.VectoCore.Tests.Utils public MeterPerSquareSecond DriverAcceleration { get; set; } public PCCStates PCCState => PCCStates.OutsideSegment; public MeterPerSecond NextBrakeTriggerSpeed => 0.SI<MeterPerSecond>(); + + protected override bool DoUpdateFrom(object other) => false; + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockGearbox.cs b/VectoCore/VectoCoreTest/Utils/MockGearbox.cs index 61ed4adf04d1aed567370c9e76a1a4127d7f2f10..26c2f5c11d4220ff5125bc5de7d41e25b6341f0e 100644 --- a/VectoCore/VectoCoreTest/Utils/MockGearbox.cs +++ b/VectoCore/VectoCoreTest/Utils/MockGearbox.cs @@ -158,6 +158,9 @@ namespace TUGraz.VectoCore.Tests.Utils { throw new NotImplementedException(); } + + protected override bool DoUpdateFrom(object other) => false; + } public class MockAxlegear : VectoSimulationComponent, IAxlegear @@ -194,5 +197,8 @@ namespace TUGraz.VectoCore.Tests.Utils { } + + protected override bool DoUpdateFrom(object other) => false; + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicle.cs b/VectoCore/VectoCoreTest/Utils/MockVehicle.cs index 3e83a0ec1916b4a205acea74bdb5c28e889bfe8e..b132b0f3c5c714e1565ba7cfcb9dd9aceea17743 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicle.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicle.cs @@ -130,5 +130,8 @@ namespace TUGraz.VectoCore.Tests.Utils } public Meter Distance => 0.SI<Meter>(); + + protected override bool DoUpdateFrom(object other) => false; + } } \ No newline at end of file