From a6bf95ca6a7910638b0c6186c1f5df7b280b6f43 Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Fri, 29 Jan 2016 16:14:01 +0100
Subject: [PATCH] added ultimate pwheel sico test

---
 .../Impl/PowertrainDrivingCycle.cs            |  4 +++
 .../Models/Simulation/PwheelModeTests.cs      | 29 +++++++++++++++
 .../TestData/Jobs/Pwheel_ultimate.vecto       | 36 +++++++++++++++++++
 VectoCoreTest/VectoCoreTest.csproj            |  3 ++
 4 files changed, 72 insertions(+)
 create mode 100644 VectoCoreTest/TestData/Jobs/Pwheel_ultimate.vecto

diff --git a/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs
index f857ab4a44..edc7272f11 100644
--- a/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs
+++ b/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs
@@ -181,6 +181,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 		public PWheelCycle(IVehicleContainer container, DrivingCycleData cycle, double axleRatio,
 			IDictionary<uint, double> gears) : base(container, cycle)
 		{
+			if (!gears.ContainsKey(0)) {
+				gears[0] = 1;
+			}
+
 			foreach (var entry in Data.Entries) {
 				entry.AngularVelocity = entry.AngularVelocity / (axleRatio * gears[entry.Gear]);
 				entry.Torque = entry.PWheel / entry.AngularVelocity;
diff --git a/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCoreTest/Models/Simulation/PwheelModeTests.cs
index cd99cc2695..2fab3f4216 100644
--- a/VectoCoreTest/Models/Simulation/PwheelModeTests.cs
+++ b/VectoCoreTest/Models/Simulation/PwheelModeTests.cs
@@ -3,6 +3,7 @@ using System.Text;
 using TUGraz.VectoCore.Utils;
 using System.Collections.Generic;
 using System.Data;
+using System.Linq;
 using TUGraz.VectoCore.OutputData;
 using TUGraz.VectoCore.Tests.Utils;
 using TUGraz.VectoCore.InputData.Reader;
@@ -118,10 +119,38 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
 
 			jobContainer.WaitFinished();
 
+			Assert.IsTrue(jobContainer.Runs.All(r => r.Success));
+
 			ResultFileHelper.TestSumFile(@"TestData\Results\Pwheel\Atego_ges.v2.vsum", @"TestData\Jobs\Pwheel.vsum");
 
 			ResultFileHelper.TestModFile(@"TestData\Results\Pwheel\Atego_ges_Gear2_pt1_rep1_actual.vmod",
 				@"TestData\Jobs\Pwheel_Gear2_pt1_rep1_actual.vmod");
 		}
+
+		/// <summary>
+		/// Tests if the simulation works and the modfile and sumfile are correct in Pwheel mode.
+		/// </summary>
+		/// <remarks>VECTO-177</remarks>
+		[TestMethod]
+		public void Pwheel_ultimate_Run_Test()
+		{
+			var jobFile = @"TestData\Jobs\Pwheel_ultimate.vecto";
+			var fileWriter = new FileOutputWriter(jobFile);
+			var sumWriter = new SummaryDataContainer(fileWriter);
+			var jobContainer = new JobContainer(sumWriter);
+
+			var inputData = JSONInputDataFactory.ReadJsonJob(jobFile);
+			var runsFactory = new SimulatorFactory(ExecutionMode.Engineering, inputData, fileWriter);
+
+			jobContainer.AddRuns(runsFactory);
+			jobContainer.Execute();
+
+			jobContainer.WaitFinished();
+
+			Assert.IsTrue(jobContainer.Runs.All(r => r.Success));
+
+			ResultFileHelper.TestModFile(@"TestData\Results\Pwheel\Atego_HDVCO2_RD_#1_AuxStd.vmod",
+				@"TestData\Jobs\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod");
+		}
 	}
 }
\ No newline at end of file
diff --git a/VectoCoreTest/TestData/Jobs/Pwheel_ultimate.vecto b/VectoCoreTest/TestData/Jobs/Pwheel_ultimate.vecto
new file mode 100644
index 0000000000..dce010bf4f
--- /dev/null
+++ b/VectoCoreTest/TestData/Jobs/Pwheel_ultimate.vecto
@@ -0,0 +1,36 @@
+{
+  "Header": {
+    "CreatedBy": "TUG ITI (59f3bd5f-1e50-474f-928a-435968d769f6)",
+    "Date": "23.11.2015 10:27:34",
+    "AppVersion": "2.2",
+    "FileVersion": 2
+  },
+  "Body": {
+    "SavedInDeclMode": false,
+    "VehicleFile": "../Components/Pwheel/Atego.vveh",
+    "EngineFile": "../Components/Pwheel/OM906.veng",
+    "GearboxFile": "../Components/Pwheel/G_85-6_6_7-0_17.vgbx",
+    "Cycles": [
+      "../Components/Pwheel/RD_#1_Pwheel_AuxStd.vdri"
+    ],
+    "VACC": "../Components/Pwheel/Truck.vacc",
+    "EngineOnlyMode": false,
+    "StartStop": {
+      "Enabled": false,
+      "MaxSpeed": 5.0,
+      "MinTime": 5.0,
+      "Delay": 0
+    },
+    "LAC": {
+      "Enabled": true,
+      "Dec": -0.5,
+      "MinSpeed": 50.0
+    },
+    "OverSpeedEcoRoll": {
+      "Mode": "Off",
+      "MinSpeed": 0.0,
+      "OverSpeed": 0.0,
+      "UnderSpeed": 0.0
+    }
+  }
+}
\ No newline at end of file
diff --git a/VectoCoreTest/VectoCoreTest.csproj b/VectoCoreTest/VectoCoreTest.csproj
index 858c94c86d..bcd9ff3cfe 100644
--- a/VectoCoreTest/VectoCoreTest.csproj
+++ b/VectoCoreTest/VectoCoreTest.csproj
@@ -797,6 +797,9 @@
     <None Include="TestData\Jobs\EngineOnlyJob.vecto">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="TestData\Jobs\Pwheel_ultimate.vecto">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
     <None Include="TestData\Jobs\Pwheel.vecto">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-- 
GitLab