From 48db8034a7adb63a51838023d293cbcb18dd8e63 Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Tue, 19 Apr 2022 14:57:57 +0200
Subject: [PATCH] More Additions to DebugData

---
 .../Models/SimulationComponent/Impl/HybridController.cs    | 4 ++--
 VectoCore/VectoCore/Utils/DebugData.cs                     | 7 ++++---
 VectoCore/VectoCore/Utils/SearchAlgorithm.cs               | 4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs
index 6cefbecddf..f1eac30799 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs
@@ -147,8 +147,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 				CurrentStrategySettings = strategySettings;
 				retVal = NextComponent.Request(absTime, dt, outTorque, outAngularVelocity, dryRun);
-				DebugData.Add("HC.R", new {
-					DrivingAction = DataBus.DriverInfo.DrivingAction,
+				DebugData.Add($"HC.R-{retryCount}", new {
+					DataBus.DriverInfo.DrivingAction,
 					StrategySettings = strategySettings,
 					Response = retVal,
 					DryRun = dryRun
diff --git a/VectoCore/VectoCore/Utils/DebugData.cs b/VectoCore/VectoCore/Utils/DebugData.cs
index 707422c157..377097346f 100644
--- a/VectoCore/VectoCore/Utils/DebugData.cs
+++ b/VectoCore/VectoCore/Utils/DebugData.cs
@@ -42,11 +42,12 @@ namespace TUGraz.VectoCore.Utils
 		private static readonly ThreadLocal<Queue<dynamic>> _data = new ThreadLocal<Queue<dynamic>>(
 			() => new Queue<dynamic>(Capacity));
 
-		private readonly Queue<dynamic> _localData = new Queue<dynamic>();
-
 		private readonly bool _globalDebug;
 
-		internal Queue<dynamic> Data => _globalDebug ? _data.Value : _localData;
+		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;
 
diff --git a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs
index bbb43bfa58..4e0058bf98 100644
--- a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs
+++ b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs
@@ -125,7 +125,7 @@ namespace TUGraz.VectoCore.Utils
 
 			var intervalFactor = 1.0;
 			var origY = y;
-			var debug = new DebugData(false);
+			var debug = new DebugData();
 			debug.Add(new { x = x.Value(), y = y.Value() });
 			log.Debug("Log Disabled during LineSearch.");
 			LogManager.DisableLogging();
@@ -208,7 +208,7 @@ namespace TUGraz.VectoCore.Utils
 			log.Debug("Log Disabled during InterpolateSearch.");
 			LogManager.DisableLogging();
 
-			var debug = new DebugData(false);
+			var debug = new DebugData();
 			debug.Add(new { x = x1, y = y1 });
 
 			try {
-- 
GitLab