From 7cf19160237d8905e2b97c314c98a1ea20de98c4 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Wed, 2 Feb 2022 09:40:57 +0100
Subject: [PATCH] ignore  eco-roll without PCC in the simulation, but keep it
 in the output (MRF, CIF, sum-data)

---
 .../AbstractSimulationDataAdapter.cs              |  1 +
 .../DataObjectAdapter/DeclarationDataAdapter.cs   |  9 ++++++++-
 .../Models/Declaration/ADASCombinations.cs        | 15 +++++++++++++++
 .../SimulationComponent/Data/VehicleData.cs       |  4 ++++
 .../VectoCore/OutputData/SummaryDataContainer.cs  |  2 +-
 .../VectoCore/OutputData/XML/XMLCustomerReport.cs |  4 ++--
 .../OutputData/XML/XMLManufacturerReport.cs       |  4 ++--
 7 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs
index 68f6aeaee5..be17fdb61d 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs
@@ -62,6 +62,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
 				CurbMass = data.CurbMassChassis,
 				GrossVehicleMass = data.GrossVehicleMassRating,
 				AirDensity = Physics.AirDensity,
+				InputData = data,
 			};
 
 			return retVal;
diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs
index 6eac5035fc..e89c136637 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs
@@ -174,11 +174,18 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
 
 		private VehicleData.ADASData CreateADAS(IAdvancedDriverAssistantSystemDeclarationInputData adas)
 		{
-			return new VehicleData.ADASData {
+			var retVal = new VehicleData.ADASData {
 				EngineStopStart = adas.EngineStopStart,
 				EcoRoll = adas.EcoRoll,
 				PredictiveCruiseControl = adas.PredictiveCruiseControl
 			};
+
+			if (retVal.PredictiveCruiseControl == PredictiveCruiseControlType.None &&
+				retVal.EcoRoll.WithoutEngineStop()) {
+				retVal.EcoRoll = EcoRollType.None;
+			}
+
+			return retVal;
 		}
 
 		private VehicleData CreateExemptedVehicleData(IVehicleDeclarationInputData data)
diff --git a/VectoCore/VectoCore/Models/Declaration/ADASCombinations.cs b/VectoCore/VectoCore/Models/Declaration/ADASCombinations.cs
index 7e7cc2810e..7d8b9900e9 100644
--- a/VectoCore/VectoCore/Models/Declaration/ADASCombinations.cs
+++ b/VectoCore/VectoCore/Models/Declaration/ADASCombinations.cs
@@ -103,10 +103,22 @@ namespace TUGraz.VectoCore.Models.Declaration
 
 		#endregion
 
+		public ADASCombination Lookup(IAdvancedDriverAssistantSystemDeclarationInputData adas, GearboxType gbxType)
+		{
+			var entry = Lookup(
+				adas.EngineStopStart, adas.EcoRoll, adas.PredictiveCruiseControl);
+			return ValidateAdasCombination(gbxType, entry);
+		}
+
 		internal ADASCombination Lookup(VehicleData.ADASData adas, GearboxType gbxType)
 		{
 			var entry = Lookup(
 				adas.EngineStopStart, adas.EcoRoll, adas.PredictiveCruiseControl);
+			return ValidateAdasCombination(gbxType, entry);
+		}
+
+		private static ADASCombination ValidateAdasCombination(GearboxType gbxType, ADASCombination entry)
+		{
 			if (gbxType.AutomaticTransmission() && !entry.AllowedForAT) {
 				throw new VectoException("ADAS combination {0} not allowed for AT transmissions", entry.ID);
 			}
@@ -118,6 +130,7 @@ namespace TUGraz.VectoCore.Models.Declaration
 			if (gbxType == GearboxType.AMT && !entry.AllowedForAMT) {
 				throw new VectoException("ADAS combination {0} not allowed for AMT transmissions", entry.ID);
 			}
+
 			return entry;
 		}
 
@@ -144,5 +157,7 @@ namespace TUGraz.VectoCore.Models.Declaration
 			return Lookup(
 				adas.EngineStopStart, adas.EcoRoll, adas.PredictiveCruiseControl);
 		}
