diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs index 026a75c3cb6e8102931be1861712230a8192b769..79efc445bab9bec0030d3d5cdd0a2212b6a5c08d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using System.Data; using System.Linq; using Newtonsoft.Json.Linq; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -76,15 +77,26 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual double Ratio { - get { return Body.GetEx(JsonKeys.Gearbox_Gears)[0].GetEx<double>(JsonKeys.Gearbox_Gear_Ratio); } + get + { + var gears = Body.GetEx(JsonKeys.Gearbox_Gears); + if (!gears.Any()) { + throw new VectoSimulationException("At least one Gear-Entry must be defined in Gearbox!"); + } + return gears[0].GetEx<double>(JsonKeys.Gearbox_Gear_Ratio); + } } public DataTable LossMap { get { + var gears = Body.GetEx(JsonKeys.Gearbox_Gears); + if (!gears.Any()) { + throw new VectoSimulationException("At least one Gear-Entry must be defined in Gearbox!"); + } return ReadTableData( - Body.GetEx(JsonKeys.Gearbox_Gears)[0].GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), "AxleGear"); + gears[0].GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), "AxleGear"); } }