diff --git a/VectoCore/Exceptions/VectoExceptions.cs b/VectoCore/Exceptions/VectoExceptions.cs index 6cc96ea95e658e2f271584f4cb65f0e381257df8..03a3b6fcc2de1a189ee266d17c2221e3b6d631aa 100644 --- a/VectoCore/Exceptions/VectoExceptions.cs +++ b/VectoCore/Exceptions/VectoExceptions.cs @@ -21,9 +21,15 @@ namespace TUGraz.VectoCore.Exceptions } } - class UnsupportedFileVersion : FileIOException + class InvalidFileFormatException : FileIOException { - public UnsupportedFileVersion(string message) : base(message) { } - public UnsupportedFileVersion(string message, Exception inner) : base(message, inner) { } + public InvalidFileFormatException(string message) : base(message) { } + public InvalidFileFormatException(string message, Exception inner) : base(message) { } + } + + class UnsupportedFileVersionException : FileIOException + { + public UnsupportedFileVersionException(string message) : base(message) { } + public UnsupportedFileVersionException(string message, Exception inner) : base(message, inner) { } } } diff --git a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index 440d116fafbf2dceb5cb93eb78b08d44708984a8..ad2abdeb9b4301e9129b6781ada10c2b9f60acef 100644 --- a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -57,10 +57,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var results = JsonConvert.DeserializeObject<dynamic>(json); //todo: handle error when fields not exist + if (results["Header"] == null) { + throw new InvalidFileFormatException("could not find 'Header' Section"); + } var header = results["Header"]; if (header["FileVersion"] > 2) - throw new UnsupportedFileVersion("Unsupported Version of .veng file. Got Version: " + header["FileVersion"]); + throw new UnsupportedFileVersionException("Unsupported Version of .veng file. Got Version: " + header["FileVersion"]); var body = results["Body"]; @@ -72,6 +75,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data engine.IdleSpeed = body["IdlingSpeed"]; engine.Inertia = body["Inertia"]; + // engine.GetType().GetProperty("Inertia").SetValue(engine, body["Inerita"]); + foreach (dynamic loadCurve in body["FullLoadCurves"]) engine._fullLoadCurves[loadCurve["Gears"].Value] = FullLoadCurve.ReadFromFile(loadCurve["Path"].Value);