diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs index 96b39572624f64bd3e3e23fd05e06771cb5ac8a9..0b72434ca692daa961c8eddedb0c08045cd0e06d 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs +++ b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs @@ -2,9 +2,13 @@ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ @@ -14,11 +18,16 @@ namespace TUGraz.VectoCommon.Resources { /// <summary> /// A strongly-typed resource class, for looking up localized strings, etc. + /// A strongly-typed resource class, for looking up localized strings, etc. /// </summary> // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -34,6 +43,7 @@ namespace TUGraz.VectoCommon.Resources { /// <summary> /// Returns the cached ResourceManager instance used by this class. + /// Returns the cached ResourceManager instance used by this class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { @@ -49,6 +59,8 @@ namespace TUGraz.VectoCommon.Resources { /// <summary> /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { @@ -6189,6 +6201,15 @@ namespace TUGraz.VectoCommon.Resources { } } + /// <summary> + /// Looks up a localized string similar to Vocational. + /// </summary> + public static string XMLCustomerReportIsVocational { + get { + return ResourceManager.GetString("XMLCustomerReportIsVocational", resourceCulture); + } + } + /// <summary> /// Looks up a localized string similar to torqueLimit. /// </summary> diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.resx b/VectoCommon/VectoCommon/Resources/XMLNames.resx index e2d5214c50f42c9b6857344d20c5ab40d0f9e39f..2c0ea6ed6d48b391c8a7805050548eef3a7b444f 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.resx +++ b/VectoCommon/VectoCommon/Resources/XMLNames.resx @@ -2175,4 +2175,10 @@ <data name="MonitoringElectricMachineGEN" xml:space="preserve"> <value>ElectricMachineGEN</value> </data> + <data name="REESS" xml:space="preserve"> + <value>REESS</value> + </data> + <data name="XMLCustomerReportIsVocational" xml:space="preserve"> + <value>Vocational</value> + </data> </root> \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 890ca899666ac0bee0bc1b1aba90b3e32fc5de29..f78cafdbf9ea349ad54def78f376e3ccf5f4bcb3 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -255,7 +255,7 @@ namespace TUGraz.VectoCore.Models.Declaration case VehicleCategory.Tractor: var vehicleGroup = GetVehicleGroupGroup(vehicleData); var propulsionPower = GetReferencePropulsionPower(vehicleData); - var co2Group = WeightingGroup.Lookup(vehicleGroup.Item1, vehicleGroup.Item2 ?? false, vehicleData.SleeperCab ?? false, propulsionPower); + var co2Group = WeightingGroup.Lookup(vehicleGroup.Item1, vehicleData.SleeperCab ?? false, propulsionPower); return co2Group; default: return Declaration.WeightingGroup.Unknown; diff --git a/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs b/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs index 7cbb8bd48867675bb917cfa4c3a2810792eae48b..23186467c80a7e2a42d8dc66d074383ededb0f96 100644 --- a/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs +++ b/VectoCore/VectoCore/Models/Declaration/WeightingFactors.cs @@ -90,7 +90,12 @@ namespace TUGraz.VectoCore.Models.Declaration foreach (var entry in Data) { var sum = entry.Value.Sum(item => item.Value); - if (!sum.IsEqual(1.0, 1e-12)) { + + bool hasVocationalWeights = sum % 2.0 == 0; + bool isNormalWeights = sum.IsEqual(1.0, 1e-12); + + if (!isNormalWeights && !hasVocationalWeights) + { throw new VectoException("Weighting Factors for {0} do not sum up to 1.0! sum: {1}", entry.Key, sum); } } diff --git a/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs b/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs index 678a3e0268786e2e1344f09b8362420d0c8d5133..b50cec54ecf85ad3a8d0a585d6175c122d3da5c3 100644 --- a/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs +++ b/VectoCore/VectoCore/Models/Declaration/WeightingGroups.cs @@ -177,7 +177,7 @@ namespace TUGraz.VectoCore.Models.Declaration } } - public class WeightingGroups : LookupData<VehicleClass, bool, bool, Watt, WeightingGroup> + public class WeightingGroups : LookupData<VehicleClass, bool, Watt, WeightingGroup> { protected readonly List<Entry> Entries = new List<Entry>(); @@ -192,7 +192,6 @@ namespace TUGraz.VectoCore.Models.Declaration foreach (DataRow row in table.Rows) { Entries.Add(new Entry() { VehicleGroup = VehicleClassHelper.Parse(row.Field<string>("vehiclegroup")), - Vocational = "1".Equals(row.Field<string>("Vocational"), StringComparison.InvariantCultureIgnoreCase), SleeperCab = "SleeperCab".Equals(row.Field<string>("cabintype"), StringComparison.InvariantCultureIgnoreCase), RatedPowerMin = row.ParseDouble("engineratedpowermin").SI(Unit.SI.Kilo.Watt).Cast<Watt>(), RatedPowerMax = row.ParseDouble("engineratedpowermax").SI(Unit.SI.Kilo.Watt).Cast<Watt>(), @@ -202,10 +201,10 @@ namespace TUGraz.VectoCore.Models.Declaration } - public override WeightingGroup Lookup(VehicleClass group, bool vocational, bool sleeperCab, Watt engineRatedPower) + public override WeightingGroup Lookup(VehicleClass group, bool sleeperCab, Watt engineRatedPower) { var rows = Entries.FindAll( - x => x.VehicleGroup == group && x.Vocational == vocational && x.SleeperCab == sleeperCab && engineRatedPower >= x.RatedPowerMin && + x => x.VehicleGroup == group && x.SleeperCab == sleeperCab && engineRatedPower >= x.RatedPowerMin && engineRatedPower < x.RatedPowerMax); return rows.Count == 0 ? WeightingGroup.Unknown : rows.First().WeightingGroup; } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/FuelConsumptionWriter.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/FuelConsumptionWriter.cs index e588f692ed3b8b9e325c7876afee649bb16771b9..a409f75d173d1bf57b150b570540b5ade70d7c16 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/FuelConsumptionWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/FuelConsumptionWriter.cs @@ -32,21 +32,13 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.Common public XElement[] GetElements(IWeightedResult entry) { - if (entry.Status == VectoRun.Status.PrimaryBusSimulationIgnore) - { - List<XElement> fcElementsIgnore = new List<XElement>(); - foreach (var fcEntry in entry.FuelConsumptionPerMeter) - { - fcElementsIgnore.Add(GetElementIgnore(fcEntry.Value, fcEntry.Key, entry.Payload, entry.CargoVolume, entry.PassengerCount)); - } - - return fcElementsIgnore.ToArray(); - } - List<XElement> fcElements = new List<XElement>(); foreach (var fcEntry in entry.FuelConsumptionPerMeter) { - fcElements.Add(GetElement(fcEntry.Value, fcEntry.Key, entry.Payload, entry.CargoVolume, entry.PassengerCount)); + XElement element = entry.Status == VectoRun.Status.PrimaryBusSimulationIgnore + ? GetElementIgnore(fcEntry.Value, fcEntry.Key, entry.Payload, entry.CargoVolume, entry.PassengerCount) + : GetElement(fcEntry.Value, fcEntry.Key, entry.Payload, entry.CargoVolume, entry.PassengerCount); + fcElements.Add(element); } return fcElements.ToArray(); diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/IResultsWriter.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/IResultsWriter.cs index 5aff2701fc60534a03ad9878f96c1095319b24b1..56a6f4006d69e0188d94042bafcbd95fe1c03acb 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/IResultsWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/Common/IResultsWriter.cs @@ -147,9 +147,9 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.Common public interface IReportResultsSummaryWriter { - XElement GetElement(IList<IResultEntry> entries); + XElement[] GetElement(IList<IResultEntry> entries); - XElement GetElement(IList<IOVCResultEntry> entries); + XElement[] GetElement(IList<IOVCResultEntry> entries); } public interface IElectricRangeWriter diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/SummaryWriter.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/SummaryWriter.cs index 3f0a30051b85e50229f766f2109e866b39a686d5..edc5e026447957473c667b62b593376413e4a943 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/SummaryWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/SummaryWriter.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Xml.Linq; +using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Declaration; @@ -11,40 +12,56 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation { public abstract class SummaryWriterBase : AbstractResultWriter, IReportResultsSummaryWriter { + private MissionType[] vocationalMissions = new[] { MissionType.Construction, MissionType.MunicipalUtility }; + protected SummaryWriterBase(ICIFResultsWriterFactory factory, XNamespace ns) : base(factory, ns) { } #region Implementation of ICifSummaryWriter - public XElement GetElement(IList<IResultEntry> entries) + public XElement[] GetElement(IList<IResultEntry> entries) { - var weighted = DeclarationData.CalculateWeightedSummary(entries); - return DoGetElement(weighted); + var weighted = DeclarationData.CalculateWeightedSummary(entries.Where(e => !vocationalMissions.Contains(e.Mission)).ToList()); + var weightedVocationals = DeclarationData.CalculateWeightedSummary(entries.Where(e => vocationalMissions.Contains(e.Mission)).ToList()); + return DoGetElement(weighted, weightedVocationals); } - public XElement GetElement(IList<IOVCResultEntry> entries) + public XElement[] GetElement(IList<IOVCResultEntry> entries) { - var weighted = DeclarationData.CalculateWeightedSummary(entries); - return DoGetElement(weighted); + var weighted = DeclarationData.CalculateWeightedSummary(entries.Where(e => !vocationalMissions.Contains(e.ChargeDepletingResult.Mission)).ToList()); + var weightedVocationals = DeclarationData.CalculateWeightedSummary(entries.Where(e => vocationalMissions.Contains(e.ChargeDepletingResult.Mission)).ToList()); + return DoGetElement(weighted, weightedVocationals); } - protected virtual XElement DoGetElement(IWeightedResult weighted) + protected virtual XElement[] DoGetElement(IWeightedResult weighted, IWeightedResult weightedVocationals) { - if (weighted == null) { - return null; + bool isVocational = false; + List<XElement> results = new List<XElement>(); + foreach (IWeightedResult weightedResult in new[] { weighted, weightedVocationals }) + { + if (weightedResult == null) + { + results.Add(null); + continue; + } + + XElement element = new XElement(TNS + XMLNames.Report_Results_Summary, + new XAttribute(xsi + XMLNames.XSIType, ResultSummaryXMLType), + new XElement(TNS + XMLNames.XMLCustomerReportIsVocational, isVocational), + GetSummary(weightedResult), + FuelConsumptionWriter != null + ? weightedResult.FuelConsumption.Select(x => + FuelConsumptionWriter.GetElements(weightedResult)) + : null, + ElectricEnergyConsumptionWriter?.GetElement(weightedResult), + CO2Writer?.GetElements(weightedResult), + ElectricRangeWriter?.GetElements(weightedResult) + ); + + results.Add(element); + isVocational = !isVocational; } - var fcWriter = FuelConsumptionWriter; - return new XElement(TNS + XMLNames.Report_Results_Summary, - new XAttribute(xsi + XMLNames.XSIType, ResultSummaryXMLType), - GetSummary(weighted), - fcWriter != null - ? weighted.FuelConsumption.Select(x => - fcWriter.GetElements(weighted)) - : null, - ElectricEnergyConsumptionWriter?.GetElement(weighted), - CO2Writer?.GetElements(weighted), - ElectricRangeWriter?.GetElements(weighted) - ); + return results.ToArray(); } public abstract string ResultSummaryXMLType { get; } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/ResultWriter/SummaryWriter.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/ResultWriter/SummaryWriter.cs index af3ef5822aa22c36d479a1b3177d52981c654258..f15c14b4ace7f5d3127d0cd0566762475434bfc3 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/ResultWriter/SummaryWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/ManufacturerReport_0_9/ResultWriter/SummaryWriter.cs @@ -8,12 +8,12 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport. { #region Implementation of IReportResultsSummaryWriter - public XElement GetElement(IList<IResultEntry> entries) + public XElement[] GetElement(IList<IResultEntry> entries) { return null; } - public XElement GetElement(IList<IOVCResultEntry> entries) + public XElement[] GetElement(IList<IOVCResultEntry> entries) { return null; } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs index f1cad693659ed5f0ab93332b33f55769f5f99f7d..ae59822096be2350f13b98bdeeaf3127f75485b4 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs @@ -294,8 +294,10 @@ namespace TUGraz.VectoCore.OutputData.XML protected override void WriteResult(ResultEntry result) { var sumWeightinFactors = _weightingFactors.Values.Sum(x => x); - if (!sumWeightinFactors.IsEqual(0) && !sumWeightinFactors.IsEqual(1)) { - throw new VectoException("Mission Profile Weighting factors do not sum up to 1!"); + bool isNormalWeights = sumWeightinFactors.IsEqual(0) || sumWeightinFactors.IsEqual(1, 1e-12); + bool isVocationalWeights = sumWeightinFactors % 2 == 0; + if (!isNormalWeights && !isVocationalWeights) { + throw new VectoException("Mission Profile Weighting factors or Mission Profile Weighting factors for Vocational misisons do not sum up to 1!"); } ManufacturerRpt.WriteResult(result); diff --git a/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.0.9.xsd b/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.0.9.xsd index db8b07718ba7265176e8a187a69aaf0f67df2d2a..fbcc49b1b5afabd8afb74f2351ca126c1101c0b6 100644 --- a/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.0.9.xsd +++ b/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.0.9.xsd @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSpy v2021 (x64) (http://www.altova.com) by Markus Quaritsch (Technische Universität Graz) --> -<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.9" xmlns:out="urn:tugraz:ivt:VectoAPI:DeclarationOutputDefinitions" xmlns:mrf="urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.9" xmlns:dd="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions" xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xmlns:v1.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" xmlns:v2.1="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.1" xmlns:v2.3="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.3" xmlns:v2.4="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.4" targetNamespace="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.9" elementFormDefault="qualified" attributeFormDefault="unqualified"> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:tugraz:ivt:VectoAPI:CustomerOutput:v1.0" xmlns:out="urn:tugraz:ivt:VectoAPI:DeclarationOutputDefinitions" xmlns:mrf="urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.9" xmlns:dd="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions" xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xmlns:v1.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" xmlns:v2.1="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.1" xmlns:v2.3="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.3" xmlns:v2.4="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.4" targetNamespace="urn:tugraz:ivt:VectoAPI:CustomerOutput:v1.0" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" schemaLocation="VectoDeclarationDefinitions.1.0.xsd"/> <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" schemaLocation="VectoDeclarationDefinitions.2.0.xsd"/> <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.1" schemaLocation="VectoDeclarationDefinitions.2.1.xsd"/> @@ -2182,7 +2182,7 @@ <xs:choice> <xs:sequence> <xs:element name="Result" type="AbstractResultType" maxOccurs="unbounded"/> - <xs:element name="Summary" type="AbstractResultSummaryType" minOccurs="0"/> + <xs:element name="Summary" type="AbstractResultSummaryType" minOccurs="0" maxOccurs="2"/> </xs:sequence> <xs:element name="ExemptedVehicle"> <xs:complexType/> @@ -2615,6 +2615,7 @@ <xs:complexContent> <xs:extension base="AbstractResultSummaryType"> <xs:sequence> + <xs:element name="Vocational" type="xs:boolean"></xs:element> <xs:choice> <xs:element name="AveragePayload"> <xs:annotation> @@ -2698,6 +2699,7 @@ <xs:documentation>II.2.6.1, II.2.6.4</xs:documentation> </xs:annotation> </xs:element> + <xs:element name="Vocational" type="xs:boolean"></xs:element> <xs:group ref="ElectricRangeSequenceGroup"/> </xs:sequence> </xs:extension> @@ -2754,6 +2756,7 @@ </xs:complexType> </xs:element> </xs:sequence> + <xs:element name="Vocational" type="xs:boolean"></xs:element> <xs:group ref="ElectricRangeSequenceGroup"/> </xs:sequence> </xs:extension>