diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs index 2edb5fed86fd7fa185d8ebd3f58cc1bc724b2cb7..2061f830f3b2c6349fb65b6c9bcc10eafe7e11d9 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs @@ -106,7 +106,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl try { do { response = DoSimulationStep(); - DebugData.Clear(); debug.Add($"[VR.R] ---- ITERATION {iterationCount++} ---- ", response); if (response is ResponseSuccess) { Container.CommitSimulationStep(AbsTime, dt); diff --git a/VectoCore/VectoCore/Utils/DebugData.cs b/VectoCore/VectoCore/Utils/DebugData.cs index f286def640435a06eeef5c0b424b2f9364621fad..dfe34c565cc838ad5b09d792d6c214a0e4f1f3e3 100644 --- a/VectoCore/VectoCore/Utils/DebugData.cs +++ b/VectoCore/VectoCore/Utils/DebugData.cs @@ -42,14 +42,9 @@ namespace TUGraz.VectoCore.Utils private static readonly ThreadLocal<Queue<dynamic>> _data = new ThreadLocal<Queue<dynamic>>( () => new Queue<dynamic>(Capacity)); - private readonly bool _globalDebug; - - internal Queue<dynamic> Data => _globalDebug ? GlobalData : LocalData; - internal static Queue<dynamic> GlobalData => _data.Value; - internal Queue<dynamic> LocalData { get; } = new Queue<dynamic>(); - public DebugData(bool globalDebug = true) => _globalDebug = globalDebug; + internal Queue<dynamic> LocalData { get; } = new Queue<dynamic>(); [Conditional("DEBUG")] public static void Clear() => GlobalData.Clear(); @@ -57,10 +52,12 @@ namespace TUGraz.VectoCore.Utils [Conditional("DEBUG")] public void Add(dynamic value) { - while (Data.Count >= Capacity) { - Data.Dequeue(); + while (GlobalData.Count >= Capacity) { + GlobalData.Dequeue(); } - Data.Enqueue(value); + GlobalData.Enqueue(value); + + LocalData.Enqueue(value); } [Conditional("DEBUG")] diff --git a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs index f56ff310294b14694e65abd42e4c2f2ac27633a2..11ff01cdc000f8a8aedcac9716c33771f9973920 100644 --- a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs +++ b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs @@ -187,16 +187,16 @@ namespace TUGraz.VectoCore.Utils [Conditional("TRACE")] private static void AppendDebug(DebugData debug) { - var xmin = debug.Data.Min(d => d.x); - var xmax = debug.Data.Max(d => d.x); - var ymin = debug.Data.Min(d => d.y); - var ymax = debug.Data.Max(d => d.y); + var xmin = debug.LocalData.Min(d => d.x); + var xmax = debug.LocalData.Max(d => d.x); + var ymin = debug.LocalData.Min(d => d.y); + var ymax = debug.LocalData.Max(d => d.y); var rand = new Random().Next(); using ( var f = new StreamWriter(File.Open("LineSearch-" + Thread.CurrentThread.ManagedThreadId + "-statistics.csv", FileMode.Append))) { - foreach (var d in debug.Data) { + foreach (var d in debug.LocalData) { f.WriteLine($"{rand}, " + $"{(d.x - xmin) / (xmax - xmin)}, " + $"{(d.y - ymin) / (ymax - ymin)}, " + @@ -312,7 +312,7 @@ namespace TUGraz.VectoCore.Utils table.Columns.Add("engineSpeed", typeof(double)); table.Columns.Add("enginePower", typeof(double)); - foreach (var entry in debug.Data.Skip(1)) { + foreach (var entry in debug.LocalData.Skip(1)) { var response = entry.result as ResponseDryRun; if (response == null) { continue;