diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IBrakes.cs b/VectoCore/VectoCore/Models/SimulationComponent/IBrakes.cs index 06e5019264e03483b670752220c06f5236bbe6d9..24c9b210d2348657fae37f93465e5da52abfbc37 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IBrakes.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IBrakes.cs @@ -33,7 +33,7 @@ using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent { - public interface IBrakes + public interface IBrakes: IUpdateable { Watt BrakePower { get; set; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index be9862dd999564a31a3da49a847e832d9b6a3ef9..7e4527e1c2d56ec070637bb823812ff701195897 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -581,7 +581,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region Implementation of IUpdateable public bool UpdateFrom(object other) { - if (other is ElectricMotor e) { + if (other is ElectricMotor e && Position == e.Position) { PreviousState = e.PreviousState.Clone(); ElectricPower = e.ElectricPower; ThermalBuffer = e.ThermalBuffer; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 3b0ce5332ac3869c977c64c1b6e7370b4d33e285..dcc2f7d07102a14366bd068086d327580f31356f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -574,10 +574,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Disengaged = g.Disengaged; DisengageGearbox = g.DisengageGearbox; _nextGear = g.NextGear; - Gear = g.Gear; - + if (DataBus.VehicleInfo.VehicleStopped) { Gear = _nextGear; + } else { + Gear = g.Gear; } return true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs index 9f93aba3f9c0fdd032594ea316578b2c2005664d..e198f3a774097cf830318e2bfc940f4a71a842da 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs @@ -118,7 +118,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies public void UpdateComponents() => Container.UpdateComponents(RealContainer); } - public class MockBrakes : VectoSimulationComponent, IBrakes + public class MockBrakes : VectoSimulationComponent, IBrakes, IUpdateable { public MockBrakes(IVehicleContainer container) : base(container) { @@ -144,6 +144,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies 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 diff --git a/VectoCore/VectoCoreTest/Utils/MockBrakes.cs b/VectoCore/VectoCoreTest/Utils/MockBrakes.cs index 755580cfdaac54c5bb8776c400073a7a9cba8365..eba2ca40b3d624acc1d5e0c3fc28dde1ae9fcdde 100644 --- a/VectoCore/VectoCoreTest/Utils/MockBrakes.cs +++ b/VectoCore/VectoCoreTest/Utils/MockBrakes.cs @@ -36,7 +36,7 @@ using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoCore.Tests.Utils { - public class MockBrakes : VectoSimulationComponent, IBrakes + public class MockBrakes : VectoSimulationComponent, IBrakes, IUpdateable { public MockBrakes(IVehicleContainer vehicle) : base(vehicle) { @@ -48,5 +48,18 @@ namespace TUGraz.VectoCore.Tests.Utils protected override void DoWriteModalResults(Second time, Second simulationInterval, IModalDataContainer container) {} protected override void DoCommitSimulationStep(Second time, Second simulationInterval) {} + + #region Implementation of IUpdateable + + public bool UpdateFrom(object other) { + if (other is IBrakes b) { + BrakePower = b.BrakePower; + return true; + } + + return false; + } + + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index 54b0580661a7a5ebf6b8e35c8b34976eebc24649..56faff6941917606749e9bd2338e5f89ff8dc6bc 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -48,7 +48,7 @@ using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoCore.Tests.Utils { - public class MockVehicleContainer : IVehicleContainer, IEngineInfo, IEngineControl, IVehicleInfo, IClutchInfo, IBrakes, IAxlegearInfo, IWheelsInfo, IDriverInfo, IDrivingCycleInfo, IMileageCounter, IGearboxInfo, IGearboxControl, IPowertainInfo + public class MockVehicleContainer : IVehicleContainer, IEngineInfo, IEngineControl, IVehicleInfo, IClutchInfo, IBrakes, IAxlegearInfo, IWheelsInfo, IDriverInfo, IDrivingCycleInfo, IMileageCounter, IGearboxInfo, IGearboxControl, IPowertainInfo, IUpdateable { // only CycleData Lookup is set / accessed... @@ -337,5 +337,13 @@ namespace TUGraz.VectoCore.Tests.Utils public VectoSimulationJobType VehicleArchitecutre { get; } #endregion + + #region Implementation of IUpdateable + + public bool UpdateFrom(object other) { + return false; + } + + #endregion } } \ No newline at end of file