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 f6ba689c authored by Michael KRISPER's avatar Michael KRISPER
Browse files

DataAdapter: Corrected errors when the limits are not defined (null)

parent 31f19c27
No related branches found
No related tags found
No related merge requests found
......@@ -257,6 +257,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
/// </summary>
/// <remarks>VECTO-1628</remarks>
internal static IList<ITransmissionInputData> FilterDisabledGears(IList<ITransmissionInputData> gears, Dictionary<int, ITorqueLimitInputData> limits) {
if (gears != null && gears.Count > 0) {
var lastGear = gears.Last().Gear;
if (limits.ContainsKey(lastGear) && limits[lastGear].MaxTorque.IsEqual(0)) {
gears.Remove(gears.Last());
......@@ -272,6 +273,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
if (l.Value.MaxTorque.IsEqual(0))
throw new VectoException($"Vehicle TorqueLimits: MaxTorque for Gear {l.Key} must not be 0.");
}
}
return gears;
}
......@@ -333,7 +335,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
throw new VectoSimulationException("Unsupported gearbox type: {0}!", retVal.Type);
}
var limits = inputData.TorqueLimits.ToDictionary(e => e.Gear);
var limits = inputData.TorqueLimits?.ToDictionary(e => e.Gear) ?? new Dictionary<int, ITorqueLimitInputData>();
var gearsInput = FilterDisabledGears(gearbox.Gears, limits);
if (gearsInput.Count < 1) {
throw new VectoSimulationException(
......
......@@ -181,7 +181,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
retVal.Inertia = engine.Inertia +
(gbx != null && gbx.Type.AutomaticTransmission() ? torqueConverter.Inertia : 0.SI<KilogramSquareMeter>());
retVal.EngineStartTime = engine.EngineStartTime ?? DeclarationData.Engine.DefaultEngineStartTime;
var limits = vehicle.TorqueLimits.ToDictionary(e => e.Gear);
var limits = vehicle.TorqueLimits?.ToDictionary(e => e.Gear) ?? new Dictionary<int, ITorqueLimitInputData>();
IList<ITransmissionInputData> gears = null;
if (gbx != null){
gears = DeclarationDataAdapter.FilterDisabledGears(gbx.Gears, limits);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment