From d0dfdb7143e002c9bbccb85bd7dfd58e9343f6f0 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Fri, 17 Apr 2020 14:13:01 +0200
Subject: [PATCH] work on creating MRF and CIF for completed buses

---
 .../Declaration/TyreDeclarationAdapter.cs     |   1 +
 .../InputData/DeclarationInputData.cs         |   2 +
 .../XMLDeclarationTyreDataProvider.cs         |  24 ++
 .../XMLEngineeringAxlesDataProvider.cs        |   3 +
 .../XMLTyreEngineeringDataProvider.cs         |   3 +
 .../VectoCore/InputData/Impl/InputData.cs     |   3 +-
 .../DeclarationDataAdapterHeavyLorry.cs       |   2 +
 .../EngineeringDataAdapter.cs                 |   1 +
 .../VectoCore/Models/Declaration/Axle.cs      |   3 +
 .../Models/Declaration/DeclarationData.cs     |   3 +-
 .../Simulation/Impl/SimulatorFactory.cs       |   2 +-
 .../OutputData/XML/XMLCustomerReport.cs       |  31 +-
 .../XML/XMLCustomerReportCompletedBus.cs      | 236 ++++++++++++++-
 .../XMLDeclarationReportCompletedVehicle.cs   |   8 +-
 .../XML/XMLManufacturerReportCompletedBus.cs  | 271 +++++++-----------
 VectoCore/VectoCore/Utils/XMLHelper.cs        |  10 +
 16 files changed, 410 insertions(+), 193 deletions(-)

diff --git a/VECTO3GUI/ViewModel/Adapter/Declaration/TyreDeclarationAdapter.cs b/VECTO3GUI/ViewModel/Adapter/Declaration/TyreDeclarationAdapter.cs
index 02d4bf77e1..319a1dac60 100644
--- a/VECTO3GUI/ViewModel/Adapter/Declaration/TyreDeclarationAdapter.cs
+++ b/VECTO3GUI/ViewModel/Adapter/Declaration/TyreDeclarationAdapter.cs
@@ -30,6 +30,7 @@ namespace VECTO3GUI.ViewModel.Impl {
 		public string Dimension { get { return ViewModel.Dimension; } }
 		public double RollResistanceCoefficient { get { return ViewModel.RollingResistanceCoefficient; } }
 		public Newton TyreTestLoad { get { return ViewModel.FzISO; } }
+		public string FuelEfficiencyClass { get; }
 
 		#endregion
 	}
diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs
index f8483fcb49..2736f510fb 100644
--- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs
+++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs
@@ -423,6 +423,8 @@ namespace TUGraz.VectoCommon.InputData
 		/// cf. VECTO Input Parameters.xlsx
 		/// </summary>
 		Newton TyreTestLoad { get; }
+
+		string FuelEfficiencyClass { get; }
 	}
 
 	public interface IGearboxDeclarationInputData : IComponentInputData
diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs
index 5686162397..7851c7b87e 100644
--- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs
@@ -4,6 +4,7 @@ using TUGraz.VectoCommon.InputData;
 using TUGraz.VectoCommon.Resources;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces;
+using TUGraz.VectoCore.Models.Declaration;
 using TUGraz.VectoCore.Utils;
 
 namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
@@ -55,6 +56,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
 			get { return _fzIso ?? (_fzIso = GetDouble(XMLNames.AxleWheels_Axles_Axle_FzISO).SI<Newton>()); }
 		}
 
+		public virtual string FuelEfficiencyClass { get { return DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); } }
+
 		#endregion
 	}
 
@@ -95,4 +98,25 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
 			get { return NAMESPACE_URI; }
 		}
 	}
+
+	// ---------------------------------------------------------------------------------------
+
+	public class XMLDeclarationTyreDataProviderV23 : XMLDeclarationTyreDataProviderV10
+	{
+		public new static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V23;
+
+		//public new const string XSD_TYPE = "TyreComponentDeclarationType";
+
+		public new static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE);
+
+		public XMLDeclarationTyreDataProviderV23(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile)
+			: base(vehicle, componentNode, sourceFile) { }
+
+		protected override XNamespace SchemaNamespace
+		{
+			get { return NAMESPACE_URI; }
+		}
+
+		public override string FuelEfficiencyClass { get { return GetString("FuelEfficiencyClass"); } }
+	}
 }
diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs
index 7524355109..cda8a6b376 100644
--- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringAxlesDataProvider.cs
@@ -8,6 +8,7 @@ using TUGraz.VectoCommon.Models;
 using TUGraz.VectoCommon.Resources;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Interfaces;
+using TUGraz.VectoCore.Models.Declaration;
 using TUGraz.VectoCore.Utils;
 
 namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider
@@ -154,6 +155,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider
 			get { return GetNode(XMLNames.AxleWheels_Axles_Axle_FzISO)?.InnerText.ToDouble().SI<Newton>(); }
 		}
 
+		public virtual string FuelEfficiencyClass { get { return DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); } }
+
 		#endregion
 
 		#region Implementation of ITyreEngineeringInputData
diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs
index bb98dc06d3..cb4a3349d2 100644
--- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLTyreEngineeringDataProvider.cs
@@ -4,6 +4,7 @@ using TUGraz.VectoCommon.InputData;
 using TUGraz.VectoCommon.Resources;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Interfaces;
+using TUGraz.VectoCore.Models.Declaration;
 using TUGraz.VectoCore.Utils;
 
 namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider
@@ -40,6 +41,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider
 			get { return GetNode(XMLNames.AxleWheels_Axles_Axle_FzISO, required: false)?.InnerText.ToDouble().SI<Newton>(); }
 		}
 
+		public virtual string FuelEfficiencyClass { get { return DeclarationData.Wheels.TyreClass.Lookup(RollResistanceCoefficient); } }
+
 		#endregion
 
 		#region Implementation of ITyreEngineeringInputData
diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs
index ae876007a7..9cbab67dcb 100644
--- a/VectoCore/VectoCore/InputData/Impl/InputData.cs
+++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs
@@ -148,10 +148,11 @@ namespace TUGraz.VectoCore.InputData.Impl
 		public double RollResistanceCoefficient { get; internal set; }
 
 		public Newton TyreTestLoad { get; internal set; }
+		public string FuelEfficiencyClass { get; internal set; }
 
 		public KilogramSquareMeter Inertia { get; internal set; }
 
-		public Meter DynamicTyreRadius { get; }
+		public Meter DynamicTyreRadius { get; internal set; }
 	}
 
 	public class AuxiliaryDataInputData : IAuxiliaryEngineeringInputData, IAuxiliaryDeclarationInputData
diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterHeavyLorry.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterHeavyLorry.cs
index 5dc4f6627c..c0b8a1ab25 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterHeavyLorry.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterHeavyLorry.cs
@@ -155,6 +155,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
 					TwinTyres = axleInput.TwinTyres,
 					RollResistanceCoefficient = axleInput.Tyre.RollResistanceCoefficient,
 					TyreTestLoad = axleInput.Tyre.TyreTestLoad,
+					FuelEfficiencyClass = axleInput.Tyre.FuelEfficiencyClass,
 					Inertia = DeclarationData.Wheels.Lookup(axleInput.Tyre.Dimension.RemoveWhitespace()).Inertia,
 					CertificationNumber = axleInput.Tyre.CertificationNumber,
 					DigestValueInput = axleInput.Tyre.DigestValue == null ? "" : axleInput.Tyre.DigestValue.DigestValue,
@@ -171,6 +172,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
 							TwinTyres = DeclarationData.Trailer.TwinTyres,
 							RollResistanceCoefficient = DeclarationData.Trailer.RollResistanceCoefficient,
 							TyreTestLoad = DeclarationData.Trailer.TyreTestLoad.SI<Newton>(),
+							FuelEfficiencyClass = DeclarationData.Trailer.FuelEfficiencyClass,
 							Inertia = trailerWheel.Inertia,
 							WheelsDimension = trailerWheel.WheelType
 						}));
diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
index 1c2a14aa6c..47e789a100 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
@@ -78,6 +78,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
 					RollResistanceCoefficient = axle.Tyre.RollResistanceCoefficient,
 					AxleWeightShare = axle.AxleWeightShare,
 					TyreTestLoad = axle.Tyre.TyreTestLoad,
+					FuelEfficiencyClass = axle.Tyre.FuelEfficiencyClass,
 					AxleType = axle.AxleType,
 
 					//Wheels = axle.WheelsStr
diff --git a/VectoCore/VectoCore/Models/Declaration/Axle.cs b/VectoCore/VectoCore/Models/Declaration/Axle.cs
index b329305389..88f73bee30 100644
--- a/VectoCore/VectoCore/Models/Declaration/Axle.cs
+++ b/VectoCore/VectoCore/Models/Declaration/Axle.cs
@@ -51,12 +51,15 @@ namespace TUGraz.VectoCore.Models.Declaration
 		[Required, SIRange(500, 100000)]
 		public Newton TyreTestLoad { get; internal set; }
 
+		public string FuelEfficiencyClass { get; internal set; }
+
 		[Required, SIRange(0, 1, ExecutionMode.Engineering), SIRange(double.MinValue, 1, ExecutionMode.Declaration)]
 		public double AxleWeightShare { get; internal set; }
 
 		public bool TwinTyres { get; internal set; }
 
 		public AxleType AxleType { get; internal set; }
+		
 
 		public static ValidationResult ValidateAxleData(Axle axle, ValidationContext validationContext)
 		{
diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
index 8e07346e6f..f33c9f979b 100644
--- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
+++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
@@ -367,7 +367,8 @@ namespace TUGraz.VectoCore.Models.Declaration
 
 		public static class Trailer
 		{
-			public static readonly double RollResistanceCoefficient = 0.0055;
+			public const double RollResistanceCoefficient = 0.0055;
+			public const string FuelEfficiencyClass = "X";
 			public const double TyreTestLoad = 37500;
 
 			public const bool TwinTyres = false;
diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs
index 5232565aff..bd0232a35b 100644
--- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs
+++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs
@@ -119,7 +119,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
 				switch (declDataProvider.JobInputData.Vehicle.VehicleCategory) {
 					case VehicleCategory.HeavyBusCompletedVehicle:
 						var reportCompleted = declarationReport ?? new XMLDeclarationReportCompletedVehicle(ModWriter, declDataProvider.JobInputData.Vehicle.VehicleCategory == VehicleCategory.HeavyBusPrimaryVehicle) {
-							PrimaryResults = declDataProvider.PrimaryVehicleData,
+							PrimaryVehicleReportInputData = declDataProvider.PrimaryVehicleData,
 						};
 						DataReader = new DeclarationModeCompletedBusVectoRunDataFactory(declDataProvider, reportCompleted);
 						return;
diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs
index 7b1b08743a..f6abd85ecd 100644
--- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs
+++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs
@@ -64,11 +64,11 @@ namespace TUGraz.VectoCore.OutputData.XML
 		protected readonly XNamespace di = XNamespace.Get("http://www.w3.org/2000/09/xmldsig#");
 		protected readonly XNamespace xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
 
-		private bool _allSuccess = true;
+		protected bool _allSuccess = true;
 
-		private KilogramPerMeter _weightedCo2 = 0.SI<KilogramPerMeter>();
+		protected KilogramPerMeter _weightedCo2 = 0.SI<KilogramPerMeter>();
 
-		private Kilogram _weightedPayload = 0.SI<Kilogram>();
+		protected Kilogram _weightedPayload = 0.SI<Kilogram>();
 
 
 		public XMLCustomerReport()
@@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 			Results = new XElement(tns + XMLNames.Report_Results);
 		}
 
-		public void Initialize(VectoRunData modelData, List<List<FuelData.Entry>> fuelModes)
+		public virtual void Initialize(VectoRunData modelData, List<List<FuelData.Entry>> fuelModes)
 		{
 			var exempted = modelData.Exempted;
 			VehiclePart.Add(
@@ -124,7 +124,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 			};
 		}
 
-		private XElement GetADAS(VehicleData.ADASData adasData)
+		protected XElement GetADAS(VehicleData.ADASData adasData)
 		{
 			return new XElement(tns + XMLNames.Vehicle_ADAS,
 								new XElement(tns + XMLNames.Vehicle_ADAS_EngineStopStart, adasData.EngineStopStart),
@@ -134,7 +134,7 @@ namespace TUGraz.VectoCore.OutputData.XML
 			);
 		}
 
-		private XElement[] ComponentData(VectoRunData modelData, List<List<FuelData.Entry>> fuelModes)
+		protected virtual XElement[] ComponentData(VectoRunData modelData, List<List<FuelData.Entry>> fuelModes)
 		{
 			return new[] {
 				new XElement(
@@ -143,8 +143,10 @@ namespace TUGraz.VectoCore.OutputData.XML
 				new XElement(
 					tns + XMLNames.Report_Vehicle_EngineDisplacement,
 					XMLHelper.ValueAsUnit(modelData.EngineData.Displacement, XMLNames.Unit_ltr, 1)),
-				new XElement(tns + XMLNames.Report_Vehicle_FuelTypes,  
-					fuelModes.SelectMany(x => x.Select(f =>  f.FuelType.ToXMLFormat())).Distinct().Select(x => new XElement(tns + XMLNames.Engine_FuelType, x))
+				new XElement(
+					tns + XMLNames.Report_Vehicle_FuelTypes,
+					fuelModes.SelectMany(x => x.Select(f => f.FuelType.ToXMLFormat())).Distinct()
+							.Select(x => new XElement(tns + XMLNames.Engine_FuelType, x))
 				),
 				new XElement(
 					tns + XMLNames.Report_Vehicle_TransmissionCertificationMethod,
@@ -155,10 +157,15 @@ namespace TUGraz.VectoCore.OutputData.XML
 				new XElement(tns + XMLNames.Report_Vehicle_AxleRatio, modelData.AxleGearData.AxleGear.Ratio.ToXMLFormat(3)),
 				new XElement(
 					tns + XMLNames.Report_Vehicle_AverageRRC, modelData.VehicleData.AverageRollingResistanceTruck.ToXMLFormat(4)),
-				new XElement(
-					tns + XMLNames.Report_Vehicle_AverageRRCLabel,
-					DeclarationData.Wheels.TyreClass.Lookup(modelData.VehicleData.AverageRollingResistanceTruck))
-			};
+
+				//new XElement(
+				//	tns + XMLNames.Report_Vehicle_AverageRRCLabel,
+				//	DeclarationData.Wheels.TyreClass.Lookup(modelData.VehicleData.AverageRollingResistanceTruck))
+			}.Concat(
+				modelData.VehicleData.AxleData.Where(x => x.AxleType != AxleType.Trailer).Select(
+					(x, idx) => new XElement(tns + "FuelEfficiencyLabelMotorVehicleTyre",
+					new XAttribute("axleNbr", idx+1),
+					x.FuelEfficiencyClass))).ToArray();
 
 		}
 
diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs
index 8a1857d5c7..9c7f0ad7e9 100644
--- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs
+++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReportCompletedBus.cs
@@ -1,19 +1,253 @@
 using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Xml.Linq;
+using TUGraz.VectoCommon.BusAuxiliaries;
 using TUGraz.VectoCommon.InputData;
+using TUGraz.VectoCommon.Models;
+using TUGraz.VectoCommon.Resources;
+using TUGraz.VectoCommon.Utils;
+using TUGraz.VectoCore.Models.Declaration;
+using TUGraz.VectoCore.Models.Simulation.Data;
+using TUGraz.VectoCore.Models.Simulation.Impl;
+using TUGraz.VectoCore.Utils;
 
 namespace TUGraz.VectoCore.OutputData.XML {
 	public class XMLCustomerReportCompletedBus : XMLCustomerReport
 	{
+		public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleRecordFile { get; set; }
+
+		public IVehicleDeclarationInputData PrimaryVehicle { get { return PrimaryVehicleRecordFile.Vehicle; } }
+
+		public override void Initialize(VectoRunData modelData, List<List<FuelData.Entry>> fuelModes)
+		{
+			VehiclePart.Add(
+				new XAttribute(xsi + "type", "VehicleCompletedBusType"),
+				new XElement(tns + XMLNames.Component_Model, modelData.VehicleData.ModelName),
+				new XElement(
+					tns + "PrimaryVehicle",
+					new XElement(tns + XMLNames.Component_Manufacturer, PrimaryVehicle.Manufacturer),
+					new XElement(tns + XMLNames.Component_ManufacturerAddress, PrimaryVehicle.ManufacturerAddress)
+				),
+				new XElement(
+					tns + "CompletedVehicle",
+
+					new XElement(tns + XMLNames.Component_Manufacturer, modelData.VehicleData.Manufacturer),
+					new XElement(tns + XMLNames.Component_ManufacturerAddress, modelData.VehicleData.ManufacturerAddress)
+				),
+
+				new XElement(tns + XMLNames.Vehicle_VIN, modelData.VehicleData.VIN),
+				new XElement(tns + "VehicleCategory", modelData.VehicleData.LegislativeClass.ToXMLFormat()),
+				new XElement(tns + XMLNames.Report_Vehicle_VehicleGroup, modelData.VehicleData.VehicleClass.GetClassNumber()),
+				new XElement(tns + XMLNames.Vehicle_RegisteredClass, modelData.VehicleData.RegisteredClass.ToXMLFormat()),
+				new XElement(tns + XMLNames.Vehicle_VehicleCode, modelData.VehicleData.VehicleCode.ToXMLFormat()),
+
+				new XElement(
+					tns + XMLNames.TPMLM,
+					XMLHelper.ValueAsUnit(modelData.VehicleData.GrossVehicleMass, XMLNames.Unit_t, 1)),
+				new XElement(
+					tns + XMLNames.Vehicle_CurbMassChassis, XMLHelper.ValueAsUnit(modelData.VehicleData.CurbMass, XMLNames.Unit_kg)),
+				new XElement(tns + XMLNames.Vehicle_ZeroEmissionVehicle, modelData.VehicleData.ZeroEmissionVehicle),
+				new XElement(tns + XMLNames.Vehicle_HybridElectricHDV, modelData.VehicleData.HybridElectricHDV),
+				new XElement(tns + XMLNames.Vehicle_DualFuelVehicle, modelData.VehicleData.DualFuelVehicle),
+
+				new XElement(tns + XMLNames.Vehicle_AxleConfiguration, modelData.VehicleData.AxleConfiguration.GetName()),
+				new XElement(tns + XMLNames.Vehicle_VocationalVehicle, modelData.VehicleData.VocationalVehicle),
+				new XElement(tns + XMLNames.Vehicle_SleeperCab, modelData.VehicleData.SleeperCab),
+				new XElement(
+					tns + "RegisteredPassengers",
+					new XElement(tns + XMLNames.Bus_LowerDeck, modelData.VehicleData.InputData.NumberOfPassengersLowerDeck),
+					new XElement(tns + XMLNames.Bus_UpperDeck, modelData.VehicleData.InputData.NumberOfPassengersUpperDeck)
+				),
+				new XElement(tns + XMLNames.Bus_LowEntry, modelData.VehicleData.InputData.FloorType == FloorType.LowFloor),
+				new XElement(tns + XMLNames.Bus_HeighIntegratedBody, modelData.VehicleData.InputData.Height.ToXMLFormat(3)),
+				new XElement(tns + XMLNames.Bus_VehicleLength, modelData.VehicleData.InputData.Length.ToXMLFormat(3)),
+				new XElement(tns + XMLNames.Bus_VehicleWidth, modelData.VehicleData.InputData.Width.ToXMLFormat(3)),
+				GetADAS(modelData.VehicleData.ADAS),
+				ComponentData(
+					modelData,
+					PrimaryVehicleRecordFile.ResultsInputData.Results
+											.Select(x => x.EnergyConsumption.Keys.Select(f => FuelData.Instance().Lookup(f)).ToList()).Distinct()
+											.ToList())
+			);
+			
+			InputDataIntegrity = new XElement(tns + XMLNames.Report_InputDataSignature,
+				modelData.InputDataHash == null ? XMLHelper.CreateDummySig(di) : new XElement(modelData.InputDataHash));
+		}
+
 		internal void WriteResult(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
 		{
+			_allSuccess &= genericResult.Status == VectoRun.Status.Success;
+			_allSuccess &= specificResult.Status == VectoRun.Status.Success;
+			Results.Add(
+				genericResult.Status == VectoRun.Status.Success && specificResult.Status == VectoRun.Status.Success
+					? GetSuccessResultEntry(genericResult, specificResult, primaryResult)
+					: GetErrorResultEntry(genericResult, specificResult, primaryResult));
+		}
+
+		private XElement GetErrorResultEntry(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
+		{
+
+			object[] content = null;
+			if (genericResult.Status == VectoRun.Status.Pending || genericResult.Status == VectoRun.Status.Running ||
+				specificResult.Status == VectoRun.Status.Pending || specificResult.Status == VectoRun.Status.Running) {
+				content = new object[] {
+					new XElement(
+						tns + XMLNames.Report_Results_Error,
+						string.Format("Simulation not finished! Status: {0} / {1}", genericResult.Status, specificResult.Status)),
+					new XElement(tns + XMLNames.Report_Results_ErrorDetails, ""),
+				}; // should not happen!
+			}
+
+			if (genericResult.Status == VectoRun.Status.Canceled || genericResult.Status == VectoRun.Status.Aborted || specificResult.Status == VectoRun.Status.Canceled || specificResult.Status == VectoRun.Status.Aborted) {
+				content = new object[] {
+					new XElement(tns + XMLNames.Report_Results_Error, genericResult.Error ?? "" + Environment.NewLine +  specificResult.Error ?? ""),
+					new XElement(tns + XMLNames.Report_Results_ErrorDetails, genericResult.StackTrace ?? "" + Environment.NewLine + specificResult.StackTrace ?? ""),
+				};
+			}
+
+			return new XElement(
+				tns + XMLNames.Report_Result_Result,
+				new XAttribute(XMLNames.Report_Result_Status_Attr, "error"),
+				new XAttribute(xsi + "type", "ResultErrorType"),
+				new XElement(tns + XMLNames.Report_Result_Mission, genericResult.Mission.ToXMLFormat()),
+				GetSimulationParameters(specificResult, primaryResult),
+				content);
+		}
+
+		private XElement GetSuccessResultEntry(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
+		{
+			return new XElement(
+				tns + XMLNames.Report_Result_Result,
+				new XAttribute(XMLNames.Report_Result_Status_Attr, "success"),
+				new XAttribute(xsi + "type", "ResultSuccessType"),
+				new XElement(tns + XMLNames.Report_Result_Mission, genericResult.Mission.ToXMLFormat()),
+				//new XElement(tns + XMLNames.Report_ResultEntry_Distance, XMLHelper.ValueAsUnit(specificResult.Distance, XMLNames.Unit_km, 3)),
+				GetSimulationParameters(specificResult, primaryResult),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_AverageSpeed,
+					XMLHelper.ValueAsUnit(specificResult.AverageSpeed, XMLNames.Unit_kmph, 1)),
+				GetFuelConsumptionResults(genericResult, specificResult, primaryResult)
+			);
+
+		}
+
+		protected virtual XElement[] GetSimulationParameters(XMLDeclarationReport.ResultEntry result, IResult primaryResult)
+		{
+			return new XElement[] {
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_TotalVehicleMass,
+					XMLHelper.ValueAsUnit(result.TotalVehicleMass, XMLNames.Unit_kg)),
+				new XElement(tns + XMLNames.Report_ResultEntry_Payload, XMLHelper.ValueAsUnit(result.Payload, XMLNames.Unit_kg)),
+				result.PassengerCount.HasValue && result.PassengerCount.Value > 0 ? new XElement(tns + "PassengerCount", result.PassengerCount.Value.ToMinSignificantDigits(3, 1)) : null,
+				new XElement(tns + XMLNames.Report_Result_FuelMode, primaryResult.SimulationParameter.FuelMode)
+			};
+		}
+
+		private XElement[] GetFuelConsumptionResults(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
+		{
+			var factor = specificResult.EnergyConsumptionTotal.Value() / genericResult.EnergyConsumptionTotal.Value();
+			var retVal = new List<XElement>();
+
+			var co2Sum = 0.SI<KilogramPerMeter>();
 			foreach (var entry in primaryResult.EnergyConsumption) {
-				// TODO!
+				var fcEnergy = entry.Value * factor;  // J/m
+				var fuelData = FuelData.Instance().Lookup(entry.Key);
+				var fcMass = fcEnergy / fuelData.LowerHeatingValueVecto; // kg/m
+				co2Sum += fcMass * fuelData.CO2PerFuelWeight;
+
+				var fcResult = new XElement(tns + XMLNames.Report_Results_Fuel, new XAttribute(XMLNames.Report_Results_Fuel_Type_Attr, fuelData.FuelType.ToXMLFormat()));
+				fcResult.Add(
+					new XElement(
+						tns + XMLNames.Report_Results_FuelConsumption,
+						new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/km"),
+						fcMass.ConvertToGrammPerKiloMeter().ToMinSignificantDigits(3, 1)),
+					new XElement(
+						tns + XMLNames.Report_Results_FuelConsumption,
+						new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/t-km"),
+						(fcMass / specificResult.Payload)
+						.ConvertToGrammPerTonKilometer().ToMinSignificantDigits(3, 1)),
+					specificResult.CargoVolume > 0
+						? new XElement(
+							tns + XMLNames.Report_Results_FuelConsumption,
+							new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/m³-km"),
+							(fcMass.ConvertToGrammPerKiloMeter() / specificResult.CargoVolume)
+							.Value().ToMinSignificantDigits(3, 1))
+						: null,
+					specificResult.PassengerCount.HasValue && specificResult.PassengerCount.Value > 0
+						? new XElement(
+							tns + XMLNames.Report_Results_FuelConsumption,
+							new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/p-km"),
+							(fcMass.ConvertToGrammPerKiloMeter() / specificResult.PassengerCount.Value).ToMinSignificantDigits(3, 1))
+						: null
+				);
+				if (fuelData.FuelDensity != null) {
+					fcResult.Add(
+						new XElement(
+							tns + XMLNames.Report_Results_FuelConsumption,
+							new XAttribute(XMLNames.Report_Results_Unit_Attr, "l/100km"),
+							(fcMass.ConvertToGrammPerKiloMeter() / fuelData.FuelDensity * 100).Value().ToMinSignificantDigits(3, 1)),
+						new XElement(
+							tns + XMLNames.Report_Results_FuelConsumption,
+							new XAttribute(XMLNames.Report_Results_Unit_Attr, "l/t-km"),
+							(fcMass.ConvertToGrammPerKiloMeter() / fuelData.FuelDensity /
+							specificResult.Payload.ConvertToTon()).Value().ToMinSignificantDigits(3, 1)));
+					if (specificResult.CargoVolume > 0) {
+						fcResult.Add(
+							new XElement(
+								tns + XMLNames.Report_Results_FuelConsumption,
+								new XAttribute(XMLNames.Report_Results_Unit_Attr, "l/m³-km"),
+								(fcMass.ConvertToGrammPerKiloMeter() / fuelData.FuelDensity /
+								specificResult.CargoVolume).Value().ToMinSignificantDigits(3, 1)));
+					}
+					if (specificResult.PassengerCount.HasValue && specificResult.PassengerCount.Value > 0) {
+						fcResult.Add(
+							new XElement(
+								tns + XMLNames.Report_Results_FuelConsumption,
+								new XAttribute(XMLNames.Report_Results_Unit_Attr, "l/p-km"),
+								(fcMass.ConvertToGrammPerKiloMeter() / fuelData.FuelDensity /
+								specificResult.PassengerCount.Value).Value().ToMinSignificantDigits(3, 1))
+						);
+					}
+				}
+				retVal.Add(fcResult);
+			}
+
+			//CO2
+			retVal.Add(
+				new XElement(
+					tns + XMLNames.Report_Results_CO2, new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/km"),
+					co2Sum.ConvertToGrammPerKiloMeter().ToMinSignificantDigits(3, 1)));
+			retVal.Add(
+				new XElement(
+					tns + XMLNames.Report_Results_CO2,
+					new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/t-km"),
+					(co2Sum.ConvertToGrammPerKiloMeter() / specificResult.Payload.ConvertToTon()).ToMinSignificantDigits(3, 1)));
+			if (specificResult.CargoVolume > 0)
+				retVal.Add(
+					new XElement(
+						tns + XMLNames.Report_Results_CO2,
+						new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/m³-km"),
+						(co2Sum.ConvertToGrammPerKiloMeter() / specificResult.CargoVolume).Value().ToMinSignificantDigits(3, 1)));
+			if (specificResult.PassengerCount.HasValue && specificResult.PassengerCount.Value > 0) {
+				retVal.Add(
+					new XElement(
+						tns + XMLNames.Report_Results_CO2,
+						new XAttribute(XMLNames.Report_Results_Unit_Attr, "g/p-km"),
+						(co2Sum.ConvertToGrammPerKiloMeter() / specificResult.PassengerCount.Value).ToMinSignificantDigits(3, 1)));
 			}
+
+			_weightedPayload += specificResult.Payload * specificResult.WeightingFactor;
+			_weightedCo2 += co2Sum * specificResult.WeightingFactor;
+
+			return retVal.ToArray();
 		}
 
 		public override void WriteResult(XMLDeclarationReport.ResultEntry resultEntry)
 		{
 			throw new NotSupportedException();
 		}
+
+		
 	}
 }
\ No newline at end of file
diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs
index 8dfefbbab4..3690a5b7fb 100644
--- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs
+++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportCompletedVehicle.cs
@@ -11,16 +11,18 @@ namespace TUGraz.VectoCore.OutputData.XML {
 	{
 		public XMLDeclarationReportCompletedVehicle(IReportWriter writer, bool writePIF = false) : base(writer) { }
 
-		public IPrimaryVehicleInformationInputDataProvider PrimaryResults { get; set; }
+		public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleReportInputData { get; set; }
 
 		#region Overrides of XMLDeclarationReport
 
 		protected override void InstantiateReports(VectoRunData modelData)
 		{
 			ManufacturerRpt = new XMLManufacturerReportCompletedBus() {
-				PrimaryVehicleRecordFile = PrimaryResults
+				PrimaryVehicleRecordFile = PrimaryVehicleReportInputData
+			};
+			CustomerRpt = new XMLCustomerReportCompletedBus() {
+				PrimaryVehicleRecordFile = PrimaryVehicleReportInputData
 			};
-			CustomerRpt = new XMLCustomerReportCompletedBus();
 		}
 
 		#endregion
diff --git a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs
index e690857fe3..d3cfc4fd06 100644
--- a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs
+++ b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReportCompletedBus.cs
@@ -37,13 +37,13 @@ namespace TUGraz.VectoCore.OutputData.XML {
 					new XElement(tns + XMLNames.Component_Manufacturer, modelData.VehicleData.Manufacturer),
 					new XElement(tns + XMLNames.Component_ManufacturerAddress, modelData.VehicleData.ManufacturerAddress),
 					new XElement(tns + XMLNames.Vehicle_VIN, modelData.VehicleData.VIN),
-					new XElement(tns + XMLNames.Vehicle_VehicleCategory, modelData.VehicleData.VehicleCategory.ToXMLFormat()),
+					new XElement(tns + XMLNames.Vehicle_VehicleCategory, modelData.VehicleData.LegislativeClass.ToXMLFormat()),
 					new XElement(tns + XMLNames.Report_Vehicle_VehicleGroup, modelData.VehicleData.VehicleClass.GetClassNumber()),
 					new XElement(tns + XMLNames.Vehicle_RegisteredClass, modelData.VehicleData.RegisteredClass.ToXMLFormat()),
 					new XElement(tns + XMLNames.Vehicle_VehicleCode, modelData.VehicleData.VehicleCode.ToXMLFormat()),
 					new XElement(tns + XMLNames.Vehicle_CurbMassChassis, XMLHelper.ValueAsUnit(modelData.VehicleData.CurbMass, XMLNames.Unit_kg)),
 					new XElement(tns + XMLNames.TPMLM,
-								XMLHelper.ValueAsUnit(modelData.VehicleData.GrossVehicleMass, XMLNames.Unit_t, 1)),
+								XMLHelper.ValueAsUnit(modelData.VehicleData.GrossVehicleMass, XMLNames.Unit_t, 2)),
 					new XElement(tns + XMLNames.Vehicle_VocationalVehicle, modelData.VehicleData.ZeroEmissionVehicle),
 					new XElement(tns + XMLNames.Vehicle_ZeroEmissionVehicle, modelData.VehicleData.ZeroEmissionVehicle),
 					new XElement(tns + XMLNames.Vehicle_HybridElectricHDV, modelData.VehicleData.HybridElectricHDV),
@@ -60,11 +60,10 @@ namespace TUGraz.VectoCore.OutputData.XML {
 					new XElement(tns + XMLNames.Bus_VehicleWidth, modelData.VehicleData.InputData.Width.ToXMLFormat(3)),
 					new XElement(tns + XMLNames.BusAux_PneumaticSystem_DoorDriveTechnology, modelData.VehicleData.InputData.DoorDriveTechnology.ToXMLFormat()),
 					
-					VehicleComponents(modelData, fuelModes)
+					VehicleComponents(modelData, fuelModes),
+					GetInputDataSignature(modelData)
 				)
 			);
-
-			InputDataIntegrity = GetInputDataSignature(modelData);
 		}
 
 		private XElement GetPrimaryVehicleInformation()
@@ -86,21 +85,18 @@ namespace TUGraz.VectoCore.OutputData.XML {
 			_allSuccess &= genericResult.Status == VectoRun.Status.Success;
 			_allSuccess &= specificResult.Status == VectoRun.Status.Success;
 			Results.Add(
-				new XElement(
-					tns + XMLNames.Report_Result_Result,
-					new XAttribute(
-						XMLNames.Report_Result_Status_Attr,
-						genericResult.Status == VectoRun.Status.Success && specificResult.Status == VectoRun.Status.Success ? "success" : "error"),
-					new XElement(tns + XMLNames.Report_Result_Mission, genericResult.Mission.ToXMLFormat()),
-					GetResults(genericResult, specificResult, primaryResult)));
+				genericResult.Status == VectoRun.Status.Success && specificResult.Status == VectoRun.Status.Success
+					? GetSuccessResultEntry(genericResult, specificResult, primaryResult)
+					: GetErrorResultEntry(genericResult, specificResult, primaryResult));
 		}
 
-		private object GetResults(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
+		private XElement GetErrorResultEntry(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
 		{
+
+			object[] content = null;
 			if (genericResult.Status == VectoRun.Status.Pending || genericResult.Status == VectoRun.Status.Running ||
 				specificResult.Status == VectoRun.Status.Pending || specificResult.Status == VectoRun.Status.Running) {
-				return new object[] {
-					GetSimulationParameters(specificResult),
+				content =  new object[] {
 					new XElement(
 						tns + XMLNames.Report_Results_Error,
 						string.Format("Simulation not finished! Status: {0} / {1}", genericResult.Status, specificResult.Status)),
@@ -109,72 +105,105 @@ namespace TUGraz.VectoCore.OutputData.XML {
 			}
 
 			if (genericResult.Status == VectoRun.Status.Canceled || genericResult.Status == VectoRun.Status.Aborted || specificResult.Status == VectoRun.Status.Canceled || specificResult.Status == VectoRun.Status.Aborted) {
-				return new object[] {
-					GetSimulationParameters(specificResult),
+				content = new object[] {
 					new XElement(tns + XMLNames.Report_Results_Error, genericResult.Error ?? "" + Environment.NewLine +  specificResult.Error ?? ""),
 					new XElement(tns + XMLNames.Report_Results_ErrorDetails, genericResult.StackTrace ?? "" + Environment.NewLine + specificResult.StackTrace ?? ""),
 				};
 			}
 
-			if (genericResult.Status == VectoRun.Status.Success && specificResult.Status == VectoRun.Status.Success) {
-				return GetSuccessResultEntry(genericResult, specificResult, primaryResult);
-			}
-			throw new ArgumentOutOfRangeException();
+			return new XElement(
+				tns + XMLNames.Report_Result_Result,
+				new XAttribute(XMLNames.Report_Result_Status_Attr, "error"),
+				new XAttribute(xsi + "type", "ResultErrorType"),
+				new XElement(tns + XMLNames.Report_Result_Mission, genericResult.Mission.ToXMLFormat()),
+				GetSimulationParameters(specificResult),
+				content);
 		}
 
-		private object GetSuccessResultEntry(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
+		private XElement GetSuccessResultEntry(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
 		{
-			return new object[] {
-				new XElement(
-					tns + XMLNames.Report_ResultEntry_Distance, new XAttribute(XMLNames.Report_Results_Unit_Attr, XMLNames.Unit_km),
-					specificResult.Distance.ConvertToKiloMeter().ToXMLFormat(3)),
+			return new XElement(
+				tns + XMLNames.Report_Result_Result,
+				new XAttribute(XMLNames.Report_Result_Status_Attr, "success"),
+				new XAttribute(xsi + "type", "ResultCompletedVehicleSuccessType"),
+				new XElement(tns + XMLNames.Report_Result_Mission, genericResult.Mission.ToXMLFormat()),
+				new XElement(tns + XMLNames.Report_ResultEntry_Distance, XMLHelper.ValueAsUnit(specificResult.Distance, XMLNames.Unit_km, 3)),
+				GetSimulationParametersPrimaryVehicle(primaryResult),
 				GetSimulationParameters(specificResult),
+				GetVehiclePerformanceResults(specificResult),
+				GetFuelConsumptionResults(genericResult, specificResult, primaryResult)
+			);
+
+		}
+
+		private XElement GetVehiclePerformanceResults(XMLDeclarationReport.ResultEntry specificResult)
+		{
+			return new XElement(
+				tns + XMLNames.Report_ResultEntry_VehiclePerformance,
 				new XElement(
-					tns + XMLNames.Report_ResultEntry_VehiclePerformance,
-					new XElement(
-						tns + XMLNames.Report_ResultEntry_AverageSpeed,
-						XMLHelper.ValueAsUnit(specificResult.AverageSpeed, XMLNames.Unit_kmph, 1)),
-					new XElement(
-						tns + XMLNames.Report_ResultEntry_AvgDrivingSpeed,
-						XMLHelper.ValueAsUnit(specificResult.AverageDrivingSpeed, XMLNames.Unit_kmph, 1)),
-					new XElement(
-						tns + XMLNames.Report_ResultEntry_MinSpeed, XMLHelper.ValueAsUnit(specificResult.MinSpeed, XMLNames.Unit_kmph, 1)),
-					new XElement(
-						tns + XMLNames.Report_ResultEntry_MaxSpeed, XMLHelper.ValueAsUnit(specificResult.MaxSpeed, XMLNames.Unit_kmph, 1)),
-					new XElement(
-						tns + XMLNames.Report_ResultEntry_MaxDeceleration,
-						XMLHelper.ValueAsUnit(specificResult.MaxDeceleration, XMLNames.Unit_mps2, 2)),
-					new XElement(
-						tns + XMLNames.Report_ResultEntry_MaxAcceleration,
-						XMLHelper.ValueAsUnit(specificResult.MaxAcceleration, XMLNames.Unit_mps2, 2)),
-					new XElement(
-						tns + XMLNames.Report_ResultEntry_FullLoadDrivingtimePercentage,
-						specificResult.FullLoadPercentage.ToXMLFormat(2)),
-					new XElement(tns + XMLNames.Report_ResultEntry_GearshiftCount, specificResult.GearshiftCount.ToXMLFormat(0)),
+					tns + XMLNames.Report_ResultEntry_AverageSpeed,
+					XMLHelper.ValueAsUnit(specificResult.AverageSpeed, XMLNames.Unit_kmph, 1)),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_AvgDrivingSpeed,
+					XMLHelper.ValueAsUnit(specificResult.AverageDrivingSpeed, XMLNames.Unit_kmph, 1)),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_MinSpeed, XMLHelper.ValueAsUnit(specificResult.MinSpeed, XMLNames.Unit_kmph, 1)),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_MaxSpeed, XMLHelper.ValueAsUnit(specificResult.MaxSpeed, XMLNames.Unit_kmph, 1)),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_MaxDeceleration,
+					XMLHelper.ValueAsUnit(specificResult.MaxDeceleration, XMLNames.Unit_mps2, 2)),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_MaxAcceleration,
+					XMLHelper.ValueAsUnit(specificResult.MaxAcceleration, XMLNames.Unit_mps2, 2)),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_FullLoadDrivingtimePercentage,
+					specificResult.FullLoadPercentage.ToXMLFormat(2)),
+				new XElement(tns + XMLNames.Report_ResultEntry_GearshiftCount, specificResult.GearshiftCount.ToXMLFormat(0)),
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_EngineSpeedDriving,
 					new XElement(
-						tns + XMLNames.Report_ResultEntry_EngineSpeedDriving,
-						new XElement(
-							tns + XMLNames.Report_ResultEntry_EngineSpeedDriving_Min,
-							XMLHelper.ValueAsUnit(specificResult.EngineSpeedDrivingMin, XMLNames.Unit_RPM, 1)),
-						new XElement(
-							tns + XMLNames.Report_ResultEntry_EngineSpeedDriving_Avg,
-							XMLHelper.ValueAsUnit(specificResult.EngineSpeedDrivingAvg, XMLNames.Unit_RPM, 1)),
-						new XElement(
-							tns + XMLNames.Report_ResultEntry_EngineSpeedDriving_Max,
-							XMLHelper.ValueAsUnit(specificResult.EngineSpeedDrivingMax, XMLNames.Unit_RPM, 1))
-					),
+						tns + XMLNames.Report_ResultEntry_EngineSpeedDriving_Min,
+						XMLHelper.ValueAsUnit(specificResult.EngineSpeedDrivingMin, XMLNames.Unit_RPM, 1)),
 					new XElement(
-						tns + XMLNames.Report_Results_AverageGearboxEfficiency,
-						XMLHelper.ValueAsUnit(specificResult.AverageGearboxEfficiency, XMLNames.UnitPercent, 2)),
+						tns + XMLNames.Report_ResultEntry_EngineSpeedDriving_Avg,
+						XMLHelper.ValueAsUnit(specificResult.EngineSpeedDrivingAvg, XMLNames.Unit_RPM, 1)),
 					new XElement(
-						tns + XMLNames.Report_Results_AverageAxlegearEfficiency,
-						XMLHelper.ValueAsUnit(specificResult.AverageAxlegearEfficiency, XMLNames.UnitPercent, 2))
+						tns + XMLNames.Report_ResultEntry_EngineSpeedDriving_Max,
+						XMLHelper.ValueAsUnit(specificResult.EngineSpeedDrivingMax, XMLNames.Unit_RPM, 1))
 				),
+				new XElement(
+					tns + XMLNames.Report_Results_AverageGearboxEfficiency,
+					XMLHelper.ValueAsUnit(specificResult.AverageGearboxEfficiency, XMLNames.UnitPercent, 2)),
+				new XElement(
+					tns + XMLNames.Report_Results_AverageAxlegearEfficiency,
+					XMLHelper.ValueAsUnit(specificResult.AverageAxlegearEfficiency, XMLNames.UnitPercent, 2))
+			);
+		}
 
-				//FC
-				GetFuelConsumptionResults(genericResult, specificResult, primaryResult)
-			};
+		private XElement GetSimulationParametersPrimaryVehicle(IResult primaryResult)
+		{
+			return new XElement(
+				tns + "SimulationParametersPrimaryVehicle",
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_TotalVehicleMass,
+					XMLHelper.ValueAsUnit(primaryResult.SimulationParameter.TotalVehicleMass, XMLNames.Unit_kg)),
+				new XElement(tns + XMLNames.Report_ResultEntry_Payload, XMLHelper.ValueAsUnit(primaryResult.SimulationParameter.Payload, XMLNames.Unit_kg)),
+				new XElement(tns + "PassengerCount", primaryResult.SimulationParameter.PassengerCount.ToMinSignificantDigits(3, 1)),
+				new XElement(tns + XMLNames.Report_Result_FuelMode, primaryResult.SimulationParameter.FuelMode)
+			);
+		}
 
+		protected override XElement GetSimulationParameters(XMLDeclarationReport.ResultEntry result)
+		{
+			return new XElement(
+				tns + "SimulationParametersCompletedVehicle",
+				new XElement(
+					tns + XMLNames.Report_ResultEntry_TotalVehicleMass,
+					XMLHelper.ValueAsUnit(result.TotalVehicleMass, XMLNames.Unit_kg)),
+				new XElement(tns + XMLNames.Report_ResultEntry_Payload, XMLHelper.ValueAsUnit(result.Payload, XMLNames.Unit_kg)),
+				result.PassengerCount.HasValue && result.PassengerCount.Value > 0 ? new XElement(tns + "PassengerCount", result.PassengerCount.Value.ToMinSignificantDigits(3, 1)) : null
+			);
 		}
 
 		private XElement[] GetFuelConsumptionResults(XMLDeclarationReport.ResultEntry genericResult, XMLDeclarationReport.ResultEntry specificResult, IResult primaryResult)
@@ -183,7 +212,7 @@ namespace TUGraz.VectoCore.OutputData.XML {
 			var retVal = new List<XElement>();
 
 			var co2Sum = 0.SI<KilogramPerMeter>();
-
+			retVal.Add(new XElement(tns + "FuelConsumptionFactor", factor.ToMinSignificantDigits(4)));
 			foreach (var entry in primaryResult.EnergyConsumption) {
 				var fcEnergy = entry.Value * factor;  // J/m
 				var fuelData = FuelData.Instance().Lookup(entry.Key);
@@ -305,94 +334,7 @@ namespace TUGraz.VectoCore.OutputData.XML {
 			);
 		}
 
-		//protected override XElement GetEngineDescription(CombustionEngineData engineData, List<List<FuelData.Entry>> fuelModes)
-		//{
-		//	return new XElement(
-		//		tns + XMLNames.Component_Engine,
-		//		GetCommonDescription(PrimaryVehicle.Components.EngineInputData),
-		//		new XElement(
-		//			tns + XMLNames.Engine_RatedPower, XMLHelper.ValueAsUnit(engineData.RatedPowerDeclared, XMLNames.Unit_kW)),
-		//		new XElement(tns + XMLNames.Engine_IdlingSpeed, XMLHelper.ValueAsUnit(engineData.IdleSpeed, XMLNames.Unit_RPM)),
-		//		new XElement(
-		//			tns + XMLNames.Engine_RatedSpeed, XMLHelper.ValueAsUnit(engineData.RatedSpeedDeclared, XMLNames.Unit_RPM)),
-		//		new XElement(
-		//			tns + XMLNames.Engine_Displacement, XMLHelper.ValueAsUnit(engineData.Displacement, XMLNames.Unit_ltr, 1)),
-		//		new XElement(tns + XMLNames.Engine_WHRType, engineData.WHRType.ToXMLFormat()),
-		//		PrimaryVehicle.Components.EngineInputData.EngineModes.Select(
-		//			x => new XElement(
-		//				tns + XMLNames.Report_Engine_FuelMode,
-		//				x.Fuels.Select(f => new XElement(tns + XMLNames.Engine_FuelType, f.FuelType.ToXMLFormat()))))
-		//	);
-		//}
-
-		//protected override XElement GetGearboxDescription(GearboxData gearboxData)
-		//{
-		//	return new XElement(
-		//		tns + XMLNames.Component_Gearbox,
-		//		GetCommonDescription(PrimaryVehicle.Components.GearboxInputData),
-		//		new XElement(tns + XMLNames.Gearbox_TransmissionType, gearboxData.Type.ToXMLFormat()),
-		//		new XElement(tns + XMLNames.Report_GetGearbox_GearsCount, gearboxData.Gears.Count),
-		//		new XElement(
-		//			tns + XMLNames.Report_Gearbox_TransmissionRatioFinalGear,
-		//			gearboxData.Gears[gearboxData.Gears.Keys.Max()].Ratio.ToXMLFormat(3))
-		//	);
-		//}
-
-		//protected override XElement GetGearboxDescription(GearboxData gearboxData, AxleGearData axlegearData)
-		//{
-		//	return new XElement(
-		//		tns + XMLNames.Component_Gearbox,
-		//		GetCommonDescription(PrimaryVehicle.Components.GearboxInputData),
-		//		new XElement(tns + XMLNames.Gearbox_TransmissionType, gearboxData.Type.ToXMLFormat()),
-		//		new XElement(tns + XMLNames.Report_GetGearbox_GearsCount, gearboxData.Gears.Count),
-		//		new XElement(tns + XMLNames.Gearbox_AxlegearRatio, axlegearData.AxleGear.Ratio.ToXMLFormat(3)),
-		//		new XElement(
-		//			tns + XMLNames.Report_Gearbox_TransmissionRatioFinalGear,
-		//			gearboxData.Gears[gearboxData.Gears.Keys.Max()].Ratio.ToXMLFormat(3))
-		//	);
-		//}
-
-
-		//protected override XElement GetTorqueConverterDescription(TorqueConverterData torqueConverterData)
-		//{
-		//	if (torqueConverterData == null) {
-		//		return null;
-		//	}
-
-		//	return new XElement(
-		//		tns + XMLNames.Component_TorqueConverter,
-		//		GetCommonDescription(PrimaryVehicle.Components.TorqueConverterInputData));
-		//}
-
-		//protected override XElement GetRetarderDescription(RetarderData retarder)
-		//{
-		//	return new XElement(
-		//		tns + XMLNames.Component_Retarder,
-		//		new XElement(tns + XMLNames.Vehicle_RetarderType, retarder.Type.ToXMLFormat())
-		//		//retarder.Type.IsDedicatedComponent() ? GetCommonDescription(PrimaryVehicle.Components.RetarderInputData) : null
-		//		);
-		//}
-
-		//protected override XElement GetAngledriveDescription(AngledriveData angledriveData)
-		//{
-		//	if (angledriveData == null) {
-		//		return null;
-		//	}
-
-		//	return new XElement(
-		//		tns + XMLNames.Component_Angledrive,
-		//		GetCommonDescription(PrimaryVehicle.Components.AngledriveInputData),
-		//		new XElement(tns + XMLNames.AngleDrive_Ratio, angledriveData.Angledrive.Ratio.ToXMLFormat(3)));
-		//}
-
-		//protected override XElement GetAxlegearDescription(AxleGearData axleGearData)
-		//{
-		//	return new XElement(
-		//		tns + XMLNames.Component_Axlegear,
-		//		GetCommonDescription(PrimaryVehicle.Components.AxleGearInputData),
-		//		new XElement(tns + XMLNames.Axlegear_LineType, axleGearData.LineType.ToXMLFormat()),
-		//		new XElement(tns + XMLNames.Axlegear_Ratio, axleGearData.AxleGear.Ratio.ToXMLFormat(3)));
-		//}
+		
 
 		protected override XElement GetAirDragDescription(AirdragData airdragData)
 		{
@@ -428,26 +370,7 @@ namespace TUGraz.VectoCore.OutputData.XML {
 			);
 		}
 
-		//protected virtual object[] GetCommonDescription(IEngineDeclarationInputData data)
-		//{
-		//	return new object[] {
-		//		new XElement(tns + XMLNames.Component_Model, data.Model),
-		//		new XElement(tns + XMLNames.Report_Component_CertificationNumber, data.CertificationNumber),
-		//		new XElement(tns + XMLNames.DI_Signature_Reference_DigestValue, data.DigestValue.DigestValue)
-		//	};
-		//}
-
-		//protected virtual object[] GetCommonDescription(IComponentInputData data)
-		//{
-		//	return new object[] {
-		//		new XElement(tns + XMLNames.Component_Model, data.Model),
-		//		new XElement(tns + XMLNames.Report_Component_CertificationMethod, data.CertificationMethod.ToXMLFormat()),
-		//		data.CertificationMethod == CertificationMethod.StandardValues
-		//			? null
-		//			: new XElement(tns + XMLNames.Report_Component_CertificationNumber, data.CertificationNumber),
-		//		new XElement(tns + XMLNames.DI_Signature_Reference_DigestValue, data.DigestValue.DigestValue)
-		//	};
-		//}
+		
 		#endregion
 
 		public override void WriteResult(XMLDeclarationReport.ResultEntry resultEntry)
diff --git a/VectoCore/VectoCore/Utils/XMLHelper.cs b/VectoCore/VectoCore/Utils/XMLHelper.cs
index d0605f5f8c..0adc70f421 100644
--- a/VectoCore/VectoCore/Utils/XMLHelper.cs
+++ b/VectoCore/VectoCore/Utils/XMLHelper.cs
@@ -134,6 +134,16 @@ namespace TUGraz.VectoCore.Utils
 			throw new NotImplementedException(string.Format("unknown unit '{0}'", unit));
 		}
 
+		public static object[] ValueAsUnit(Meter m, string unit, uint? decimals)
+		{
+			switch (unit) {
+				case "m": return GetValueAsUnit(m.Value(), unit, decimals);
+				case "km": return GetValueAsUnit(m.ConvertToKiloMeter(), unit, decimals);
+			}
+
+			throw new NotImplementedException(string.Format("unknown unit '{0}'", unit));
+		}
+
 		public static object[] ValueAsUnit(double value, string unit, uint? decimals)
 		{
 			switch (unit) {
-- 
GitLab