Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 0b9bae1a authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

introducing architecture type for binding results writer (conventional, HEV, PEV)

adding empty classes for results writer, adding binding,
extending testcase to check the correct results writers are created
parent c00c67e7
No related branches found
No related tags found
No related merge requests found
......@@ -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; }
......
......@@ -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));
}
}
......
......@@ -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
......@@ -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);
}
......
......@@ -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;
}
}
......
......@@ -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)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment