Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit f5a84793 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

Minor changes in DebugData (Local Variable stores LocalData, but all will also...

Minor changes in DebugData (Local Variable stores LocalData, but all will also be stored in Global Data)
parent 6ed77bc3
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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")]
......
......@@ -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;
......
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