diff --git a/VectoCore/Exceptions/VectoExceptions.cs b/VectoCore/Exceptions/VectoExceptions.cs new file mode 100644 index 0000000000000000000000000000000000000000..6cc96ea95e658e2f271584f4cb65f0e381257df8 --- /dev/null +++ b/VectoCore/Exceptions/VectoExceptions.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TUGraz.VectoCore.Exceptions +{ + + + abstract class FileIOException : Exception + { + protected FileIOException(string message) : base(message) + { + + } + + protected FileIOException(string message, Exception inner) + : base(message, inner) + { + } + } + + class UnsupportedFileVersion : FileIOException + { + public UnsupportedFileVersion(string message) : base(message) { } + public UnsupportedFileVersion(string message, Exception inner) : base(message, inner) { } + } +} diff --git a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index 52730cfefc20cc93d25246f4f0262c1c55dee96a..440d116fafbf2dceb5cb93eb78b08d44708984a8 100644 --- a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Net.Mime; using System.Runtime.CompilerServices; using Newtonsoft.Json; +using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; namespace TUGraz.VectoCore.Models.SimulationComponent.Data @@ -59,7 +60,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var header = results["Header"]; if (header["FileVersion"] > 2) - throw new Exception("Unsupported Version of .veng file. Got Version: " + header["FileVersion"]); + throw new UnsupportedFileVersion("Unsupported Version of .veng file. Got Version: " + header["FileVersion"]); var body = results["Body"]; @@ -77,22 +78,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data engine.ConsumptionMap = FuelConsumptionMap.ReadFromFile(body["FuelMap"].Value); if (body["WHTC-Urban"] != null) - WHTCUrban = body["WHTC-Urban"].Value; + engine.WHTCUrban = body["WHTC-Urban"].Value; if (body["WHTC-Rural"] != null) - WHTCRural = body["WHTC-Rural"].Value; + engine.WHTCRural = body["WHTC-Rural"].Value; if (body["WHTC-Motorway"] != null) - WHTCMotorway = body["WHTC-Motorway"].Value; + engine.WHTCMotorway = body["WHTC-Motorway"].Value; return engine; } - public static double WHTCMotorway { get; set; } + public double WHTCMotorway { get; set; } - public static double WHTCRural { get; set; } + public double WHTCRural { get; set; } - public static double WHTCUrban { get; set; } + public double WHTCUrban { get; set; } public bool SavedInDeclarationMode { get; set; } diff --git a/VectoCore/Models/SimulationComponent/Data/EngineOnlyDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Data/EngineOnlyDrivingCycle.cs index 7d00d4a4936b29ff533ce138adfaa669af4f7395..a0f56e66a11c1f852e91a5f33d4d297548e31170 100644 --- a/VectoCore/Models/SimulationComponent/Data/EngineOnlyDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Data/EngineOnlyDrivingCycle.cs @@ -25,8 +25,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// </summary> public double Pe { - get { return 2 * Math.PI / 60 * T * n; } - set { T = 60 / (2 * Math.PI) * value / n; } + get { return 2.0 * Math.PI / 60.0 * T * n; } + set { T = 60.0 / (2.0 * Math.PI) * value / n; } } public static List<EngineOnlyDrivingCycle> Read(string fileName) diff --git a/VectoCore/Models/SimulationComponent/Data/ModalResult.cs b/VectoCore/Models/SimulationComponent/Data/ModalResult.cs index 61877639fc0216ff3ff8a5cdc4e919c5f63236d9..952f447ea567743f9e1500cf9bad40a959ebc146 100644 --- a/VectoCore/Models/SimulationComponent/Data/ModalResult.cs +++ b/VectoCore/Models/SimulationComponent/Data/ModalResult.cs @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { public static Type GetDataType(this ModalResult field) { - return typeof(double); + return GetAttr(field).FieldType; } private static ModalResultFieldAttr GetAttr(ModalResult field) diff --git a/VectoCore/Models/SimulationComponent/IDataWriter.cs b/VectoCore/Models/SimulationComponent/IModalDataWriter.cs similarity index 84% rename from VectoCore/Models/SimulationComponent/IDataWriter.cs rename to VectoCore/Models/SimulationComponent/IModalDataWriter.cs index 2248d7a53ff9efd3b072ea848c06cf6a1b5ef7b4..0b7b917d2398cf204d2e16f2226814f35af1d0e2 100644 --- a/VectoCore/Models/SimulationComponent/IDataWriter.cs +++ b/VectoCore/Models/SimulationComponent/IModalDataWriter.cs @@ -2,14 +2,14 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data; namespace TUGraz.VectoCore.Models.SimulationComponent { - public interface IDataWriter + public interface IModalDataWriter { /// <summary> /// Indexer for fields of the DataWriter. Accesses the data of the current step. /// </summary> /// <param name="key"></param> /// <returns></returns> - object this[Enum key] { get; set; } + object this[ModalResult key] { get; set; } /// <summary> /// Commits the data of the current simulation step. diff --git a/VectoCoreTest/Utils/TestDataWriter.cs b/VectoCoreTest/Utils/TestModalDataWriter.cs similarity index 100% rename from VectoCoreTest/Utils/TestDataWriter.cs rename to VectoCoreTest/Utils/TestModalDataWriter.cs