Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

validation: check for number of driven axles depending on axle configuration...

validation: check for number of driven axles depending on axle configuration (allow more than one driven axle)
parent 87c5a643
No related branches found
No related tags found
No related merge requests found
...@@ -105,5 +105,25 @@ namespace TUGraz.VectoCommon.Models ...@@ -105,5 +105,25 @@ namespace TUGraz.VectoCommon.Models
} }
return 0; 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
...@@ -56,9 +56,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -56,9 +56,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public static ValidationResult ValidateAirDragData(AirdragData airDragData, ValidationContext validationContext) public static ValidationResult ValidateAirDragData(AirdragData airDragData, ValidationContext validationContext)
{ {
if (airDragData.CrossWindCorrectionMode != CrossWindCorrectionMode.DeclarationModeCorrection && if (airDragData.CrossWindCorrectionMode != CrossWindCorrectionMode.DeclarationModeCorrection &&
airDragData.CrossWindCorrectionCurve.AirDragArea == null) airDragData.CrossWindCorrectionCurve.AirDragArea == null) {
return new ValidationResult( return new ValidationResult(
"AirDrag Area (CdxA) must not be empty when the cross wind correction mode is not \"Speed dependent (Declaration Mode)\""); "AirDrag Area (CdxA) must not be empty when the cross wind correction mode is not \"Speed dependent (Declaration Mode)\"");
}
return ValidationResult.Success; return ValidationResult.Success;
} }
...@@ -280,8 +281,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -280,8 +281,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
} }
var numDrivenAxles = vehicleData._axleData.Count(x => x.AxleType == AxleType.VehicleDriven); var numDrivenAxles = vehicleData._axleData.Count(x => x.AxleType == AxleType.VehicleDriven);
if (numDrivenAxles != 1) { if (numDrivenAxles != vehicleData.AxleConfiguration.NumDrivenAxles()) {
return new ValidationResult("Exactly one axle has to be defined as driven!"); 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; return ValidationResult.Success;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment