From 0098d690866b3a88270d1dee1190675397375b90 Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Mon, 14 Nov 2016 09:56:20 +0100
Subject: [PATCH] Updated Test Data of measured speed test cases (sometimes n
 was lower than idle speed); Corrected Error in CycleGearbox
 (TorqueConverterLocked check); Updated ENG_Class5 .veng data

---
 .../Class5_Tractor_4x2/Class5_Tractor_ENG.vsum   |  2 --
 .../Class5_Tractor_4x2/Engine_325kW_12.7l.veng   |  1 +
 VECTO/My Project/AssemblyInfo.vb                 |  2 +-
 .../SimulationComponent/Data/GearboxData.cs      | 14 +++-----------
 .../SimulationComponent/Impl/CycleGearbox.cs     | 16 ++++++++--------
 .../FileIO/SimulationDataReaderTest.cs           |  5 +++--
 .../MeasuredSpeed/MeasuredSpeedGear_AT-PS.vdri   |  2 +-
 .../MeasuredSpeed/MeasuredSpeedGear_AT-Ser.vdri  |  8 ++++----
 8 files changed, 21 insertions(+), 29 deletions(-)
 delete mode 100644 Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Class5_Tractor_ENG.vsum

diff --git a/Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Class5_Tractor_ENG.vsum b/Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Class5_Tractor_ENG.vsum
deleted file mode 100644
index 99cb9e049d..0000000000
--- a/Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Class5_Tractor_ENG.vsum	
+++ /dev/null
@@ -1,2 +0,0 @@
-Job [-],Input File [-],Cycle [-],Status,Mass [kg],Loading [kg],time [s],distance [km],speed [km/h],altitudeDelta [m],FC-Map [g/h],FC-Map [g/km],FC-AUXc [g/h],FC-AUXc [g/km],FC-WHTCc [g/h],FC-WHTCc [g/km],FC-AAUX [g/h],FC-AAUX [g/km],FC-Final [g/h],FC-Final [g/km],FC-Final [l/100km],FC-Final [l/100tkm],CO2 [g/km],CO2 [g/tkm],P_wheel_in_pos [kW],P_brake_loss [kW],P_angle_loss [kW],P_tc_loss [kW],P_clutch_pos [kW],P_clutch_neg [kW],P_fcmap_pos [kW],E_aux_CYCLE [kWh],E_aux_CONSTANTAUX [kWh],E_aux_ES [kWh],E_aux_sum [kWh],E_air [kWh],E_roll [kWh],E_grad [kWh],E_inertia [kWh],E_brake [kWh],E_gbx_loss [kWh],E_axl_loss [kWh],E_angle_loss [kWh],E_ret_loss [kWh],E_tc_loss [kWh],E_clutch_pos [kWh],E_clutch_neg [kWh],E_fcmap_pos [kWh],a [m/s^2],a_pos [m/s^2],a_neg [m/s^2],AccelerationTimeShare [%],DecelerationTimeShare [%],CruiseTimeShare [%],StopTimeShare [%]
-1-0,Class5_Tractor_ENG,Long_Haul.vdri,Success,15729.0000,19300.0000,5352.7246,108.1910,72.7644,0.1702,22838.5126,313.8695,22838.5126,313.8695,22838.5126,313.8695,22838.5126,313.8695,22838.5126,313.8695,37.7247,1.9546,991.8275,51.3900,101.6342,15.1578,0.0000,0.0000,154.7178,-24.5568,150.7650,0.0000,7.4350,4.0021,11.4371,56.8832,60.9612,0.0026,-0.0138,22.5376,9.7783,7.5428,0.0000,2.0417,0.0000,167.1868,-7.5101,176.9343,0.0000,0.3424,-0.4739,6.5396,4.6898,0.0000,4.5584
diff --git a/Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Engine_325kW_12.7l.veng b/Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Engine_325kW_12.7l.veng
index 27be26b719..5e17fea53f 100644
--- a/Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Engine_325kW_12.7l.veng	
+++ b/Generic Vehicles/Engineering Mode/Class5_Tractor_4x2/Engine_325kW_12.7l.veng	
@@ -16,6 +16,7 @@
     "WHTC-Urban": 0.0,
     "WHTC-Rural": 0.0,
     "WHTC-Motorway": 0.0,
+    "WHTC-Engineering": 1.0,
     "ColdHotBalancingFactor": 0.0
   }
 }
\ No newline at end of file
diff --git a/VECTO/My Project/AssemblyInfo.vb b/VECTO/My Project/AssemblyInfo.vb
index ead781488a..23ca07a043 100644
--- a/VECTO/My Project/AssemblyInfo.vb	
+++ b/VECTO/My Project/AssemblyInfo.vb	
@@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
 <Assembly: AssemblyDescription("Vehicle Energy Consumption Calculation Tool")> 
 <Assembly: AssemblyCompany("")> 
 <Assembly: AssemblyProduct("VECTO")> 
