From 75fc53eee15f5c70f922ce66188032004c2edab4 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Wed, 14 Dec 2016 10:10:57 +0100
Subject: [PATCH] adapt testcases

---
 .../Impl/AMTShiftStrategy.cs                  |  2 +-
 .../Impl/BusAuxiliariesAdapter.cs             |  1 +
 .../Impl/CombustionEngine.cs                  | 20 ++++++++++---------
 .../Impl/EngineOnlyCombustionEngine.cs        |  4 ++--
 .../SimulationRuns/TestSimulationRuns.cs      |  3 ++-
 .../CombustionEngineTest.cs                   |  6 ++++--
 .../Models/SimulationComponent/DriverTest.cs  |  2 +-
 .../GearboxPowertrainTest.cs                  |  4 ++--
 VectoCore/VectoCoreTest/VectoCoreTest.csproj  |  1 +
 9 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs
index c70dd44a6e..13077fffda 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs
@@ -88,7 +88,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 					var response = _gearbox.Initialize(gear, outTorque, outAngularVelocity);
 
-					var fullLoadPower = response.EnginePowerRequest - response.DeltaFullLoad;
+					var fullLoadPower = response.DynamicFullLoadPower; //EnginePowerRequest - response.DeltaFullLoad;
 					var reserve = 1 - response.EnginePowerRequest / fullLoadPower;
 					var inTorque = response.ClutchPowerRequest / inAngularSpeed;
 
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
index c6676b08c2..bbe1a721ca 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
@@ -61,6 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			//	mAAUX_Global.advancedAuxModel.Signals.WHTC = Declaration.WHTCcorrFactor
 			CurrentState = new BusAuxState();
 			PreviousState = new BusAuxState();
+			PreviousState.AngularSpeed = engineIdleSpeed;
 
 			AdditionalAux = additionalAux;
 
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
index 89382ec400..38dc43c9d9 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs
@@ -75,14 +75,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 		protected IAuxPort EngineAux;
 
-		public CombustionEngine(IVehicleContainer cockpit, CombustionEngineData modelData, bool pt1Disabled = false)
-			: base(cockpit)
+		public CombustionEngine(IVehicleContainer container, CombustionEngineData modelData, bool pt1Disabled = false)
+			: base(container)
 		{
 			PT1Disabled = pt1Disabled;
 			ModelData = modelData;
 
-			PreviousState.OperationMode = EngineOperationMode.Idle;
-			//PreviousState.EnginePower = 0.SI<Watt>();
+			PreviousState.OperationMode = EngineOperationMode.Undef;
+			PreviousState.EnginePower = 0.SI<Watt>();
 			PreviousState.EngineSpeed = ModelData.IdleSpeed;
 			PreviousState.dt = 1.SI<Second>();
 
@@ -305,7 +305,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			}
 			var auxDemand = EngineAux == null ? 0.SI<NewtonMeter>() : EngineAux.Initialize(outTorque, outAngularVelocity);
 			PreviousState = new EngineState {
-				EngineSpeed = PreviousState.EngineSpeed,
+				EngineSpeed = outAngularVelocity,
 				dt = 1.SI<Second>(),
 				InertiaTorqueLoss = 0.SI<NewtonMeter>(),
 				StationaryFullLoadTorque = ModelData.FullLoadCurve.FullLoadStationaryTorque(outAngularVelocity),
@@ -514,9 +514,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity,
 				bool dryRun = false)
 			{
-				if (!_dataBus.VehicleStopped && _dataBus.Gear != _dataBus.NextGear && _dataBus.Gear != 0 && _dataBus.NextGear != 0)
+				if (!_dataBus.VehicleStopped && _dataBus.Gear != _dataBus.NextGear && _dataBus.Gear != 0 && _dataBus.NextGear != 0) {
 					return RequestDoubleClutch(absTime, dt, outTorque, outAngularVelocity, dryRun);
-				else {
+				} else {
 					return RequestIdling(absTime, dt, outTorque, outAngularVelocity, dryRun);
 				}
 			}
@@ -535,8 +535,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 				var velocitySlope = (targetVelocity - _engine.PreviousState.EngineSpeed) / _dataBus.TractionInterruption;
 
 				var nextAngularSpeed = (velocitySlope * dt + _engine.PreviousState.EngineSpeed);
-				if (nextAngularSpeed < _engine.ModelData.IdleSpeed)
+				if (nextAngularSpeed < _engine.ModelData.IdleSpeed) {
 					nextAngularSpeed = _engine.ModelData.IdleSpeed;
+				}
 
 				var retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), nextAngularSpeed);
 				retVal.Switch().
@@ -549,8 +550,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 							criterion: result => ((ResponseDryRun)result).DeltaDragLoad.Value());
 						Log.Debug("Found operating point for idling. absTime: {0}, dt: {1}, torque: {2}, angularSpeed: {3}", absTime, dt,
 							0.SI<NewtonMeter>(), angularSpeed);
