diff --git a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs index cc139e4276e3c9e44ae0a6fc2e59f4bac400937c..5e74a98f3e2aaa441a62c0f37696aa95f0d03b7b 100644 --- a/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs +++ b/VectoCore/VectoCore/OutputData/FileIO/FileOutputWriter.cs @@ -65,6 +65,11 @@ namespace TUGraz.VectoCore.OutputData.FileIO get { return Path.ChangeExtension(_jobFile, "RSLT_CUSTOMER.xml"); } } + public string XMLMonitoringReportName + { + get { return Path.ChangeExtension(_jobFile, "RSLT_MONITORING.xml"); } + } + public string XMLVTPReportName { get { return Path.ChangeExtension(_jobFile, "VTP_Report.xml"); } @@ -116,6 +121,9 @@ namespace TUGraz.VectoCore.OutputData.FileIO case ReportType.DeclarationReportCustomerXML: fileName = XMLCustomerReportName; break; + case ReportType.DeclarationReportMonitoringXML: + fileName = XMLMonitoringReportName; + break; case ReportType.DeclarationVTPReportXML: fileName = XMLVTPReportName; break; diff --git a/VectoCore/VectoCore/OutputData/IDataWriter.cs b/VectoCore/VectoCore/OutputData/IDataWriter.cs index 651bbd4c025c72b6a6c7490d53026384aef655fb..622424670347d18f6bb503d0d399794a8aff3c38 100644 --- a/VectoCore/VectoCore/OutputData/IDataWriter.cs +++ b/VectoCore/VectoCore/OutputData/IDataWriter.cs @@ -59,6 +59,7 @@ namespace TUGraz.VectoCore.OutputData DeclarationReportPdf, DeclarationReportManufacturerXML, DeclarationReportCustomerXML, - DeclarationVTPReportXML + DeclarationVTPReportXML, + DeclarationReportMonitoringXML } } \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs index c4e1239a1d73d7d0316eaf861761fbec7a65ea23..9a1ae17d46be6174e4af81949fdc3062f55ac07a 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs @@ -52,6 +52,7 @@ namespace TUGraz.VectoCore.OutputData.XML { private readonly XMLManufacturerReport _manufacturerReport; private readonly XMLCustomerReport _customerReport; + private readonly XMLMonitoringReport _monitoringReport; private readonly IOutputDataWriter _writer; @@ -171,6 +172,7 @@ namespace TUGraz.VectoCore.OutputData.XML { _manufacturerReport = new XMLManufacturerReport(); _customerReport = new XMLCustomerReport(); + _monitoringReport = new XMLMonitoringReport(_manufacturerReport); _writer = writer; } @@ -185,6 +187,11 @@ namespace TUGraz.VectoCore.OutputData.XML get { return _customerReport.Report; } } + public XDocument MonitoringReport + { + get { return _monitoringReport.Report; } + } + protected override void DoAddResult(ResultEntry entry, VectoRunData runData, IModalDataContainer modData) { @@ -206,6 +213,7 @@ namespace TUGraz.VectoCore.OutputData.XML if (_writer != null) { _writer.WriteReport(ReportType.DeclarationReportCustomerXML, _customerReport.Report); _writer.WriteReport(ReportType.DeclarationReportManufacturerXML, _manufacturerReport.Report); + _writer.WriteReport(ReportType.DeclarationReportMonitoringXML, _monitoringReport.Report); } } @@ -227,6 +235,7 @@ namespace TUGraz.VectoCore.OutputData.XML : DeclarationData.WeightingFactors.Lookup(weightingGroup); _manufacturerReport.Initialize(modelData); _customerReport.Initialize(modelData); + _monitoringReport.Initialize(modelData); } private static IDictionary<Tuple<MissionType, LoadingType>, double> ZeroWeighting diff --git a/VectoCore/VectoCore/OutputData/XML/XMLMonitoringReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLMonitoringReport.cs new file mode 100644 index 0000000000000000000000000000000000000000..52ab1e9ad50421af4f150d78251bdc41c00ceaff --- /dev/null +++ b/VectoCore/VectoCore/OutputData/XML/XMLMonitoringReport.cs @@ -0,0 +1,149 @@ +using System; +using System.Linq; +using System.Xml.Linq; +using System.Xml.XPath; +using TUGraz.IVT.VectoXML.Writer; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.OutputData.XML +{ + public class XMLMonitoringReport + { + public const string CURRENT_SCHEMA_VERSION = "0.7"; + + private XMLManufacturerReport _manufacturerReport; + + protected XNamespace tns; + protected XNamespace di; + private XElement _additionalFields; + + + public XMLMonitoringReport(XMLManufacturerReport manufacturerReport) + { + di = "http://www.w3.org/2000/09/xmldsig#"; + tns = "urn:tugraz:ivt:VectoAPI:MonitoringOutput:v" + CURRENT_SCHEMA_VERSION; + _manufacturerReport = manufacturerReport; + } + + public XDocument Report + { + get { + var mrf = _manufacturerReport.Report; + if (mrf == null) { + return null; + } + + var retVal = GenerateReport(); + + retVal.Root?.Add( + new XElement( + tns + "ManufacturerRecord", + GetManufacturerData(mrf)), + _additionalFields + ); + return retVal; + } + } + + + private object[] GetManufacturerData(XDocument mrf) + { + return mrf.Root?.XPathSelectElements("./*").ToArray<object>(); + } + + 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 + "VectoMonitoring", + new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION), + new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), + new XAttribute("xmlns", tns), + new XAttribute(XNamespace.Xmlns + "di", di), + new XAttribute( + xsi + "schemaLocation", + string.Format( + "{0} {1}VectoMonitoring.{2}.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl, CURRENT_SCHEMA_VERSION)) + ) + ); + return retVal; + } + + public void Initialize(VectoRunData modelData) + { + var numAxles = modelData.VehicleData.AxleData.Count(x => x.AxleType != AxleType.Trailer); + var axleData = new object[numAxles]; + for (var i = 0; i < axleData.Length; i++) { + axleData[i] = new XElement(tns + "Axle", + new XAttribute("axleNumber", i+1), + new XElement(tns + "Tyre", GetStandardFields(string.Format("TYRE_{0}", i+1)) + )); + } + + + _additionalFields = new XElement( + tns + "AdditionalData", + new XElement(tns + "Vehicle", + new XElement(tns + "Make", "##VEHICLE_MAKE##")), + new XElement(tns + "Engine", + new XElement(tns + "WHTC", + new XElement(tns + "CO2", XMLHelper.ValueAsUnit(double.NaN, "g/kWh", 0)), + new XElement(tns + "FuelConsumption", XMLHelper.ValueAsUnit(double.NaN, "g/kWh", 0)) + ), + new XElement(tns + "WHSC", + new XElement(tns + "CO2", XMLHelper.ValueAsUnit(double.NaN, "g/kWh", 0)), + new XElement(tns + "FuelConsumption", XMLHelper.ValueAsUnit(double.NaN, "g/kWh", 0)) + ) + ), + new XElement(tns + "Gearbox",GetStandardFields("GEARBOX")), + new XElement(tns + "Axlegear", GetStandardFields("AXLEGEAR")), + new XElement(tns + "AxleWheels", axleData), + new XElement(tns + "AdvancedReducingTechnologies", new XComment(GetReducingTechnologiesExample())), + new XElement(tns + "VectoLicenseNbr", "##VECTO_LICENSE_NUMBER##") + ); + } + + private object[] GetStandardFields(string prefix) + { + return new[] { + new XElement(tns + "Manufacturer", string.Format("##{0}_MANUFACTURER##", prefix)), + new XElement(tns + "ManufacturerAddress", string.Format("##{0}_MANUFACTURERADDRESS##", prefix)), + new XElement(tns + "Make", string.Format("##{0}_MAKE##", prefix)) + }; + } + + private string GetReducingTechnologiesExample() + { + var categories = new[] { + "advanced aerodynamic measures", + "advanced rolling resistance measures", + "advanced drivetrain technologies", + "advanced engine technologies", + "advanced auxiliary technologies", + "additional ADAS technologies", + "advanced powertrain integration and hybridisation", + "other" + }; + var retVal = new object[categories.Length]; + //var tmp = new XElement(tns + "foo"); + for (var i = 0; i < retVal.Length; i++) { + retVal[i] = new XElement("Entry", + new XAttribute("category", categories[i]), + "##TECHNOLOGY_BRAND_NAME##" + ); + } + + return Environment.NewLine + string.Join(Environment.NewLine, retVal.Select(x => x.ToString())) + Environment.NewLine; + } + } +} diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index ac90b8ee3794c0cc2013e39121674c72bb274479..6842dba8c8949cd71698030687ac94e74c3bb0f9 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -202,6 +202,7 @@ <Compile Include="InputData\Reader\Impl\EngineeringVTPModeVectoRunDataFactory.cs" /> <Compile Include="Models\SimulationComponent\Impl\VTPCycle.cs" /> <Compile Include="Models\Simulation\Impl\ExemptedRun.cs" /> + <Compile Include="OutputData\XML\XMLMonitoringReport.cs" /> <Compile Include="OutputData\XML\XMLVTPReport.cs" /> <Compile Include="OutputData\VTPReport.cs" /> <Compile Include="OutputData\ModFilter\ActualModalDataFilter.cs" /> @@ -476,6 +477,9 @@ <EmbeddedResource Include="Resources\Declaration\CO2Standards\MissionProfileWeights.csv" /> <EmbeddedResource Include="Resources\Declaration\CO2Standards\WeightingGroups.csv" /> <EmbeddedResource Include="Resources\Declaration\TyreLabeling.csv" /> + <EmbeddedResource Include="Resources\XSD\VectoMonitoring.0.7.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> <None Include="Utils\VectoVersionCore.tt"> <Generator>TextTemplatingFileGenerator</Generator> <LastGenOutput>VectoVersionCore.cs</LastGenOutput>