From 03e33b3b7cce1fc3c83360c20286bdce8892240f Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Wed, 7 Nov 2018 18:01:16 +0100
Subject: [PATCH] extending vehicle declaration interface with ADAS parameters
 (new interface)

---
 VECTO/Input Files/Vehicle.vb                  | 32 ++++++++++++-
 .../InputData/DeclarationInputData.cs         | 38 ++++++++++++++++
 .../Resources/XMLNames.Designer.cs            | 45 +++++++++++++++++++
 .../VectoCommon/Resources/XMLNames.resx       | 15 +++++++
 .../FileIO/JSON/JSONComponentInputData.cs     | 14 +++++-
 .../InputData/FileIO/JSON/JSONVehicleData.cs  | 14 +++++-
 .../XMLDeclarationVehicleDataProvider.cs      | 35 ++++++++++++++-
 .../XMLEngineeringVehicleDataProvider.cs      |  1 +
 .../Models/Declaration/DeclarationData.cs     |  7 +++
 9 files changed, 197 insertions(+), 4 deletions(-)

diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb
index 498f2aa990..df47550b81 100644
--- a/VECTO/Input Files/Vehicle.vb	
+++ b/VECTO/Input Files/Vehicle.vb	
@@ -28,7 +28,7 @@ Imports TUGraz.VectoCore.Utils
 <CustomValidation(GetType(Vehicle), "ValidateVehicle")>
 Public Class Vehicle
 	Implements IVehicleEngineeringInputData, IVehicleDeclarationInputData, IRetarderInputData, IPTOTransmissionInputData, 
-				IAngledriveInputData, IAirdragEngineeringInputData
+				IAngledriveInputData, IAirdragEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData
 
 	Private _filePath As String
 	Private _path As String
@@ -670,6 +670,12 @@ Public Class Vehicle
     End Get
     End Property
 
+    Public ReadOnly Property ADAS As IAdvancedDriverAssistantSystemDeclarationInputData Implements IVehicleDeclarationInputData.ADAS
+    get
+            return Me
+    End Get
+    End Property
+
     Public ReadOnly Property ZeroEmissionVehicle As Boolean Implements IVehicleDeclarationInputData.ZeroEmissionVehicle
     get
             Return DeclarationData.Vehicle.ZeroEmissionVehicleDefault
@@ -699,4 +705,28 @@ Public Class Vehicle
             Return Nothing
     End Get
     End Property
+
+    Public ReadOnly Property EngineStopStart As Boolean Implements IAdvancedDriverAssistantSystemDeclarationInputData.EngineStopStart
+    get
+            return DeclarationData.Vehicle.ADAS.EngineStopStartDefault
+    End Get
+    End Property
+
+    Public ReadOnly Property EcoRollWitoutEngineStop As Boolean Implements IAdvancedDriverAssistantSystemDeclarationInputData.EcoRollWitoutEngineStop
+    get
+            return DeclarationData.Vehicle.ADAS.EcoRollWitoutEngineStop
+    End Get
+    End Property
+
+    Public ReadOnly Property EcoRollWithEngineStop As Boolean Implements IAdvancedDriverAssistantSystemDeclarationInputData.EcoRollWithEngineStop
+    get
+            Return DeclarationData.Vehicle.ADAS.EcoRollWithEngineStop
+    End Get
+    End Property
+
+    Public ReadOnly Property PredictiveCruiseControl As PredictiveCruiseControlType Implements IAdvancedDriverAssistantSystemDeclarationInputData.PredictiveCruiseControl
+    get
+            Return DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault
+    End Get
+    End Property
 End Class
diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs
index ec33ce5057..90541c0111 100644
--- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs
+++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs
@@ -29,7 +29,9 @@
 *   Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
 */
 
+using System;
 using System.Collections.Generic;
+using System.Net.NetworkInformation;
 using TUGraz.VectoCommon.Models;
 using TUGraz.VectoCommon.Utils;
 
@@ -142,6 +144,8 @@ namespace TUGraz.VectoCommon.InputData
 
 		NgTankSystem TankSystem { get; }
 
