diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index 765eb45c20d5b74974c43285939d067354199e39..0882913402ef443cb1ef5bd2b0d9be800b56cd3c 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -44,7 +44,7 @@ <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> - <DefineTrace>true</DefineTrace> + <DefineTrace>false</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <DocumentationFile>VECTO.xml</DocumentationFile> <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> @@ -56,8 +56,8 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>None</DebugType> <DefineDebug>false</DefineDebug> - <DefineTrace>true</DefineTrace> - <Optimize>false</Optimize> + <DefineTrace>false</DefineTrace> + <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DocumentationFile>VECTO.xml</DocumentationFile> <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> diff --git a/VECTO/app.config b/VECTO/app.config index 96e61fb67a97a48111dc6b6283bd4e4bf6928593..45ad93e0f06bbae24bc038c097101ae13f95eb04 100644 --- a/VECTO/app.config +++ b/VECTO/app.config @@ -5,18 +5,28 @@ <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" /> </configSections> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" - autoReload="true" - throwExceptions="false" - internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> - <targets> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" + autoReload="false" + throwExceptions="false" + internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> + <targets async="true"> <target xsi:type="Console" name="ConsoleLogger" error="true" /> - <target name="WarningLogger" xsi:type="MethodCall" className="VECTO.F_MAINForm, VECTO" methodName="LogMethod"><parameter layout="${level}" /><parameter layout="${message}" /></target> - <target xsi:type="File" name="LogFile" fileName="${basedir}/logs/log.txt" - layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message} ${exception:format=tostring}" /> + <target name="WarningLogger" xsi:type="MethodCall" className="VECTO.F_MAINForm, VECTO" methodName="LogMethod"> + <parameter layout="${level}" /> + <parameter layout="${message}" /> + </target> + <target xsi:type="File" + name="LogFile" + fileName="${basedir}/logs/log.txt" + layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite:skipFrames=1} ${level:uppercase=true}: ${message} ${exception:format=tostring}" + keepFileOpen="false" + archiveFileName="${basedir}/logs/archive{#}.txt" + maxArchiveFiles="1" + archiveAboveSize="10000000" /> </targets> <rules> + <logger name="TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory" minlevel="Info" writeTo="LogFile" /> <logger name="*" minlevel="Warn" writeTo="LogFile" /> <logger name="*" minlevel="Error" writeTo="WarningLogger" /> </rules> @@ -37,8 +47,8 @@ </switches> <sharedListeners> <add name="FileLog" - type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" - initializeData="FileLogWriter" /> + type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" + initializeData="FileLogWriter" /> <!-- Auskommentierung des nachfolgenden Abschnitts aufheben und APPLICATION_NAME durch den Namen der Anwendung ersetzen, um in das Anwendungsereignisprotokoll zu schreiben --> <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> --> </sharedListeners> diff --git a/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs b/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs index 46f62d57b21cd2ca8851e6823de1906458b1854b..d5551f7a00dcc7a93c7c373f04b27eec3f40dbc2 100644 --- a/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs +++ b/VectoCommon/VectoCommon/Exceptions/VectoExceptions.cs @@ -31,6 +31,7 @@ using System; using System.IO; +using System.Runtime.Serialization; using TUGraz.VectoCommon.Models; namespace TUGraz.VectoCommon.Exceptions @@ -38,8 +39,11 @@ namespace TUGraz.VectoCommon.Exceptions /// <summary> /// Base Exception for all Exception in VECTO. /// </summary> + [Serializable] public class VectoException : Exception { + protected VectoException(SerializationInfo info, StreamingContext context) : base(info, context) {} + public VectoException(string message) : base(message) { LogManager.Flush(); @@ -66,6 +70,7 @@ namespace TUGraz.VectoCommon.Exceptions /// <summary> /// Exception when an Input/Output related error occured. /// </summary> + [Serializable] public abstract class FileIOException : VectoException { protected FileIOException(string message) : base(message) {} @@ -75,6 +80,7 @@ namespace TUGraz.VectoCommon.Exceptions /// <summary> /// Exception when the file format is invalid or a file was not found. /// </summary> + [Serializable] public class InvalidFileFormatException : FileIOException { public InvalidFileFormatException(string message) : base(message) {} @@ -85,6 +91,7 @@ namespace TUGraz.VectoCommon.Exceptions /// <summary> /// Exception which gets thrown when the version of a file is not supported. /// </summary> + [Serializable] public class UnsupportedFileVersionException : FileIOException { public UnsupportedFileVersionException(string message) : base(message) {} @@ -98,6 +105,7 @@ namespace TUGraz.VectoCommon.Exceptions /// <summary> /// Exception which gets thrown when an error occurred during read of a vecto csv-file. /// </summary> + [Serializable] public class CSVReadException : FileIOException { public CSVReadException(string message) : base(message) {} diff --git a/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs b/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs index 4ad924d871fe2b310a9875f51dee79b841d114b2..502b8e1b8c22b349c5534b3794b3b59566ee201a 100644 --- a/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs +++ b/VectoCommon/VectoCommon/Exceptions/VectoSimulationException.cs @@ -30,10 +30,12 @@ */ using System; +using System.Runtime.Serialization; using TUGraz.VectoCommon.Models; namespace TUGraz.VectoCommon.Exceptions { + [Serializable] public class VectoSimulationException : VectoException { public VectoSimulationException(string msg) : base(msg) {} @@ -44,8 +46,11 @@ namespace TUGraz.VectoCommon.Exceptions //[StringFormatMethod("message")] public VectoSimulationException(string message, Exception inner, params object[] args) : base(message, inner, args) {} + + protected VectoSimulationException(SerializationInfo info, StreamingContext context) : base(info, context) { } } + [Serializable] public class VectoEngineSpeedTooLowException : VectoSimulationException { public VectoEngineSpeedTooLowException(string msg) : base(msg) {} @@ -56,8 +61,20 @@ namespace TUGraz.VectoCommon.Exceptions : base(message, inner, args) {} } + [Serializable] public class UnexpectedResponseException : VectoSimulationException { + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("Response", Response); + } + + protected UnexpectedResponseException(SerializationInfo info, StreamingContext context) : base(info, context) + { + Response = (IResponse)info.GetValue("Response", typeof(IResponse)); + } + public IResponse Response; public UnexpectedResponseException(string message, IResponse resp) @@ -67,11 +84,13 @@ namespace TUGraz.VectoCommon.Exceptions } } + [Serializable] public class VectoSearchFailedException : VectoException { public VectoSearchFailedException(string message, params object[] args) : base(message, args) {} } + [Serializable] public class VectoSearchAbortedException : VectoException { public VectoSearchAbortedException(string message, params object[] args) : base(message, args) { } diff --git a/VectoConsole/App.config b/VectoConsole/App.config index 01a0f2b2072b9e9239ef8fce5c709d3ddddb5f70..0118145833f876dac701cd4569041be4608add55 100644 --- a/VectoConsole/App.config +++ b/VectoConsole/App.config @@ -8,17 +8,27 @@ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" - autoReload="true" - throwExceptions="false" - internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> - <targets> - <target xsi:type="Console" name="ConsoleLogger" error="true" /> - <target xsi:type="File" name="LogFile" fileName="${basedir}/logs/log_${threadid}.txt" - layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message} ${exception:format=tostring}" /> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" + autoReload="false" + throwExceptions="false" + internalLogLevel="Off" + internalLogFile="c:\temp\nlog-internal.log"> + <targets async="true"> + <target xsi:type="Console" + name="ConsoleLogger" + error="true" /> + <target xsi:type="File" + name="LogFile" + fileName="${basedir}/logs/log.txt" + layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite:skipFrames=1} ${level:uppercase=true}: ${message} ${exception:format=tostring}" + keepFileOpen="false" + archiveFileName="${basedir}/logs/archive{#}.txt" + maxArchiveFiles="1" + archiveAboveSize="10000000" /> </targets> <rules> + <logger name="TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory" minlevel="Info" writeTo="LogFile" /> <logger name="*" minlevel="Warn" writeTo="LogFile" /> </rules> </nlog> diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index 3788cf7cbad53f4c8186ae64cfe8c7f7f50bca4f..046cd421aa5007dc5696dcfccaa131d29b24c41b 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -140,9 +140,6 @@ Examples: } LogManager.Configuration = config; - // todo mk 2016-03-02: trace listener still needed? - Trace.Listeners.Add(new ConsoleTraceListener(true)); - if (args.Contains("-V") || debugEnabled) { ShowVersionInformation(); } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs index c43592437d16e535628680356f8b200bf55e6869..0a5fe6474cdaa33dceef8e9ad7d2b25cc05de3fa 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs @@ -75,6 +75,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual double Ratio { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { var gears = Body.GetEx(JsonKeys.Gearbox_Gears); @@ -87,6 +88,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public DataTable LossMap { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { var gears = Body.GetEx(JsonKeys.Gearbox_Gears); @@ -185,7 +187,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual bool Enabled { - get { return false; // TODO @@@ + get { return false; // TODO mk-2016-05-09: JSON ITorqueConverterInputData.Enabled always true --> as soon as TC is implemented, set to correct value! } } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 257a90f3a6dc798d52947c54edb87fbfa2ea9ba0..ffbf6bab3609efb177172eb292eee4d0d95d78c2 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -265,6 +265,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IVehicleEngineeringInputData VehicleInputData { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (VehicleData == null) { @@ -276,6 +277,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IGearboxEngineeringInputData GearboxInputData { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Gearbox == null) { @@ -287,6 +289,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IAxleGearInputData AxleGearInputData { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (AxleGear == null) { @@ -303,6 +306,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IEngineEngineeringInputData EngineInputData { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Engine == null) { @@ -329,6 +333,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IRetarderInputData RetarderInputData { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Retarder == null) { @@ -354,6 +359,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual IList<ICycleData> Cycles { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { var retVal = new List<ICycleData>(); @@ -461,6 +467,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual DataTable AccelerationCurve { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { var acceleration = Body[JsonKeys.DriverData_AccelerationCurve]; diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs index 2adc7cc15b72f69c12f14a3267af4f8f03e540b6..f412415e9c5d489f38ee074bbb90d671c7db3ab0 100644 --- a/VectoCore/VectoCore/InputData/Impl/InputData.cs +++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs @@ -92,9 +92,10 @@ namespace TUGraz.VectoCore.InputData.Impl public class AxleInputData : IAxleEngineeringInputData { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] public bool SavedInDeclarationMode { - get { throw new System.NotImplementedException(); } + get {throw new System.NotImplementedException(); } } public string Vendor { get; internal set; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs index 81a5721df36b1909824a681ef03848122ba24718..99e45cf5258e6b92a2c445f4980ed4cf63883867 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs @@ -98,6 +98,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper retarder.Ratio = 1; break; default: + // ReSharper disable once NotResolvedInText + // ReSharper disable once LocalizableElement throw new ArgumentOutOfRangeException("retarder.Type", "RetarderType unknown"); } @@ -164,7 +166,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper if (gearCurve == null) { return engineCurve; } - // TODO MK-2016-04-18: also combine the curves at the intersection-points of line segments! + // TODO mk-2016-04-18: refactor when new gearbox full load is implemented: gearbox will then only have 1 constant value as full load. var entries = gearCurve.FullLoadEntries.Concat(engineCurve.FullLoadEntries) .OrderBy(x => x.EngineSpeed) diff --git a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs index 5521e0b0f9d2581dbb614432c47cc0e345975cf6..7ddcaab7d648dacea8dbbd9960179f7e16b9ac94 100644 --- a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs @@ -271,7 +271,6 @@ namespace TUGraz.VectoCore.InputData.Reader return true; } - // todo MK-2016-01-19: move fields to resource file private static class Fields { public const string PWheel = "Pwheel"; @@ -539,7 +538,6 @@ namespace TUGraz.VectoCore.InputData.Reader public static bool ValidateHeader(string[] header, bool throwExceptions = true) { - //todo mk-2016-02-15: check if vair_res, and vair_beta only when needed var allowedCols = new[] { Fields.Time, Fields.VehicleSpeed, @@ -587,7 +585,6 @@ namespace TUGraz.VectoCore.InputData.Reader public static bool ValidateHeader(string[] header, bool throwExceptions = true) { - //todo mk-2016-02-15: check if vair_res, and vair_beta only when needed var allowedCols = new[] { Fields.Time, Fields.VehicleSpeed, diff --git a/VectoCore/VectoCore/Models/Declaration/AirDrag.cs b/VectoCore/VectoCore/Models/Declaration/AirDrag.cs index 780d6a1e9312604b0761aa7f00fe93c461884e8a..119d3bf3d44e59d7c49d8fb7c5926f2f053aaa89 100644 --- a/VectoCore/VectoCore/Models/Declaration/AirDrag.cs +++ b/VectoCore/VectoCore/Models/Declaration/AirDrag.cs @@ -37,9 +37,9 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class AirDrag : LookupData<string, AirDrag.AirDragEntry> + public sealed class AirDrag : LookupData<string, AirDrag.AirDragEntry> { - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VCDV.parameters.csv"; + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VCDV.parameters.csv"; public AirDrag() { diff --git a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs index 2b455f077a6d186f4471983e9b53a7e44b297eee..f183e9e5037932a2181b08dee8253d23cedf908d 100644 --- a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs @@ -38,18 +38,16 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class ElectricSystem : LookupData<MissionType, string[], Watt> + public sealed class ElectricSystem : LookupData<MissionType, string[], Watt> { private readonly Alternator _alternator = new Alternator(); + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ES-Tech.csv"; private const string BaseLine = "Baseline electric power consumption"; private readonly Dictionary<Tuple<MissionType, string>, Watt> _data = new Dictionary<Tuple<MissionType, string>, Watt>(); - - protected string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ES-Tech.csv"; - - + public ElectricSystem() { ParseData(ReadCsvResource(ResourceId)); @@ -86,16 +84,14 @@ namespace TUGraz.VectoCore.Models.Declaration return sum / _alternator.Lookup(missionType, null); } - private class Alternator : LookupData<MissionType, string, double> + private sealed class Alternator : LookupData<MissionType, string, double> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ALT-Tech.csv"; private const string Default = "Standard alternator"; private readonly Dictionary<Tuple<MissionType, string>, double> _data = new Dictionary<Tuple<MissionType, string>, double>(); - - protected string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ALT-Tech.csv"; - - + public Alternator() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/Fan.cs b/VectoCore/VectoCore/Models/Declaration/Fan.cs index e9e43e1f4a726ffc9df0b2286762090300e95143..e3aa0a43a97d57fcd0f3d4ba88e92d9c0142f798 100644 --- a/VectoCore/VectoCore/Models/Declaration/Fan.cs +++ b/VectoCore/VectoCore/Models/Declaration/Fan.cs @@ -38,15 +38,14 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class Fan : LookupData<MissionType, string, Watt> + public sealed class Fan : LookupData<MissionType, string, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.Fan-Tech.csv"; + private const string DefaultTechnology = "Crankshaft mounted - Electronically controlled visco clutch (Default)"; + private readonly Dictionary<Tuple<MissionType, string>, Watt> _data = new Dictionary<Tuple<MissionType, string>, Watt>(); - - private const string DefaultTechnology = "Crankshaft mounted - Electronically controlled visco clutch (Default)"; - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.Fan-Tech.csv"; - + public Fan() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/HVAC.cs b/VectoCore/VectoCore/Models/Declaration/HVAC.cs index acb6fc93fd71ba0950c9a3c01ea6c815a6e81e7d..a0a8201492a396b12f2384b124967d85c7791de2 100644 --- a/VectoCore/VectoCore/Models/Declaration/HVAC.cs +++ b/VectoCore/VectoCore/Models/Declaration/HVAC.cs @@ -38,13 +38,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class HeatingVentilationAirConditioning : LookupData<MissionType, VehicleClass, Watt> + public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, VehicleClass, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.HVAC-Table.csv"; private readonly Dictionary<Tuple<MissionType, VehicleClass>, Watt> _data = new Dictionary<Tuple<MissionType, VehicleClass>, Watt>(); - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.HVAC-Table.csv"; - + public HeatingVentilationAirConditioning() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/PT1.cs b/VectoCore/VectoCore/Models/Declaration/PT1.cs index b49fe0117a5f53d3637d087f4ea05721e9cae458..4aae13967b97b2653c79f6b757daf33df4a6af4f 100644 --- a/VectoCore/VectoCore/Models/Declaration/PT1.cs +++ b/VectoCore/VectoCore/Models/Declaration/PT1.cs @@ -38,12 +38,11 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class PT1 : LookupData<PerSecond, Second> + public sealed class PT1 : LookupData<PerSecond, Second> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.PT1.csv"; private List<KeyValuePair<PerSecond, Second>> _entries; - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.PT1.csv"; - + public PT1() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs index 85dff29c258304e2e464c292585ec825db675344..3dbbfe6f2de33fe632be41abfe76b1a112c63b49 100644 --- a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs @@ -38,13 +38,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class PneumaticSystem : LookupData<MissionType, VehicleClass, Watt> + public sealed class PneumaticSystem : LookupData<MissionType, VehicleClass, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.PS-Table.csv"; private readonly Dictionary<Tuple<MissionType, VehicleClass>, Watt> _data = new Dictionary<Tuple<MissionType, VehicleClass>, Watt>(); - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.PS-Table.csv"; - + public PneumaticSystem() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/Segments.cs b/VectoCore/VectoCore/Models/Declaration/Segments.cs index 9ddc828128bb0c4a00000a44afcf50140d2a477f..03f5181a72a470d482d162a9059eb903303dc3bf 100644 --- a/VectoCore/VectoCore/Models/Declaration/Segments.cs +++ b/VectoCore/VectoCore/Models/Declaration/Segments.cs @@ -40,7 +40,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class Segments : LookupData<VehicleCategory, AxleConfiguration, Kilogram, Kilogram, Segment> + public sealed class Segments : LookupData<VehicleCategory, AxleConfiguration, Kilogram, Kilogram, Segment> { public Segments() { diff --git a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs index 7f80fcd974cc6e0b0adf2e3e46944f116b217c74..4fbaf72c36eb87a08c36d975902cc3cc8fabf553 100644 --- a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs +++ b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs @@ -39,15 +39,13 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class SteeringPump : LookupData<MissionType, VehicleClass, string, Watt> + public sealed class SteeringPump : LookupData<MissionType, VehicleClass, string, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Table.csv"; private readonly SteeringPumpTechnologies _technologies = new SteeringPumpTechnologies(); - private readonly Dictionary<Tuple<MissionType, VehicleClass>, Watt[]> _data = new Dictionary<Tuple<MissionType, VehicleClass>, Watt[]>(); - - private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Table.csv"; - + public SteeringPump() { ParseData(ReadCsvResource(ResourceId)); @@ -87,7 +85,7 @@ namespace TUGraz.VectoCore.Models.Declaration } } - private class SteeringPumpTechnologies : LookupData<string, double[]> + private sealed class SteeringPumpTechnologies : LookupData<string, double[]> { private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Tech.csv"; diff --git a/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs b/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs index 1458460b454dd04686ce0355b3b8bdd1bcd7ecfb..9aa9837f63135794a7a34dcb24ed659679b1d40c 100644 --- a/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs +++ b/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs @@ -36,19 +36,18 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class TorqueConverter : LookupData<double, TorqueConverter.TorqueConverterEntry> + public sealed class TorqueConverter : LookupData<double, TorqueConverter.TorqueConverterEntry> { - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.DefaultTC.vtcc"; - - + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.DefaultTC.vtcc"; + public TorqueConverter() { ParseData(ReadCsvResource(ResourceId)); } - [Obsolete("Default Lookup not availabel. Use LookupMu or LookupTorque instead.", true)] - protected new TorqueConverterEntry Lookup(double key) + [Obsolete("Default Lookup not available. Use LookupMu or LookupTorque instead.", true)] + private new TorqueConverterEntry Lookup(double key) { throw new InvalidOperationException( "Default Lookup not available. Use TorqueConverter.LookupMu() or TorqueConverter.LookupTorque() instead."); diff --git a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs index 652a10ca60fb55b41c9f57bd3118c98d9a9d8432..94a96663c4c72dba3a9fe8d550261d365995b2eb 100644 --- a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs +++ b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs @@ -38,13 +38,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class WHTCCorrection : LookupData<MissionType, double, double, double, double> + public sealed class WHTCCorrection : LookupData<MissionType, double, double, double, double> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.WHTC-Weighting-Factors.csv"; private readonly Dictionary<MissionType, WHTCCorrectionEntry> _data = new Dictionary<MissionType, WHTCCorrectionEntry>(); - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.WHTC-Weighting-Factors.csv"; - + public WHTCCorrection() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs index db5fd352f6d31640f0b35961556af535f4e4e498..4c98903fd6f0575218165859ffa05b23ef49990e 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/ModalResult.cs @@ -33,6 +33,7 @@ using System; using System.ComponentModel; using System.Data; using System.Reflection; +using System.Runtime.Serialization; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; @@ -42,6 +43,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.Data { [DesignerCategory("")] // Full qualified attribute needed to disable design view in VisualStudio + [Serializable] public class ModalResults : DataTable { public static class ExtendedPropertyNames @@ -51,6 +53,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Data public const string ShowUnit = "showUnit"; } + protected ModalResults(SerializationInfo info, StreamingContext context) : base(info, context){} + public ModalResults() { foreach (var value in EnumHelper.GetValues<ModalResultField>()) { diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs index 4cc9f75bf8a66815f28baa47c4a8d5e373ece81c..9c8e0d45f996bc526a74a68e2fd9e4ea9b1cc4e9 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs @@ -187,7 +187,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public string RunSuffix; } - internal class RunEntry : LoggingObject + internal class RunEntry : LoggingObject, IDisposable { public IVectoRun Run; public JobContainer JobContainer; @@ -244,6 +244,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ExecException = e.Error; } } + + public void Dispose() + { + _worker.Dispose(); + } } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index b257ec726395c64761bd9f773001ff0305696c22..1a84dd10c4438513171acb7accb113ecd4a7aade 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -345,12 +345,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl case GearboxType.MT: strategy = new MTShiftStrategy(data, container); break; - case GearboxType.AT: - strategy = new ATShiftStrategy(data, container); - break; - case GearboxType.Custom: - strategy = new CustomShiftStrategy(data, container); - break; default: throw new VectoSimulationException("Unknown Gearbox Type: {0}", data.Type); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index 1e3895d59b0ad5eb35e829f39ea2bc3258ade185..7393feb48eeaaa85002082b13d97cd48002e12f9 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -58,7 +58,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public SimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer, DeclarationReport report = null) { - Log.Fatal("########## VectoCore Version {0} ##########", Assembly.GetExecutingAssembly().GetName().Version); + Log.Info("########## VectoCore Version {0} ##########", Assembly.GetExecutingAssembly().GetName().Version); JobNumber = Interlocked.Increment(ref _jobNumberCounter); _mode = mode; ModWriter = writer; @@ -99,7 +99,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public IOutputDataWriter ModWriter { get; private set; } - public int JobNumber { get; set; } public bool WriteModalResults { get; set; } @@ -146,10 +145,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var validationErrors = run.Validate(); if (validationErrors.Any()) { - throw new VectoException("Validation of Run-Data Failed: " + "\n".Join(validationErrors.Select(r => r.ErrorMessage))); + throw new VectoException("Validation of Run-Data Failed: " + + "\n".Join(validationErrors.Select(r => r.ErrorMessage))); } - yield return run; } } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 734fd8905b1c92c5e821f4abc8e8b06c82e7fa93..bacce2a04f4526602190ab49c2ee1fe7d5f4b04e 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -32,7 +32,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; @@ -75,6 +74,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public uint Gear { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Gearbox == null) { @@ -84,9 +84,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } - [DebuggerHidden] public MeterPerSecond StartSpeed { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Gearbox == null) { @@ -96,9 +96,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } - [DebuggerHidden] public MeterPerSquareSecond StartAcceleration { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Gearbox == null) { @@ -119,6 +119,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public PerSecond EngineSpeed { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] get { if (Engine == null) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs index 6f907ef7137f98e6245f0777d3e4ba879f398382..d9169ad8d7d165a52b85a838830fc2eca7976ff2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Data; @@ -44,7 +45,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { [CustomValidation(typeof(AuxiliaryData), "ValidateAuxMap")] - public class AuxiliaryData + public sealed class AuxiliaryData: IDisposable { [Required, Range(double.Epsilon, 1)] public double EfficiencyToSupply { get; set; } @@ -192,6 +193,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } return ValidationResult.Success; } + + public void Dispose() + { + _map.Dispose(); + } } public class AdvancedAuxData diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs index 4f6666dd6b8925254e5210c7850d17607fb4a904..0968285e11bf72a469a6af6c6b3780e35e097b99 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs @@ -40,11 +40,10 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { - public class FuelConsumptionMap : SimulationComponentData + public class FuelConsumptionMap : SimulationComponentData, IDisposable { [Required, ValidateObject] private readonly DelaunayMap _fuelMap = new DelaunayMap("FuelConsumptionMap"); - - + private FuelConsumptionMap() {} public static FuelConsumptionMap ReadFromFile(string fileName) @@ -228,6 +227,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine return _fuelMap != null ? _fuelMap.GetHashCode() : 0; } + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + _fuelMap.Dispose(); + } + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs index c5395b4b4992dca8eea7c88c439e2e5f8660f0e6..32d9b6f27bd29aa2200e31a4d881b134a5dd3f5a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs @@ -40,7 +40,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { - public class PT1Curve : LookupData<PerSecond, Second> + public sealed class PT1Curve : LookupData<PerSecond, Second> { private List<KeyValuePair<PerSecond, Second>> _entries; @@ -54,12 +54,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine return new PT1Curve(data); } - protected PT1Curve(DataTable data) + private PT1Curve(DataTable data) { ParseData(data); } - protected PT1Curve(string file) + private PT1Curve(string file) { DataTable data; try { @@ -100,7 +100,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine } } - protected bool HeaderIsValid(DataColumnCollection columns) + private bool HeaderIsValid(DataColumnCollection columns) { return columns.Contains(Fields.EngineSpeed) && columns.Contains(Fields.PT1); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs index 17a538f2cd792ceb5a6bdcf75a3af545a6d9c722..e864ad1198eb6fb5b501235fc00100fbfb382d85 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox [Required, Range(double.Epsilon, 25)] public double Ratio { get; internal set; } - public bool TorqueConverterActive { get; internal set; } // TODO: think about refactoring... + public bool TorqueConverterActive { get; internal set; } // TODO mk-2016-05-09: Refactor TorqueConverterActive Flag when implementing Torque Converter // public double AverageEfficiency { get; internal set; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs index 06e28994308b07be560a98cfd40fc15abfe67463..f37bfc525ec973088e595025929b1df30a499bee 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs @@ -38,12 +38,11 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { - public class TransmissionLossMap : LoggingObject + public sealed class TransmissionLossMap : LoggingObject, IDisposable { [ValidateObject] private readonly List<GearLossMapEntry> _entries; @@ -67,7 +66,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox get { return _lossMap.Extrapolated; } } - public string GearName { get; protected set; } + public string GearName { get; private set; } public static TransmissionLossMap ReadFromFile(string fileName, double gearRatio, string gearName) @@ -224,5 +223,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox /// <summary>[-]</summary> public const string Efficiency = "Eff"; } + + public void Dispose() + { + _lossMap.Dispose(); + _invertedLossMap.Dispose(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 5125e3db06a1b1f7cbc5b0fc7cdd98c6a4c5bebb..90c9b97008a487fa2615752958700b5e5daf08a7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -92,7 +92,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region IEngineCockpit - PerSecond IEngineInfo.EngineSpeed + public PerSecond EngineSpeed { get { return PreviousState.EngineSpeed; } } @@ -142,7 +142,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region ITnOutPort - IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun) + public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun) { IterationStatistics.Increment(this, "Requests"); @@ -337,7 +337,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var fc = ModelData.ConsumptionMap.GetFuelConsumption(CurrentState.EngineTorque, avgEngineSpeed, allowExtrapolation: (DataBus.ExecutionMode != ExecutionMode.Declaration)); - //todo (MK, 2015-11-11): calculate aux start stop correction when start stop functionality is implemented in v3 + //TODO mk-2015-11-11: calculate aux start stop correction var fcAux = fc; var fcWHTC = fcAux * ModelData.WHTCCorrectionFactor; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index 7b6695b89e80288df1845ad97f7c96a2b850de50..76a4f0334911617dce28b3994cb6b49c41e39b3d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -116,7 +116,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region ITnInPort - void ITnInPort.Connect(ITnOutPort other) + public void Connect(ITnOutPort other) { NextComponent = other; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index e4534f04f7db7a650c76fc607f55924263785774..ddcf7e06248995ea94fab57f191d53999907543c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -541,7 +541,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseDrivingCycleDistanceExceeded>(r => { if (!ds.IsEqual(r.MaxDistance)) { // distance has been reduced due to vehicle stop in coast/roll action => use brake action to get exactly to the stop-distance - // TODO: what if no gear is enaged (and we need driveline power to get to the stop-distance? + // TODO what if no gear is enaged (and we need driveline power to get to the stop-distance? response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } }). diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 9e63593692e31c1abe1b88959bc96304b7ccbad3..f0db6c2284e483b91d6f58712cb45fbd210510b1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -50,26 +50,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <summary> /// Class representing one Distance Based Driving Cycle /// </summary> - public class DistanceBasedDrivingCycle : StatefulVectoSimulationComponent<DistanceBasedDrivingCycle.DrivingCycleState>, - IDrivingCycle, - ISimulationOutPort, IDrivingCycleInPort, IRoadLookAhead + public sealed class DistanceBasedDrivingCycle : + StatefulVectoSimulationComponent<DistanceBasedDrivingCycle.DrivingCycleState>, IDrivingCycle, ISimulationOutPort, + IDrivingCycleInPort, IRoadLookAhead, IDisposable { - protected const double LookaheadTimeSafetyMargin = 1.5; - protected readonly DrivingCycleData Data; + private const double LookaheadTimeSafetyMargin = 1.5; + private readonly DrivingCycleData _data; internal readonly DrivingCycleEnumerator CycleIntervalIterator; - protected IDrivingCycleOutPort NextComponent; + private IDrivingCycleOutPort _nextComponent; - protected bool IntervalProlonged; + private bool _intervalProlonged; public DistanceBasedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container) { - Data = cycle; - CycleIntervalIterator = new DrivingCycleEnumerator(Data); - CycleStartDistance = Data.Entries.Count > 0 ? Data.Entries.First().Distance : 0.SI<Meter>(); + _data = cycle; + CycleIntervalIterator = new DrivingCycleEnumerator(_data); + CycleStartDistance = _data.Entries.Count > 0 ? _data.Entries.First().Distance : 0.SI<Meter>(); - var first = Data.Entries.First(); + var first = _data.Entries.First(); PreviousState = new DrivingCycleState { AbsTime = 0.SI<Second>(), WaitTime = 0.SI<Second>(), @@ -99,16 +99,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region IDrivingCycleInPort - void IDrivingCycleInPort.Connect(IDrivingCycleOutPort other) + public void Connect(IDrivingCycleOutPort other) { - NextComponent = other; + _nextComponent = other; } #endregion #region ISimulationOutPort - IResponse ISimulationOutPort.Request(Second absTime, Meter ds) + public IResponse Request(Second absTime, Meter ds) { var retVal = DoHandleRequest(absTime, ds); CurrentState.Response = retVal; @@ -159,13 +159,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var remainingDistance = nextSpeedChange - PreviousState.Distance - ds; var estimatedRemainingTime = remainingDistance / DataBus.VehicleSpeed; - if (IntervalProlonged || remainingDistance.IsEqual(0.SI<Meter>()) || + if (_intervalProlonged || remainingDistance.IsEqual(0.SI<Meter>()) || estimatedRemainingTime.IsGreater(Constants.SimulationSettings.LowerBoundTimeInterval)) { return DriveDistance(absTime, ds); } Log.Debug("Extending distance by {0} to next sample point. ds: {1} new ds: {2}", remainingDistance, ds, nextSpeedChange - PreviousState.Distance); - IntervalProlonged = true; + _intervalProlonged = true; return new ResponseDrivingCycleDistanceExceeded { Source = this, MaxDistance = nextSpeedChange - PreviousState.Distance @@ -187,7 +187,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.Gradient = ComputeGradient(0.SI<Meter>()); CurrentState.VehicleTargetSpeed = CycleIntervalIterator.LeftSample.VehicleTargetSpeed; - return NextComponent.Request(absTime, dt, CycleIntervalIterator.LeftSample.VehicleTargetSpeed, CurrentState.Gradient); + return _nextComponent.Request(absTime, dt, CycleIntervalIterator.LeftSample.VehicleTargetSpeed, CurrentState.Gradient); } private IResponse DriveDistance(Second absTime, Meter ds) @@ -208,12 +208,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.VehicleTargetSpeed = CycleIntervalIterator.LeftSample.VehicleTargetSpeed; CurrentState.Gradient = ComputeGradient(ds); - var retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); + var retVal = _nextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); retVal.Switch() .Case<ResponseFailTimeInterval>( r => { - retVal = NextComponent.Request(absTime, r.DeltaT, 0.SI<MeterPerSecond>(), CurrentState.Gradient); - retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); + retVal = _nextComponent.Request(absTime, r.DeltaT, 0.SI<MeterPerSecond>(), CurrentState.Gradient); + retVal = _nextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); }); return retVal; } @@ -229,7 +229,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var leftSamplePoint = cycleIterator.LeftSample; var rightSamplePoint = cycleIterator.RightSample; - if (leftSamplePoint.Distance.IsEqual(rightSamplePoint.Distance)) { return leftSamplePoint.RoadGradient; } @@ -261,22 +260,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return null; } - IResponse ISimulationOutPort.Request(Second absTime, Second dt) + public IResponse Request(Second absTime, Second dt) { throw new NotImplementedException("Distance Based Driving Cycle does not support time requests."); } - IResponse ISimulationOutPort.Initialize() + public IResponse Initialize() { if (CycleIntervalIterator.LeftSample.VehicleTargetSpeed.IsEqual(0)) { - var retVal = NextComponent.Initialize(DataBus.StartSpeed, + var retVal = _nextComponent.Initialize(DataBus.StartSpeed, CycleIntervalIterator.LeftSample.RoadGradient, DataBus.StartAcceleration); if (!(retVal is ResponseSuccess)) { throw new UnexpectedResponseException("Couldn't find start gear.", retVal); } } - return NextComponent.Initialize(CycleIntervalIterator.LeftSample.VehicleTargetSpeed, + return _nextComponent.Initialize(CycleIntervalIterator.LeftSample.VehicleTargetSpeed, CycleIntervalIterator.LeftSample.RoadGradient); } @@ -284,9 +283,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { get { - return Data.Entries.Count > 0 - ? ((CurrentState.Distance - Data.Entries.First().Distance) / - (Data.Entries.Last().Distance - Data.Entries.First().Distance)).Value() + return _data.Entries.Count > 0 + ? ((CurrentState.Distance - _data.Entries.First().Distance) / + (_data.Entries.Last().Distance - _data.Entries.First().Distance)).Value() : 0; } } @@ -314,7 +313,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl PreviousState = CurrentState; CurrentState = CurrentState.Clone(); - IntervalProlonged = false; + _intervalProlonged = false; if (!CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(0) && CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(PreviousState.WaitTime)) { @@ -387,22 +386,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CycleStartDistance = startDistance; } - public class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> + public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> { - protected int CurrentCycleIndex; - protected DrivingCycleData Data; + private int _currentCycleIndex; + private DrivingCycleData _data; public DrivingCycleEnumerator(DrivingCycleData data) { - CurrentCycleIndex = 0; - Data = data; + _currentCycleIndex = 0; + _data = data; LastEntry = false; } public DrivingCycleEnumerator Clone() { - return new DrivingCycleEnumerator(Data) { - CurrentCycleIndex = CurrentCycleIndex, + return new DrivingCycleEnumerator(_data) { + _currentCycleIndex = _currentCycleIndex, LastEntry = LastEntry }; } @@ -419,17 +418,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public DrivingCycleData.DrivingCycleEntry LeftSample { - get { return Data.Entries[CurrentCycleIndex]; } + get { return _data.Entries[_currentCycleIndex]; } } public DrivingCycleData.DrivingCycleEntry RightSample { - get { return CurrentCycleIndex + 1 >= Data.Entries.Count ? null : Data.Entries[CurrentCycleIndex + 1]; } + get { return _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; } } - public bool LastEntry { get; protected set; } - - public void Dispose() {} + public bool LastEntry { get; private set; } object System.Collections.IEnumerator.Current { @@ -439,12 +436,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool MoveNext() { // cycleIndex has to be max. next to last (so that rightSample is still valid. - if (CurrentCycleIndex >= Data.Entries.Count - 2) { + if (_currentCycleIndex >= _data.Entries.Count - 2) { LastEntry = true; return false; } - CurrentCycleIndex++; - if (CurrentCycleIndex == Data.Entries.Count - 2) { + _currentCycleIndex++; + if (_currentCycleIndex == _data.Entries.Count - 2) { LastEntry = true; } @@ -453,8 +450,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void Reset() { - CurrentCycleIndex = 0; + _currentCycleIndex = 0; } + + public void Dispose() {} } public class DrivingCycleState @@ -490,5 +489,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Meter SimulationDistance; } + + public void Dispose() + { + CycleIntervalIterator.Dispose(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 78914d7ddcea0601e677a0a6ba6c90a93492e034..4804a1d41c7adf3435dbcf456d6a04c54b3f0733 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -138,9 +138,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - IDataBus IDriverActions.DataBus + public new IDataBus DataBus { - get { return DataBus; } + get { return base.DataBus; } } /// <summary> diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 227de3d7bd5a5134c13698479d51d575dcaa1a71..c52d979cd5ce828d9ad8a04feaa3606409591636 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -223,7 +223,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } IResponse retVal; - // TODO: MQ 2016/03/10: investigate further the effects of having the condition angularvelocity != 0 + // TODO MQ 2016/03/10: investigate further the effects of having the condition angularvelocity != 0 if (ClutchClosed(absTime) /* && !angularVelocity.IsEqual(0) */) { retVal = RequestGearEngaged(absTime, dt, torque, angularVelocity, dryRun); } else { @@ -393,7 +393,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region ITnInPort - void ITnInPort.Connect(ITnOutPort other) + public void Connect(ITnOutPort other) { NextComponent = other; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 0dd0e1f6247dd2078c87ca06833fac65bc77b93c..b475517770c06485e8f8abf83dc4ca211f94aff2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -182,7 +182,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region ITnInPort - void ITnInPort.Connect(ITnOutPort other) + public void Connect(ITnOutPort other) { NextComponent = other; } @@ -479,7 +479,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region IDriverDemandInPort - void IDriverDemandInPort.Connect(IDriverDemandOutPort other) + public void Connect(IDriverDemandOutPort other) { NextComponent = other; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index 38b620258c82fee359428a5daf1c1e52fd4b1432..4307d9ecb09540faf9d48fe5ed50cc8f7b0f6ab5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -122,8 +122,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public AMTShiftStrategy(GearboxData data, IDataBus dataBus) : base(data, dataBus) { PreviousGear = 1; - - // todo: move to settings Data.EarlyShiftUp = true; Data.SkipGears = true; } @@ -326,60 +324,4 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Data.SkipGears = true; } } - - // TODO Implement ATShiftStrategy - public class ATShiftStrategy : ShiftStrategy - { - public ATShiftStrategy(GearboxData data, IDataBus bus) : base(data, bus) {} - - public override uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - throw new NotImplementedException(); - } - - public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - throw new NotImplementedException(); - } - - public override bool ShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, - NewtonMeter inTorque, - PerSecond inAngularSpeed, uint gear, Second lastShiftTime) - { - throw new NotImplementedException(); - } - - public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - throw new NotImplementedException(); - } - } - - // TODO Implement CustomShiftStrategy - public class CustomShiftStrategy : ShiftStrategy - { - public CustomShiftStrategy(GearboxData data, IDataBus dataBus) : base(data, dataBus) {} - - public override bool ShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, - NewtonMeter inTorque, - PerSecond inAngularSpeed, uint gear, Second lastShiftTime) - { - throw new NotImplementedException(); - } - - public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - throw new NotImplementedException(); - } - - public override uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - throw new NotImplementedException(); - } - - public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - throw new NotImplementedException(); - } - } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs deleted file mode 100644 index 27dacf639cabb0ed13429bb6e50e6338fc114670..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs +++ /dev/null @@ -1,154 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2016 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models.Connector.Ports; -using TUGraz.VectoCore.Models.Connector.Ports.Impl; -using TUGraz.VectoCore.Models.Simulation; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.OutputData; - -namespace TUGraz.VectoCore.Models.SimulationComponent.Impl -{ - /// <summary> - /// Class representing one Time Based Driving Cycle - /// </summary> - public class TimeBasedDrivingCycle : VectoSimulationComponent, IDrivingCycle, - IDrivingCycleInPort, ISimulationOutPort - { - protected DrivingCycleData Data; - protected IDrivingCycleOutPort NextComponent; - - public TimeBasedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container) - { - Data = cycle; - } - - #region ISimulationOutProvider - - public ISimulationOutPort OutPort() - { - return this; - } - - #endregion - - #region IDrivingCycleInProvider - - public IDrivingCycleInPort InPort() - { - return this; - } - - #endregion - - #region ISimulationOutPort - - IResponse ISimulationOutPort.Request(Second absTime, Meter ds) - { - throw new NotImplementedException(); - } - - public IResponse Request(Second absTime, Second dt) - { - //todo: change to variable time steps - var index = (int)Math.Floor(absTime.Value()); - if (index >= Data.Entries.Count) { - return new ResponseCycleFinished(); - } - - // TODO: implement request and response handling!! - var dx = 0.SI<Meter>(); - return NextComponent.Request(absTime, dt, Data.Entries[index].VehicleTargetSpeed, - Data.Entries[index].RoadGradient); - } - - public IResponse Initialize() - { - // nothing to initialize here... - // TODO: _outPort.initialize(); - throw new NotImplementedException(); - } - - - public double Progress - { - get { throw new NotImplementedException(); } - } - - public Meter StartDistance - { - get { return 0.SI<Meter>(); } - } - - #endregion - - #region IDrivingCycleInPort - - void IDrivingCycleInPort. - Connect(IDrivingCycleOutPort - other) - { - NextComponent = other; - } - - #endregion - - #region VectoSimulationComponent - - protected override void DoWriteModalResults(IModalDataContainer container) - { - // TODO: write data... - } - - protected override void DoCommitSimulationStep() - { - // TODO: commit step - } - - #endregion - - public CycleData CycleData - { - get - { - return new CycleData { - AbsTime = 0.SI<Second>(), - AbsDistance = 0.SI<Meter>(), - LeftSample = null, - RightSample = null - }; - } - } - } -} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index 1b691725ab1b27ffdeccd2dc117ba5931db8948c..f1f79f63bbba35ba6b2e2070e73bf259c50582fb 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -173,6 +173,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.P_air] = CurrentState.AirDragResistance * averageVelocity; container[ModalResultField.P_slope] = CurrentState.SlopeResistance * averageVelocity; container[ModalResultField.P_trac] = CurrentState.VehicleTractionForce * averageVelocity; + // sanity check: is the vehicle in step with the cycle? if (container[ModalResultField.dist] == DBNull.Value) { Log.Warn("Distance field is not set!"); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs index 16c5f9ceec9788add6faac1ada09d1782336901c..bc7422019a51fbb609ae263d4eb5747fdb99f6ea 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Wheels.cs @@ -105,7 +105,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region ITnInPort - void ITnInPort.Connect(ITnOutPort other) + public void Connect(ITnOutPort other) { NextComponent = other; } diff --git a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs index 116ebdd358c5571d020f06c32ddd33d2f59506e5..6163dc235e2056783e408eeb7d7735138473c776 100644 --- a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs @@ -233,7 +233,7 @@ namespace TUGraz.VectoCore.OutputData public static WattSecond WorkTorqueConverter(this IModalDataContainer data) { - //TODO (MK, 2015-11-10): return torque converter work - this was currently not possible because torque converter is not implemented. + //TODO mk-2015-11-10: return torque converter work when TorqueConverter is implemented return 0.SI<WattSecond>(); } diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs index eb4ce09495535c5ccf3d37a73fef6cee5eb9f342..6dd12d98eb28ec65bf0f00cf70090dd7d8c61b29 100644 --- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Data; using System.Linq; using System.Runtime.CompilerServices; @@ -42,7 +43,7 @@ namespace TUGraz.VectoCore.OutputData /// <summary> /// Class for the sum file in vecto. /// </summary> - public class SummaryDataContainer : LoggingObject + public class SummaryDataContainer : LoggingObject, IDisposable { // ReSharper disable InconsistentNaming private const string JOB = "Job [-]"; @@ -254,5 +255,17 @@ namespace TUGraz.VectoCore.OutputData { return text.Replace('#', '_').Replace(',', '_').Replace('\n', '_').Replace('\r', '_'); } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + _table.Dispose(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index 57c98eb3120f32cfd7f012ad2fec971c58858c04..f019b82c253647440b99b7be1fc4a8852a4e1003 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -37,15 +37,13 @@ using System.IO; using System.Linq; using System.Threading; using System.Windows.Forms.DataVisualization.Charting; -using Newtonsoft.Json; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Utils { - [JsonObject(MemberSerialization.Fields)] - public class DelaunayMap : LoggingObject + public sealed class DelaunayMap : LoggingObject, IDisposable { internal readonly ICollection<Point> Points = new HashSet<Point>(); private List<Triangle> _triangles = new List<Triangle>(); @@ -98,11 +96,6 @@ namespace TUGraz.VectoCore.Utils var points = Points.ToArray(); - var xmin = points.Min(p => p.X); - var xmax = points.Max(p => p.X); - var ymin = points.Min(p => p.Y); - var ymax = points.Max(p => p.Y); - // iteratively add each point into the correct triangle and split up the triangle foreach (var point in points) { // If the vertex lies inside the circumcircle of a triangle, the edges of this triangle are @@ -133,7 +126,7 @@ namespace TUGraz.VectoCore.Utils } } - //DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax); + DrawGraph(pointCount, triangles, superTriangle, points); _convexHull = triangles.FindAll(t => t.SharesVertexWith(superTriangle)). SelectMany(t => t.GetEdges()). @@ -160,9 +153,13 @@ namespace TUGraz.VectoCore.Utils /// Draws the delaunay map (except supertriangle). /// </summary> [Conditional("TRACE")] - private static void DrawGraph(int i, List<Triangle> triangles, Triangle superTriangle, double xmin, double xmax, double ymin, - double ymax, Point lastPoint = null) + private static void DrawGraph(int i, List<Triangle> triangles, Triangle superTriangle, Point[] points, Point lastPoint = null) { + var xmin = points.Min(p => p.X); + var xmax = points.Max(p => p.X); + var ymin = points.Min(p => p.Y); + var ymax = points.Max(p => p.Y); + using (var chart = new Chart { Width = 1000, Height = 1000 }) { chart.ChartAreas.Add(new ChartArea("main") { AxisX = new Axis { Minimum = Math.Min(xmin, xmin), Maximum = Math.Max(xmax, xmax) }, @@ -198,6 +195,7 @@ namespace TUGraz.VectoCore.Utils var frame = new StackFrame(2); var method = frame.GetMethod(); + System.Diagnostics.Debug.Assert(method.DeclaringType != null, "method.DeclaringType != null"); var type = string.Join("", method.DeclaringType.Name.Split(Path.GetInvalidFileNameChars())); var methodName = string.Join("", method.Name.Split(Path.GetInvalidFileNameChars())); Directory.CreateDirectory("delaunay"); @@ -269,19 +267,19 @@ namespace TUGraz.VectoCore.Utils } // 2d vector of the edge: A--->B - var AB = new Point(edge.Vector.X, edge.Vector.Y); + var ab = new Point(edge.Vector.X, edge.Vector.Y); // 2d vector of the point: A---->P - var AP = new Point(x - edge.P1.X, y - edge.P1.Y); + var ap = new Point(x - edge.P1.X, y - edge.P1.Y); // projection of point (x,y) onto the edge - var z = edge.P1.Z + edge.Vector.Z * (AP.Dot(AB) / AB.Dot(AB)); + var z = edge.P1.Z + edge.Vector.Z * (ap.Dot(ab) / ab.Dot(ab)); return z; } #region Equality members - protected bool Equals(DelaunayMap other) + private bool Equals(DelaunayMap other) { return Points.SequenceEqual(other.Points) && _triangles.SequenceEqual(other._triangles); } @@ -308,6 +306,11 @@ namespace TUGraz.VectoCore.Utils } } + public void Dispose() + { + _extrapolated.Dispose(); + } + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 645bd17134fda1be7be7c8c3e5b1b02410d7ae60..fa99d46a5000ca58ed4e98ed38d0f68e6148e044 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -240,7 +240,6 @@ <Compile Include="Models\SimulationComponent\IGearbox.cs" /> <Compile Include="Models\Connector\Ports\ISimulationPort.cs" /> <Compile Include="Models\SimulationComponent\Impl\DistanceBasedDrivingCycle.cs" /> - <Compile Include="Models\SimulationComponent\Impl\TimeBasedDrivingCycle.cs" /> <Compile Include="Models\SimulationComponent\Impl\CombustionEngine.cs" /> <Compile Include="Models\SimulationComponent\Impl\Gearbox.cs" /> <Compile Include="Models\SimulationComponent\Impl\Wheels.cs" /> diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index 36e7d39a00a05688847b3d4dac757b0246bc9374..d83b5069791738f47513f2155216f02054401290 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -296,18 +296,17 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns @"TestData\job_1-Gear-Test-dist.vmod", testRowCount: false); } - // todo: add realistic FullLoadCurve private static GearboxData CreateGearboxData() { var ratios = new[] { 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 }; - + return new GearboxData { Gears = ratios.Select((ratio, i) => Tuple.Create((uint)i, new GearData { + // TODO mk-2016-05-09: add realistic FullLoadCurve for gearbox - gearbox will have only 1 constant value as full load FullLoadCurve = FullLoadCurveReader.ReadFromFile(GearboxFullLoadCurveFile), - LossMap = - TransmissionLossMap.ReadFromFile(GearboxLossMap, ratio, string.Format("Gear {0}", i)), + LossMap = TransmissionLossMap.ReadFromFile(GearboxLossMap, ratio, string.Format("Gear {0}", i)), Ratio = ratio, ShiftPolygon = ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) })) diff --git a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs index fe22ad13d1eafb716daa46e0cad3060bd29402a6..450061d769e2257b582b130b385b7ad11a75646d 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs @@ -151,33 +151,6 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation } } - [TestMethod] - public void Test_TimeBased_FirstCycle() - { - var container = new VehicleContainer(ExecutionMode.Engineering); - - var cycleData = DrivingCycleDataReader.ReadFromFile(@"TestData\Cycles\Coach First Cycle only.vdri", - CycleType.MeasuredSpeed, false); - var cycle = new TimeBasedDrivingCycle(container, cycleData); - - var outPort = new MockDrivingCycleOutPort(); - - var inPort = cycle.InPort(); - var cycleOut = cycle.OutPort(); - - inPort.Connect(outPort); - - var absTime = 0.SI<Second>(); - var dt = 1.SI<Second>(); - - var response = cycleOut.Request(absTime, dt); - Assert.IsInstanceOfType(response, typeof(ResponseSuccess)); - - Assert.AreEqual(absTime, outPort.AbsTime); - Assert.AreEqual(0.SI<MeterPerSecond>(), outPort.Velocity); - AssertHelper.AreRelativeEqual(-0.000202379727237.SI<Radian>(), outPort.Gradient); - } - [TestMethod] public void DrivingCycle_AutoDetect() { diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs index f62525dabd8b35c46c64649db8cf558b2a06ba95..d6f68d7466d87ccf198b5c248e0af3dc07ffe1b0 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs @@ -197,7 +197,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent modalData[ModalResultField.time] = t; modalData[ModalResultField.simulationInterval] = dt; engine.CommitSimulationStep(modalData); - // todo: compare results... Assert.AreEqual(expectedResults.Rows[i].ParseDouble(0), t.Value(), 0.001, "Time"); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(1), ((SI)modalData[ModalResultField.P_eng_full]).Value(), 0.1, string.Format("Load in timestep {0}", t)); @@ -248,7 +247,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent modalData[ModalResultField.time] = t; modalData[ModalResultField.simulationInterval] = dt; engine.CommitSimulationStep(modalData); - // todo: compare results... Assert.AreEqual(expectedResults.Rows[i].ParseDouble(0), t.Value(), 0.001, "Time"); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(1), ((SI)modalData[ModalResultField.P_eng_full]).Value(), 0.1, string.Format("Load in timestep {0}", t)); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs index de4c27e99a08475d5a79aae59df2bca4d702d291..7afa881ed1d9428554310a9288370b1f9622f122 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs @@ -29,7 +29,11 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; +using NLog; +using NLog.Config; +using NLog.Targets; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Simulation.Data; @@ -47,6 +51,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData private const string CoachEngineFLD = @"TestData\Components\24t Coach.vfld"; private const double Tolerance = 0.0001; + public static List<string> LogList = new List<string>(); + [TestMethod] public void TestFullLoadStaticTorque() { @@ -159,13 +165,29 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData } /// <summary> - /// [VECTO-78] + /// [VECTO-78] /// </summary> [TestMethod] public void Test_FileRead_HeaderColumnsNotNamedCorrectly() { + LogList.Clear(); + var target = new MethodCallTarget { + ClassName = typeof(FullLoadCurveTest).AssemblyQualifiedName, + MethodName = "LogMethod_Test_FileRead_HeaderColumnsNotNamedCorrectly" + }; + target.Parameters.Add(new MethodCallParameter("${level}")); + target.Parameters.Add(new MethodCallParameter("${message}")); + SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Warn); EngineFullLoadCurve.ReadFromFile(@"TestData\Components\FullLoadCurve wrong header.vfld"); - //todo: check log file: ensure header warning was written! + Assert.IsTrue( + LogList.Contains( + "FullLoadCurve: Header Line is not valid. Expected: \'engine speed, full load torque, motoring torque\', Got: \'n, Mfull, Mdrag, PT1\'. Falling back to column index.")); + LogList.Clear(); + } + + public static void LogMethod_Test_FileRead_HeaderColumnsNotNamedCorrectly(string level, string message) + { + LogList.Add(message); } /// <summary> @@ -216,7 +238,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData } /// <summary> - /// [VECTO-190] + /// [VECTO-190] /// </summary> [TestMethod] public void TestSortingFullLoadEntries() diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs index 719ca06b815eefeaa650c0193fcf44c779a50738..7bb2e59effe41d358a9d0cb1b413ee5b78d29583 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs @@ -58,13 +58,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData [TestMethod] public void TestGearboxDataReadTest() { + var axleData = MockSimulationDataFactory.CreateAxleGearDataFromFile(GearboxFile); + Assert.AreEqual(3.240355, axleData.AxleGear.Ratio, 0.0001); + var gbxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxFile, EngineFile, false); - Assert.AreEqual(GearboxType.AMT, gbxData.Type); Assert.AreEqual(1.0, gbxData.TractionInterruption.Value(), 0.0001); Assert.AreEqual(8, gbxData.Gears.Count); - - // Todo: Assert.AreEqual(3.240355, gbxData.AxleGearData.Ratio, 0.0001); + Assert.AreEqual(1.0, gbxData.Gears[7].Ratio, 0.0001); Assert.AreEqual(-400, gbxData.Gears[1].ShiftPolygon.Downshift[0].Torque.Value(), 0.0001);