+
+		
 	}
 }
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs
index 1589052382..fc65c2ffe0 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs
@@ -33,6 +33,7 @@ using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
+using Newtonsoft.Json;
 using TUGraz.VectoCommon.BusAuxiliaries;
 using TUGraz.VectoCommon.Exceptions;
 using TUGraz.VectoCommon.InputData;
@@ -229,6 +230,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
 		public bool? SleeperCab { get; internal set; }
 		public ADASData ADAS { get; internal set; }
 		public bool VocationalVehicle { get; internal set; }
+		
+		[JsonIgnore]
+		public IVehicleDeclarationInputData InputData { get; set; }
 
 		public class ADASData
 		{
diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs
index b811d6d624..45b28382ce 100644
--- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs
+++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs
@@ -731,7 +731,7 @@ namespace TUGraz.VectoCore.OutputData
 
 			row[Fields.R_DYN] = (ConvertedSI)data.DynamicTyreRadius;
 
-			row[Fields.ADAS_TECHNOLOGY_COMBINATION] = data.ADAS != null ? DeclarationData.ADASCombinations.Lookup(data.ADAS, gbxType).ID : "";
+			row[Fields.ADAS_TECHNOLOGY_COMBINATION] = data.ADAS != null ? DeclarationData.ADASCombinations.Lookup(data.InputData.ADAS, gbxType).ID : "";
 
 			//var cap = "";
 			//row[Fields.REESS_CAPACITY] = cap;
diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs
index 1b5abd6670..aeaaba58ef 100644
--- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs
+++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs
@@ -103,7 +103,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 					new XElement(tns + XMLNames.Report_CO2StandardsGroup, DeclarationReport.WeightingGroup.ToXMLFormat()),
 					new XElement(tns + XMLNames.Vehicle_VocationalVehicle, modelData.VehicleData.VocationalVehicle),
 					new XElement(tns + XMLNames.Vehicle_SleeperCab, modelData.VehicleData.SleeperCab),
-					GetADAS(modelData.VehicleData.ADAS)
+					GetADAS(modelData.VehicleData.InputData.ADAS)
 				}.Concat(ComponentData(modelData))
 				);
 			if (exempted) {
@@ -121,7 +121,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 			};
 		}
 
-		private XElement GetADAS(VehicleData.ADASData adasData)
+		private XElement GetADAS(IAdvancedDriverAssistantSystemDeclarationInputData adasData)
 		{
 			return new XElement(tns + XMLNames.Vehicle_ADAS,
 								new XElement(tns + XMLNames.Vehicle_ADAS_EngineStopStart, adasData.EngineStopStart),
diff --git a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs
index 43438af13c..165659e391 100644
--- a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs
+++ b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs
@@ -101,7 +101,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 						new XElement(tns + XMLNames.Vehicle_VocationalVehicle, modelData.VehicleData.VocationalVehicle),
 						new XElement(tns + XMLNames.Vehicle_SleeperCab, modelData.VehicleData.SleeperCab),
 						new XElement(tns + XMLNames.Vehicle_PTO, modelData.PTO != null),
-						GetADAS(modelData.VehicleData.ADAS),
+						GetADAS(modelData.VehicleData.InputData.ADAS),
 						GetTorqueLimits(modelData.EngineData),
 						VehicleComponents(modelData)
 					}
@@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 				modelData.InputDataHash == null ? CreateDummySig() : new XElement(modelData.InputDataHash));
 		}
 
-		private XElement GetADAS(VehicleData.ADASData adasData)
+		private XElement GetADAS(IAdvancedDriverAssistantSystemDeclarationInputData adasData)
 		{
 			return new XElement(tns + XMLNames.Vehicle_ADAS,
 				new XElement(tns + XMLNames.Vehicle_ADAS_EngineStopStart, adasData.EngineStopStart),
-- 
GitLab