From f1ac192c483d49eda2816c32d5f383571a8ffe7f Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Tue, 26 Apr 2016 15:28:51 +0200
Subject: [PATCH] get correct cycle name and estimated driving time

---
 .../Impl/BusAuxiliariesAdapter.cs             | 68 +++++++++----------
 1 file changed, 31 insertions(+), 37 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
index 0d9e86a4a3..a3a4ec3ca5 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs
@@ -1,5 +1,6 @@
 using System;
 using System.IO;
+using System.Windows.Forms.VisualStyles;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.Configuration;
 using TUGraz.VectoCore.Models.Simulation;
@@ -29,57 +30,50 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			var tmpAux = new AdvancedAuxiliaries();
 
 			// 'Set Statics
-			tmpAux.VectoInputs.Cycle = DetermineCycle(cycleName);
+			tmpAux.VectoInputs.Cycle = DetermineCycle(cycleName, tmpAux.Signals);
 			tmpAux.VectoInputs.VehicleWeightKG = (float)vehicleWeight.Value();
 			_fcMapAdapter = new FuelConsumptionAdapter() { FcMap = fcMap };
 			tmpAux.VectoInputs.FuelMap = _fcMapAdapter;
 			tmpAux.VectoInputs.FuelDensity = Physics.FuelDensity.Value();
 
 			//'Set Signals
-			tmpAux.Signals.TotalCycleTimeSeconds = 15000; // TODO MQ: get cycle time somehow!
 			tmpAux.Signals.EngineIdleSpeed = (float)(engineIdleSpeed.Value() / Constants.RPMToRad);
 			tmpAux.Initialise(Path.GetFileName(aauxFile), Path.GetDirectoryName(Path.GetFullPath(aauxFile)) + @"\");
 
 			Auxiliaries = tmpAux;
 		}
 
-		private static string DetermineCycle(string cycleName)
+		private static string DetermineCycle(string cycleName, ISignals aauxsignals)
 		{
-			return "Coach";
-			//			Public Function DetermineCycleNameFromCurrentFile() As String
+			var cycle = cycleName.ToLower();
 
-			//	'Get DriveFile without path and without extension
-			//	Dim driveFile As String = fFILE(CurrentCycleFile, False)
-
-			//	Select Case (True)
-
-			//		'DJN - update to make contains test case insensitive
-			//		Case driveFile.ToLower().Contains("heavy_urban") AndAlso driveFile.ToLower().Contains("bus")
-			//			Return "Heavy urban"
-
-			//		Case driveFile.ToLower().Contains("suburban") AndAlso driveFile.ToLower().Contains("bus")
-			//			Return "Suburban"
-
-			//		Case driveFile.ToLower().Contains("urban") AndAlso driveFile.ToLower().Contains("bus")
-			//			Return "Urban"
-
-			//		Case driveFile.ToLower().Contains("interurban") AndAlso driveFile.ToLower().Contains("bus")
-			//			Return "Interurban"
-
-			//		Case driveFile.ToLower().Contains("coach")
-			//			Return "Coach"
-
-			//		Case Else
-			//			WorkerMsg(tMsgID.Warn,
-			//					String.Format("UnServiced Cycle Name '{0}' in Pneumatics Actuations Map 0 Actuations returned", driveFile),
-			//					"Advanced Auxiliaries")
-			//			Return "UnknownCycleName"
-
-			//	End Select
-
-
-			//	Return "Urban"
-			//End Function
+			// cycle time is hard coded based on previous simulations
+			if (cycle.Contains("bus")) {
+				if (cycle.Contains("heavy_urban")) {
+					aauxsignals.TotalCycleTimeSeconds = 8912;
+					return "Heavy urban";
+				}
+				if (cycle.Contains("suburban")) {
+					aauxsignals.TotalCycleTimeSeconds = 3283;
+					return "Suburban";
+				}
+				if (cycle.Contains("urban")) {
+					aauxsignals.TotalCycleTimeSeconds = 8149;
+					return "Urban";
+				}
+				if (cycle.Contains("interurban")) {
+					aauxsignals.TotalCycleTimeSeconds = 12962;
+					return "Interurban";
+				}
+			}
+			if (cycle.Contains("coach")) {
+				aauxsignals.TotalCycleTimeSeconds = 15086;
+				return "Coach";
+			}
+			Logger<BusAuxiliariesAdapter>()
+				.Warn("UnServiced Cycle Name '{0}' in Pneumatics Actuations Map 0 Actuations returned", cycleName);
+			aauxsignals.TotalCycleTimeSeconds = 1;
+			return "UnknownCycleName";
 		}
 
 		public IEngineAuxPort Port()
-- 
GitLab