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