diff --git a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs index 42796d2030061254f6b08cb76d2bb23233a9fbbd..8f05e2e8b1b4b7a4e2f5aedc8d4fcea8c656e4a3 100644 --- a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs +++ b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -64,6 +65,32 @@ namespace TUGraz.VectoCommon.InputData IHPC } + public static class VectoSimulationJobTypeHelper + { + public const string Conventional = "Conventional"; + public const string Hybrid = "Hybrid"; + public const string PureElectric = "PureElectric"; + + public static string GetPowertrainArchitectureType(this VectoSimulationJobType jobType) + { + switch (jobType) { + case VectoSimulationJobType.EngineOnlySimulation: + case VectoSimulationJobType.ConventionalVehicle: + return Conventional; + case VectoSimulationJobType.ParallelHybridVehicle: + case VectoSimulationJobType.SerialHybridVehicle: + case VectoSimulationJobType.IHPC: + case VectoSimulationJobType.IEPC_S: + return Hybrid; + case VectoSimulationJobType.BatteryElectricVehicle: + case VectoSimulationJobType.IEPC_E: + return PureElectric; + default: + throw new ArgumentOutOfRangeException(nameof(jobType), jobType, null); + } + } + } + public interface IHybridStrategyParameters { double EquivalenceFactorDischarge { get; } 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 d23d55c35b042cc65438a8f55f53e7b7e927c780..1d07831d8599ee2881c48c27c2b21282533f481d 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 @@ -420,8 +420,29 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation } })).InSingletonScope(); - Bind<IResultsWriter>().To<ExemptedResultsWriter>().Named( + Bind<IResultsWriter>().To<CIFResultsWriter.ConventionalLorry>().Named( + _namingHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobTypeHelper.Conventional, false)); + Bind<IResultsWriter>().To<CIFResultsWriter.HEVNonOVCLorry>().Named( + _namingHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobTypeHelper.Hybrid, false)); + Bind<IResultsWriter>().To<CIFResultsWriter.HEVOVCLorry>().Named( + _namingHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobTypeHelper.Hybrid, true)); + Bind<IResultsWriter>().To<CIFResultsWriter.PEVLorry>().Named( + _namingHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobTypeHelper.PureElectric, true)); + Bind<IResultsWriter>().To<CIFResultsWriter.ExemptedResultsWriter>().Named( _namingHelper.GetName(VehicleCategoryHelper.Lorry, true)); + + Bind<IResultsWriter>().To<CIFResultsWriter.ConventionalBus>().Named( + _namingHelper.GetName(VehicleCategoryHelper.CompletedBus, VectoSimulationJobTypeHelper.Conventional, false)); + Bind<IResultsWriter>().To<CIFResultsWriter.HEVNonOVCBus>().Named( + _namingHelper.GetName(VehicleCategoryHelper.CompletedBus, VectoSimulationJobTypeHelper.Hybrid, false)); + Bind<IResultsWriter>().To<CIFResultsWriter.HEVOVCBus>().Named( + _namingHelper.GetName(VehicleCategoryHelper.CompletedBus, VectoSimulationJobTypeHelper.Hybrid, true)); + Bind<IResultsWriter>().To<CIFResultsWriter.PEVBus>().Named( + _namingHelper.GetName(VehicleCategoryHelper.CompletedBus, VectoSimulationJobTypeHelper.PureElectric, true)); + Bind<IResultsWriter>().To<CIFResultsWriter.ExemptedResultsWriter>().Named( + _namingHelper.GetName(VehicleCategoryHelper.CompletedBus, true)); + + } } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/IResultsWriter.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/IResultsWriter.cs index e60af7a75c51aabd26f66c946bb9de45c27eb48b..bc8cbf3be30a55e85cdae1cd02399a1c24f50d33 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/IResultsWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/IResultsWriter.cs @@ -9,20 +9,52 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation XElement GenerateResults(List<IResultEntry> results); } - - public class ExemptedResultsWriter : IResultsWriter + public abstract class AbstractResultsWriter : IResultsWriter { - protected XNamespace XmlNS => XNamespace.Get("urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.9"); - #region Implementation of IResultsWriter - public XElement GenerateResults(List<IResultEntry> results) + //public abstract XElement GenerateResults(List<IResultEntry> results); + + public virtual XElement GenerateResults(List<IResultEntry> results) { - return new XElement(XmlNS + "Results", - new XElement(XmlNS + "Status", "success"), - new XElement(XmlNS + "ExemptedVehicle")); + return null; } #endregion } + + public class CIFResultsWriter + { + public class ConventionalLorry : AbstractResultsWriter {} + + public class HEVNonOVCLorry : AbstractResultsWriter {} + + public class HEVOVCLorry : AbstractResultsWriter {} + + public class PEVLorry : AbstractResultsWriter {} + + public class ConventionalBus : AbstractResultsWriter {} + + public class HEVNonOVCBus : AbstractResultsWriter {} + + public class HEVOVCBus : AbstractResultsWriter {} + + public class PEVBus : AbstractResultsWriter {} + + public class ExemptedResultsWriter : IResultsWriter + { + protected XNamespace XmlNS => XNamespace.Get("urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.9"); + + #region Implementation of IResultsWriter + + public XElement GenerateResults(List<IResultEntry> results) + { + return new XElement(XmlNS + "Results", + new XElement(XmlNS + "Status", "success"), + new XElement(XmlNS + "ExemptedVehicle")); + } + + #endregion + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/ResultWriterFactory.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/ResultWriterFactory.cs index c1f05540aa7958a55f268e6b4e5861a9e4da40aa..a4fc4d4b11f1de48110deb828c9634b2c42e6840 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/ResultWriterFactory.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/CustomerInformationFile_0_9/ResultWriter/ResultWriterFactory.cs @@ -20,7 +20,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation try { return _internalFactory.GetCIFResultsWriter( new VehicleTypeAndArchitectureStringHelperResults.ResultsVehicleClassification(vehicleCategory, - jobType, ovc, exempted)); + jobType.GetPowertrainArchitectureType(), ovc, exempted)); } catch (Exception e) { throw new Exception($"Could not create ResultsWriter for vehicle category {vehicleCategory}, {jobType}, ovc: {ovc}, exempted: {exempted}", e); } diff --git a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs index 916d79e65583bf09c6fd6a3100e4e1e559af71a9..8ad5051ad0ed8e8f9552ea1f946ca008c747cba1 100644 --- a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs +++ b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs @@ -250,7 +250,7 @@ namespace TUGraz.VectoCore.Utils.Ninject return classification.GetHashCode().ToString(); } - public string GetName(string vehicleCategory, VectoSimulationJobType jobType, bool ovc = false, + public string GetName(string vehicleCategory, string jobType, bool ovc, bool exempted = false) { return GetName(new ResultsVehicleClassification(vehicleCategory, jobType, ovc, exempted)); @@ -258,27 +258,27 @@ namespace TUGraz.VectoCore.Utils.Ninject public string GetName(string vehicleType, bool exempted) { - return GetName(vehicleType, VectoSimulationJobType.ConventionalVehicle, exempted: exempted); + return GetName(vehicleType, VectoSimulationJobTypeHelper.Conventional, false, exempted: exempted); } public struct ResultsVehicleClassification { private readonly string _vehicleCategory; - private readonly VectoSimulationJobType _jobType; + private readonly string _powertrainCategory; private readonly bool _ovc; private readonly bool _exempted; - public ResultsVehicleClassification(string vehicleCategory, VectoSimulationJobType jobType, bool ovc, bool exempted) + public ResultsVehicleClassification(string vehicleCategory, string powertrainCategory, bool ovc, bool exempted) { _vehicleCategory = vehicleCategory; - _jobType = jobType; + _powertrainCategory = powertrainCategory; _ovc = ovc; _exempted = exempted; } public bool Exempted => _exempted; - public VectoSimulationJobType JobType => Exempted ? VectoSimulationJobType.ConventionalVehicle : _jobType; + public string JobType => Exempted ? VectoSimulationJobTypeHelper.Conventional : _powertrainCategory; public string VehicleCategory => _vehicleCategory; public bool OVC => _ovc; @@ -301,10 +301,10 @@ namespace TUGraz.VectoCore.Utils.Ninject public override int GetHashCode() { unchecked { - var hashCode = VehicleCategory != null ? VehicleCategory.GetHashCode() : 0; - hashCode = (hashCode * 397) ^ (int)JobType; - hashCode = (hashCode * 397) ^ OVC.GetHashCode(); - hashCode = (hashCode * 397) ^ Exempted.GetHashCode(); + var hashCode = (_vehicleCategory != null ? _vehicleCategory.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (_powertrainCategory != null ? _powertrainCategory.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ _ovc.GetHashCode(); + hashCode = (hashCode * 397) ^ _exempted.GetHashCode(); return hashCode; } } diff --git a/VectoCore/VectoCoreTest/Reports/TestXMLResultsWriting.cs b/VectoCore/VectoCoreTest/Reports/TestXMLResultsWriting.cs index 9ce696c8f3b17dd5ee57bf65fc5c9d399bf3ab24..10850fef5a8a33d8657e0c96db5ac9eff8b8787e 100644 --- a/VectoCore/VectoCoreTest/Reports/TestXMLResultsWriting.cs +++ b/VectoCore/VectoCoreTest/Reports/TestXMLResultsWriting.cs @@ -24,7 +24,15 @@ public class TestXMLResultsWriting _reportResultsFactory = _kernel.Get<IResultsWriterFactory>(); } - [TestCase(VehicleCategory.RigidTruck, VectoSimulationJobType.ConventionalVehicle, false, true, typeof(ExemptedResultsWriter))] + [ + TestCase(VehicleCategory.RigidTruck, VectoSimulationJobType.ConventionalVehicle, false, true, typeof(CIFResultsWriter.ExemptedResultsWriter)), + TestCase(VehicleCategory.RigidTruck, VectoSimulationJobType.ConventionalVehicle, false, false, typeof(CIFResultsWriter.ConventionalLorry)), + TestCase(VehicleCategory.Tractor, VectoSimulationJobType.ConventionalVehicle, false, false, typeof(CIFResultsWriter.ConventionalLorry)), + TestCase(VehicleCategory.RigidTruck, VectoSimulationJobType.ParallelHybridVehicle, false, false, typeof(CIFResultsWriter.HEVNonOVCLorry)), + TestCase(VehicleCategory.RigidTruck, VectoSimulationJobType.SerialHybridVehicle, true, false, typeof(CIFResultsWriter.HEVOVCLorry)), + TestCase(VehicleCategory.RigidTruck, VectoSimulationJobType.BatteryElectricVehicle, true, false, typeof(CIFResultsWriter.PEVLorry)), + //TestCase(VehicleCategory.RigidTruck, VectoSimulationJobType.BatteryElectricVehicle, false, false, typeof(CIFResultsWriter.PEVLorry)), // for PEV, OVC is always true! + ] public void TestReportResultInstance(VehicleCategory vehicleCategory, VectoSimulationJobType jobType, bool ovc, bool exempted, Type expectedResultWriterType) {