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

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

add validation of tyre dimension (declaration mode)

parent 592c0e35
No related branches found
No related tags found
No related merge requests found
......@@ -29,31 +29,46 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System.ComponentModel.DataAnnotations;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Models.Declaration
{
public class Axle : SimulationComponentData
{
public string WheelsDimension { get; internal set; }
[Required, SIRange(0, 100)]
public KilogramSquareMeter Inertia { get; internal set; }
[Required, SIRange(0.003, 0.015)]
public double RollResistanceCoefficient { get; internal set; }
[Required, SIRange(500, 100000)]
public Newton TyreTestLoad { get; internal set; }
[Required, SIRange(0, 1, ExecutionMode.Engineering), SIRange(double.MinValue, 1, ExecutionMode.Declaration)]
public double AxleWeightShare { get; internal set; }
public bool TwinTyres { get; internal set; }
public AxleType AxleType { get; internal set; }
}
}
\ No newline at end of file
using System;
using System.ComponentModel.DataAnnotations;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Models.Declaration
{
[CustomValidation(typeof(Axle), "ValidateAxleData")]
public class Axle : SimulationComponentData
{
public string WheelsDimension { get; internal set; }
[Required, SIRange(0, 100)]
public KilogramSquareMeter Inertia { get; internal set; }
[Required, SIRange(0.003, 0.015)]
public double RollResistanceCoefficient { get; internal set; }
[Required, SIRange(500, 100000)]
public Newton TyreTestLoad { get; internal set; }
[Required, SIRange(0, 1, ExecutionMode.Engineering), SIRange(double.MinValue, 1, ExecutionMode.Declaration)]
public double AxleWeightShare { get; internal set; }
public bool TwinTyres { get; internal set; }
public AxleType AxleType { get; internal set; }
public static ValidationResult ValidateAxleData(Axle axle, ValidationContext validationContext)
{
var execMode = GetExecutionMode(validationContext);
if (execMode == ExecutionMode.Engineering)
return ValidationResult.Success;
try {
DeclarationData.Wheels.Lookup(axle.WheelsDimension);
} catch (Exception) {
return new ValidationResult(string.Format("Unknown Tyre dimenstion '{0}'", axle.WheelsDimension));
}
return ValidationResult.Success;
}
}
}
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