+		IAdvancedDriverAssistantSystemDeclarationInputData ADAS { get; }
+
 		// fields for exempted vehicles
 
 		bool ZeroEmissionVehicle { get; }
@@ -155,6 +159,40 @@ namespace TUGraz.VectoCommon.InputData
 		Watt MaxNetPower2 { get; }
 	}
 
+	public interface IAdvancedDriverAssistantSystemDeclarationInputData
+	{
+		bool EngineStopStart { get; }
+
+		bool EcoRollWitoutEngineStop { get; }
+
+		bool EcoRollWithEngineStop { get; }
+
+		PredictiveCruiseControlType PredictiveCruiseControl { get; }
+	}
+
+	public enum PredictiveCruiseControlType
+	{
+		None,
+		Option_1_2,
+		Option_1_2_3	
+	}
+
+	public static class PredictiveCruiseControlTypeHelper
+	{
+		public const string Prefix = "Option_";
+		public const string SeparatorXML = ",";
+		public const string SeparatorEnum = "_";
+
+		public static PredictiveCruiseControlType Parse(string value)
+		{
+			if (PredictiveCruiseControlType.None.ToString().Equals(value, StringComparison.InvariantCultureIgnoreCase)) {
+				return PredictiveCruiseControlType.None;
+			}
+			return (Prefix + value.Replace(SeparatorXML, SeparatorEnum)).ParseEnum<PredictiveCruiseControlType>();
+		}
+	}
+
+
 	public enum NgTankSystem
 	{
 		Liquefied,
diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs
index d8d00d3d99..85d9b9b155 100644
--- a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs
+++ b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs
@@ -2121,6 +2121,51 @@ namespace TUGraz.VectoCommon.Resources {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to ADAS.
+        /// </summary>
+        public static string Vehicle_ADAS {
+            get {
+                return ResourceManager.GetString("Vehicle_ADAS", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to EcoRollWithEngineStop.
+        /// </summary>
+        public static string Vehicle_ADAS_EcoRollWithEngineStopStart {
+            get {
+                return ResourceManager.GetString("Vehicle_ADAS_EcoRollWithEngineStopStart", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to EcoRollWithoutEngineStop.
+        /// </summary>
+        public static string Vehicle_ADAS_EcoRollWithoutEngineStop {
+            get {
+                return ResourceManager.GetString("Vehicle_ADAS_EcoRollWithoutEngineStop", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to EngineStopStart.
+        /// </summary>
+        public static string Vehicle_ADAS_EngineStopStart {
+            get {
+                return ResourceManager.GetString("Vehicle_ADAS_EngineStopStart", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to PredictiveCruiseControl.
+        /// </summary>
+        public static string Vehicle_ADAS_PCC {
+            get {
+                return ResourceManager.GetString("Vehicle_ADAS_PCC", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to AdvancedDriverAssist.
         /// </summary>
diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.resx b/VectoCommon/VectoCommon/Resources/XMLNames.resx
index 254061c611..57457bfb9b 100644
--- a/VectoCommon/VectoCommon/Resources/XMLNames.resx
+++ b/VectoCommon/VectoCommon/Resources/XMLNames.resx
@@ -975,4 +975,19 @@
   <data name="Vehicle_MaxNetPower2" xml:space="preserve">
     <value>MaxNetPower2</value>
   </data>
+  <data name="Vehicle_ADAS" xml:space="preserve">
+    <value>ADAS</value>
+  </data>
+  <data name="Vehicle_ADAS_PCC" xml:space="preserve">
+    <value>PredictiveCruiseControl</value>
+  </data>
+  <data name="Vehicle_ADAS_EcoRollWithEngineStopStart" xml:space="preserve">
+    <value>EcoRollWithEngineStop</value>
+  </data>
+  <data name="Vehicle_ADAS_EcoRollWithoutEngineStop" xml:space="preserve">
+    <value>EcoRollWithoutEngineStop</value>
+  </data>
+  <data name="Vehicle_ADAS_EngineStopStart" xml:space="preserve">
+    <value>EngineStopStart</value>
+  </data>
 </root>
\ No newline at end of file
diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs
index e08492963a..db46d56edb 100644
--- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs
@@ -45,7 +45,7 @@ using TUGraz.VectoCore.Utils;
 namespace TUGraz.VectoCore.InputData.FileIO.JSON
 {
 	public class JSONComponentInputData : IEngineeringInputDataProvider, IDeclarationInputDataProvider,
-		IEngineeringJobInputData, IVehicleEngineeringInputData
+		IEngineeringJobInputData, IVehicleEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData
 	{
 		protected IGearboxEngineeringInputData Gearbox;
 		protected IAxleGearInputData AxleGear;
@@ -305,6 +305,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
 		public bool VocationalVehicle { get { return DeclarationData.Vehicle.VocationalVehicleDefault; } }
 		public bool SleeperCab { get { return DeclarationData.Vehicle.SleeperCabDefault; } }
 		public NgTankSystem TankSystem { get { return DeclarationData.Vehicle.NgTankSystemDefault; } }
+		public IAdvancedDriverAssistantSystemDeclarationInputData ADAS { get { return this; } }
 		public bool ZeroEmissionVehicle { get { return DeclarationData.Vehicle.ZeroEmissionVehicleDefault; } }
 		public bool HybridElectricHDV { get { return DeclarationData.Vehicle.HybridElectricHDVDefault; } }
 		public bool DualFuelVehicle { get { return DeclarationData.Vehicle.DualFuelVehicleDefault; } }
@@ -325,5 +326,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
 		{
 			get { return PTOTransmission; }
 		}
+
+		#region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData
+
+		public bool EngineStopStart { get { return DeclarationData.Vehicle.ADAS.EngineStopStartDefault; } }
+		public bool EcoRollWitoutEngineStop { get { return DeclarationData.Vehicle.ADAS.EcoRollWitoutEngineStop; } }
+		public bool EcoRollWithEngineStop { get { return DeclarationData.Vehicle.ADAS.EcoRollWithEngineStop; } }
+		public PredictiveCruiseControlType PredictiveCruiseControl { get {
+			return DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault;
+		} }
+
+		#endregion
 	}
 }
diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs
index 0602186de0..5911f957e0 100644
--- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs
@@ -44,7 +44,7 @@ using TUGraz.VectoCore.Models.Declaration;
 namespace TUGraz.VectoCore.InputData.FileIO.JSON
 {
 	public class JSONVehicleDataV7 : JSONFile, IVehicleEngineeringInputData, IRetarderInputData, IAngledriveInputData,
-		IPTOTransmissionInputData, IAirdragEngineeringInputData
+		IPTOTransmissionInputData, IAirdragEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData
 	{
 		public JSONVehicleDataV7(JObject data, string fileName, IJSONVehicleComponents job, bool tolerateMissing = false)
 			: base(data, fileName, tolerateMissing)
@@ -261,6 +261,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
 		public bool SleeperCab { get { return DeclarationData.Vehicle.SleeperCabDefault; } }
 
 		public NgTankSystem TankSystem { get { return DeclarationData.Vehicle.NgTankSystemDefault; } }
+		public IAdvancedDriverAssistantSystemDeclarationInputData ADAS { get { return this; } }
 
 		public bool ZeroEmissionVehicle { get { return DeclarationData.Vehicle.ZeroEmissionVehicleDefault; } }
 
@@ -509,5 +510,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
 		{
 			get { return null; }
 		}
+
+		#region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData
+
+		public bool EngineStopStart { get { return DeclarationData.Vehicle.ADAS.EngineStopStartDefault; } }
+		public bool EcoRollWitoutEngineStop { get { return DeclarationData.Vehicle.ADAS.EcoRollWitoutEngineStop; } }
+		public bool EcoRollWithEngineStop { get { return DeclarationData.Vehicle.ADAS.EcoRollWithEngineStop; } }
+		public PredictiveCruiseControlType PredictiveCruiseControl { get {
+			return DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault;
+		} }
+
+		#endregion
 	}
 }
diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs
index f61aa9b84d..e22ffbb70b 100644
--- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs
@@ -44,7 +44,7 @@ using TUGraz.VectoCore.Models.Declaration;
 namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration
 {
 	public class XMLDeclarationVehicleDataProvider : AbstractDeclarationXMLComponentDataProvider,
-		IVehicleDeclarationInputData, IPTOTransmissionInputData
+		IVehicleDeclarationInputData, IPTOTransmissionInputData, IAdvancedDriverAssistantSystemDeclarationInputData
 	{
 		private readonly IAuxiliariesDeclarationInputData XMLAuxiliaryData;
 
@@ -270,6 +270,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration
 				? EnumHelper.ParseEnum<NgTankSystem>(GetElementValue(XMLNames.Vehicle_NgTankSystem))
 				: DeclarationData.Vehicle.NgTankSystemDefault;
 		} }
+
+		public IAdvancedDriverAssistantSystemDeclarationInputData ADAS { get { return this; } }
+
 		public bool ZeroEmissionVehicle { get {
 			return ElementExists(XMLNames.Vehicle_ZeroEmissionVehicle)
 				? XmlConvert.ToBoolean(GetElementValue(XMLNames.Vehicle_ZeroEmissionVehicle))
@@ -295,5 +298,35 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration
 				? GetDoubleElementValue(XMLNames.Vehicle_MaxNetPower2).SI<Watt>()
 				: null;
 		} }
+
+		#region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData
+
+		public bool EngineStopStart { get {
+			return ElementExists(XMLNames.Vehicle_ADAS)
+				? XmlConvert.ToBoolean(GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_EngineStopStart)))
+				: DeclarationData.Vehicle.ADAS.EngineStopStartDefault;
+		} }
+		public bool EcoRollWitoutEngineStop { get {
+			return ElementExists(XMLNames.Vehicle_ADAS)
+				? XmlConvert.ToBoolean(GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_EcoRollWithoutEngineStop)))
+				: DeclarationData.Vehicle.ADAS.EcoRollWitoutEngineStop;
+		} }
+		public bool EcoRollWithEngineStop { get {
+			return ElementExists(XMLNames.Vehicle_ADAS)
+				? XmlConvert.ToBoolean(GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_EcoRollWithEngineStopStart)))
+				: DeclarationData.Vehicle.ADAS.EcoRollWithEngineStop;
+		} }
+
+		public PredictiveCruiseControlType PredictiveCruiseControl
+		{
+			get {
+				return ElementExists(XMLNames.Vehicle_ADAS)
+					? PredictiveCruiseControlTypeHelper.Parse(
+						GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_PCC)))
+					: DeclarationData.Vehicle.ADAS.PredictiveCruiseControlDefault;
+			}
+		}
+
+		#endregion
 	}
 }
diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs
index da1651a477..43ef2dd192 100644
--- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs
@@ -294,6 +294,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering
 		public bool VocationalVehicle { get { return false; } }
 		public bool SleeperCab { get { return true; } }
 		public NgTankSystem TankSystem { get; }
+		public IAdvancedDriverAssistantSystemDeclarationInputData ADAS { get { return null; } }
 		public bool ZeroEmissionVehicle { get { return false; } }
 		public bool HybridElectricHDV { get { return false; } }
 		public bool DualFuelVehicle { get { return false; } }
diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
index 82bfe4f136..428449cd28 100644
--- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
+++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
@@ -536,6 +536,13 @@ namespace TUGraz.VectoCore.Models.Declaration
 			public const NgTankSystem NgTankSystemDefault = NgTankSystem.Compressed;
 			public const bool SleeperCabDefault = true;
 			public const bool VocationalVehicleDefault = false;
+
+			public static class ADAS {
+				public const PredictiveCruiseControlType PredictiveCruiseControlDefault = PredictiveCruiseControlType.None;
+				public const bool EcoRollWithEngineStop = false;
+				public const bool EcoRollWitoutEngineStop = false;
+				public const bool EngineStopStartDefault = false;
+			}
 		}
 	}
 }
\ No newline at end of file
-- 
GitLab