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