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

Skip to content
Snippets Groups Projects
Commit 773f8610 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

AxleGearLossMap and PTOLossMap: Changed Handling of empty values (no...

AxleGearLossMap and PTOLossMap: Changed Handling of empty values (no exception, instead return null value)
parent b5ba11d1
No related branches found
No related tags found
No related merge requests found
......@@ -128,8 +128,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
if (!gears.Any()) {
throw new VectoSimulationException("At least one Gear-Entry must be defined in Gearbox!");
}
return ReadTableData(
gears[0].GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), "AxleGear");
var lossMap = gears[0][JsonKeys.Gearbox_Gear_LossMapFile];
if (lossMap != null)
return ReadTableData(gears[0][JsonKeys.Gearbox_Gear_LossMapFile].Value<string>(), "AxleGear", required: false);
return null;
}
}
......
......@@ -187,9 +187,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
{
get
{
return Body.GetEx(JsonKeys.Vehicle_AngularGear)
.GetEx<string>(JsonKeys.Vehicle_AngularGear_Type)
.ParseEnum<AngularGearType>();
return Body.GetEx(JsonKeys.Vehicle_AngularGear)
.GetEx<string>(JsonKeys.Vehicle_AngularGear_Type)
.ParseEnum<AngularGearType>();
}
}
......@@ -205,7 +205,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
return ReadTableData(
Body.GetEx(JsonKeys.Vehicle_AngularGear)
.GetEx<string>(JsonKeys.Vehicle_AngularGear_LossMapFile),
"LossMap");
"LossMap");
}
}
......@@ -222,11 +222,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
{
get
{
try {
return Body.GetEx(JsonKeys.Vehicle_PTO).GetEx<string>(JsonKeys.Vehicle_PTO_Type);
} catch (Exception) {
return "None";
var pto = Body[JsonKeys.Vehicle_PTO];
if (pto != null) {
return pto[JsonKeys.Vehicle_PTO_Type].Value<string>();
}
return "None";
}
}
......
......@@ -140,14 +140,13 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
internal AxleGearData CreateAxleGearData(IAxleGearInputData data, bool useEfficiencyFallback)
{
TransmissionLossMap axleLossMap;
try {
if (data.LossMap == null && useEfficiencyFallback) {
axleLossMap = TransmissionLossMapReader.Create(data.Efficiency, data.Ratio, "AxleGear");
} else {
axleLossMap = TransmissionLossMapReader.Create(data.LossMap, data.Ratio, "AxleGear");
} catch (InvalidFileFormatException) {
if (useEfficiencyFallback) {
axleLossMap = TransmissionLossMapReader.Create(data.Efficiency, data.Ratio, "AxleGear");
} else {
throw;
}
}
if (axleLossMap == null) {
throw new Exception("LossMap for AxleGear is missing.");
}
return new AxleGearData {
......
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