Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit c663dfb8 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

Merge pull request #174 in VECTO/vecto-sim from ~EMKRISPMI/vecto-sim:code-cleanup to develop

* commit 'e3dd6b58':
  updated async-log flag in app.config, TRACE & DEBUG constants
  moved max coordinates into the DrawGraph Debug Method, code formatting
  ModalResults Serializable
  changed explicit interface implementations do implicit
  implemented IDisposable
  rewrote TODO for gearbox overload constant value
  sealed many classes
  CodeAnalysis: Suppressed Unexpected Exception Location in Properties
  CodeAnalysis: Made VectoExceptions serializable
  updated todo comments (more uniform format) and removed some (vair and beta input check)
  removed trace listener from vecto console (trace output not used anyway)
  updated tests with TODO's
  removed obsolete TODO comments
  removed not implemented objects for ATShiftStrategy and CustomShiftStrategy (implement only when needed)
  removed class for TimeBased Driving Cycle (this case is not needed - was replaced by pwheel, measured speed and engineOnly cycles)
  enhanced header test for correct message of header warning
parents 511fe31a e3dd6b58
No related branches found
No related tags found
No related merge requests found
Showing
with 97 additions and 72 deletions
......@@ -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>
......
......@@ -5,16 +5,19 @@
<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 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}" />
layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message} ${exception:format=tostring}" />
</targets>
<rules>
<logger name="*" minlevel="Warn" writeTo="LogFile" />
......@@ -37,8 +40,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>
......
......@@ -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) {}
......
......@@ -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) { }
......
......@@ -8,15 +8,15 @@
<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>
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_${threadid}.txt"
layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message} ${exception:format=tostring}" />
layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message} ${exception:format=tostring}" />
</targets>
<rules>
<logger name="*" minlevel="Warn" writeTo="LogFile" />
......
......@@ -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();
}
......
......@@ -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!
}
}
......
......@@ -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];
......
......@@ -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; }
......
......@@ -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)
......
......@@ -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,
......
......@@ -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()
{
......
......@@ -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));
......
......@@ -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));
......
......@@ -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));
......
......@@ -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));
......
......@@ -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));
......
......@@ -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()
{
......
......@@ -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";
......
......@@ -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.");
......
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