From ee692531b722c1166f2f5f3a6b2c8bddca49a358 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Thu, 1 Jun 2017 10:05:26 +0200 Subject: [PATCH] make testcases work --- VectoCommon/VectoHashing/VectoHash.cs | 4 ++-- ...stractDeclarationXMLComponentDataProvider.cs | 14 ++++---------- ...stractEngineeringXMLComponentDataProvider.cs | 12 ++++-------- .../XMLEngineeringAxlegearDataProvider.cs | 6 +++++- .../AbstractSimulationDataAdapter.cs | 17 +++++++++++++---- .../DataObjectAdapter/DeclarationDataAdapter.cs | 2 ++ .../Models/Simulation/Data/VectoRunData.cs | 2 +- .../SimulationComponent/Data/VehicleData.cs | 17 ++++++----------- .../Resources/Declaration/SegmentTable.csv | 4 ++-- .../FileIO/SimulationDataReaderTest.cs | 2 +- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/VectoCommon/VectoHashing/VectoHash.cs b/VectoCommon/VectoHashing/VectoHash.cs index 31f22e326f..113a409a07 100644 --- a/VectoCommon/VectoHashing/VectoHash.cs +++ b/VectoCommon/VectoHashing/VectoHash.cs @@ -59,8 +59,8 @@ namespace TUGraz.VectoHashing var retVal = new List<VectoComponents>(); foreach (var component in EnumHelper.GetValues<VectoComponents>()) { var count = - Document.SelectNodes(string.Format("//*[local-name()='VectoInputDeclaration']/*[local-name()='{0}']", - component.XMLElementName())).Count; + Document.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']", + XMLNames.VectoInputDeclaration,component.XMLElementName())).Count; for (var i = 0; i < count; i++) { retVal.Add(component); } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/AbstractDeclarationXMLComponentDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/AbstractDeclarationXMLComponentDataProvider.cs index 95d726f8ad..49d0f23449 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/AbstractDeclarationXMLComponentDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/AbstractDeclarationXMLComponentDataProvider.cs @@ -63,10 +63,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration get { return GetElementValue(XMLNames.Component_Model); } } - public virtual string Creator - { - get { return "N.A."; } - } + public virtual string Date { @@ -78,7 +75,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration get { return GetElementValue(XMLNames.Component_TechnicalReportId); } } - public CertificationMethod CertificationMethod + public virtual CertificationMethod CertificationMethod { get { var value = GetElementValue(XMLNames.Component_CertificationMethod); @@ -86,7 +83,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration } } - public string CertificationNumber + public virtual string CertificationNumber { get { return GetAttributeValue("..", "certificationNumber"); } } @@ -96,10 +93,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration get { return GetElementValue("..//*[local-name()='DigestValue']"); } } - public virtual IntegrityStatus IntegrityStatus - { - get { return IntegrityStatus.Unknown; } - } + protected bool ElementExists(string relativePath) { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs index 6ef8935c83..ba7ace4b10 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs @@ -53,11 +53,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering get { return GetElementValue(XMLNames.Component_Model); } } - public override string Creator - { - get { return GetElementValue(XMLNames.Component_Creator); } - } - + public override string Date { get { return GetElementValue(XMLNames.Component_Date); } @@ -73,12 +69,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering get { return ""; } } - public override IntegrityStatus IntegrityStatus + public override CertificationMethod CertificationMethod { - get { return IntegrityStatus.Unknown; } + get { return CertificationMethod.NotCertified;} } - + protected TableData ReadCSVResourceFile(string relPath) { if (!ElementExists(Helper.Query(relPath, ExtCsvResourceTag))) { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs index d0ff022d73..f5837fcbcd 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs @@ -36,7 +36,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering public AxleLineType LineType { - get { return GetElementValue(XMLNames.Axlegear_LineType).ParseEnum<AxleLineType>(); } + get { + return ElementExists(XMLNames.Axlegear_LineType) + ? GetElementValue(XMLNames.Axlegear_LineType).ParseEnum<AxleLineType>() + : AxleLineType.SinglePortalAxle; + } } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index c763eeeacb..035586c466 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -52,13 +52,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { var retVal = new VehicleData { SavedInDeclarationMode = data.SavedInDeclarationMode, - VIN = data.VIN, Manufacturer = data.Manufacturer, ModelName = data.Model, Date = data.Date, //CertificationNumber = data.CertificationNumber, DigestValueInput = data.DigestValue, - LegislativeClass = data.LegislativeClass, VehicleCategory = data.VehicleCategory, AxleConfiguration = data.AxleConfiguration, CurbWeight = data.CurbMassChassis, @@ -155,7 +153,14 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter }; } - internal AxleGearData CreateAxleGearData(IAxleGearInputData data, bool useEfficiencyFallback) + public AxleGearData CreateAxleGearData(IAxleGearInputData data, bool useEfficiencyFallback) + { + var retVal = SetCommonAxleGearData(data); + retVal.AxleGear.LossMap = ReadAxleLossMap(data, useEfficiencyFallback); + return retVal; + } + + internal TransmissionLossMap ReadAxleLossMap(IAxleGearInputData data, bool useEfficiencyFallback) { TransmissionLossMap axleLossMap; if (data.LossMap == null && useEfficiencyFallback) { @@ -169,7 +174,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter if (axleLossMap == null) { throw new InvalidFileFormatException("LossMap for Axlegear is missing."); } + return axleLossMap; + } + internal AxleGearData SetCommonAxleGearData(IAxleGearInputData data) + { return new AxleGearData { SavedInDeclarationMode = data.SavedInDeclarationMode, Manufacturer = data.Manufacturer, @@ -179,7 +188,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter CertificationMethod = data.CertificationMethod, CertificationNumber = data.CertificationNumber, DigestValueInput = data.DigestValue, - AxleGear = new GearData { LossMap = axleLossMap, Ratio = data.Ratio } + AxleGear = new GearData { Ratio = data.Ratio } }; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index 3556dae703..b33ae94d72 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -88,6 +88,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter } var retVal = SetCommonVehicleData(data); + retVal.VIN = data.VIN; + retVal.LegislativeClass = data.LegislativeClass; retVal.TrailerGrossVehicleWeight = mission.Trailer.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0); retVal.BodyAndTrailerWeight = (mission.MissionType == MissionType.MunicipalUtility diff --git a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs index cf94796b32..5eb3f3e2c1 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs @@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data [ValidateObject] public VehicleData VehicleData { get; internal set; } - [Required, ValidateObject] + [ValidateObject] public AirdragData AirdragData { get; internal set; } [ValidateObject] diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index c25999c543..0ce74d45a2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -42,10 +42,8 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { - public class AirdragData : SimulationComponentData { - public CrossWindCorrectionMode CrossWindCorrectionMode { get; set; } [Required, ValidateObject] @@ -70,7 +68,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public AxleConfiguration AxleConfiguration { get; internal set; } - + [Required, ValidateObject] private List<Axle> _axleData; private KilogramSquareMeter _wheelsInertia; @@ -165,14 +163,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public Kilogram TotalVehicleWeight { get { - var retVal = 0.0; - if (CurbWeight != null) { - retVal += CurbWeight.Value(); - } - if (Loading != null) { - retVal += Loading.Value(); - } - return retVal.SI<Kilogram>(); + var retVal = 0.0.SI<Kilogram>(); + retVal += CurbWeight ?? 0.SI<Kilogram>(); + retVal += BodyAndTrailerWeight ?? 0.SI<Kilogram>(); + retVal += Loading ?? 0.SI<Kilogram>(); + return retVal; } } diff --git a/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv b/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv index 44b2ad00f7..341ab33a60 100644 --- a/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv +++ b/VectoCore/VectoCore/Resources/Declaration/SegmentTable.csv @@ -18,8 +18,8 @@ Valid,Vehicle Category,Axle Conf.,GVW_Min,GVW_Max,HDV class,Height,DesignSpeed,B 0 ,RigidTruck ,6x6 ,0 ,99 ,13 ,3.6 ,85 , , , ,Truck.vacc, , ,RigidSolo , , , , , , , , ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- , , , 0 ,Tractor ,6x6 ,0 ,99 ,14 ,3.6 ,85 , , , ,Truck.vacc, , ,TractorSemitrailer , , , , , , , , ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- , , , 0 ,RigidTruck ,8x2 ,0 ,99 ,15 ,3.6 ,85 , , , ,Truck.vacc, , ,RigidSolo , , , , , , , , ,- ,- ,??? ,- ,- ,- ,- ,- ,- ,- ,- ,- , , , -1 ,RigidTruck ,8x4 ,0 ,99 ,16 ,3.6 ,85 , , , ,Truck.vacc, , ,RigidSolo , ,25/25/25/25 , , , , , , ,- ,- ,- ,- ,- ,- ,2600/12900 ,- ,- ,- ,- ,- , , , -0 ,RigidTruck ,8x6 ,0 ,99 ,17 ,3.6 ,85 , , , ,Truck.vacc, , ,RigidSolo , , , , , , , , ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- ,9.0 ,9.0 , +1 ,RigidTruck ,8x4 ,0 ,99 ,16 ,3.6 ,85 , , , ,Truck.vacc, , ,RigidSolo , ,25/25/25/25 , , , , , , ,- ,- ,- ,- ,- ,- ,2600/12900 ,- ,- ,- ,- ,- ,9.0 ,9.0 , +0 ,RigidTruck ,8x6 ,0 ,99 ,17 ,3.6 ,85 , , , ,Truck.vacc, , ,RigidSolo , , , , , , , , ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- , , , 0 ,RigidTruck ,8x8 ,0 ,99 ,17 ,4.0 ,85 , , , ,Truck.vacc, , ,RigidSolo , , , , , , , , ,- ,- ,- ,- ,- ,- ,??? ,- ,- ,- ,- ,- , , , 0 ,CityBus ,4x2 ,0 ,18 ,B1 ,4.0 ,85 , , , , , , ,CoachBus , , , , , , , , ,- ,- ,- ,- ,- ,- ,- ,??? ,??? ,??? ,- ,- , , , 0 ,InterurbanBus ,4x2 ,0 ,18 ,B2 ,4.0 ,85 , , , , , , ,CoachBus , , , , , , , , ,- ,- ,- ,- ,- ,- ,- ,- ,- ,- ,??? ,- , , , diff --git a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs index 854f752b0f..1a36cd2d94 100644 --- a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs @@ -68,7 +68,7 @@ namespace TUGraz.VectoCore.Tests.FileIO Assert.AreEqual(Path.GetFileNameWithoutExtension(DeclarationJob), runData.JobName); // curbweight + bodyCurbWeight + trailerCurbWeight (for Long Haul only) - Assert.AreEqual(5850 + 1900 + 3400, runData.VehicleData.CurbWeight.Value()); + Assert.AreEqual(5850 + 1900 + 3400, runData.VehicleData.TotalCurbWeight.Value()); Assert.AreEqual(11900, runData.VehicleData.GrossVehicleWeight.Value()); Assert.AreEqual(AxleConfiguration.AxleConfig_4x2, runData.VehicleData.AxleConfiguration); -- GitLab