From 0a5c091cb06659af173e4bb7fdf16096a898152d Mon Sep 17 00:00:00 2001
From: "VKMTHD\\franzjosefkober" <franz.josef.kober@ivt.tugraz.at>
Date: Wed, 6 Jul 2022 11:17:57 +0200
Subject: [PATCH] added electric machnie system types

---
 .../VIFElectricMachineSystemMeasuredType.cs   | 112 ++++++++++++++++--
 .../IVIFReportFactory.cs                      |   4 +-
 .../VIFNinjectModule.cs                       |   6 +
 3 files changed, 109 insertions(+), 13 deletions(-)

diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/Components/VIFElectricMachineSystemMeasuredType.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/Components/VIFElectricMachineSystemMeasuredType.cs
index 66afcb4734..93b48eb332 100644
--- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/Components/VIFElectricMachineSystemMeasuredType.cs
+++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/Components/VIFElectricMachineSystemMeasuredType.cs
@@ -18,25 +18,24 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
 
 	public class XmlElectricMachineSystemMeasuredType : AbstractVIFXmlType, IXmlElectricMachineSystemType
 	{
-		public XmlElectricMachineSystemMeasuredType(IVIFReportFactory vifFactory) : base(vifFactory) { }
+		public string XmlTypeAttributeName { get; set; }
+
+		public XmlElectricMachineSystemMeasuredType(IVIFReportFactory vifFactory) : base(vifFactory)
+		{
+			XmlTypeAttributeName = "ElectricMachineSystemMeasuredDataDeclarationType";
+		}
 
 		#region Implementation of IVIFElectricMachineSystemType
 
-		public XElement GetElement(IElectricMotorDeclarationInputData em)
+		public virtual XElement GetElement(IElectricMotorDeclarationInputData em)
 		{
 			return new XElement(_vif + XMLNames.ElectricMachineSystem,
 				new XElement(_vif + XMLNames.ComponentDataWrapper,
-					new XAttribute(_xsi + "type", "vif:ElectricMachineSystemMeasuredDataDeclarationType"),
+					new XAttribute(_xsi + "type", $"vif:{XmlTypeAttributeName}"),
 					new XAttribute("id", em.DigestValue.Reference),
-					new XElement(_vif + XMLNames.Component_Manufacturer, em.Manufacturer),
-					new XElement(_vif + XMLNames.Component_Model, em.Model),
-					new XElement(_vif + XMLNames.Component_CertificationNumber, em.CertificationNumber),
-					new XElement(_vif + XMLNames.Component_Date, XmlConvert.ToString(em.Date, XmlDateTimeSerializationMode.Utc)),
-					new XElement(_vif + XMLNames.Component_AppVersion, em.AppVersion),
-					new XElement(_vif + XMLNames.ElectricMachine_ElectricMachineType, em.ElectricMachineType.ToString()),
+					GetElectricMachineSystemCommon(em),
 					new XElement(_vif + XMLNames.Component_CertificationMethod, em.CertificationMethod.ToXMLFormat()),
-					new XElement(_vif + XMLNames.ElectricMachine_R85RatedPower, em.R85RatedPower.ToXMLFormat()),
-					new XElement(_vif + XMLNames.ElectricMachine_RotationalInertia, em.Inertia.ToXMLFormat(2)),
+					GetElectricMachineSystemPowerRange(em),
 					new XElement(_vif + XMLNames.ElectricMachine_DcDcConverterIncluded, em.DcDcConverterIncluded),
 					new XElement(_vif + XMLNames.ElectricMachine_IHPCType, em.IHPCType),
 					GetVoltageLevels(em.VoltageLevels),
@@ -49,7 +48,29 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
 		
 		#endregion
 
-		
+		protected virtual List<XElement> GetElectricMachineSystemCommon(IElectricMotorDeclarationInputData em)
+		{
+			return new List<XElement> {
+				new XElement(_vif + XMLNames.Component_Manufacturer, em.Manufacturer),
+				new XElement(_vif + XMLNames.Component_Model, em.Model),
+				new XElement(_vif + XMLNames.Component_CertificationNumber, em.CertificationNumber),
+				new XElement(_vif + XMLNames.Component_Date,
+					XmlConvert.ToString(em.Date, XmlDateTimeSerializationMode.Utc)),
+				new XElement(_vif + XMLNames.Component_AppVersion, em.AppVersion),
+				new XElement(_vif + XMLNames.ElectricMachine_ElectricMachineType, em.ElectricMachineType.ToString()),
+			};
+		}
+
+		protected virtual List<XElement> GetElectricMachineSystemPowerRange(IElectricMotorDeclarationInputData em)
+		{
+			return new List<XElement> {
+				new XElement(_vif + XMLNames.ElectricMachine_R85RatedPower, em.R85RatedPower.ToXMLFormat()),
+				new XElement(_vif + XMLNames.ElectricMachine_RotationalInertia, em.Inertia.ToXMLFormat(2))
+			};
+		}
+
+
+
 		protected virtual List<XElement> GetVoltageLevels(IList<IElectricMotorVoltageLevel> voltageLevels)
 		{
 			var result = new List<XElement>();
@@ -167,4 +188,71 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
 			return new XElement(_vif + XMLNames.Conditioning, entries);
 		}
 	}
+
+
+	public class XmlElectricMachineSystemIHPCMeasuredType :  XmlElectricMachineSystemMeasuredType
+	{
+		public XmlElectricMachineSystemIHPCMeasuredType(IVIFReportFactory vifFactory) : base(vifFactory)
+		{
+			XmlTypeAttributeName = "ElectricMachineSystemIHPCMeasuredDataDeclarationType";
+		}
+	}
+
+
+	public class XmlElectricMachineSystemStandardValueType : XmlElectricMachineSystemMeasuredType
+	{
+		public XmlElectricMachineSystemStandardValueType(IVIFReportFactory vifFactory) : base(vifFactory)
+		{
+			XmlTypeAttributeName = "ElectricMachineSystemStandardValuesDataDeclarationType";
+		}
+		
+		#region Overrides of XmlElectricMachineSystemMeasuredType
+
+		public override XElement GetElement(IElectricMotorDeclarationInputData em)
+		{
+			return new XElement(_vif + XMLNames.ElectricMachineSystem,
+				new XElement(_vif + XMLNames.ComponentDataWrapper,
+					new XAttribute(_xsi + "type", $"vif:{XmlTypeAttributeName}"),
+					new XAttribute("id", em.DigestValue.Reference),
+					GetElectricMachineSystemCommon(em),
+					new XElement(_vif + XMLNames.Component_CertificationMethod, em.CertificationMethod.ToXMLFormat()),
+					GetElectricMachineSystemPowerRange(em),
+					new XElement(_vif + XMLNames.ElectricMachine_DcDcConverterIncluded, em.DcDcConverterIncluded),
+					new XElement(_vif + XMLNames.ElectricMachine_IHPCType, em.IHPCType),
+					GetVoltageLevels(em.VoltageLevels),
+					GetDragCurve(em.DragCurve)
+				),
+				GetSignature(em.DigestValue)
+			);
+		}
+
+		#endregion
+
+		#region Overrides of XmlElectricMachineSystemMeasuredType
+
+		protected override List<XElement> GetVoltageLevels(IList<IElectricMotorVoltageLevel> voltageLevels)
+		{
+			var result = new List<XElement>();
+
+			foreach (var voltageLevel in voltageLevels)
+			{
+
+				var entry = new XElement(_vif + XMLNames.ElectricMachine_VoltageLevel,
+					new XElement(_vif + XMLNames.ElectricMachine_ContinuousTorque, voltageLevel.ContinuousTorque.ToXMLFormat(2)),
+					new XElement(_vif + XMLNames.ElectricMachine_TestSpeedContinuousTorque, voltageLevel.ContinuousTorqueSpeed.ToXMLFormat(2)),
+					new XElement(_vif + XMLNames.ElectricMachine_OverloadTorque, voltageLevel.OverloadTorque.ToXMLFormat(2)),
+					new XElement(_vif + XMLNames.ElectricMachine_TestSpeedOverloadTorque, voltageLevel.OverloadTestSpeed.ToXMLFormat(2)),
+					new XElement(_vif + XMLNames.ElectricMachine_OverloadDuration, voltageLevel.OverloadTime.ToXMLFormat(2)),
+					GetMaxTorqueCurve(voltageLevel.FullLoadCurve),
+					GetPowerMap(voltageLevel.PowerMap)
+
+				);
+				result.Add(entry);
+			}
+
+			return result;
+		}
+
+		#endregion
+	}
 }
diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/IVIFReportFactory.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/IVIFReportFactory.cs
index a21a649811..6d4879cf5f 100644
--- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/IVIFReportFactory.cs
+++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/IVIFReportFactory.cs
@@ -41,7 +41,9 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
 		IXmlTypeWriter GetBoostingLimitationsType();
 		IXmlTypeWriter GetElectricEnergyStorageType();
 		IXmlTypeWriter GetElectricMachineGENType();
-		IVIFElectricMachineSystemType GetElectricMachineSystemMeasuredType();
+		IXmlElectricMachineSystemType GetElectricMachineSystemMeasuredType();
+		IXmlElectricMachineSystemType GetElectricMachineSystemIHPCMeasuredType();
+		IXmlElectricMachineSystemType GetElectricMachineSystemStandardValueType();
 		IXmlTypeWriter GetElectricMotorTorqueLimitsType();
 		IXmlTypeWriter GetEngineType();
 		IXmlTypeWriter GetTorqueConvertType();
diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs
index 0d3e4ada44..a7ef0afa3b 100644
--- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs
+++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/VehicleInformationFile/VehicleInformationFile_0_1/VIFNinjectModule.cs
@@ -106,6 +106,12 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
 			Bind<IXmlElectricMachineSystemType>().To<XmlElectricMachineSystemMeasuredType>().When(AccessedViaVIFFactory)
 				.NamedLikeFactoryMethod((IVIFReportFactory f) => f.GetElectricMachineSystemMeasuredType());
 
+			Bind<IXmlElectricMachineSystemType>().To<XmlElectricMachineSystemIHPCMeasuredType>().When(AccessedViaVIFFactory)
+				.NamedLikeFactoryMethod((IVIFReportFactory f) => f.GetElectricMachineSystemIHPCMeasuredType());
+
+			Bind<IXmlElectricMachineSystemType>().To<XmlElectricMachineSystemStandardValueType>().When(AccessedViaVIFFactory)
+				.NamedLikeFactoryMethod((IVIFReportFactory f) => f.GetElectricMachineSystemStandardValueType());
+			
 			Bind<IXmlTypeWriter>().To<VIFElectricMotorTorqueLimitsType>().When(AccessedViaVIFFactory)
 				.NamedLikeFactoryMethod((IVIFReportFactory f) => f.GetElectricMotorTorqueLimitsType());
 
-- 
GitLab