-						if (angularSpeed < _engine.ModelData.IdleSpeed)
+						if (angularSpeed < _engine.ModelData.IdleSpeed) {
 							angularSpeed = _engine.ModelData.IdleSpeed;
+						}
 
 						retVal = RequestPort.Request(absTime, dt, 0.SI<NewtonMeter>(), angularSpeed);
 					}).
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs
index 7c1f26b6f3..ed1dad20bd 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs
@@ -43,8 +43,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 	{
 		protected readonly List<Second> EnginePowerCorrections = new List<Second>();
 
-		public EngineOnlyCombustionEngine(IVehicleContainer cockpit, CombustionEngineData modelData)
-			: base(cockpit, modelData) {}
+		public EngineOnlyCombustionEngine(IVehicleContainer container, CombustionEngineData modelData)
+			: base(container, modelData) {}
 
 		// the behavior in engine-only mode differs a little bit from normal driving cycle simulation: in engine-only mode
 		// certain amount of overload is tolerated.
diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/TestSimulationRuns.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/TestSimulationRuns.cs
index 76fb323144..feb720c725 100644
--- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/TestSimulationRuns.cs
+++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/TestSimulationRuns.cs
@@ -14,7 +14,8 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns
 		[Category("UserBugs"),
 		TestCase("Kies-20161115"),
 		TestCase("Mandl-20161115"),
-		TestCase("Silberholz-20161121")]
+		TestCase("Silberholz-20161121"),
+		TestCase("Kies-20161212_ObjectReference")]
 		public static void RunJob_Eng(string jobName)
 		{
 			var writer = new FileOutputWriter(jobName);
diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs
index 57d3c77e2f..f6ba35fa5d 100644
--- a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs
+++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs
@@ -268,7 +268,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			var container = new VehicleContainer(ExecutionMode.Engineering);
 			var gearbox = new MockGearbox(container);
 			var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(CoachEngine);
-
+			var vehicle = new MockVehicle(container);
+			vehicle.MyVehicleSpeed = 0.SI<MeterPerSecond>();
 			var engine = new CombustionEngine(container, engineData);
 			var clutch = new Clutch(container, engineData);
 
@@ -533,7 +534,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			aux.AddConstant("CONST", 5000.SI<Watt>());
 
 			gearbox.Gear = 1;
-
+			var vehicle = new MockVehicle(container);
+			vehicle.MyVehicleSpeed = 0.SI<MeterPerSecond>();
 			//gearbox.InPort().Connect(engine.OutPort());
 			gearbox.InPort().Connect(clutch.OutPort());
 			clutch.InPort().Connect(engine.OutPort());
diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs
index 565b4313ef..0247a92262 100644
--- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs
+++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs
@@ -158,7 +158,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval);
 			absTime += response.SimulationInterval;
 
-			Assert.AreEqual(4.9812, vehicleContainer.VehicleSpeed.Value(), Tolerance);
+			Assert.AreEqual(4.9816, vehicleContainer.VehicleSpeed.Value(), Tolerance);
 			Assert.AreEqual(0.2004, response.SimulationInterval.Value(), Tolerance);
 			Assert.AreEqual(engine.PreviousState.FullDragTorque.Value(), engine.PreviousState.EngineTorque.Value(),
 				Constants.SimulationSettings.LineSearchTolerance);
diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs
index ff09734f44..91bba3f958 100644
--- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs
+++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs
@@ -113,10 +113,10 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
 			var container = Truck40tPowerTrain.CreatePowerTrain(cycle, "Gearbox_Initialize", 7500.0.SI<Kilogram>(),
 				19300.SI<Kilogram>());
 			var retVal = container.Cycle.Initialize();
-			Assert.AreEqual(11u, container.Gear);
+			Assert.AreEqual(12u, container.Gear);
 			Assert.IsInstanceOfType(retVal, typeof(ResponseSuccess));
 
-			AssertHelper.AreRelativeEqual(1530.263.RPMtoRad(), container.EngineSpeed, toleranceFactor: 1e-3);
+			AssertHelper.AreRelativeEqual(1195.996.RPMtoRad(), container.EngineSpeed, toleranceFactor: 1e-3);
 
 			var absTime = 0.SI<Second>();
 			var ds = 1.SI<Meter>();
diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj
index dec721b622..56224703b2 100644
--- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj
+++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj
@@ -105,6 +105,7 @@
     <Compile Include="Models\Simulation\GearboxInertiaTest.cs" />
     <Compile Include="Models\Simulation\MockSumWriter.cs" />
     <Compile Include="Models\Simulation\GetSectionTest.cs" />
+    <Compile Include="Reports\ActualModalSimulationDataTest.cs" />
     <Compile Include="Reports\ModDataTest.cs" />
     <Compile Include="Models\Simulation\MeasuredSpeedModeTest.cs" />
     <Compile Include="Models\Simulation\PwheelModeTests.cs" />
-- 
GitLab