diff --git a/VectoConsole/App.config b/VectoConsole/App.config index 8e15646352ec1d9a84bbc6504ef6b46e16bf7823..b9fc82b72b412787b48895da9c5ccb501157bd12 100644 --- a/VectoConsole/App.config +++ b/VectoConsole/App.config @@ -1,6 +1,23 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> - <startup> - <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> - </startup> + <configSections> + <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" /> + </configSections> + <startup> + <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.txt" layout="${longdate} [${processid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message}" /> + </targets> + <rules> + <logger name="*" minlevel="Info" writeTo="LogFile" /> + </rules> + </nlog> </configuration> \ No newline at end of file diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index 7b9065187b716022ab8ab45b0c1174d2f7361763..c04f147828ea5bfd7a9a7fdf069ac5e0ac229bdb 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -2,6 +2,8 @@ using System.Diagnostics; using System.IO; using System.Linq; +using NLog; +using NLog.Config; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -19,13 +21,17 @@ namespace VectoConsole } if (args.Contains("-v")) { + var config = LogManager.Configuration; + var target = config.FindTargetByName("ConsoleLogger"); + config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, target)); + LogManager.Configuration = config; Trace.Listeners.Add(new ConsoleTraceListener(true)); } var fileList = args.Where(a => a != "-v").ToList().ToList(); - var sumWriter = - new SummaryFileWriter(Path.GetFileNameWithoutExtension(fileList.First()) + Constants.FileExtensions.SumFile); + var sumFileName = Path.GetFileNameWithoutExtension(fileList.First()) + Constants.FileExtensions.SumFile; + var sumWriter = new SummaryFileWriter(sumFileName); var jobContainer = new JobContainer(sumWriter); foreach (var file in fileList.Where(f => Path.GetExtension(f) == Constants.FileExtensions.VectoJobFile)) { diff --git a/VectoConsole/VectoConsole.csproj b/VectoConsole/VectoConsole.csproj index f15867a55928d8b17fd7dea3ee3ea84897172cbd..77f9978ce87b741c69dc59c1f413342526734b76 100644 --- a/VectoConsole/VectoConsole.csproj +++ b/VectoConsole/VectoConsole.csproj @@ -38,6 +38,10 @@ <ApplicationIcon>VECTO.ico</ApplicationIcon> </PropertyGroup> <ItemGroup> + <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> @@ -204,6 +208,7 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <None Include="packages.config" /> <None Include="VECTO.ico" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> diff --git a/VectoConsole/packages.config b/VectoConsole/packages.config new file mode 100644 index 0000000000000000000000000000000000000000..573e2fd16f8cd28f35e521d53253818d0d0b2e95 --- /dev/null +++ b/VectoConsole/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="NLog" version="4.0.1" targetFramework="net45" /> +</packages> \ No newline at end of file diff --git a/VectoCore/FileIO/DeclarationFile/JobFileDecl.cs b/VectoCore/FileIO/DeclarationFile/JobFileDecl.cs index 553783faca7e27d947814715b8736cebf167af4a..c52ebc7adcefef4562e97032601633ecc7829066 100644 --- a/VectoCore/FileIO/DeclarationFile/JobFileDecl.cs +++ b/VectoCore/FileIO/DeclarationFile/JobFileDecl.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using Newtonsoft.Json; -using TUGraz.VectoCore.Models.SimulationComponent.Data; namespace TUGraz.VectoCore.FileIO.DeclarationFile { @@ -102,7 +101,7 @@ namespace TUGraz.VectoCore.FileIO.DeclarationFile //[JsonProperty(Required = Required.Always)] public LACData LAC; [JsonProperty(Required = Required.Always)] public OverSpeedEcoRollDataDecl OverSpeedEcoRoll; - public class AuxDataDecl + public class AuxDataDecl : VectoAuxiliaryFile { [JsonProperty(Required = Required.Always)] public string ID; [JsonProperty(Required = Required.Always)] public string Type; diff --git a/VectoCore/FileIO/InputFileReader.cs b/VectoCore/FileIO/InputFileReader.cs index 6c30603206d5b129cd81c9ce816c46f73362ecef..c580aaa48bc4a9c8a4205c7bf943dd84edaa7ca6 100644 --- a/VectoCore/FileIO/InputFileReader.cs +++ b/VectoCore/FileIO/InputFileReader.cs @@ -1,22 +1,17 @@ -using Common.Logging; -using Newtonsoft.Json; +using Newtonsoft.Json; +using TUGraz.VectoCore.Models; namespace TUGraz.VectoCore.FileIO { - public class InputFileReader + public class InputFileReader : LoggingObject { - protected ILog Log; - protected class VersionInfo { public bool SavedInDeclarationMode; public int Version; } - protected InputFileReader() - { - Log = LogManager.GetLogger(GetType()); - } + protected InputFileReader() {} protected static VersionInfo GetFileVersion(string jsonStr) { diff --git a/VectoCore/FileIO/Reader/DrivingCycleDataReader.cs b/VectoCore/FileIO/Reader/DrivingCycleDataReader.cs index 09b7b7c4038ae74a72f9afbba39cc92eca298e05..047f0a2ea300e3f4bae0423c381d006f4cf32c59 100644 --- a/VectoCore/FileIO/Reader/DrivingCycleDataReader.cs +++ b/VectoCore/FileIO/Reader/DrivingCycleDataReader.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; -using Common.Logging; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Exceptions; +using TUGraz.VectoCore.Models; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.FileIO.Reader { - public class DrivingCycleDataReader + public class DrivingCycleDataReader : LoggingObject { // --- Factory Methods public static DrivingCycleData ReadFromStream(Stream stream, DrivingCycleData.CycleType type) @@ -61,8 +61,6 @@ namespace TUGraz.VectoCore.FileIO.Reader private static List<DrivingCycleData.DrivingCycleEntry> FilterDrivingCycleEntries( List<DrivingCycleData.DrivingCycleEntry> entries) { - var log = LogManager.GetLogger<DrivingCycleData>(); - var filtered = new List<DrivingCycleData.DrivingCycleEntry>(); var current = entries.First(); current.Altitude = 0.SI<Meter>(); @@ -81,7 +79,7 @@ namespace TUGraz.VectoCore.FileIO.Reader } distance = entry.Distance; } - log.Info(string.Format("Data loaded. Number of Entries: {0}, filtered Entries: {1}", entries.Count, filtered.Count)); + Log.Info("Data loaded. Number of Entries: {0}, filtered Entries: {1}", entries.Count, filtered.Count); entries = filtered; AdjustDistanceAfterStop(entries); @@ -426,9 +424,8 @@ namespace TUGraz.VectoCore.FileIO.Reader } if (header.Contains(Fields.EngineTorque) && header.Contains(Fields.EnginePower)) { - LogManager.GetLogger<DrivingCycleData>() - .WarnFormat("Found column '{0}' and column '{1}': only column '{0}' will be used.", - Fields.EngineTorque, Fields.EnginePower); + Log.Warn("Found column '{0}' and column '{1}': only column '{0}' will be used.", + Fields.EngineTorque, Fields.EnginePower); } } } diff --git a/VectoCore/FileIO/Reader/Impl/AbstractSimulationDataReader.cs b/VectoCore/FileIO/Reader/Impl/AbstractSimulationDataReader.cs index 17fa5779af7822f6c3dccd84686f6f21582b53b2..8cbca82720868a968eea3538172d2e68d96dae9e 100644 --- a/VectoCore/FileIO/Reader/Impl/AbstractSimulationDataReader.cs +++ b/VectoCore/FileIO/Reader/Impl/AbstractSimulationDataReader.cs @@ -19,7 +19,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl public void SetJobFile(string filename) { - ReadJobFile(filename); + Job = ReadJobFile(filename); ProcessJob(Job); } @@ -34,15 +34,18 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl /// <summary> /// has to read the file string and create file-container /// </summary> - protected abstract void ReadJobFile(string file); + protected abstract VectoJobFile ReadJobFile(string file); /// <summary> /// has to read the file string and create file-container /// </summary> - protected abstract void ReadVehicle(string file); + protected abstract VectoVehicleFile ReadVehicle(string file); - protected abstract void ReadEngine(string file); + protected abstract VectoEngineFile ReadEngine(string file); - protected abstract void ReadGearbox(string file); + protected abstract VectoGearboxFile ReadGearbox(string file); + + protected abstract IList<VectoRunData.AuxData> ReadAuxiliary(string basePath, + IEnumerable<VectoAuxiliaryFile> auxiliaries); } } \ No newline at end of file diff --git a/VectoCore/FileIO/Reader/Impl/DeclarationModeSimulationDataReader.cs b/VectoCore/FileIO/Reader/Impl/DeclarationModeSimulationDataReader.cs index 85bdb10d96535ad0d86a5147d54d3fd56c143f8d..c4e1f2e5f5ea07979135d6de80859666131b8e70 100644 --- a/VectoCore/FileIO/Reader/Impl/DeclarationModeSimulationDataReader.cs +++ b/VectoCore/FileIO/Reader/Impl/DeclarationModeSimulationDataReader.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using Newtonsoft.Json; @@ -14,13 +15,14 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl { public class DeclarationModeSimulationDataReader : AbstractSimulationDataReader { + internal DeclarationModeSimulationDataReader() {} - protected void CheckForDeclarationMode(InputFileReader.VersionInfo info, string msg) + protected void CheckForDeclarationMode(VersionInfo info, string msg) { if (!info.SavedInDeclarationMode) { // throw new VectoException("File not saved in Declaration Mode! - " + msg); - Log.WarnFormat("File not saved in Declaration Mode! - {0}", msg); + Log.Warn("File not saved in Declaration Mode! - {0}", msg); } } @@ -56,22 +58,25 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl protected override void ProcessJob(VectoJobFile vectoJob) { - var declaration = vectoJob as VectoJobFileV2Declaration; - if (declaration == null) { - return; + try { + var job = vectoJob as VectoJobFileV2Declaration; + if (job == null) { + throw new VectoException( + string.Format("Unhandled Job File Format. Expected: Job File, Version 2, Declaration Mode. Got: {0}", + vectoJob.GetType())); + } + Vehicle = ReadVehicle(Path.Combine(job.BasePath, job.Body.VehicleFile)); + Engine = ReadEngine(Path.Combine(job.BasePath, job.Body.EngineFile)); + Gearbox = ReadGearbox(Path.Combine(job.BasePath, job.Body.GearboxFile)); + Aux = ReadAuxiliary(job.BasePath, job.Body.Aux); + } catch (VectoException e) { + var message = string.Format("Exception during processing of job file \"{0}\": {1}", vectoJob.JobFile, e.Message); + Log.Error(message); + throw new VectoException(message, e); } - var job = declaration; - - ReadVehicle(Path.Combine(job.BasePath, job.Body.VehicleFile)); - - ReadEngine(Path.Combine(job.BasePath, job.Body.EngineFile)); - - ReadGearbox(Path.Combine(job.BasePath, job.Body.GearboxFile)); - - ReadAuxiliary(job.Body.Aux); } - protected override void ReadJobFile(string file) + protected override VectoJobFile ReadJobFile(string file) { var json = File.ReadAllText(file); var fileInfo = GetFileVersion(json); @@ -79,16 +84,16 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 2: - Job = JsonConvert.DeserializeObject<VectoJobFileV2Declaration>(json); - Job.BasePath = Path.GetDirectoryName(Path.GetFullPath(file)) + Path.DirectorySeparatorChar; - Job.JobFile = Path.GetFileName(file); - break; + var job = JsonConvert.DeserializeObject<VectoJobFileV2Declaration>(json); + job.BasePath = file; + job.JobFile = file; + return job; default: throw new UnsupportedFileVersionException("Unsupported version of job-file. Got version " + fileInfo.Version); } } - protected override void ReadVehicle(string file) + protected override VectoVehicleFile ReadVehicle(string file) { var json = File.ReadAllText(file); var fileInfo = GetFileVersion(json); @@ -96,15 +101,15 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 5: - Vehicle = JsonConvert.DeserializeObject<VehicleFileV5Declaration>(json); - Vehicle.BasePath = Path.GetDirectoryName(file); - break; + var vehicle = JsonConvert.DeserializeObject<VehicleFileV5Declaration>(json); + vehicle.BasePath = file; + return Vehicle; default: throw new UnsupportedFileVersionException("Unsupported Version of vehicle-file. Got version " + fileInfo.Version); } } - protected override void ReadEngine(string file) + protected override VectoEngineFile ReadEngine(string file) { var json = File.ReadAllText(file); var fileInfo = GetFileVersion(json); @@ -112,15 +117,15 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 3: - Engine = JsonConvert.DeserializeObject<EngineFileV3Declaration>(json); - Engine.BasePath = Path.GetDirectoryName(file); - break; + var engine = JsonConvert.DeserializeObject<EngineFileV3Declaration>(json); + engine.BasePath = file; + return engine; default: throw new UnsupportedFileVersionException("Unsupported Version of engine-file. Got version " + fileInfo.Version); } } - protected override void ReadGearbox(string file) + protected override VectoGearboxFile ReadGearbox(string file) { var json = File.ReadAllText(file); var fileInfo = GetFileVersion(json); @@ -128,31 +133,35 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 5: - Gearbox = JsonConvert.DeserializeObject<GearboxFileV5Declaration>(json); - Gearbox.BasePath = Path.GetDirectoryName(file); - break; + var gearbox = JsonConvert.DeserializeObject<GearboxFileV5Declaration>(json); + gearbox.BasePath = file; + return gearbox; default: throw new UnsupportedFileVersionException("Unsupported Version of gearbox-file. Got version " + fileInfo.Version); } } - private void ReadAuxiliary(IEnumerable<VectoJobFileV2Declaration.DataBodyDecl.AuxDataDecl> auxiliaries) + protected override IList<VectoRunData.AuxData> ReadAuxiliary(string basePath, + IEnumerable<VectoAuxiliaryFile> auxiliaries) { - var aux = DeclarationData.AuxiliaryIDs().Select(id => { - var a = auxiliaries.First(decl => decl.ID == id); - return new VectoRunData.AuxData { - ID = a.ID, - Type = AuxiliaryTypeHelper.Parse(a.Type), - Technology = a.Technology, - TechList = a.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray(), - DemandType = AuxiliaryDemandType.Constant - }; - }); - - // add a direct auxiliary - aux = aux.Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()); - - Aux = aux.ToArray(); + var inputAuxiliaries = auxiliaries.Cast<VectoJobFileV2Declaration.DataBodyDecl.AuxDataDecl>().ToArray(); + return DeclarationData.AuxiliaryIDs().Select(id => { + try { + var a = inputAuxiliaries.First(decl => decl.ID == id); + return new VectoRunData.AuxData { + ID = a.ID, + Type = AuxiliaryTypeHelper.Parse(a.Type), + Technology = a.Technology, + TechList = a.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray(), + DemandType = AuxiliaryDemandType.Constant + }; + } catch (InvalidOperationException) { + var message = string.Format("Auxiliary was not found: Expected: [{0}], Got: [{1}]", + string.Join(", ", DeclarationData.AuxiliaryIDs()), string.Join(", ", inputAuxiliaries.Select(a => a.ID))); + Log.Error(message); + throw new VectoException(message); + } + }).Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()).ToList(); } internal Segment GetVehicleClassification(VehicleCategory category, AxleConfiguration axles, Kilogram grossMassRating, diff --git a/VectoCore/FileIO/Reader/Impl/EngineOnlySimulationDataReader.cs b/VectoCore/FileIO/Reader/Impl/EngineOnlySimulationDataReader.cs index 1bdf919b3f6ed4487b2c10999257fa48521ee235..32829cf7e40f5360646165a0e29ec9f0e2e22bf5 100644 --- a/VectoCore/FileIO/Reader/Impl/EngineOnlySimulationDataReader.cs +++ b/VectoCore/FileIO/Reader/Impl/EngineOnlySimulationDataReader.cs @@ -1,14 +1,9 @@ -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; -using System.Linq; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.FileIO.EngineeringFile; using TUGraz.VectoCore.FileIO.Reader.DataObjectAdaper; using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.Simulation.Impl; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Impl; namespace TUGraz.VectoCore.FileIO.Reader.Impl { @@ -42,7 +37,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl } var job = declaration; - ReadEngine(Path.Combine(job.BasePath, job.Body.EngineFile)); + Engine = ReadEngine(Path.Combine(job.BasePath, job.Body.EngineFile)); } public override bool IsEngineOnly diff --git a/VectoCore/FileIO/Reader/Impl/EngineeringModeSimulationDataReader.cs b/VectoCore/FileIO/Reader/Impl/EngineeringModeSimulationDataReader.cs index 757dae0e047b1a33671fd158dee6d5f7c00b0d44..9b18ef84e3d6640cc94d0e7ccf5ee4f426f1a2c0 100644 --- a/VectoCore/FileIO/Reader/Impl/EngineeringModeSimulationDataReader.cs +++ b/VectoCore/FileIO/Reader/Impl/EngineeringModeSimulationDataReader.cs @@ -2,7 +2,6 @@ using System.IO; using System.Linq; using System.Runtime.CompilerServices; -using Common.Logging; using Newtonsoft.Json; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.FileIO.EngineeringFile; @@ -26,50 +25,47 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl protected static void CheckForEngineeringMode(VersionInfo info, string msg) { if (info.SavedInDeclarationMode) { - LogManager.GetLogger(typeof(EngineeringModeSimulationDataReader)) - .WarnFormat("File was saved in Declaration Mode but is used for Engineering Mode!"); + Log.Warn("File was saved in Declaration Mode but is used for Engineering Mode!"); } } protected override void ProcessJob(VectoJobFile vectoJob) { - var engineering = vectoJob as VectoJobFileV2Engineering; - if (engineering == null) { - throw new VectoException("Unhandled Job File Format"); + try { + var job = vectoJob as VectoJobFileV2Engineering; + if (job == null) { + throw new VectoException( + string.Format("Unhandled Job File Format. Expected: Job File, Version 2, Engineering Mode. Got: {0}", + vectoJob.GetType())); + } + + if (job.Body.EngineOnlyMode) { + throw new VectoException("Job File has been saved in EngineOnlyMode!"); + } + + Vehicle = ReadVehicle(Path.Combine(job.BasePath, job.Body.VehicleFile)); + Engine = ReadEngine(Path.Combine(job.BasePath, job.Body.EngineFile)); + Gearbox = ReadGearbox(Path.Combine(job.BasePath, job.Body.GearboxFile)); + Aux = ReadAuxiliary(job.BasePath, job.Body.Aux); + } catch (VectoException e) { + Log.Error("Exception during processing of job file {0}: {1}", e.Message); } - var job = engineering; - - if (job.Body.EngineOnlyMode) { - throw new VectoException("Job File has been saved in EngineOnlyMode!"); - } - - ReadVehicle(Path.Combine(job.BasePath, job.Body.VehicleFile)); - - ReadEngine(Path.Combine(job.BasePath, job.Body.EngineFile)); - - ReadGearbox(Path.Combine(job.BasePath, job.Body.GearboxFile)); - - ReadAuxiliary(engineering.Body.Aux); } - private void ReadAuxiliary(IEnumerable<VectoJobFileV2Engineering.DataBodyEng.AuxDataEng> auxiliaries) + protected override IList<VectoRunData.AuxData> ReadAuxiliary(string basePath, + IEnumerable<VectoAuxiliaryFile> auxiliaries) { - var aux = auxiliaries.Select(a => new VectoRunData.AuxData { + return auxiliaries.Cast<VectoJobFileV2Engineering.DataBodyEng.AuxDataEng>().Select(a => new VectoRunData.AuxData { ID = a.ID, Technology = a.Technology, TechList = a.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray(), DemandType = AuxiliaryDemandType.Mapping, - Data = AuxiliaryData.ReadFromFile(Path.Combine(Job.BasePath, a.Path)) - }); - - // add a direct auxiliary - aux = aux.Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()); - - Aux = aux.ToArray(); + Data = AuxiliaryData.ReadFromFile(Path.Combine(basePath, a.Path)) + }).Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()).ToList(); } - protected override void ReadVehicle(string file) + protected override VectoVehicleFile ReadVehicle(string file) { var json = File.ReadAllText(file); var fileInfo = GetFileVersion(json); @@ -77,9 +73,9 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 5: - Vehicle = JsonConvert.DeserializeObject<VehicleFileV5Engineering>(json); - Vehicle.BasePath = Path.GetDirectoryName(file); - break; + var vehicle = JsonConvert.DeserializeObject<VehicleFileV5Engineering>(json); + vehicle.BasePath = Path.GetDirectoryName(file); + return vehicle; default: throw new UnsupportedFileVersionException("Unsupported Version of .vveh file. Got Version " + fileInfo.Version); } @@ -160,27 +156,27 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl /// initialize vecto job member (deserialize Vecot-file /// </summary> /// <param name="file"></param> - protected override void ReadJobFile(string file) + protected override VectoJobFile ReadJobFile(string file) { - Job = DoReadJobFile(file); + return DoReadJobFile(file); } /// <summary> /// initialize Engine member (deserialize Engine-file) /// </summary> /// <param name="file"></param> - protected override void ReadEngine(string file) + protected override VectoEngineFile ReadEngine(string file) { - Engine = DoReadEngineFile(file); + return DoReadEngineFile(file); } /// <summary> /// initialize Gearbox member (deserialize Gearbox-file) /// </summary> /// <param name="file"></param> - protected override void ReadGearbox(string file) + protected override VectoGearboxFile ReadGearbox(string file) { - Gearbox = DoReadGearboxFile(file); + return DoReadGearboxFile(file); } //============================================================== @@ -198,8 +194,8 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 2: var tmp = JsonConvert.DeserializeObject<VectoJobFileV2Engineering>(json); - tmp.BasePath = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar; - tmp.JobFile = Path.GetFileName(file); + tmp.BasePath = file; + tmp.JobFile = file; return tmp; default: throw new UnsupportedFileVersionException("Unsupported version of job-file. Got version " + fileInfo.Version); @@ -220,7 +216,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 3: var tmp = JsonConvert.DeserializeObject<EngineFileV3Engineering>(json); - tmp.BasePath = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar; + tmp.BasePath = file; return tmp; default: throw new UnsupportedFileVersionException("Unsopported Version of engine-file. Got version " + fileInfo.Version); @@ -241,7 +237,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 5: var tmp = JsonConvert.DeserializeObject<GearboxFileV5Engineering>(json); - tmp.BasePath = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar; + tmp.BasePath = file; return tmp; default: throw new UnsupportedFileVersionException("Unsopported Version of gearbox-file. Got version " + fileInfo.Version); @@ -262,7 +258,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl switch (fileInfo.Version) { case 5: var tmp = JsonConvert.DeserializeObject<VehicleFileV5Engineering>(json); - tmp.BasePath = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar; + tmp.BasePath = file; return tmp; default: throw new UnsupportedFileVersionException("Unsopported Version of vehicle-file. Got version " + fileInfo.Version); diff --git a/VectoCore/FileIO/VectoFiles.cs b/VectoCore/FileIO/VectoFiles.cs index 65fd64c20ed0372f98d3e1023bdf47fdf7e52656..17b68ce81afaa39cd80edaa7b415f1db788d74cf 100644 --- a/VectoCore/FileIO/VectoFiles.cs +++ b/VectoCore/FileIO/VectoFiles.cs @@ -1,25 +1,38 @@ -using System.Runtime.Serialization; +using System.IO; +using System.Runtime.Serialization; namespace TUGraz.VectoCore.FileIO { - public abstract class VectoJobFile + public abstract class VectoBaseFile { - [DataMember] internal string BasePath; - [DataMember] internal string JobFile; - } + protected string basePath; - public abstract class VectoVehicleFile - { - [DataMember] internal string BasePath; + [DataMember] + internal string BasePath + { + get { return basePath; } + set { basePath = Path.GetDirectoryName(Path.GetFullPath(value)); } + } } - public abstract class VectoGearboxFile - { - [DataMember] internal string BasePath; - } - public abstract class VectoEngineFile + public abstract class VectoJobFile : VectoBaseFile { - [DataMember] internal string BasePath; + private string _jobFile; + + [DataMember] + internal string JobFile + { + get { return _jobFile; } + set { _jobFile = Path.GetFileName(value); } + } } + + public abstract class VectoVehicleFile : VectoBaseFile {} + + public abstract class VectoGearboxFile : VectoBaseFile {} + + public abstract class VectoEngineFile : VectoBaseFile {} + + public abstract class VectoAuxiliaryFile : VectoBaseFile {} } \ No newline at end of file diff --git a/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/Models/Declaration/DeclarationData.cs index 42ac5840cec11b5873e334b988195bcfc8e95217..1beca9e1d9bbf3536bc59db696da812fb4f8d5d0 100644 --- a/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/Models/Declaration/DeclarationData.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using NLog.Targets.Wrappers; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; -using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration @@ -258,7 +256,7 @@ namespace TUGraz.VectoCore.Models.Declaration } } - public static string[] AuxiliaryIDs() + public static IEnumerable<string> AuxiliaryIDs() { return new[] { Constants.Auxiliaries.IDs.Fan, Constants.Auxiliaries.IDs.SteeringPump, diff --git a/VectoCore/Models/Declaration/LookupData.cs b/VectoCore/Models/Declaration/LookupData.cs index fc9b9a5a0fbb9ae512c8c3699c35a07fbb0ba191..3f192547fdbdbaceccbdbd715a6e89699e68fcb7 100644 --- a/VectoCore/Models/Declaration/LookupData.cs +++ b/VectoCore/Models/Declaration/LookupData.cs @@ -1,20 +1,11 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Data; -using Common.Logging; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public abstract class LookupData + public abstract class LookupData : LoggingObject { - protected LookupData() - { - Log = LogManager.GetLogger(GetType()); - } - - [NonSerialized] protected ILog Log; - protected abstract void ParseData(DataTable table); protected DataTable ReadCsvResource(string resourceId) diff --git a/VectoCore/Models/Declaration/PT1.cs b/VectoCore/Models/Declaration/PT1.cs index cc1905e50f79a381701b772ea677c891c69da926..0e3bfa13ce533b49fd1dffe89facf503e0488773 100644 --- a/VectoCore/Models/Declaration/PT1.cs +++ b/VectoCore/Models/Declaration/PT1.cs @@ -29,7 +29,7 @@ namespace TUGraz.VectoCore.Models.Declaration { var index = 1; if (key < _entries[0].Key) { - Log.ErrorFormat("requested rpm below minimum rpm in pt1 - extrapolating. n: {0}, rpm_min: {1}", + Log.Error("requested rpm below minimum rpm in pt1 - extrapolating. n: {0}, rpm_min: {1}", key.ConvertTo().Rounds.Per.Minute, _entries[0].Key.ConvertTo().Rounds.Per.Minute); } else { index = _entries.FindIndex(x => x.Key > key); diff --git a/VectoCore/Models/LoggingObject.cs b/VectoCore/Models/LoggingObject.cs new file mode 100644 index 0000000000000000000000000000000000000000..6136c50bbd2e3b182f57cae6b1a11d69813eed65 --- /dev/null +++ b/VectoCore/Models/LoggingObject.cs @@ -0,0 +1,10 @@ +using System; +using NLog; + +namespace TUGraz.VectoCore.Models +{ + public class LoggingObject + { + [NonSerialized] protected static readonly Logger Log = LogManager.GetCurrentClassLogger(); + } +} \ No newline at end of file diff --git a/VectoCore/Models/Simulation/Impl/JobContainer.cs b/VectoCore/Models/Simulation/Impl/JobContainer.cs index ad718b2e1d8bce72ab61450e747c6696cd245ecf..d399e270a4b35e684d1d50a27acbf416264739e5 100644 --- a/VectoCore/Models/Simulation/Impl/JobContainer.cs +++ b/VectoCore/Models/Simulation/Impl/JobContainer.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading.Tasks; -using Common.Logging; using TUGraz.VectoCore.Models.Simulation.Data; namespace TUGraz.VectoCore.Models.Simulation.Impl @@ -14,7 +12,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl /// <summary> /// Container for simulation jobs. /// </summary> - public class JobContainer + public class JobContainer : LoggingObject { private readonly List<IVectoRun> _runs = new List<IVectoRun>(); private readonly SummaryFileWriter _sumWriter; @@ -54,7 +52,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl /// </summary> public void Execute() { - LogManager.GetLogger(GetType()).Info("VectoRun started running. Executing Runs."); + Log.Info("VectoRun started running. Executing Runs."); Task.WaitAll(_runs.Select(r => Task.Factory.StartNew(r.Run)).ToArray()); diff --git a/VectoCore/Models/Simulation/Impl/VectoRun.cs b/VectoCore/Models/Simulation/Impl/VectoRun.cs index b6feaf95763ddc640450128ca5f386f3eb6816fc..648ec5535c764ea0c4821cf0560bdfb9137bc80a 100644 --- a/VectoCore/Models/Simulation/Impl/VectoRun.cs +++ b/VectoCore/Models/Simulation/Impl/VectoRun.cs @@ -1,6 +1,4 @@ -using System; -using Common.Logging; -using TUGraz.VectoCore.Models.Connector.Ports; +using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Utils; @@ -10,7 +8,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl /// <summary> /// Simulator for one vecto simulation job. /// </summary> - public abstract class VectoRun : IVectoRun + public abstract class VectoRun : LoggingObject, IVectoRun { protected Second AbsTime = 0.SI<Second>(); @@ -39,7 +37,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public void Run() { - LogManager.GetLogger(GetType()).Info("VectoJob started running."); + Log.Info("VectoJob started running."); IResponse response; Initialize(); @@ -55,7 +53,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl Container.FinishSimulation(); - LogManager.GetLogger(GetType()).Info("VectoJob finished."); + Log.Info("VectoJob finished."); } protected abstract IResponse DoSimulationStep(); diff --git a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 85ba72ed618998e7ec189d15c6b58f73c11bcd1e..0794dbf788ec4f99993ce213c547e05e985b62f5 100644 --- a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Globalization; -using Common.Logging; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Simulation.Data; @@ -12,7 +10,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.Impl { - public class VehicleContainer : IVehicleContainer + public class VehicleContainer : LoggingObject, IVehicleContainer { internal readonly IList<VectoSimulationComponent> Components = new List<VectoSimulationComponent>(); internal IEngineInfo Engine; @@ -28,8 +26,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl internal ISummaryDataWriter SumWriter; internal IModalDataWriter DataWriter; - private readonly ILog _logger; - #region IGearCockpit public uint Gear() @@ -80,7 +76,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public VehicleContainer(IModalDataWriter dataWriter = null, ISummaryDataWriter sumWriter = null) { - _logger = LogManager.GetLogger(GetType()); DataWriter = dataWriter; SumWriter = sumWriter; } @@ -130,7 +125,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public void CommitSimulationStep(Second time, Second simulationInterval) { - _logger.Info("VehicleContainer committing simulation."); + Log.Info("VehicleContainer committing simulation."); foreach (var component in Components) { component.CommitSimulationStep(DataWriter); } @@ -144,7 +139,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public void FinishSimulation() { - _logger.Info("VehicleContainer finishing simulation."); + Log.Info("VehicleContainer finishing simulation."); DataWriter.Finish(); SumWriter.Write(DataWriter, VehicleMass(), VehicleLoading()); diff --git a/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs b/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs index 43e1c4d4782ca5bc72d70f9d732fe2220af65945..060806038220ea84372f453f76232b2a6df6b375 100644 --- a/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs +++ b/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs @@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var index = 1; if (key < _entries[0].Key) { - Log.ErrorFormat("requested velocity below minimum - extrapolating. velocity: {0}, min: {1}", + Log.Error("requested velocity below minimum - extrapolating. velocity: {0}, min: {1}", key.ConvertTo().Kilo.Meter.Per.Hour, _entries[0].Key.ConvertTo().Kilo.Meter.Per.Hour); } else { index = _entries.FindIndex(x => x.Key > key); diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs b/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs index 5b2e82d0e1daab584e5d814aef59015cfcabe94b..d0cbb0fe2f9dbee00a681672d28e1f08f38b51b8 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs @@ -3,11 +3,8 @@ using System.Collections.Generic; using System.Data; using System.Diagnostics.Contracts; using System.Linq; -using Common.Logging; -using Newtonsoft.Json; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine @@ -47,8 +44,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine if (HeaderIsValid(data.Columns)) { entriesFld = CreateFromColumnNames(data); } else { - var log = LogManager.GetLogger<EngineFullLoadCurve>(); - log.WarnFormat( + Log.Warn( "FullLoadCurve: Header Line is not valid. Expected: '{0}, {1}, {2}', Got: '{3}'. Falling back to column index.", Fields.EngineSpeed, Fields.TorqueFullLoad, Fields.TorqueDrag, string.Join(", ", data.Columns.Cast<DataColumn>().Select(c => c.ColumnName).Reverse())); @@ -262,7 +258,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine } area += additionalArea; } - Log.WarnFormat("Could not compute preferred speed, check FullLoadCurve! N95h: {0}, maxArea: {1}", N95hSpeed, maxArea); + Log.Warn("Could not compute preferred speed, check FullLoadCurve! N95h: {0}, maxArea: {1}", N95hSpeed, maxArea); } private PerSecond ComputeEngineSpeedForSegmentArea(FullLoadCurveEntry p1, FullLoadCurveEntry p2, Watt area) @@ -281,7 +277,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine var retVal = VectoMath.QuadraticEquationSolver(k.Value() / 2.0, d.Value(), (k * p1.EngineSpeed * p1.EngineSpeed + 2 * p1.EngineSpeed * d).Value()); if (retVal.Count == 0) { - Log.InfoFormat("No real solution found for requested area: P: {0}, p1: {1}, p2: {2}", area, p1, p2); + Log.Info("No real solution found for requested area: P: {0}, p1: {1}, p2: {2}", area, p1, p2); } return retVal.First(x => x >= p1.EngineSpeed.Value() && x <= p2.EngineSpeed.Value()).SI<PerSecond>(); } @@ -295,7 +291,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { int idx; if (angularVelocity < _fullLoadEntries[0].EngineSpeed) { - Log.ErrorFormat("requested rpm below minimum rpm in FLD curve - extrapolating. n: {0}, rpm_min: {1}", + Log.Error("requested rpm below minimum rpm in FLD curve - extrapolating. n: {0}, rpm_min: {1}", angularVelocity.ConvertTo().Rounds.Per.Minute, _fullLoadEntries[0].EngineSpeed.ConvertTo().Rounds.Per.Minute); idx = 1; } else { @@ -333,7 +329,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine // power = M(n) * n = (k * n + d) * n = k * n^2 + d * n retVal = VectoMath.QuadraticEquationSolver(k.Value(), d.Value(), -power.Value()).SI<PerSecond>().ToList(); if (retVal.Count == 0) { - Log.InfoFormat("No real solution found for requested power demand: P: {0}, p1: {1}, p2: {2}", power, p1, p2); + Log.Info("No real solution found for requested power demand: P: {0}, p1: {1}, p2: {2}", power, p1, p2); } } retVal = retVal.Where(x => x >= p1.EngineSpeed && x <= p2.EngineSpeed).ToList(); diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs b/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs index d75e95e62392f77a5be825b02d4484c056c17775..cd7ebfc16594be7f9fdda4c09c687c7ee89d71df 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Data; using System.Linq; -using Common.Logging; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Utils; @@ -19,7 +18,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine protected PT1Curve(string file) { - Log = LogManager.GetLogger(GetType()); ParseData(ReadCsvFile(file)); } @@ -67,7 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { var index = 1; if (key < _entries[0].Key) { - Log.ErrorFormat("requested rpm below minimum rpm in pt1 - extrapolating. n: {0}, rpm_min: {1}", + Log.Error("requested rpm below minimum rpm in pt1 - extrapolating. n: {0}, rpm_min: {1}", key.ConvertTo().Rounds.Per.Minute, _entries[0].Key.ConvertTo().Rounds.Per.Minute); } else { index = _entries.FindIndex(x => x.Key > key); diff --git a/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs b/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs index ab8f23ef124dafc4484be161b77844392638457e..5c8e0d7335efec09db321041b2566afbcb4a6720 100644 --- a/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs +++ b/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; using System.Linq; -using System.Runtime.Remoting.Messaging; -using Common.Logging; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Utils; @@ -38,8 +35,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox entriesDown = CreateFromColumnNames(data, Fields.AngluarSpeedDown); entriesUp = CreateFromColumnNames(data, Fields.AngularSpeedUp); } else { - var log = LogManager.GetLogger<ShiftPolygon>(); - log.WarnFormat( + Log.Warn( "ShiftPolygon: Header Line is not valid. Expected: '{0}, {1}, {2}', Got: '{3}'. Falling back to column index", Fields.Torque, Fields.AngularSpeedUp, Fields.AngluarSpeedDown, string.Join(", ", data.Columns.Cast<DataColumn>().Select(c => c.ColumnName).Reverse())); diff --git a/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs b/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs index bc429a3f29fc25e2aee419ad7de7010784c67a70..85831dd73ae491ea21a584a6adc9b88b60022375 100644 --- a/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs +++ b/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs @@ -2,14 +2,13 @@ using System.Collections.Generic; using System.Data; using System.Linq; -using Common.Logging; using Newtonsoft.Json; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { - public class TransmissionLossMap + public class TransmissionLossMap : LoggingObject { [JsonProperty] private readonly List<GearLossMapEntry> _entries; @@ -33,8 +32,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox if (HeaderIsValid(data.Columns)) { entries = CreateFromColumnNames(data); } else { - var log = LogManager.GetLogger<TransmissionLossMap>(); - log.WarnFormat( + Log.Warn( "TransmissionLossMap: Header line is not valid. Expected: '{0}, {1}, {2}, <{3}>'. Got: '{4}'. Falling back to column index.", Fields.InputSpeed, Fields.InputTorque, Fields.TorqeLoss, Fields.Efficiency, string.Join(", ", data.Columns.Cast<DataColumn>().Select(c => c.ColumnName).Reverse())); diff --git a/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs b/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs index e610c1ca8a98c3120e01b8457bb401a63aed77a6..5170b9c277898d6c767716d906e2e8128dbea0c1 100644 --- a/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs +++ b/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Data; using System.Linq; -using Common.Logging; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Utils; @@ -28,8 +27,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (HeaderIsValid(data.Columns)) { entries = CreateFromColumnNames(data); } else { - var log = LogManager.GetLogger<RetarderLossMap>(); - log.WarnFormat( + Log.Warn( "RetarderLossMap: Header Line is not valid. Expected: '{0}, {1}', Got: '{2}'. Falling back to column index.", Fields.RetarderSpeed, Fields.TorqueLoss, string.Join(", ", data.Columns.Cast<DataColumn>().Select(c => c.ColumnName).Reverse())); @@ -49,7 +47,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { int idx; if (angularVelocity < _entries[0].RetarderSpeed) { - Log.InfoFormat("requested rpm below minimum rpm in retarder loss map - extrapolating. n: {0}, rpm_min: {1}", + Log.Info("requested rpm below minimum rpm in retarder loss map - extrapolating. n: {0}, rpm_min: {1}", angularVelocity.ConvertTo().Rounds.Per.Minute, _entries[0].RetarderSpeed.ConvertTo().Rounds.Per.Minute); idx = 1; } else { diff --git a/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs b/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs index b79c726f6d8c1b0eccaeadf3c5422d15337bbc73..79ccea370674df106696d99666b0c2054a29f94e 100644 --- a/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs +++ b/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs @@ -1,18 +1,7 @@ -using System; -using Common.Logging; -using Newtonsoft.Json; - -namespace TUGraz.VectoCore.Models.SimulationComponent.Data +namespace TUGraz.VectoCore.Models.SimulationComponent.Data { - public class SimulationComponentData + public class SimulationComponentData : LoggingObject { - [NonSerialized] protected ILog Log; - - public SimulationComponentData() - { - Log = LogManager.GetLogger(GetType()); - } - public bool SavedInDeclarationMode { get; internal set; } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs b/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs index 16c934d2fb56ede284214ad0132340f748fb21bd..cd3f19f2d5440951098a5f45b139d4e90575acea 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Common.Logging; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Simulation; @@ -111,7 +110,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { if (!cycle.CycleData().LeftSample.AuxiliarySupplyPower.ContainsKey("Aux_" + auxId)) { var error = string.Format("driving cycle does not contain column for auxiliary: {0}", auxId); - LogManager.GetLogger(GetType()).ErrorFormat(error); + Log.Error(error); throw new VectoException(error); } diff --git a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index febe784069de97f747170bfd773e719bf4e0cb1d..dbf8ac58240271f036949b4fe204384da1b9a2bf 100644 --- a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -161,7 +161,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl .ConvertTo() .Gramm.Per.Hour; } catch (VectoException ex) { - Log.WarnFormat("t: {0} - {1} n: {2} Tq: {3}", _currentState.AbsTime, ex.Message, + Log.Warn("t: {0} - {1} n: {2} Tq: {3}", _currentState.AbsTime, ex.Message, _currentState.EngineSpeed, _currentState.EngineTorque); writer[ModalResultField.FCMap] = double.NaN.SI(); } @@ -203,7 +203,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (requestedEnginePower > _currentState.DynamicFullLoadPower) { if (requestedEnginePower / _currentState.DynamicFullLoadPower > MaxPowerExceededThreshold) { _enginePowerCorrections.Add(_currentState.AbsTime); - Log.WarnFormat( + Log.Warn( "t: {0} requested power > P_engine_full * 1.05 - corrected. P_request: {1} P_engine_full: {2}", _currentState.AbsTime, requestedEnginePower, _currentState.DynamicFullLoadPower); } @@ -213,7 +213,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (requestedEnginePower / _currentState.FullDragPower > MaxPowerExceededThreshold && requestedEnginePower > -99999) { _enginePowerCorrections.Add(_currentState.AbsTime); - Log.WarnFormat( + Log.Warn( "t: {0} requested power < P_engine_drag * 1.05 - corrected. P_request: {1} P_engine_drag: {2}", _currentState.AbsTime, requestedEnginePower, _currentState.FullDragPower); } diff --git a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 5c0e718e19c54ec1223be169745a729a736c26a3..9e63a49531273f6f3f1c73bfc831a0974c1952f6 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -86,7 +86,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl && CycleIntervalIterator.LeftSample.StoppingTime > PreviousState.WaitTime) { // stop for certain time unless we've already waited long enough... if (!CycleIntervalIterator.LeftSample.VehicleTargetSpeed.IsEqual(0)) { - Log.WarnFormat("Stopping Time requested in cycle but target-velocity not zero. distance: {0}, target speed: {1}", + Log.Warn("Stopping Time requested in cycle but target-velocity not zero. distance: {0}, target speed: {1}", CycleIntervalIterator.LeftSample.StoppingTime, CycleIntervalIterator.LeftSample.VehicleTargetSpeed); throw new VectoSimulationException("Stopping Time only allowed when target speed is zero!"); } diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs index d75603342c654bb727cc28a94ff0f33894db5149..3a9dbad3d1f96a2ff9de44edfa752176a0aaca5b 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -161,7 +161,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl solutions = solutions.Where(x => x >= 0).ToList(); if (solutions.Count == 0) { - Log.WarnFormat( + Log.Warn( "Could not find solution for computing required time interval to drive distance {0}. currentSpeed: {1}, targetSpeed: {2}, acceleration: {3}", ds, currentSpeed, targetVelocity, acceleration); return 0.SI<Second>(); diff --git a/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs b/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs index 5bb6ca5aba36236424cd746f09188d8b4dca6a3c..23b8d8388445ccf2cd9ee31cf57c502177bc7aac 100644 --- a/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs +++ b/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse ITnOutPort.Request(Second absTime, Second dt, NewtonMeter torque, PerSecond engineSpeed, bool dryRun) { if (_outPort == null) { - Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime); + Log.Error("{0} cannot handle incoming request - no outport available", absTime); throw new VectoSimulationException( string.Format("{0} cannot handle incoming request - no outport available", absTime)); diff --git a/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs b/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs index 33bfc0070d6b58b6341837f1d5f84dee62e61b53..207bb4b4c54abd18f765c4632ad2cddcd9bccdad 100644 --- a/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs +++ b/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs @@ -1,5 +1,4 @@ using System; -using Common.Logging; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; @@ -9,10 +8,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent /// <summary> /// Base class for all vecto simulation components. /// </summary> - public abstract class VectoSimulationComponent + public abstract class VectoSimulationComponent : LoggingObject { [NonSerialized] protected IDataBus DataBus; - [NonSerialized] protected ILog Log; /// <summary> /// Constructor. Registers the component in the cockpit. @@ -21,8 +19,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent protected VectoSimulationComponent(IVehicleContainer dataBus) { DataBus = dataBus; - Log = LogManager.GetLogger(GetType()); - dataBus.AddComponent(this); } diff --git a/VectoCore/Utils/DelauneyMap.cs b/VectoCore/Utils/DelauneyMap.cs index d759555529a17fc5f4620469bafbaabd93a11d4e..a31c5d95ef5c7bc238ecd4dc67e4a026486d1e8f 100644 --- a/VectoCore/Utils/DelauneyMap.cs +++ b/VectoCore/Utils/DelauneyMap.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Linq; -using Common.Logging; using Newtonsoft.Json; using TUGraz.VectoCore.Exceptions; +using TUGraz.VectoCore.Models; namespace TUGraz.VectoCore.Utils { [JsonObject(MemberSerialization.Fields)] - public class DelauneyMap + public class DelauneyMap : LoggingObject { private readonly List<Point> _points = new List<Point>(); private List<Triangle> _triangles = new List<Triangle>(); @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.Utils { var tr = _triangles.Find(triangle => triangle.IsInside(x, y, true)); if (tr == null) { - LogManager.GetLogger(GetType()).Info("Exact search found no fitting triangle. Approximation will be used."); + Log.Info("Exact search found no fitting triangle. Approximation will be used."); tr = _triangles.Find(triangle => triangle.IsInside(x, y, false)); if (tr == null) { throw new VectoException(string.Format("Interpolation failed. x: {0}, y: {1}", x, y)); diff --git a/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/Utils/VectoCSVFile.cs index 2fa5b42b578d36c91a5322a9b8d609742daddb79..ef0383b40c4d6c242261c61f620a66a956c45926 100644 --- a/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/Utils/VectoCSVFile.cs @@ -7,8 +7,8 @@ using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; -using Common.Logging; using TUGraz.VectoCore.Exceptions; +using TUGraz.VectoCore.Models; namespace TUGraz.VectoCore.Utils { @@ -25,7 +25,7 @@ namespace TUGraz.VectoCore.Utils /// max: id (name) [unit], id (name) [unit], ... /// min: id,id,... /// </remarks> - public static class VectoCSVFile + public class VectoCSVFile : LoggingObject { private const char Delimiter = ','; private const char Comment = '#'; @@ -79,8 +79,7 @@ namespace TUGraz.VectoCore.Utils // Valid Columns found => header was valid => skip header line lines = lines.Skip(1).ToArray(); } else { - var log = LogManager.GetLogger(typeof(VectoCSVFile)); - log.Warn("No valid Data Header found. Interpreting the first line as data line."); + Log.Warn("No valid Data Header found. Interpreting the first line as data line."); // set the validColumns to: {"0", "1", "2", "3", ...} for all columns in first line. validColumns = GetColumns(lines.First()).Select((_, index) => index.ToString()).ToArray(); } diff --git a/VectoCore/VectoCore.csproj b/VectoCore/VectoCore.csproj index 6fd2bc46d9a89e946085b1a9b8b220e20221c1d0..46e5af42c458d0bb50da304bd488b0e322c37be6 100644 --- a/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore.csproj @@ -78,23 +78,13 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Common.Logging"> - <HintPath>..\packages\Common.Logging.3.0.0\lib\net40\Common.Logging.dll</HintPath> - </Reference> - <Reference Include="Common.Logging.Core"> - <HintPath>..\packages\Common.Logging.Core.3.0.0\lib\net40\Common.Logging.Core.dll</HintPath> - </Reference> - <Reference Include="Common.Logging.NLog31"> - <HintPath>..\packages\Common.Logging.NLog31.3.0.0\lib\net40\Common.Logging.NLog31.dll</HintPath> - <Private>True</Private> - </Reference> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> - <Reference Include="NLog, Version=3.2.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> + <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\NLog.3.2.0.0\lib\net45\NLog.dll</HintPath> + <HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> @@ -157,6 +147,7 @@ <Compile Include="Models\Declaration\Mission.cs" /> <Compile Include="Models\Declaration\MissionType.cs" /> <Compile Include="Models\SimulationComponent\Data\Engine\PT1Curve.cs" /> + <Compile Include="Models\LoggingObject.cs" /> <Compile Include="Models\SimulationComponent\IDrivingCycleInfo.cs" /> <Compile Include="Models\SimulationComponent\Impl\AuxiliaryData.cs" /> <Compile Include="Models\Simulation\Data\AuxiliaryDemandType.cs" /> diff --git a/VectoCore/app.config b/VectoCore/app.config index 275e46a27e77b434708c616ce57bc44e44093d6f..a4fbc4b605af87b415cce7e84f8c1100815b9cff 100644 --- a/VectoCore/app.config +++ b/VectoCore/app.config @@ -1,35 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> - <configuration> - <configSections> - <sectionGroup name="common"> - <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> - </sectionGroup> - <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" /> - </configSections> - <runtime> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" /> - </dependentAssembly> - </assemblyBinding> - </runtime> - <common> - <logging> - <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog31"> - <arg key="configType" value="INLINE" /> - </factoryAdapter> - </logging> - </common> - <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <targets> - <target xsi:type="Console" name="ConsoleLogger" error="true" /> - <target xsi:type="File" name="LogFile" filename="${basedir}/logs/log.txt" - layout="${longdate} [${processid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message}" /> - </targets> - <rules> - <logger name="*" minlevel="Info" writeTo="LogFile" /> - </rules> - </nlog> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> + </startup> </configuration> \ No newline at end of file diff --git a/VectoCore/packages.config b/VectoCore/packages.config index 3229bd6e1e32bfc7e0c7e84bf89f6373ad829be4..549984a6a8ddab6bf0dd93850834376ce5659664 100644 --- a/VectoCore/packages.config +++ b/VectoCore/packages.config @@ -1,9 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="Common.Logging" version="3.0.0" targetFramework="net45" /> - <package id="Common.Logging.Core" version="3.0.0" targetFramework="net45" /> - <package id="Common.Logging.NLog31" version="3.0.0" targetFramework="net45" /> - <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> - <package id="NLog" version="3.2.0.0" targetFramework="net45" /> + <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> + <package id="NLog" version="4.0.1" targetFramework="net45" /> </packages> \ No newline at end of file diff --git a/VectoCoreTest/Utils/MockPorts.cs b/VectoCoreTest/Utils/MockPorts.cs index a6f6b3eb82c3c8eac7593e98527d4e79db1d27e5..0467404d896de71f686d4461c39f55c7890e4395 100644 --- a/VectoCoreTest/Utils/MockPorts.cs +++ b/VectoCoreTest/Utils/MockPorts.cs @@ -1,5 +1,6 @@ using System; -using Common.Logging; +using NLog; +using TUGraz.VectoCore.Models; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Utils; @@ -8,6 +9,8 @@ namespace TUGraz.VectoCore.Tests.Utils { public class MockTnOutPort : ITnOutPort { + protected static readonly Logger Log = LogManager.GetCurrentClassLogger(); + public Second AbsTime { get; set; } public Second Dt { get; set; } public NewtonMeter Torque { get; set; } @@ -19,8 +22,7 @@ namespace TUGraz.VectoCore.Tests.Utils Dt = dt; Torque = torque; AngularVelocity = angularVelocity; - LogManager.GetLogger(GetType()).DebugFormat("Request: absTime: {0}, dt: {1}, torque: {3}, engineSpeed: {4}", - absTime, dt, torque, angularVelocity); + Log.Debug("Request: absTime: {0}, dt: {1}, torque: {3}, engineSpeed: {4}", absTime, dt, torque, angularVelocity); return new ResponseSuccess(); } @@ -30,7 +32,7 @@ namespace TUGraz.VectoCore.Tests.Utils } } - public class MockDrivingCycleOutPort : IDrivingCycleOutPort + public class MockDrivingCycleOutPort : LoggingObject, IDrivingCycleOutPort { public Second AbsTime { get; set; } public Meter Ds { get; set; } @@ -45,8 +47,7 @@ namespace TUGraz.VectoCore.Tests.Utils Ds = ds; Velocity = targetVelocity; Gradient = gradient; - LogManager.GetLogger(GetType()).DebugFormat("Request: absTime: {0}, ds: {1}, velocity: {2}, gradient: {3}", - absTime, ds, targetVelocity, gradient); + Log.Debug("Request: absTime: {0}, ds: {1}, velocity: {2}, gradient: {3}", absTime, ds, targetVelocity, gradient); return new ResponseSuccess(); } @@ -56,8 +57,7 @@ namespace TUGraz.VectoCore.Tests.Utils Dt = dt; Velocity = targetVelocity; Gradient = gradient; - LogManager.GetLogger(GetType()).DebugFormat("Request: absTime: {0}, ds: {1}, velocity: {2}, gradient: {3}", - absTime, dt, targetVelocity, gradient); + Log.Debug("Request: absTime: {0}, ds: {1}, velocity: {2}, gradient: {3}", absTime, dt, targetVelocity, gradient); return new ResponseSuccess(); } @@ -67,7 +67,7 @@ namespace TUGraz.VectoCore.Tests.Utils } } - public class MockFvOutPort : IFvOutPort + public class MockFvOutPort : LoggingObject, IFvOutPort { public Second AbsTime { get; set; } public Second Dt { get; set; } @@ -81,8 +81,7 @@ namespace TUGraz.VectoCore.Tests.Utils Dt = dt; Force = force; Velocity = velocity; - LogManager.GetLogger(GetType()) - .DebugFormat("Request: abstime: {0}, dt: {1}, force: {2}, velocity: {3}", absTime, dt, force, velocity); + Log.Debug("Request: abstime: {0}, dt: {1}, force: {2}, velocity: {3}", absTime, dt, force, velocity); return new ResponseSuccess(); } diff --git a/VectoCoreTest/VectoCoreTest.csproj b/VectoCoreTest/VectoCoreTest.csproj index 750f13f441a996f106ab17b561ef709b9fb470fc..6b17e43369b9df3f646151d37278451d7241f8d6 100644 --- a/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCoreTest/VectoCoreTest.csproj @@ -35,20 +35,9 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Common.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\Common.Logging.3.0.0\lib\net40\Common.Logging.dll</HintPath> - </Reference> - <Reference Include="Common.Logging.Core"> - <HintPath>..\packages\Common.Logging.Core.3.0.0\lib\net40\Common.Logging.Core.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Common.Logging.NLog31"> - <HintPath>..\packages\Common.Logging.NLog31.3.0.0\lib\net40\Common.Logging.NLog31.dll</HintPath> - </Reference> <Reference Include="Microsoft.CSharp" /> <Reference Include="NLog"> - <HintPath>..\packages\NLog.3.2.0.0\lib\net45\NLog.dll</HintPath> + <HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> diff --git a/VectoCoreTest/app.config b/VectoCoreTest/app.config index 275e46a27e77b434708c616ce57bc44e44093d6f..b9fc82b72b412787b48895da9c5ccb501157bd12 100644 --- a/VectoCoreTest/app.config +++ b/VectoCoreTest/app.config @@ -1,35 +1,23 @@ <?xml version="1.0" encoding="utf-8"?> - <configuration> - <configSections> - <sectionGroup name="common"> - <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> - </sectionGroup> - <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" /> - </configSections> - <runtime> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" /> - </dependentAssembly> - </assemblyBinding> - </runtime> - <common> - <logging> - <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog31"> - <arg key="configType" value="INLINE" /> - </factoryAdapter> - </logging> - </common> - <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <targets> - <target xsi:type="Console" name="ConsoleLogger" error="true" /> - <target xsi:type="File" name="LogFile" filename="${basedir}/logs/log.txt" - layout="${longdate} [${processid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message}" /> - </targets> - <rules> - <logger name="*" minlevel="Info" writeTo="LogFile" /> - </rules> - </nlog> + <configSections> + <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" /> + </configSections> + <startup> + <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.txt" layout="${longdate} [${processid}@${machinename}] ${callsite} ${level:uppercase=true}: ${message}" /> + </targets> + <rules> + <logger name="*" minlevel="Info" writeTo="LogFile" /> + </rules> + </nlog> </configuration> \ No newline at end of file diff --git a/VectoCoreTest/packages.config b/VectoCoreTest/packages.config index 98ab3a90aabf4fa10c001d853b73ce05fc7e81f3..573e2fd16f8cd28f35e521d53253818d0d0b2e95 100644 --- a/VectoCoreTest/packages.config +++ b/VectoCoreTest/packages.config @@ -1,8 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> - <packages> - <package id="Common.Logging" version="3.0.0" targetFramework="net45" /> - <package id="Common.Logging.Core" version="3.0.0" targetFramework="net45" /> - <package id="Common.Logging.NLog31" version="3.0.0" targetFramework="net45" /> - <package id="NLog" version="3.2.0.0" targetFramework="net45" /> + <package id="NLog" version="4.0.1" targetFramework="net45" /> </packages> \ No newline at end of file