diff --git a/VectoCommon/VectoCommon/Models/AxleConfiguration.cs b/VectoCommon/VectoCommon/Models/AxleConfiguration.cs index 19d6524dce6fbccbf49c362d0c4b673609e97fe1..c03fdd32d0404d68137a5da18f8d45679506ebd4 100644 --- a/VectoCommon/VectoCommon/Models/AxleConfiguration.cs +++ b/VectoCommon/VectoCommon/Models/AxleConfiguration.cs @@ -29,81 +29,101 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; -using System.Diagnostics.CodeAnalysis; -using TUGraz.VectoCommon.Utils; - -namespace TUGraz.VectoCommon.Models -{ - [SuppressMessage("ReSharper", "InconsistentNaming")] - public enum AxleConfiguration - { - AxleConfig_4x2, - AxleConfig_4x4, - AxleConfig_6x2, - AxleConfig_6x4, - AxleConfig_6x6, - AxleConfig_8x2, - AxleConfig_8x4, - AxleConfig_8x6, - AxleConfig_8x8, - } - - public enum AxleType - { - VehicleDriven, - VehicleNonDriven, - Trailer - } - - public static class AxleTypeHelper - { - public static string GetLabel(this AxleType self) - { - switch (self) { - case AxleType.VehicleDriven: - return "Vehicle driven"; - case AxleType.VehicleNonDriven: - return "Vehicle non-driven"; - case AxleType.Trailer: - return "Trailer"; - default: - throw new ArgumentOutOfRangeException("self", self, null); - } - } - } - - public static class AxleConfigurationHelper - { - private const string Prefix = "AxleConfig_"; - - public static string GetName(this AxleConfiguration self) - { - return self.ToString().Replace(Prefix, ""); - } - - public static AxleConfiguration Parse(string typeString) - { - return (Prefix + typeString).ParseEnum<AxleConfiguration>(); - } - - public static int NumAxles(this AxleConfiguration self) - { - switch (self) { - case AxleConfiguration.AxleConfig_4x2: - case AxleConfiguration.AxleConfig_4x4: - return 2; - case AxleConfiguration.AxleConfig_6x2: - case AxleConfiguration.AxleConfig_6x4: - case AxleConfiguration.AxleConfig_6x6: - return 3; - case AxleConfiguration.AxleConfig_8x2: - case AxleConfiguration.AxleConfig_8x4: - case AxleConfiguration.AxleConfig_8x6: - case AxleConfiguration.AxleConfig_8x8: - return 4; - } - return 0; - } - } +using System; +using System.Diagnostics.CodeAnalysis; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCommon.Models +{ + [SuppressMessage("ReSharper", "InconsistentNaming")] + public enum AxleConfiguration + { + AxleConfig_4x2, + AxleConfig_4x4, + AxleConfig_6x2, + AxleConfig_6x4, + AxleConfig_6x6, + AxleConfig_8x2, + AxleConfig_8x4, + AxleConfig_8x6, + AxleConfig_8x8, + } + + public enum AxleType + { + VehicleDriven, + VehicleNonDriven, + Trailer + } + + public static class AxleTypeHelper + { + public static string GetLabel(this AxleType self) + { + switch (self) { + case AxleType.VehicleDriven: + return "Vehicle driven"; + case AxleType.VehicleNonDriven: + return "Vehicle non-driven"; + case AxleType.Trailer: + return "Trailer"; + default: + throw new ArgumentOutOfRangeException("self", self, null); + } + } + } + + public static class AxleConfigurationHelper + { + private const string Prefix = "AxleConfig_"; + + public static string GetName(this AxleConfiguration self) + { + return self.ToString().Replace(Prefix, ""); + } + + public static AxleConfiguration Parse(string typeString) + { + return (Prefix + typeString).ParseEnum<AxleConfiguration>(); + } + + public static int NumAxles(this AxleConfiguration self) + { + switch (self) { + case AxleConfiguration.AxleConfig_4x2: + case AxleConfiguration.AxleConfig_4x4: + return 2; + case AxleConfiguration.AxleConfig_6x2: + case AxleConfiguration.AxleConfig_6x4: + case AxleConfiguration.AxleConfig_6x6: + return 3; + case AxleConfiguration.AxleConfig_8x2: + case AxleConfiguration.AxleConfig_8x4: + case AxleConfiguration.AxleConfig_8x6: + case AxleConfiguration.AxleConfig_8x8: + return 4; + } + return 0; + } + + public static int NumDrivenAxles(this AxleConfiguration self) + { + switch (self) { + case AxleConfiguration.AxleConfig_4x2: + case AxleConfiguration.AxleConfig_6x2: + case AxleConfiguration.AxleConfig_8x2: + return 1; + case AxleConfiguration.AxleConfig_4x4: + case AxleConfiguration.AxleConfig_6x4: + case AxleConfiguration.AxleConfig_8x4: + return 2; + case AxleConfiguration.AxleConfig_6x6: + case AxleConfiguration.AxleConfig_8x6: + return 3; + case AxleConfiguration.AxleConfig_8x8: + return 4; + } + return 0; + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index 308a3112abab7dfae8e48d0d1096140880d41ff7..2422a84ff6faa1154fef0106916db14c0267ee7c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -56,9 +56,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public static ValidationResult ValidateAirDragData(AirdragData airDragData, ValidationContext validationContext) { if (airDragData.CrossWindCorrectionMode != CrossWindCorrectionMode.DeclarationModeCorrection && - airDragData.CrossWindCorrectionCurve.AirDragArea == null) + airDragData.CrossWindCorrectionCurve.AirDragArea == null) { return new ValidationResult( "AirDrag Area (CdxA) must not be empty when the cross wind correction mode is not \"Speed dependent (Declaration Mode)\""); + } return ValidationResult.Success; } @@ -280,8 +281,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } var numDrivenAxles = vehicleData._axleData.Count(x => x.AxleType == AxleType.VehicleDriven); - if (numDrivenAxles != 1) { - return new ValidationResult("Exactly one axle has to be defined as driven!"); + if (numDrivenAxles != vehicleData.AxleConfiguration.NumDrivenAxles()) { + return + new ValidationResult(string.Format( + vehicleData.AxleConfiguration.NumAxles() == 1 + ? "Exactly {0} axle has to be defined as driven, given {1}!" + : "Exactly {0} axles have to be defined as driven, given {1}!", vehicleData.AxleConfiguration.NumDrivenAxles(), + numDrivenAxles)); } return ValidationResult.Success;