diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/AbstractCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/AbstractCustomerReport.cs index 1203dcf03305e502d0aee57068d1963a4eb3ed2b..9b05406b28eae60555165f4783721a62650973b1 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/AbstractCustomerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/AbstractCustomerReport.cs @@ -13,9 +13,9 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation { public abstract class AbstractCustomerReport : IXMLCustomerReport { - private readonly ICustomerInformationFileFactory _cifFactory; + protected readonly ICustomerInformationFileFactory _cifFactory; - protected XElement Vehicle { get; private set; } + protected XElement Vehicle { get; set; } protected AbstractCustomerReport(ICustomerInformationFileFactory cifFactory) { @@ -23,7 +23,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation } - public abstract void InitializeVehicleData(IVehicleDeclarationInputData inputData); + public abstract void InitializeVehicleData(IDeclarationInputDataProvider inputData); #region Implementation of IXMLCustomerReport diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs index 7fac4e9d640aa5bab9410c306918267af9fd04a9..e3a6927d29a82849e8ac28b9b11354e393699207 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFNinjectModule.cs @@ -1,10 +1,19 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using Ninject.Activation; using Ninject.Extensions.Factory; +using Ninject.Extensions.NamedScope; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9.CIFWriter; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9.CustomerInformationFile; using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportGroupWriter; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportXMLTypeWriter; using TUGraz.VectoCore.Utils.Ninject; namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9 @@ -16,19 +25,76 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation public override void Load() { Bind<ICustomerInformationFileFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider( - nameCombinationMethod, - 4, - 4, - typeof(ICustomerInformationFileFactory).GetMethod(nameof(ICustomerInformationFileFactory + nameCombinationMethod, 6, 6, typeof(ICustomerInformationFileFactory).GetMethod(nameof(ICustomerInformationFileFactory .GetCustomerReport)))).InSingletonScope(); + Bind<IXMLCustomerReport>().To<ConventionalLorry_CIF>().Named(nameCombinationMethod( + ToParams(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ConventionalVehicle, + ArchitectureID.UNKNOWN, false, false, false))); + Bind<IXMLCustomerReport>().To<HEV_PxLorry_CIF>().Named(nameCombinationMethod( + ToParams(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ParallelHybridVehicle, + ArchitectureID.UNKNOWN, false, false, false))); + Bind<IXMLCustomerReport>().To<HEV_S2_Lorry_CIF>().Named(nameCombinationMethod( + ToParams(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.S2, false, false, false))); + Bind<IXMLCustomerReport>().To<HEV_S3_Lorry_CIF>().Named(nameCombinationMethod( + ToParams(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.S3, false, false, false))); + Bind<IXMLCustomerReport>().To<HEV_S4_Lorry_CIF>().Named(nameCombinationMethod( + ToParams(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.S4, false, false, false))); + + Bind<IXMLCustomerReport>().To<HEV_IEPC_Lorry_CIF>().Named(nameCombinationMethod( + ToParams(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.UNKNOWN, false,true, false))); + + + + + #region VehicleTypes + Bind<IXmlTypeWriter>().To<CIFConventionalLorryVehicleWriter>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetConventionalLorryVehicleType()); + + Bind<IXmlTypeWriter>().To<CIF_HEVPx_LorryVehicleWriter>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetHEV_PxLorryVehicleType()); + + #endregion + #region VehicleGroups + Bind<IMrfXmlGroup>().To<GeneralVehicleSequenceGroupCIF>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetGeneralVehicleSequenceGroupWriter()); + Bind<IMrfXmlGroup>().To<LorryGeneralVehicleSequenceGroupCIF>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetLorryGeneralVehicleSequenceGroupWriter()); + Bind<IMrfXmlGroup>().To<ConventionalLorryVehicleSequenceGroupCIF>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetConventionalLorryVehicleSequenceGroupWriter()); + + + #endregion + #region ComponentGroups + Bind<IMrfXmlGroup>().To<ComponentGroupWriters>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetEngineGroup()); + Bind<IMrfXmlGroup>().To<TransmissionGroup>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetTransmissionGroup()); + Bind<IMrfXmlGroup>().To<AxleWheelsGroup>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetAxleWheelsGroup()); + Bind<IMrfXmlGroup>().To<ElectricMachineGroup>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetElectricMachineGroup()); + Bind<IMrfXmlGroup>().To<REESSGroup>() + .NamedLikeFactoryMethod((ICustomerInformationFileFactory f) => f.GetREESSGroup()); + #endregion + + + + + } + + #endregion } } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/AbstractCIFGroupWriter.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/AbstractCIFGroupWriter.cs new file mode 100644 index 0000000000000000000000000000000000000000..93de2794f038cb93494fc90d10251265d27fee04 --- /dev/null +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/AbstractCIFGroupWriter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportXMLTypeWriter; + +namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportGroupWriter +{ + public abstract class AbstractCIFGroupWriter : IMrfXmlGroup + { + protected XNamespace _mrf = "urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.9"; + protected XNamespace _cif = "urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.9"; + protected readonly ICustomerInformationFileFactory _cifFactory; + + protected AbstractCIFGroupWriter(ICustomerInformationFileFactory cifFactory) + { + _cifFactory = cifFactory; + } + + #region Implementation of IMRFGroupWriter + + public abstract IList<XElement> GetElements(IDeclarationInputDataProvider inputData); + + #endregion + } +} diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/ComponentGroupWriters.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/ComponentGroupWriters.cs new file mode 100644 index 0000000000000000000000000000000000000000..e7aef00cd1a8d10acc10cc53b3a25f37cb164563 --- /dev/null +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/ComponentGroupWriters.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportGroupWriter; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9.CIFWriter +{ + public class ComponentGroupWriters : AbstractCIFGroupWriter + { + public ComponentGroupWriters(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var engine = inputData.JobInputData.Vehicle.Components.EngineInputData; + var fuelTypesXElement = new XElement(_cif + XMLNames.Report_Vehicle_FuelTypes); + + var fuelTypes = new HashSet<FuelType>(); + foreach (var engineMode in engine.EngineModes) + { + foreach (var fuel in engineMode.Fuels) { + fuelTypes.Add(fuel.FuelType); + } + } + var sortedFuels = fuelTypes.ToList(); + sortedFuels.Sort((fuelType1, fuelType2) => fuelType1.CompareTo(fuelType2)); + + sortedFuels.ForEach(type => fuelTypesXElement.Add(new XElement(_cif + XMLNames.Engine_FuelType, type))); + + return new List<XElement>() { + new XElement(_cif + XMLNames.Engine_RatedPower, engine.RatedPowerDeclared.ValueAsUnit("kW")), + new XElement(_cif + "EngineCapacity", engine.Displacement.ValueAsUnit("ltr")), + fuelTypesXElement + }; + } + + #endregion + } + + + public class TransmissionGroup : AbstractCIFGroupWriter + { + public TransmissionGroup(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var gearbox = inputData.JobInputData.Vehicle.Components.GearboxInputData; + return new List<XElement>() { + new XElement(_cif + "TransmissionValues", gearbox.CertificationMethod.ToXMLFormat()), + new XElement(_cif + XMLNames.Gearbox_TransmissionType, gearbox.Type.ToXMLFormat()), + new XElement(_cif + "NrOfGears", gearbox.Gears.Count) + }; + } + + #endregion + } + + public class AxleWheelsGroup : AbstractCIFGroupWriter + { + public AxleWheelsGroup(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var axleWheels = inputData.JobInputData.Vehicle.Components.AxleWheels; + double averageRRC = 0; + var result = new List<XElement>(); + int axleCount = 0; + + foreach (var axle in axleWheels.AxlesDeclaration) { + averageRRC += axle.Tyre.RollResistanceCoefficient; + result.Add(new XElement(_cif + XMLNames.AxleWheels_Axles_Axle, + new XAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, ++axleCount), + new XElement(_cif + XMLNames.Report_Tyre_TyreDimension, axle.Tyre.Dimension), + new XElement(_cif + "FuelEfficiencyClass", axle.Tyre.FuelEfficiencyClass), + new XElement(_cif + XMLNames.Report_Tyre_TyreCertificationNumber, axle.Tyre.CertificationNumber))); + } + averageRRC /= axleWheels.AxlesDeclaration.Count; + result.Insert(0, new XElement(_cif + "AverageRRC", averageRRC)); + + + return result; + } + + #endregion + } + + public class LorryAuxGroup : AbstractCIFGroupWriter + { + public LorryAuxGroup(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + return new List<XElement>() { + new XElement(_cif + "SteeringPumpTechnology", + inputData.JobInputData.Vehicle.Components.AuxiliaryInputData.Auxiliaries + .Single(aux => aux.Type == AuxiliaryType.SteeringPump).Technology.Join()) + }; + } + + #endregion + } + + public class ElectricMachineGroup : AbstractCIFGroupWriter + { + public ElectricMachineGroup(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var result = new List<XElement>(); + var totalRatedPropulsionPower = + inputData.JobInputData.Vehicle.Components.ElectricMachines.Entries + .Where(e => e.Position != PowertrainPosition.GEN).Sum((e => e.ElectricMachine.R85RatedPower)); + result.Add(new XElement(_cif + "TotalRatedPropulsionPower", totalRatedPropulsionPower.ValueAsUnit("kW"))); + result.Add(new XElement(_cif + "MaxContinousPropulsionPower", "TODO")); + + + + return result; + } + + #endregion + } + + public class REESSGroup : AbstractCIFGroupWriter + { + public REESSGroup(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var reess = inputData.JobInputData.Vehicle.Components.ElectricStorage; + var batteries = reess.ElectricStorageElements + .Where(es => es.REESSPack.StorageType == REESSType.Battery) + .Select(es => es.REESSPack as IBatteryPackDeclarationInputData); + var totalStorageCapacity = batteries + .Sum(bp => bp.Capacity); + var totalUsableCapacity = batteries.Sum(bp => bp.TotalUsableCapacityInSimulation()); + return new List<XElement>() { + new XElement(_cif + "TotalStorageCapacity", totalUsableCapacity), + new XElement(_cif + "UsableStorageCapacity", totalStorageCapacity) + }; + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/VehicleGroups.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/VehicleGroups.cs new file mode 100644 index 0000000000000000000000000000000000000000..9fd1359dd91af8d61475363cd5fb8036f8a1c018 --- /dev/null +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/VehicleGroups.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportGroupWriter; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9.CIFWriter +{ + public class GeneralVehicleSequenceGroupCIF : AbstractCIFGroupWriter + { + public GeneralVehicleSequenceGroupCIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var vehicleData = inputData.JobInputData.Vehicle; + var result = new List<XElement>() { + new XElement(_cif + XMLNames.Vehicle_VIN, vehicleData.VIN), + new XElement(_cif + XMLNames.Vehicle_VehicleCategory, vehicleData.LegislativeClass.ToXMLFormat()), + new XElement(_cif + XMLNames.Vehicle_AxleConfiguration, vehicleData.AxleConfiguration.ToXMLFormat()), + new XElement(_cif + XMLNames.Vehicle_TPMLM, XMLHelper.ValueAsUnit(vehicleData.GrossVehicleMassRating, "kg")), + new XElement(_cif + XMLNames.Report_Vehicle_VehicleGroup, vehicleData.VehicleCategory.ToXMLFormat()) + + }; + return result; + } + + #endregion + } + + + public class LorryGeneralVehicleSequenceGroupCIF : AbstractCIFGroupWriter + { + public LorryGeneralVehicleSequenceGroupCIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var vehicleData = inputData.JobInputData.Vehicle; + var result = new List<XElement>() { + new XElement(_cif + "VehicleGroupCO2", "todo"), + new XElement(_cif + XMLNames.Component_Manufacturer, vehicleData.Manufacturer), + new XElement(_cif + XMLNames.Component_ManufacturerAddress, vehicleData.ManufacturerAddress), + new XElement(_cif + XMLNames.Component_Model, vehicleData.Model), + new XElement(_cif + XMLNames.VehicleTypeApprovalNumber, vehicleData.VehicleTypeApprovalNumber), + new XElement(_cif + XMLNames.CorrectedActualMass, vehicleData.CurbMassChassis.ValueAsUnit("kg")), + new XElement(_cif + XMLNames.Vehicle_VocationalVehicle, vehicleData.VocationalVehicle), + new XElement(_cif + XMLNames.Vehicle_SleeperCab, vehicleData.SleeperCab), + new XElement(_cif + XMLNames.Vehicle_ZeroEmissionVehicle, vehicleData.ZeroEmissionVehicle), + new XElement(_cif + XMLNames.Vehicle_HybridElectricHDV, vehicleData.HybridElectricHDV) + }; + return result; + } + + #endregion + } + + public class ConventionalLorryVehicleSequenceGroupCIF : AbstractCIFGroupWriter + { + public ConventionalLorryVehicleSequenceGroupCIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var vehicleData = inputData.JobInputData.Vehicle; + return new List<XElement>() { + new XElement(_cif + "WasteHeatRecovery", + vehicleData.Components.EngineInputData.WHRType != WHRType.None), + new XElement(_cif + XMLNames.Vehicle_DualFuelVehicle, vehicleData.DualFuelVehicle) + }; + } + + #endregion + } + + public class HEV_LorryVehicleTypeGroupCIF : AbstractCIFGroupWriter + { + public HEV_LorryVehicleTypeGroupCIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var result = new List<XElement>(); + result.AddRange(_cifFactory.GetGeneralVehicleSequenceGroupWriter().GetElements(inputData)); + result.AddRange(_cifFactory.GetLorryGeneralVehicleSequenceGroupWriter().GetElements(inputData)); + result.AddRange(_cifFactory.GetHEV_VehicleSequenceGroupWriter().GetElements(inputData)); + + return result; + } + + #endregion + } + + + public class HEV_VehicleSequenceGroupWriter : AbstractCIFGroupWriter + { + public HEV_VehicleSequenceGroupWriter(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCIFGroupWriter + + public override IList<XElement> GetElements(IDeclarationInputDataProvider inputData) + { + var result = new List<XElement>(); + var ovCc = inputData.JobInputData.Vehicle.OvcHev; + result.AddRange(_cifFactory.GetConventionalLorryVehicleSequenceGroupWriter().GetElements(inputData)); + result.AddRange(new List<XElement>() { + new XElement(_cif + "HEVArchitecture", inputData.JobInputData.Vehicle.ArchitectureID.GetLabel()), + new XElement(_cif + "OffVehicleChargingCapability", ovCc) + }); + if (ovCc) { + result.Add(new XElement(_cif + "OffVehicleChargingMaxPower", inputData.JobInputData.Vehicle.MaxChargingPower.ValueAsUnit("kW"))); + } + return result; + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/VehicleWriter.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/VehicleWriter.cs new file mode 100644 index 0000000000000000000000000000000000000000..dd96f035d868bbb637591cc13a54cc38cb85dd35 --- /dev/null +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CIFWriter/VehicleWriter.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using Castle.Components.DictionaryAdapter.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9.CustomerInformationFile; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportXMLTypeWriter; + +namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9.CIFWriter +{ + public abstract class VehicleWriter : IXmlTypeWriter + { + protected readonly ICustomerInformationFileFactory _cifFactory; + protected readonly IManufacturerReportFactory _mrfFactory; + protected XNamespace _cif = "urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.9"; + + public VehicleWriter(ICustomerInformationFileFactory cifFactory, IManufacturerReportFactory mrfFactory) + { + _cifFactory = cifFactory; + _mrfFactory = mrfFactory; + } + + + #region Implementation of IXmlTypeWriter + + public abstract XElement GetElement(IDeclarationInputDataProvider inputData); + + #endregion + } + + + public class CIFConventionalLorryVehicleWriter : VehicleWriter + { + public CIFConventionalLorryVehicleWriter(ICustomerInformationFileFactory cifFactory, + IManufacturerReportFactory mrfFactory) : base(cifFactory, mrfFactory) + { + + } + + #region Overrides of VehicleWriter + + public override XElement GetElement(IDeclarationInputDataProvider inputData) + { + return new XElement(_cif + XMLNames.Component_Vehicle, + _cifFactory.GetGeneralVehicleSequenceGroupWriter().GetElements(inputData), + _cifFactory.GetLorryGeneralVehicleSequenceGroupWriter().GetElements(inputData), + _cifFactory.GetConventionalLorryVehicleSequenceGroupWriter().GetElements(inputData), + _mrfFactory.GetConventionalADASType().GetXmlType(inputData.JobInputData.Vehicle.ADAS), + _cifFactory.GetEngineGroup().GetElements(inputData), + _cifFactory.GetTransmissionGroup().GetElements(inputData), + new XElement(_cif + XMLNames.Component_Retarder, inputData.JobInputData.Vehicle.Components.RetarderInputData.Type != RetarderType.None), + new XElement(_cif + XMLNames.Axlegear_Ratio, inputData.JobInputData.Vehicle.Components.AxleGearInputData.Ratio.ToXMLFormat(2)), + _cifFactory.GetAxleWheelsGroup().GetElements(inputData), + _cifFactory.GetLorryAuxGroup().GetElements(inputData) + ); + + + + } + + #endregion + } + + public class CIF_HEVPx_LorryVehicleWriter : VehicleWriter + { + public CIF_HEVPx_LorryVehicleWriter(ICustomerInformationFileFactory cifFactory, IManufacturerReportFactory mrfFactory) : base(cifFactory, mrfFactory) { } + + #region Overrides of VehicleWriter + + public override XElement GetElement(IDeclarationInputDataProvider inputData) + { + return new XElement(_cif + XMLNames.Component_Vehicle, + _cifFactory.GetHEV_LorryVehicleTypeGroup().GetElements(inputData), + _mrfFactory.GetHEVADASType().GetXmlType(inputData.JobInputData.Vehicle.ADAS), + _cifFactory.GetEngineGroup().GetElements(inputData), + _cifFactory.GetTransmissionGroup().GetElements(inputData), + _cifFactory.GetElectricMachineGroup().GetElements(inputData), + _cifFactory.GetREESSGroup().GetElements(inputData), + _cifFactory.GetLorryAuxGroup().GetElements(inputData) + ); + } + + #endregion + } + + +} diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CustomerInformationFile/LorryCustomerInformationFile.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CustomerInformationFile/LorryCustomerInformationFile.cs index c7c1dd23fbcfac73c993fbf1f4ff0d2d7b9ac5fa..a1d0cc98a54336fed2dcfc5d384099b84db54dcb 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CustomerInformationFile/LorryCustomerInformationFile.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/CustomerInformationFile/LorryCustomerInformationFile.cs @@ -35,9 +35,135 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation #region Overrides of AbstractCustomerReport - public override void InitializeVehicleData(IVehicleDeclarationInputData inputData) + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) { - Vehicle = _cifFactory.GetConventionalLorryVehicleType(inputData); + Vehicle = _cifFactory.GetConventionalLorryVehicleType().GetElement(inputData); + } + + #endregion + } + + public class HEV_PxLorry_CIF : LorryCustomerInformationFile + { + public HEV_PxLorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + var vehicle = _cifFactory.GetHEV_PxLorryVehicleType(); + Vehicle = _cifFactory.GetHEV_PxLorryVehicleType().GetElement(inputData); + } + #endregion + } + + public class HEV_S2_Lorry_CIF : LorryCustomerInformationFile + { + public HEV_S2_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); + } + + #endregion + } + + public class HEV_S3_Lorry_CIF : LorryCustomerInformationFile + { + public HEV_S3_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); + } + + #endregion + } + + public class HEV_S4_Lorry_CIF : LorryCustomerInformationFile + { + public HEV_S4_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); + } + + #endregion + } + + public class HEV_IEPC_Lorry_CIF : LorryCustomerInformationFile + { + public HEV_IEPC_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); + } + + #endregion + } + + public class PEV_E2_Lorry_CIF : LorryCustomerInformationFile + { + public PEV_E2_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); + } + + #endregion + } + + public class PEV_E3_Lorry_CIF : LorryCustomerInformationFile + { + public PEV_E3_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); + } + + #endregion + } + + public class PEV_E4_Lorry_CIF : LorryCustomerInformationFile + { + public PEV_E4_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); + } + + #endregion + } + + public class PEV_IEPC_Lorry_CIF : LorryCustomerInformationFile + { + public PEV_IEPC_Lorry_CIF(ICustomerInformationFileFactory cifFactory) : base(cifFactory) { } + + #region Overrides of AbstractCustomerReport + + public override void InitializeVehicleData(IDeclarationInputDataProvider inputData) + { + throw new NotImplementedException(); } #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ICustomerInformationFileFactory.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ICustomerInformationFileFactory.cs index 69cf8f8d9873bfcbc80faa16b7e0233d2b1dec1d..08d608bea64d1f0f85b01af317c563cca69f34cf 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ICustomerInformationFileFactory.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ICustomerInformationFileFactory.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Xml.Linq; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportGroupWriter; using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.ManufacturerReportXMLTypeWriter; namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9 @@ -15,6 +16,29 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation IXMLCustomerReport GetCustomerReport(VehicleCategory vehicleType, VectoSimulationJobType jobType, ArchitectureID archId, bool exempted, bool iepc, bool ihpc); - IXmlTypeWriter GetConventionalLorryVehicleType(IVehicleDeclarationInputData inputData); + IXmlTypeWriter GetConventionalLorryVehicleType(); + IXmlTypeWriter GetHEV_PxLorryVehicleType(); + IXmlTypeWriter GetHEV_S2_LorryVehicleType(); + IXmlTypeWriter GetHEV_S3_LorryVehicleType(); + IXmlTypeWriter GetHEV_S4_LorryVehicleType(); + IXmlTypeWriter GetHEV_IEPC_LorryVehicleType(); + + IXmlTypeWriter GetPEV_E2_LorryVehicleType(); + IXmlTypeWriter GetPEV_E3_LorryVehicleType(); + IXmlTypeWriter GetPEV_E4_LorryVehicleType(); + IXmlTypeWriter GetPEV_IEPC_LorryVehicleType(); + + + IMrfXmlGroup GetGeneralVehicleSequenceGroupWriter(); + IMrfXmlGroup GetLorryGeneralVehicleSequenceGroupWriter(); + IMrfXmlGroup GetConventionalLorryVehicleSequenceGroupWriter(); + IMrfXmlGroup GetEngineGroup(); + IMrfXmlGroup GetTransmissionGroup(); + IMrfXmlGroup GetAxleWheelsGroup(); + IMrfXmlGroup GetLorryAuxGroup(); + IMrfXmlGroup GetHEV_VehicleSequenceGroupWriter(); + IMrfXmlGroup GetHEV_LorryVehicleTypeGroup(); + IMrfXmlGroup GetElectricMachineGroup(); + IMrfXmlGroup GetREESSGroup(); } } diff --git a/VectoCore/VectoCore/Utils/XMLHelper.cs b/VectoCore/VectoCore/Utils/XMLHelper.cs index 7e315fa5d8e6a2c6364c3539c3bf1c93dc4839c8..a8d38c812fa64ed1ce4d42bc69e8440c8008589b 100644 --- a/VectoCore/VectoCore/Utils/XMLHelper.cs +++ b/VectoCore/VectoCore/Utils/XMLHelper.cs @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.Utils .Replace(versionPrefix, string.Empty); } - public static object[] ValueAsUnit(Kilogram mass, string unit, uint? decimals = 0) + public static object[] ValueAsUnit(this Kilogram mass, string unit, uint? decimals = 0) { switch (unit) { case "t": return GetValueAsUnit(mass.ConvertToTon(), unit, decimals); @@ -88,7 +88,7 @@ namespace TUGraz.VectoCore.Utils throw new NotImplementedException($"unknown unit '{unit}'"); } - public static object[] ValueAsUnit(Watt power, string unit, uint? decimals = 0) + public static object[] ValueAsUnit(this Watt power, string unit, uint? decimals = 0) { switch (unit) { case "kW": return GetValueAsUnit(power?.ConvertToKiloWatt(), unit, decimals); @@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Utils throw new NotImplementedException($"unknown unit '{unit}'"); } - public static object[] ValueAsUnit(CubicMeter volume, string unit, uint? decimals = 0) + public static object[] ValueAsUnit(this CubicMeter volume, string unit, uint? decimals = 0) { switch (unit) { case "ltr": return GetValueAsUnit(volume.ConvertToCubicDeziMeter(), unit, decimals); @@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.Utils throw new NotImplementedException($"unknown unit '{unit}'"); } - public static object[] ValueAsUnit(PerSecond angSpeed, string unit, uint? decimals = 0) + public static object[] ValueAsUnit(this PerSecond angSpeed, string unit, uint? decimals = 0) { switch (unit) { case "rpm": return GetValueAsUnit(angSpeed.ConvertToRoundsPerMinute(), unit, decimals); @@ -119,7 +119,7 @@ namespace TUGraz.VectoCore.Utils } - public static object[] ValueAsUnit(MeterPerSecond speed, string unit, uint? decimals) + public static object[] ValueAsUnit(this MeterPerSecond speed, string unit, uint? decimals) { switch (unit) { case "km/h": return GetValueAsUnit(speed.ConvertToKiloMeterPerHour(), unit, decimals); @@ -128,7 +128,7 @@ namespace TUGraz.VectoCore.Utils throw new NotImplementedException($"unknown unit '{unit}'"); } - public static object[] ValueAsUnit(MeterPerSquareSecond acc, string unit, uint? decimals) + public static object[] ValueAsUnit(this MeterPerSquareSecond acc, string unit, uint? decimals) { switch (unit) { case "m/s²": return GetValueAsUnit(acc.Value(), unit, decimals); @@ -137,7 +137,7 @@ namespace TUGraz.VectoCore.Utils throw new NotImplementedException($"unknown unit '{unit}'"); } - public static object[] ValueAsUnit(Meter m, string unit, uint? decimals) + public static object[] ValueAsUnit(this Meter m, string unit, uint? decimals) { switch (unit) { case "m": return GetValueAsUnit(m.Value(), unit, decimals); diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 79bce16ff9796b82f5386b87fc51610425e6b9df..e55fa01a288430432308c48dc14c5556cbc242ca 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -483,6 +483,10 @@ <Compile Include="OutputData\XML\ComponentWriter\IComponentWriterFactory.cs" /> <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\AbstractCustomerReport.cs" /> <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\CIFNinjectModule.cs" /> + <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\CIFWriter\AbstractCIFGroupWriter.cs" /> + <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\CIFWriter\ComponentGroupWriters.cs" /> + <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\CIFWriter\VehicleGroups.cs" /> + <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\CIFWriter\VehicleWriter.cs" /> <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\CustomerInformationFile\LorryCustomerInformationFile.cs" /> <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\CustomerInformationFile_0_9\ICustomerInformationFileFactory.cs" /> <Compile Include="OutputData\XML\DeclarationReports\CustomerInformationFile\IXMLCustomerReport.cs" /> diff --git a/VectoCore/VectoCoreTest/XML/Reports/CustomerInformationFileWriterTest.cs b/VectoCore/VectoCoreTest/XML/Reports/CustomerInformationFileWriterTest.cs index 88d111176d54ff189b918a1a167a094e5962542d..0d8c0a7966d5cd5f894be458209e3106c5253761 100644 --- a/VectoCore/VectoCoreTest/XML/Reports/CustomerInformationFileWriterTest.cs +++ b/VectoCore/VectoCoreTest/XML/Reports/CustomerInformationFileWriterTest.cs @@ -7,6 +7,7 @@ using NUnit.Framework; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile; +using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9.CustomerInformationFile; using TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport; namespace TUGraz.VectoCore.Tests.XML.Reports @@ -40,11 +41,26 @@ namespace TUGraz.VectoCore.Tests.XML.Reports [TestCase(ConventionalHeavyLorry)] public void ConventionalLorryCIFTest(string fileName) { - var report = GetCustomerReport(fileName, out var dataProvider) as + var report = GetCustomerReport(fileName, out var dataProvider) as ConventionalLorry_CIF; + Assert.NotNull(report); + report.InitializeVehicleData(dataProvider); + Assert.IsTrue(ValidateAndPrint(report.Report)); } + [TestCase(HEV_Px_HeavyLorry)] + public void HEV_Px_IHPC_LorryCIFTest(string fileName) + { + var report = GetCustomerReport(fileName, out var dataProvider) as HEV_PxLorry_CIF; + Assert.NotNull(report); + report.InitializeVehicleData(dataProvider); + + Assert.IsTrue(ValidateAndPrint(report.Report)); + } + + +