Refactored Run and Wafer classes for improved wafer retrieval logic
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.pcl;
|
||||
@ -46,7 +47,7 @@ public class Wafer
|
||||
Recipe = recipe;
|
||||
}
|
||||
|
||||
private static Wafer? Get(string id) =>
|
||||
internal static Wafer Get(string id) =>
|
||||
new(date: string.Empty,
|
||||
id: id,
|
||||
comments: string.Empty,
|
||||
@ -113,13 +114,14 @@ public class Wafer
|
||||
public string Thruput { get; }
|
||||
public string Recipe { get; }
|
||||
|
||||
internal static ReadOnlyDictionary<string, Wafer> Get(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName, Header header)
|
||||
internal static ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> Get(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName)
|
||||
{
|
||||
Dictionary<string, Wafer> results = new();
|
||||
Dictionary<string, ReadOnlyCollection<Wafer>> results = new();
|
||||
Wafer wafer;
|
||||
string? text;
|
||||
List<string> stringList;
|
||||
int[] i = new int[] { 0 };
|
||||
Dictionary<string, List<Wafer>> keyValuePairs = new();
|
||||
foreach (KeyValuePair<string, string> keyValuePair in pages)
|
||||
{
|
||||
if (keyValuePair.Key == headerFileName)
|
||||
@ -139,8 +141,6 @@ public class Wafer
|
||||
if (id.Length > 5)
|
||||
id = string.Concat(id.Substring(0, 5), "... - ***");
|
||||
id = id.Replace("*", "");
|
||||
if (results.ContainsKey(id))
|
||||
continue;
|
||||
Header.ScanPast(text, i, "Comments:");
|
||||
string comments = Header.GetToEOL(text, i);
|
||||
Header.ScanPast(text, i, "Sort:");
|
||||
@ -190,8 +190,6 @@ public class Wafer
|
||||
string thruput = Header.GetToEOL(text, i);
|
||||
Header.ScanPast(text, i, "Recipe ID:");
|
||||
string recipe = Header.GetToEOL(text, i);
|
||||
if (recipe != header.Recipe)
|
||||
continue;
|
||||
wafer = new(date: date,
|
||||
id: id,
|
||||
comments: comments,
|
||||
@ -224,28 +222,15 @@ public class Wafer
|
||||
hazeRng: hazeRng,
|
||||
thruput: thruput,
|
||||
recipe: recipe);
|
||||
results.Add(id, wafer);
|
||||
if (!keyValuePairs.ContainsKey(id))
|
||||
keyValuePairs.Add(id, new List<Wafer>());
|
||||
keyValuePairs[id].Add(wafer);
|
||||
}
|
||||
foreach (KeyValuePair<string, List<Wafer>> keyValuePair in keyValuePairs)
|
||||
results.Add(keyValuePair.Key, keyValuePair.Value.AsReadOnly());
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static ReadOnlyCollection<Wafer> Get(ReadOnlyCollection<string> waferIds, ReadOnlyDictionary<string, Wafer> keyValuePairs)
|
||||
{
|
||||
List<Wafer> results = new();
|
||||
string id;
|
||||
Wafer? wafer;
|
||||
for (int i = 0; i < waferIds.Count; i++)
|
||||
{
|
||||
id = waferIds[i];
|
||||
if (!keyValuePairs.TryGetValue(id, out wafer))
|
||||
wafer = Get(id);
|
||||
if (wafer is null)
|
||||
break;
|
||||
results.Add(wafer);
|
||||
}
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
|
||||
Reference in New Issue
Block a user