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

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

adding validation for gearbox: validate torque converter if AT gearbox

parent db937357
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
...@@ -42,7 +43,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -42,7 +43,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
/// Class for Gearbox Data. Gears can be accessed via Gears-Dictionary and range from 1 upwards. /// Class for Gearbox Data. Gears can be accessed via Gears-Dictionary and range from 1 upwards.
/// </summary> /// </summary>
/// <remarks>The Axle Gear has its own Property "AxleGearData" and is *not included* in the Gears-Dictionary.</remarks> /// <remarks>The Axle Gear has its own Property "AxleGearData" and is *not included* in the Gears-Dictionary.</remarks>
[DataContract] [DataContract, CustomValidation(typeof(GearboxData), "ValidateGearboxData")]
public class GearboxData : SimulationComponentData public class GearboxData : SimulationComponentData
{ {
public GearboxType Type { get; internal set; } public GearboxType Type { get; internal set; }
...@@ -112,5 +113,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -112,5 +113,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
[Required, SIRange(0, double.MaxValue)] [Required, SIRange(0, double.MaxValue)]
public MeterPerSquareSecond UpshiftMinAcceleration { get; internal set; } public MeterPerSquareSecond UpshiftMinAcceleration { get; internal set; }
// ReSharper disable once UnusedMember.Global -- used via Validation
public static ValidationResult ValidateGearboxData(GearboxData gearboxData, ValidationContext validationContext)
{
var mode = GetExecutionMode(validationContext);
var result = new List<ValidationResult>();
if (gearboxData.Type.AutomaticTransmission()) {
result.AddRange(gearboxData.TorqueConverterData.Validate(mode));
}
if (result.Any()) {
return new ValidationResult("Validation of Gearbox Data failed", result.Select(x => x.ErrorMessage));
}
return ValidationResult.Success;
}
} }
} }
\ No newline at end of file
...@@ -170,6 +170,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -170,6 +170,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
WheelsInertia = wheelsInertia; WheelsInertia = wheelsInertia;
} }
// ReSharper disable once UnusedMember.Global -- used via Validation
public static ValidationResult ValidateVehicleData(VehicleData vehicleData, ValidationContext validationContext) public static ValidationResult ValidateVehicleData(VehicleData vehicleData, ValidationContext validationContext)
{ {
var mode = GetExecutionMode(validationContext); var mode = GetExecutionMode(validationContext);
......
...@@ -207,8 +207,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -207,8 +207,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// get max. torque as limited by gearbox. gearbox only limits torqueOut! // get max. torque as limited by gearbox. gearbox only limits torqueOut!
var gearboxFullLoad = DataBus.GearMaxTorque; var gearboxFullLoad = DataBus.GearMaxTorque;
var deltaFull = ComputeDelta(torqueOut, totalTorqueDemand + (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()), CurrentState.DynamicFullLoadTorque, gearboxFullLoad, true); var deltaFull = ComputeDelta(torqueOut,
var deltaDrag = ComputeDelta(torqueOut, totalTorqueDemand - (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()), CurrentState.FullDragTorque, totalTorqueDemand + (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()),
CurrentState.DynamicFullLoadTorque, gearboxFullLoad, true);
var deltaDrag = ComputeDelta(torqueOut,
totalTorqueDemand - (CurrentState.InertiaTorqueLoss < 0 ? CurrentState.InertiaTorqueLoss : 0.SI<NewtonMeter>()),
CurrentState.FullDragTorque,
gearboxFullLoad != null ? -gearboxFullLoad : null, false); gearboxFullLoad != null ? -gearboxFullLoad : null, false);
if (dryRun) { if (dryRun) {
...@@ -332,12 +336,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -332,12 +336,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
if (CurrentState.FullDragTorque >= 0 && torqueDemand < 0) { if (CurrentState.FullDragTorque >= 0 && torqueDemand < 0) {
throw new VectoSimulationException("P_engine_drag > 0! Tq_drag: {1}, Tq_eng: {2}, n_eng_avg: {0} [1/min] ", throw new VectoSimulationException("P_engine_drag > 0! Tq_drag: {1}, Tq_eng: {2}, n_eng_avg: {0} [1/min] ",
CurrentState.EngineSpeed.Value().RadToRPM(), CurrentState.FullDragTorque, CurrentState.EngineTorque); CurrentState.EngineSpeed.AsRPM, CurrentState.FullDragTorque, CurrentState.EngineTorque);
} }
if (CurrentState.DynamicFullLoadTorque <= 0 && torqueDemand > 0) { if (CurrentState.DynamicFullLoadTorque <= 0 && torqueDemand > 0) {
throw new VectoSimulationException("P_engine_full < 0! Tq_drag: {1}, Tq_eng: {2}, n_eng_avg: {0} [1/min] ", throw new VectoSimulationException("P_engine_full < 0! Tq_drag: {1}, Tq_eng: {2}, n_eng_avg: {0} [1/min] ",
CurrentState.EngineSpeed.Value().RadToRPM(), CurrentState.FullDragTorque, CurrentState.EngineTorque); CurrentState.EngineSpeed.AsRPM, CurrentState.FullDragTorque, CurrentState.EngineTorque);
} }
} }
......
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