From 81b18a6f60e3b2224ccbfe816eeae08edc2e0861 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 24 Feb 2020 17:13:45 +0100 Subject: [PATCH] updating writing customer report, manufacturer report, vtp report. consider FWD vehicles --- .../XML/AbstractXMLManufacturerReport.cs | 2 +- .../OutputData/XML/XMLCustomerReport.cs | 51 +++++++----- .../VectoCore/OutputData/XML/XMLVTPReport.cs | 80 ++++++++++++++----- VectoCore/VectoCore/Utils/XMLDefinitions.cs | 5 +- VectoCore/VectoCore/Utils/XMLHelper.cs | 7 ++ 5 files changed, 100 insertions(+), 45 deletions(-) diff --git a/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs b/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs index cca2c7d746..ca48a31a6b 100644 --- a/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/AbstractXMLManufacturerReport.cs @@ -234,7 +234,7 @@ namespace TUGraz.VectoCore.OutputData.XML protected virtual XElement GetADAS(VehicleData.ADASData adasData) { - if (adasData.InputData.XMLSource == null) { + if (adasData.InputData.XMLSource == null || XMLHelper.GetVersion(adasData.InputData.XMLSource) < 2.0) { return CreateADAS(adasData); } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs index 4973b3f4e9..84df04d0c8 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs @@ -59,8 +59,10 @@ namespace TUGraz.VectoCore.OutputData.XML protected readonly XElement Results; - protected readonly XNamespace tns; - protected readonly XNamespace di; + protected readonly XNamespace rootNS = XNamespace.Get("urn:tugraz:ivt:VectoAPI:CustomerOutput"); + protected readonly XNamespace tns = XNamespace.Get("urn:tugraz:ivt:VectoAPI:CustomerOutput:v" + CURRENT_SCHEMA_VERSION); + 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; @@ -71,8 +73,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XMLCustomerReport() { - di = "http://www.w3.org/2000/09/xmldsig#"; - tns = "urn:tugraz:ivt:VectoAPI:CustomerOutput:v" + CURRENT_SCHEMA_VERSION; + VehiclePart = new XElement(tns + XMLNames.Component_Vehicle); Results = new XElement(tns + XMLNames.Report_Results); } @@ -86,30 +87,38 @@ namespace TUGraz.VectoCore.OutputData.XML new XElement(tns + XMLNames.Component_ManufacturerAddress, modelData.VehicleData.ManufacturerAddress), new XElement(tns + XMLNames.Vehicle_VIN, modelData.VehicleData.VIN), new XElement(tns + XMLNames.Vehicle_LegislativeClass, modelData.VehicleData.LegislativeClass.ToXMLFormat()), - new XElement(tns + XMLNames.Vehicle_GrossVehicleMass, 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_GrossVehicleMass, + 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_DualFuelVehicle, modelData.VehicleData.DualFuelVehicle) + ); - exempted ? ExemptedData(modelData) : new[] { + if (exempted) { + VehiclePart.Add(new XAttribute(xsi + "type", "ExemptedVehicleType"), + ExemptedData(modelData)); + Results.Add(new XElement(tns + XMLNames.Report_ExemptedVehicle)); + } else { + VehiclePart.Add( + new XAttribute(xsi + "type", "VehicleType"), new XElement(tns + XMLNames.Vehicle_AxleConfiguration, modelData.VehicleData.AxleConfiguration.GetName()), new XElement(tns + XMLNames.Report_Vehicle_VehicleGroup, modelData.VehicleData.VehicleClass.GetClassNumber()), new XElement(tns + XMLNames.Vehicle_VocationalVehicle, modelData.VehicleData.VocationalVehicle), new XElement(tns + XMLNames.Vehicle_SleeperCab, modelData.VehicleData.SleeperCab), - GetADAS(modelData.VehicleData.ADAS) - }.Concat(ComponentData(modelData, fuelModes)) - ); - if (exempted) { - Results.Add(new XElement(tns + XMLNames.Report_ExemptedVehicle)); + GetADAS(modelData.VehicleData.ADAS), + ComponentData(modelData, fuelModes) + ); } InputDataIntegrity = new XElement(tns + XMLNames.Report_InputDataSignature, modelData.InputDataHash == null ? CreateDummySig() : new XElement(modelData.InputDataHash)); } - private XElement[] ExemptedData(VectoRunData modelData) + private object[] ExemptedData(VectoRunData modelData) { - return new[] { + return new object[] { modelData.VehicleData.HybridElectricHDV ? new XElement(tns + XMLNames.Vehicle_MaxNetPower1, XMLHelper.ValueAsUnit(modelData.VehicleData.MaxNetPower1, XMLNames.Unit_W)) : null, modelData.VehicleData.HybridElectricHDV ? new XElement(tns + XMLNames.Vehicle_MaxNetPower2, XMLHelper.ValueAsUnit(modelData.VehicleData.MaxNetPower2, XMLNames.Unit_W)) : null }; @@ -222,7 +231,7 @@ namespace TUGraz.VectoCore.OutputData.XML public void GenerateReport(XElement resultSignature) { - var xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance"); + var retVal = new XDocument(); var results = new XElement(Results); results.AddFirst(new XElement(tns + XMLNames.Report_Result_Status, _allSuccess ? "success" : "error")); @@ -242,14 +251,16 @@ namespace TUGraz.VectoCore.OutputData.XML var vehicle = new XElement(VehiclePart); vehicle.Add(InputDataIntegrity); retVal.Add(new XProcessingInstruction("xml-stylesheet", "href=\"https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/CSS/VectoReports.css\"")); - retVal.Add(new XElement(tns + XMLNames.VectoCustomerReport, - new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION), + retVal.Add(new XElement(rootNS + XMLNames.VectoCustomerReport, + //new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION), new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), new XAttribute("xmlns", tns), + new XAttribute(XNamespace.Xmlns + "tns", rootNS), new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}VectoOutputCustomer.{2}.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl, CURRENT_SCHEMA_VERSION)), - new XElement(tns + XMLNames.Report_DataWrap, + string.Format("{0} {1}VectoOutputCustomer.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), + new XElement(rootNS + XMLNames.Report_DataWrap, + new XAttribute(xsi + "type", "VectoOutputDataType"), vehicle, new XElement(tns + XMLNames.Report_ResultData_Signature, resultSignature), results, diff --git a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs index d776b0cda7..0c02b536af 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs @@ -59,7 +59,7 @@ namespace TUGraz.VectoCore.OutputData.XML { internal class XMLVTPReport : DeclarationReport<XMLVTPReport.ResultEntry>, IVTPReport { - public const string CURRENT_SCHEMA_VERSION = "0.1"; + public const string CURRENT_SCHEMA_VERSION = "0.2"; private const string VTPReportTartetName = "VTPReportTarget"; @@ -70,7 +70,9 @@ namespace TUGraz.VectoCore.OutputData.XML protected XElement ResultsPart; - protected XNamespace tns; + protected XNamespace xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance"); + protected XNamespace rootNS = "urn:tugraz:ivt:VectoAPI:VTPReport"; + protected XNamespace tns = "urn:tugraz:ivt:VectoAPI:VTPReport:v" + CURRENT_SCHEMA_VERSION; private static List<string> LogList = new List<string>(); private LoggingRule cycleChecksRule; @@ -118,7 +120,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XMLVTPReport(IReportWriter writer) : base(writer) { //di = "http://www.w3.org/2000/09/xmldsig#"; - tns = "urn:tugraz:ivt:VectoAPI:VTPReport:v" + CURRENT_SCHEMA_VERSION; + VehiclePart = new XElement(tns + XMLNames.Component_Vehicle); GeneralPart = new XElement(tns + "General"); DataIntegrityPart = new XElement(tns + "DataIntegrityCheck"); @@ -255,24 +257,26 @@ namespace TUGraz.VectoCore.OutputData.XML private XDocument GenerateReport() { - var xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance"); + var retVal = new XDocument(); retVal.Add( new XProcessingInstruction( "xml-stylesheet", "href=\"https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/CSS/VectoReports.css\"")); retVal.Add( new XElement( - tns + "VectoVTPReport", - new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION), + rootNS + "VectoVTPReport", + //new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION), new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), new XAttribute("xmlns", tns), + new XAttribute(XNamespace.Xmlns + "tns", rootNS), //new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute( xsi + "schemaLocation", - string.Format("{0} {1}VTPReport.{2}.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl, CURRENT_SCHEMA_VERSION)), + string.Format("{0} {1}VTPReport.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)), new XElement( - tns + "Data", + rootNS + "Data", + new XAttribute(xsi + "type", "VTPReportDataType"), new XElement(GeneralPart), new XElement(VehiclePart), new XElement(DataIntegrityPart), @@ -292,6 +296,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XElement(tns + XMLNames.Component_Manufacturer, modelData.VehicleData.Manufacturer), new XElement(tns + XMLNames.Component_ManufacturerAddress, modelData.VehicleData.ManufacturerAddress)); VehiclePart.Add( + new XAttribute(xsi + "type", "VehicleType"), new XElement(tns + XMLNames.Component_Model, modelData.VehicleData.ModelName), new XElement(tns + XMLNames.Vehicle_VIN, modelData.VehicleData.VIN), new XElement(tns + XMLNames.Vehicle_LegislativeClass, modelData.VehicleData.LegislativeClass.ToXMLFormat()), @@ -302,20 +307,37 @@ namespace TUGraz.VectoCore.OutputData.XML modelData.Retarder.Type.IsDedicatedComponent() ? new XElement(tns + XMLNames.Vehicle_RetarderRatio, modelData.Retarder.Ratio.ToXMLFormat(3)) : null, - new XElement(tns + XMLNames.Vehicle_PTO, modelData.PTO != null), - new XElement( - tns + XMLNames.Vehicle_Components, - GetEngineDescription(modelData.EngineData, fuelModes), - GetGearboxDescription(modelData.GearboxData), - GetTorqueConverterDescription(modelData.GearboxData.TorqueConverterData), - GetRetarderDescription(modelData.Retarder), - GetAngledriveDescription(modelData.AngledriveData), - GetAxlegearDescription(modelData.AxleGearData), - GetAirDragDescription(modelData.AirdragData), - GetAxleWheelsDescription(modelData.VehicleData), - GetAuxiliariesDescription(modelData.Aux) - ) - ); + new XElement(tns + XMLNames.Vehicle_PTO, modelData.PTO != null)); + if (modelData.VehicleData.AxleConfiguration.AxlegearIncludedInGearbox()) { + VehiclePart.Add( + new XElement( + tns + XMLNames.Vehicle_Components, + new XAttribute(xsi + "type", "ComponentsTruckFWDType"), + GetEngineDescription(modelData.EngineData, fuelModes), + GetGearboxDescription(modelData.GearboxData, modelData.AxleGearData.AxleGear.Ratio), + GetTorqueConverterDescription(modelData.GearboxData.TorqueConverterData), + GetRetarderDescription(modelData.Retarder), + GetAngledriveDescription(modelData.AngledriveData), + GetAirDragDescription(modelData.AirdragData), + GetAxleWheelsDescription(modelData.VehicleData), + GetAuxiliariesDescription(modelData.Aux) + )); + } else { + VehiclePart.Add( + new XElement( + tns + XMLNames.Vehicle_Components, + new XAttribute(xsi + "type", "ComponentsTruckType"), + GetEngineDescription(modelData.EngineData, fuelModes), + GetGearboxDescription(modelData.GearboxData), + GetTorqueConverterDescription(modelData.GearboxData.TorqueConverterData), + GetRetarderDescription(modelData.Retarder), + GetAngledriveDescription(modelData.AngledriveData), + GetAxlegearDescription(modelData.AxleGearData), + GetAirDragDescription(modelData.AirdragData), + GetAxleWheelsDescription(modelData.VehicleData), + GetAuxiliariesDescription(modelData.Aux) + )); + } if (InputDataHash == null) { return; @@ -497,6 +519,20 @@ namespace TUGraz.VectoCore.OutputData.XML ); } + private XElement GetGearboxDescription(GearboxData gearboxData, double axlegearRatio) + { + return new XElement( + tns + XMLNames.Component_Gearbox, + GetCommonDescription(gearboxData), + 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, axlegearRatio.ToXMLFormat(3)), + new XElement( + tns + XMLNames.Report_Gearbox_TransmissionRatioFinalGear, + gearboxData.Gears.Last().Value.Ratio.ToXMLFormat(3)) + ); + } + private XElement GetTorqueConverterDescription(TorqueConverterData torqueConverterData) { if (torqueConverterData == null) { diff --git a/VectoCore/VectoCore/Utils/XMLDefinitions.cs b/VectoCore/VectoCore/Utils/XMLDefinitions.cs index 29093bdd30..6708d5b9f4 100644 --- a/VectoCore/VectoCore/Utils/XMLDefinitions.cs +++ b/VectoCore/VectoCore/Utils/XMLDefinitions.cs @@ -14,8 +14,8 @@ namespace TUGraz.VectoCore.Utils EngineeringComponentData = 1 << 5, ManufacturerReport = 1 << 6, CustomerReport = 1 << 7, - MonitoringReport = 1 << 8 - + MonitoringReport = 1 << 8, + VTPReport = 1 << 9 } @@ -91,6 +91,7 @@ namespace TUGraz.VectoCore.Utils {XmlDocumentType.ManufacturerReport, "VectoOutputManufacturer.xsd" }, {XmlDocumentType.CustomerReport , "VectoOutputCustomer.xsd"}, {XmlDocumentType.MonitoringReport , "VectoMonitoring.xsd"}, + {XmlDocumentType.VTPReport , "VTPReport.xsd"}, }; public static XNamespace DECLARATION_OUTPUT_PRIMARY_HEAVY_BUS = "urn:tugraz:ivt:VectoAPI:DeclarationOutput:PrimaryVehicleInformation:HeavyBus:v0.1"; diff --git a/VectoCore/VectoCore/Utils/XMLHelper.cs b/VectoCore/VectoCore/Utils/XMLHelper.cs index e87178fbb5..718437960c 100644 --- a/VectoCore/VectoCore/Utils/XMLHelper.cs +++ b/VectoCore/VectoCore/Utils/XMLHelper.cs @@ -266,5 +266,12 @@ namespace TUGraz.VectoCore.Utils { return string.Join(":", schemaInfoSchemaType.QualifiedName.Namespace, schemaInfoSchemaType.QualifiedName.Name); } + + public static double GetVersion(XmlNode node) + { + const string versionPrefix = "v"; + var namesp = node.SchemaInfo.SchemaType.QualifiedName.Namespace; + return namesp.Split(':').Last(x => x.StartsWith(versionPrefix)).Replace(versionPrefix, string.Empty).ToDouble(); + } } } -- GitLab