From fdd7eb56b7a1935f9725081a74b43e57024674b3 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <quaritsch@ivt.tugraz.at>
Date: Wed, 18 Jan 2023 11:28:30 +0100
Subject: [PATCH] refactoring updateComponent method: make sure only components
 on a testpowertrain are updated implemented this check in the base class for
 all components

---
 .../Impl/Electrics/SimpleBattery.cs              |  4 ++--
 .../Models/Simulation/Impl/PowertrainBuilder.cs  | 10 ++++++++++
 .../Models/Simulation/Impl/WHRCharger.cs         |  2 +-
 .../Models/SimulationComponent/DCDCConverter.cs  |  2 +-
 .../Models/SimulationComponent/ElectricSystem.cs |  2 +-
 .../SimulationComponent/Impl/ATClutchInfo.cs     |  2 ++
 .../Models/SimulationComponent/Impl/ATGearbox.cs |  2 +-
 .../SimulationComponent/Impl/Angledrive.cs       |  2 ++
 .../Impl/Auxiliaries/ElectricAuxiliaries.cs      |  2 ++
 .../Models/SimulationComponent/Impl/AxleGear.cs  |  2 +-
 .../Models/SimulationComponent/Impl/Battery.cs   | 16 +++++++++++++++-
 .../SimulationComponent/Impl/BatterySystem.cs    |  2 +-
 .../Models/SimulationComponent/Impl/Brakes.cs    |  2 +-
 .../Impl/BusAuxiliariesAdapter.cs                |  2 +-
 .../Models/SimulationComponent/Impl/Clutch.cs    |  2 +-
 .../SimulationComponent/Impl/CombustionEngine.cs |  2 ++
 .../SimulationComponent/Impl/CycleGearbox.cs     |  2 ++
 .../Impl/CycleTorqueConverter.cs                 |  2 ++
 .../Impl/DistanceBasedDrivingCycle.cs            |  2 +-
 .../Models/SimulationComponent/Impl/Driver.cs    |  2 ++
 .../Impl/DummyAxleGearInfo.cs                    |  2 ++
 .../SimulationComponent/Impl/DummyGearboxInfo.cs |  2 ++
 .../SimulationComponent/Impl/ElectricMotor.cs    |  2 +-
 .../Impl/ElectricSystemDrivingCycle.cs           |  2 ++
 .../SimulationComponent/Impl/EngineAuxiliary.cs  |  2 +-
 .../Models/SimulationComponent/Impl/Gearbox.cs   |  2 +-
 .../SimulationComponent/Impl/HybridController.cs |  2 ++
 .../Impl/MeasuredSpeedDrivingCycle.cs            |  2 ++
 .../Models/SimulationComponent/Impl/PEVPTO.cs    |  2 ++
 .../Impl/PowertrainDrivingCycle.cs               |  2 ++
 .../Models/SimulationComponent/Impl/Retarder.cs  |  2 ++
 .../Impl/SerialHybridController.cs               |  2 ++
 .../Impl/SimpleHybridController.cs               |  2 ++
 .../Impl/SingleSpeedGearbox.cs                   |  2 ++
 .../Models/SimulationComponent/Impl/SuperCap.cs  |  2 +-
 .../SimulationComponent/Impl/TorqueConverter.cs  |  2 +-
 .../Models/SimulationComponent/Impl/Vehicle.cs   |  2 +-
 .../Models/SimulationComponent/Impl/Wheels.cs    |  2 +-
 .../Strategies/TestPowertrain.cs                 |  4 ++++
 .../VectoSimulationComponent.cs                  | 15 ++++++++++++++-
 .../BatteryElectric/BatteryElectricTest.cs       |  2 ++
 .../Models/SimulationComponent/ClutchTest.cs     |  3 +++
 .../DistanceBasedDrivingCycleTest.cs             |  2 ++
 .../Models/SimulationComponent/VehicleTest.cs    |  3 +++
 .../VectoCoreTest/Utils/MockAuxiliaryDemand.cs   |  3 +++
 VectoCore/VectoCoreTest/Utils/MockBrakes.cs      |  3 ++-
 VectoCore/VectoCoreTest/Utils/MockComponent.cs   |  3 +++
 VectoCore/VectoCoreTest/Utils/MockDriver.cs      |  3 +++
 VectoCore/VectoCoreTest/Utils/MockGearbox.cs     |  6 ++++++
 VectoCore/VectoCoreTest/Utils/MockVehicle.cs     |  3 +++
 50 files changed, 128 insertions(+), 22 deletions(-)

diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/SimpleBattery.cs
index 2a7375c231..8d75c6b87d 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 f103c39708..f1f7084bd1 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 6ee398a33c..533a22dce5 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 324aa905f8..36fbbd3b1a 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 1e0bc2ecad..530de30379 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/ATClutchInfo.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATClutchInfo.cs
index 59593d6bf4..566475edad 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 0ff958d56c..c1a26ab1a8 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 4d50c43c3d..add7dc439a 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 d69ef3935b..9f603d6637 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 d8a66e3599..9d7ff8d920 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 6490723010..78440c8c38 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 abd479fe01..4a50545c50 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 738460f4cf..9e7df2eef8 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 186e701e75..fe8c3b23d9 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 32640b8bae..4e63db4f49 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 1929d05093..cddf1f60dd 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 100f857b49..6819865184 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 d2952ad794..b07e37f4b1 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 57f46260cf..0772429479 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 2d70b00345..a144bd0869 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 6c4729eec1..88d52e93c4 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 66cbd71d1c..61ff921d30 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 220dc2a231..072b66c009 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 a8723c696a..c77e5cfc1c 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 f416d84a5c..6f8c380ab8 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 fdba784629..f763965760 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs
@@ -522,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 8a2ec15079..0dde710412 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs
@@ -246,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)
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs
index a7a0f16b66..bac76f3641 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/PEVPTO.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PEVPTO.cs
index 930ba6d813..a0560cd8db 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 be196cbf4f..5f2df9758d 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 16d3959e7d..42c76bb1c1 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 e9571b1486..02b128dc51 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/SimpleHybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimpleHybridController.cs
index e294003b24..d07c8a79a6 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 9adda1a9a6..628ca68f24 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 bd0aa3e00d..1ee48a2dda 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 a623f26eed..f7f36cc5d5 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 9a70a3d0db..b526d5762a 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 fa96f336de..97627d1ad8 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 9f40b75880..35f070f42a 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Strategies/TestPowertrain.cs
@@ -219,6 +219,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
 
 		}
 
+		protected override bool DoUpdateFrom(object other) => false;
+
 		#endregion
 	}
 
@@ -255,6 +257,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 9e2874f554..fc7d97da6d 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 b4137da916..0a32bcf29f 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 61ebd64506..e5fb363a8e 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 f51d0443de..629be28cca 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 e47c29e1c5..9eff10827a 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 6ba0f3433b..756d5a3602 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 eba2ca40b3..a2d37a5414 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 658107cb03..821a4a55c6 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 14db237ec6..e387785e4c 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 61ed4adf04..26c2f5c11d 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 3e83a0ec19..b132b0f3c5 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
-- 
GitLab