diff --git a/Adaptation/FileHandlers/pcl/Run.cs b/Adaptation/FileHandlers/pcl/Run.cs index 516c329..07a221a 100644 --- a/Adaptation/FileHandlers/pcl/Run.cs +++ b/Adaptation/FileHandlers/pcl/Run.cs @@ -15,14 +15,36 @@ namespace Adaptation.FileHandlers.pcl; internal class Run { + public Header Header { get; } + public ReadOnlyCollection Wafers { get; } + public Run(Header header, ReadOnlyCollection wafers) { Header = header; Wafers = wafers; } - public Header Header { get; } - public ReadOnlyCollection Wafers { get; } + private static ReadOnlyCollection GetLastWaferForEachSlot(ReadOnlyDictionary pages, Constant constant, string headerFileName, Header header) + { + List results = new(); + string id; + Wafer wafer; + ReadOnlyCollection? wafers; + ReadOnlyDictionary> keyValuePairs = Wafer.Get(pages, constant, headerFileName); + ReadOnlyCollection 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 fileInfoCollection, Run result) { @@ -107,9 +129,7 @@ internal class Run result = null; else { - ReadOnlyCollection waferIds = GetWaferIds(header); - ReadOnlyDictionary keyValuePairs = Wafer.Get(pages, constant, headerFileName, header); - ReadOnlyCollection wafers = Wafer.Get(waferIds, keyValuePairs); + ReadOnlyCollection wafers = GetLastWaferForEachSlot(pages, constant, headerFileName, header); result = new(header, wafers); WriteJson(logistics, fileInfoCollection, result); WriteCommaSeparatedValues(logistics, result); diff --git a/Adaptation/FileHandlers/pcl/Wafer.cs b/Adaptation/FileHandlers/pcl/Wafer.cs index e2ec94b..36d8a02 100644 --- a/Adaptation/FileHandlers/pcl/Wafer.cs +++ b/Adaptation/FileHandlers/pcl/Wafer.cs @@ -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 Get(ReadOnlyDictionary pages, Constant constant, string headerFileName, Header header) + internal static ReadOnlyDictionary> Get(ReadOnlyDictionary pages, Constant constant, string headerFileName) { - Dictionary results = new(); + Dictionary> results = new(); Wafer wafer; string? text; List stringList; int[] i = new int[] { 0 }; + Dictionary> keyValuePairs = new(); foreach (KeyValuePair 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()); + keyValuePairs[id].Add(wafer); } + foreach (KeyValuePair> keyValuePair in keyValuePairs) + results.Add(keyValuePair.Key, keyValuePair.Value.AsReadOnly()); return new(results); } - internal static ReadOnlyCollection Get(ReadOnlyCollection waferIds, ReadOnlyDictionary keyValuePairs) - { - List 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)] diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index 1fb9e2a..92b9f3d 100644 --- a/Adaptation/Shared/ProcessDataStandardFormat.cs +++ b/Adaptation/Shared/ProcessDataStandardFormat.cs @@ -903,7 +903,7 @@ internal class ProcessDataStandardFormat } foreach (KeyValuePair> keyValuePair in results) { - if (body.Count < 3) + if (body.Count < 2) break; if (keyValuePair.Value.Count != body.Count) continue;