-<Assembly: AssemblyCopyright("© European Commission 2014")> 
+<Assembly: AssemblyCopyright("© European Commission 2016")> 
 <Assembly: AssemblyTrademark("")> 
 
 <Assembly: ComVisible(False)>
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs
index 8b946ad87b..27edfa2f52 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs
@@ -32,12 +32,14 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
+using System.Diagnostics;
 using System.Linq;
 using System.Runtime.Serialization;
 using TUGraz.VectoCommon.Models;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.Configuration;
 using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
+using TUGraz.VectoCore.Utils;
 
 namespace TUGraz.VectoCore.Models.SimulationComponent.Data
 {
@@ -46,13 +48,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
 	/// </summary>
 	/// <remarks>The Axle Gear has its own Property "AxleGearData" and is *not included* in the Gears-Dictionary.</remarks>
 	[DataContract, CustomValidation(typeof(GearboxData), "ValidateGearboxData")]
+	[DebuggerDisplay("GearboxData({Type}, #Gears: {Gears.Count}, ...)")]
 	public class GearboxData : SimulationComponentData
 	{
 		public GearboxType Type { get; internal set; }
 
-		/// <summary>
-		/// The gear data.
-		/// </summary>
 		[Required, ValidateObject] public Dictionary<uint, GearData> Gears = new Dictionary<uint, GearData>();
 
 		public TorqueConverterData TorqueConverterData { get; internal set; }
@@ -89,14 +89,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
 		[Required, SIRange(double.Epsilon, 2)]
 		public MeterPerSquareSecond StartAcceleration { get; internal set; }
 
-		///// <summary>
-		///// Gets a value indicating whether this instance has torque converter.
-		///// </summary>
-		///// <value>
-		///// <c>true</c> if this instance has torque converter; otherwise, <c>false</c>.
-		///// </value>
-		//public bool HasTorqueConverter { get; internal set; }
-
 		[Required, SIRange(0, double.MaxValue)]
 		public Second UpshiftAfterDownshiftDelay { get; internal set; }
 
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs
index a240612444..549e8b1c9d 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs
@@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 	{
 		protected bool? TorqueConverterActive;
 
-		protected internal TorqueConverterData TorqueConverter;
+		protected internal readonly TorqueConverterData TorqueConverter;
 		private readonly KilogramSquareMeter _engineInertia;
 
 		public CycleGearbox(IVehicleContainer container, GearboxData gearboxModelData, KilogramSquareMeter engineInertia)
@@ -164,11 +164,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 		private IResponse RequestEngaged(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity,
 			bool dryRun)
 		{
-			var TorqueConverterLocked = TorqueConverterActive != null && !TorqueConverterActive.Value;
+			var torqueConverterLocked = TorqueConverterActive == null || !TorqueConverterActive.Value;
 
 			var effectiveRatio = ModelData.Gears[Gear].Ratio;
 			var effectiveLossMap = ModelData.Gears[Gear].LossMap;
-			if (!TorqueConverterLocked) {
+			if (!torqueConverterLocked) {
 				effectiveRatio = ModelData.Gears[Gear].TorqueConverterRatio;
 				effectiveLossMap = ModelData.Gears[Gear].TorqueConverterGearLossMap;
 			}
@@ -179,17 +179,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			var inTorque = outTorque / effectiveRatio + inTorqueLossResult.Value;
 			CurrentState.TorqueLossResult = inTorqueLossResult;
 
-			if (!TorqueConverterLocked && !ModelData.Gears[Gear].HasTorqueConverter) {
+			if (!torqueConverterLocked && !ModelData.Gears[Gear].HasTorqueConverter) {
 				throw new VectoSimulationException("Torque converter requested by strategy for gear without torque converter!");
 			}
 
 			var inAngularVelocity = outAngularVelocity * effectiveRatio;
 
-			if (ModelData.Type.AutomaticTransmission() && TorqueConverterLocked &&
+			if (ModelData.Type.AutomaticTransmission() && torqueConverterLocked &&
 				inAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) {
 				Log.Error(
 					"ERROR: EngineSpeed is lower than Idlespeed in Measuredspeed-Cycle with given Gear (Automatic Transmission). AbsTime: {0}, Gear: {1} TC-Active: {2}, EngineSpeed: {3}",
-					absTime, Gear, !TorqueConverterLocked, inAngularVelocity.AsRPM);
+					absTime, Gear, !torqueConverterLocked, inAngularVelocity.AsRPM);
 				return new ResponseEngineSpeedTooLow { Source = this };
 			}
 
@@ -204,7 +204,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			}
 
 			if (dryRun) {
-				if (TorqueConverter != null && TorqueConverterActive != null && TorqueConverterActive.Value) {
+				if (TorqueConverter != null && !torqueConverterLocked) {
 					return RequestTorqueConverter(absTime, dt, inTorque, inAngularVelocity, true);
 				}
 				if (outTorque.IsSmaller(0) && inAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) {
@@ -226,7 +226,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			CurrentState.Gear = Gear;
 			// end critical section
 
-			if (TorqueConverter != null && TorqueConverterActive != null && TorqueConverterActive.Value) {
+			if (TorqueConverter != null && !torqueConverterLocked) {
 				CurrentState.TorqueConverterActive = true;
 				return RequestTorqueConverter(absTime, dt, inTorque, inAngularVelocity);
 			}
diff --git a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs
index df0a95bb97..e4c06384b3 100644
--- a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs
+++ b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs
@@ -107,8 +107,9 @@ namespace TUGraz.VectoCore.Tests.FileIO
 			Assert.AreEqual(downshiftSpeeds.Length, runData.GearboxData.Gears[2].ShiftPolygon.Downshift.Count);
 			for (var i = 0; i < downshiftSpeeds.Length; i++) {
 				Assert.AreEqual(downshiftSpeeds[i].RPMtoRad().Value(),
-					runData.GearboxData.Gears[2].ShiftPolygon.Downshift[i].AngularSpeed.Value(), Tolerance);
-				Assert.AreEqual(downshiftTorque[i], runData.GearboxData.Gears[2].ShiftPolygon.Downshift[i].Torque.Value(), Tolerance);
+					runData.GearboxData.Gears[2].ShiftPolygon.Downshift[i].AngularSpeed.Value(), Tolerance, "i: " + i);
+				Assert.AreEqual(downshiftTorque[i], runData.GearboxData.Gears[2].ShiftPolygon.Downshift[i].Torque.Value(), Tolerance,
+					"i: " + i);
 			}
 
 			var upshiftSpeed = new[] { 1889.6633, 1889.6633, 606.64575 / Constants.RPMToRad };
diff --git a/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-PS.vdri b/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-PS.vdri
index 88f0ff3eff..8ba5ba57dd 100644
--- a/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-PS.vdri
+++ b/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-PS.vdri
@@ -172,7 +172,7 @@
 171,31.0,-0.3,2,0,4.5
 172,26.6,-0.3,1,0,4.5
 173,22.0,-0.3,1,0,4.5
-174,17.0,-0.3,1,0,4.5
+174,17.0,-0.3,0,0,4.5
 175,11.9,-0.3,0,0,4.5
 176,6.8,-0.3,0,0,4.5
 177,2.4,-0.3,0,0,4.5
diff --git a/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-Ser.vdri b/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-Ser.vdri
index 925d3dbda1..507c016419 100644
--- a/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-Ser.vdri
+++ b/VectoCore/VectoCoreTest/TestData/MeasuredSpeed/MeasuredSpeedGear_AT-Ser.vdri
@@ -20,7 +20,7 @@
 19,18.1,-0.3,3,0,4.5
 20,15.1,-0.3,2,0,4.5
 21,11.5,-0.3,1,0,4.5
-22,8.0,-0.3,1,0,4.5
+22,8.0,-0.3,1,1,4.5
 23,4.2,-0.3,1,1,4.5
 24,0.6,-0.3,1,1,4.5
 25,0.0,-0.3,1,1,4.5
@@ -73,7 +73,7 @@
 72,17.4,-0.3,1,0,4.5
 73,13.8,-0.3,1,0,4.5
 74,10.3,-0.3,1,0,4.5
-75,7.0,-0.3,1,0,4.5
+75,7.0,-0.3,1,1,4.5
 76,2.5,-0.3,1,1,4.5
 77,0.0,-0.3,1,1,4.5
 78,0.0,-0.3,1,1,4.5
@@ -124,7 +124,7 @@
 123,16.8,-0.3,1,0,4.5
 124,13.5,-0.3,1,0,4.5
 125,10.1,-0.3,1,0,4.5
-126,7.0,-0.3,1,0,4.5
+126,7.0,-0.3,1,1,4.5
 127,3.1,-0.3,1,1,4.5
 128,0.2,-0.3,1,1,4.5
 129,0.0,-0.3,1,1,4.5
@@ -152,7 +152,7 @@
 151,18.9,0.3,2,0,4.5
 152,16.5,0.3,2,0,4.5
 153,12.8,0.3,1,0,4.5
-154,8.5,0.3,1,0,4.5
+154,8.5,0.3,1,1,4.5
 155,3.8,0.3,1,1,4.5
 156,0.2,0.3,1,1,4.5
 157,0.0,0.3,1,1,4.5
-- 
GitLab