diff --git a/Adaptation/FileHandlers/pcl/Complete.cs b/Adaptation/FileHandlers/pcl/Complete.cs index f6653f5..9e2ee68 100644 --- a/Adaptation/FileHandlers/pcl/Complete.cs +++ b/Adaptation/FileHandlers/pcl/Complete.cs @@ -19,10 +19,10 @@ internal class Complete public Header Header { get; } public Wafer[] Wafers { get; } - internal static Complete? Get(string headerFileName, Dictionary pages, Dictionary> slots, Constant constant) + internal static Complete? Get(string headerFileName, Dictionary pages, Constant constant) { Complete? result; - Header? header = Header.Get(headerFileName, pages, slots, constant); + Header? header = Header.Get(headerFileName, pages, constant); if (header is null) result = null; else diff --git a/Adaptation/FileHandlers/pcl/Header.cs b/Adaptation/FileHandlers/pcl/Header.cs index 13144fe..a94b1a9 100644 --- a/Adaptation/FileHandlers/pcl/Header.cs +++ b/Adaptation/FileHandlers/pcl/Header.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Text.Json.Serialization; namespace Adaptation.FileHandlers.pcl; @@ -12,6 +13,7 @@ public class Header public Header(string date, string recipe, string id, + WaferSummary[] waferSummary, string lPDCountMin, string lPDCM2Min, string areaCountMin, @@ -52,6 +54,7 @@ public class Header Date = date; Recipe = recipe; Id = id; + WaferSummary = waferSummary; LPDCountMin = lPDCountMin; LPDCM2Min = lPDCM2Min; AreaCountMin = areaCountMin; @@ -93,6 +96,7 @@ public class Header public string Date { get; } public string Recipe { get; } public string Id { get; } + public WaferSummary[] WaferSummary { get; } public string LPDCountMin { get; } public string LPDCM2Min { get; } public string AreaCountMin { get; } @@ -209,14 +213,16 @@ public class Header return GetBefore(text, i, "\n", false); } - internal static Header Get(string headerFileName, Dictionary pages, Dictionary> slots, Constant constant) + internal static Header Get(string headerFileName, Dictionary pages, Constant constant) { Header? result; string id; - string slot; - string toEOL; string? text; + string[] segmentsB; + string[] segmentsC; int[] i = new int[] { 0 }; + WaferSummary waferSummary; + List collection = new(); if (!pages.TryGetValue(headerFileName, out text)) throw new Exception(); ScanPast(text, i, constant.Date); @@ -230,15 +236,25 @@ public class Header id = GetBefore(text, i, "[7]"); else id = GetBefore(text, i, "["); - int slotCount = text.Substring(i[0]).Split('*').Length - 1; - for (int j = 0; j < slotCount; j++) + ScanPast(text, i, "*"); + string[] segments = text.Substring(i[0]).Split('*'); + string[] split = new string[] { Environment.NewLine }; + foreach (string segment in segments) { - i[0] = j; - ScanPast(text, i, "*"); - toEOL = GetToEOL(text, i, false); - slot = string.Concat("*", toEOL.Substring(0, 2)); - if (!slots.ContainsKey(slot)) - slots.Add(slot, new List()); + segmentsB = segment.Split(split, StringSplitOptions.None); + segmentsC = segmentsB[0].Split(' '); + waferSummary = new(id: segmentsC[0].Trim(), + lPDCount: segmentsC[1].Trim(), + lPDCM2: segmentsC[2].Trim(), + areaCount: segmentsC[3].Trim(), + areaTotal: segmentsC[4].Trim(), + scratchCount: segmentsC[5].Trim(), + scratchTotal: segmentsC[6].Trim(), + sumOfDefects: segmentsC[7].Trim(), + hazeRegion: segmentsC[8].Trim(), + hazeAverage: segmentsC[9].Trim(), + grade: segmentsC[10].Trim()); + collection.Add(waferSummary); } ScanPast(text, i, constant.Min); string[] preToEol1 = GetToEOL(text, i, false).Trim().Split(' '); @@ -255,6 +271,7 @@ public class Header result = new(date: date, recipe: recipe, id: id, + waferSummary: collection.ToArray(), lPDCountMin: toEol1[0].Trim(), lPDCM2Min: toEol1[1].Trim(), areaCountMin: toEol1[2].Trim(), @@ -294,4 +311,10 @@ public class Header return result; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Header))] +internal partial class HeaderSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/pcl/ProcessData.cs b/Adaptation/FileHandlers/pcl/ProcessData.cs index 15d6e22..20d11d2 100644 --- a/Adaptation/FileHandlers/pcl/ProcessData.cs +++ b/Adaptation/FileHandlers/pcl/ProcessData.cs @@ -604,11 +604,11 @@ public class ProcessData : IProcessData #nullable enable - private static Complete? GetComplete(string headerFileName, Dictionary pages, Dictionary> slots) + private static Complete? GetComplete(string headerFileName, Dictionary pages) { Complete? result; Constant constant = new(); - result = Complete.Get(headerFileName, pages, slots, constant); + result = Complete.Get(headerFileName, pages, constant); return result; } @@ -621,7 +621,6 @@ public class ProcessData : IProcessData List sourceFiles = new(); List missingSlots = new(); Dictionary pages = new(); - Dictionary> slots = new(); string sourceFileNamePdf = ConvertSourceFileToPdf(ghostPCLFileName, logistics); sourceFiles.Add(sourceFileNamePdf); string sourcePath = Path.GetDirectoryName(logistics.ReportFullPath) ?? throw new Exception(); @@ -690,6 +689,24 @@ public class ProcessData : IProcessData _Log.Debug($"****ParseData - Parsing lot summary"); List> pageMapping = new(); string headerFileName = string.Concat(sourcePath, @"\", sourceFileNameWithoutExtension, "_", pages.Count, ".pdf"); + try + { + Complete? complete = GetComplete(headerFileName, pages); + if (complete is null) + _Log.Warn($"Could not get Complete from {sourceFileNameWithoutExtension}"); + else + { + FileInfo fileInfo = new($"{sourceFileNameWithoutExtension}.json"); + string json = JsonSerializer.Serialize(complete, CompleteSourceGenerationContext.Default.Complete); + File.WriteAllText(fileInfo.FullName, json); + fileInfoCollection.Add(fileInfo); + } + } + catch (Exception ex) + { + _Log.Error($"Error in {nameof(GetComplete)}", ex); + } + Dictionary> slots = new(); ParseLotSummary(fileRead, logistics, headerFileName, pages, slots); foreach (KeyValuePair keyValuePair in pages) { @@ -774,23 +791,6 @@ public class ProcessData : IProcessData foreach (string sourceFile in sourceFiles) fileInfoCollection.Add(new FileInfo(sourceFile)); fileInfoCollection.Add(logistics.FileInfo); - try - { - Complete? complete = GetComplete(headerFileName, pages, slots); - if (complete is null) - _Log.Warn($"Could not get Complete from {sourceFileNameWithoutExtension}"); - else - { - FileInfo fileInfo = new($"{sourceFileNameWithoutExtension}.json"); - string json = JsonSerializer.Serialize(complete, CompleteSourceGenerationContext.Default.Complete); - File.WriteAllText(fileInfo.FullName, json); - fileInfoCollection.Add(fileInfo); - } - } - catch (Exception ex) - { - _Log.Error($"Error in {nameof(GetComplete)}", ex); - } } #nullable enable diff --git a/Adaptation/FileHandlers/pcl/Wafer.cs b/Adaptation/FileHandlers/pcl/Wafer.cs index 07bb3e6..dc3333c 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.Text.Json.Serialization; namespace Adaptation.FileHandlers.pcl; @@ -78,45 +79,6 @@ public class Wafer public string Thruput { get; } public string Recipe { get; } - // private static bool IsNullOrWhiteSpace(string search) - // { - // for (int index = 0; index < search.Length; ++index) - // { - // if (!char.IsWhiteSpace(search[index])) - // return false; - // } - // return true; - // } - - // private static bool IsBlankLine(string text, int[] i) - // { - // int num = text.IndexOf("\n", i[0]); - // return IsNullOrWhiteSpace(num > -1 ? text.Substring(i[0], num - i[0]) : text.Substring(i[0])); - // } - - // private static string GetToText(string text, int[] i, string search) => - // text.Substring(i[0], text.IndexOf(search, i[0]) - i[0]).Trim(); - - // private static string GetToken(string text, int[] i) - // { - // while (i[0] < text.Length && IsNullOrWhiteSpace(text.Substring(i[0], 1))) - // ++i[0]; - // int j = i[0]; - // while (j < text.Length && !IsNullOrWhiteSpace(text.Substring(j, 1))) - // ++j; - // string str = text.Substring(i[0], j - i[0]); - // i[0] = j; - // return str.Trim(); - // } - - // private static string PeekNextLine(string text, int[] i) - // { - // int j = i[0]; - // string result = Header.GetToEOL(text, i); - // i[0] = j; - // return result; - // } - internal static ReadOnlyCollection Get(string headerFileName, Dictionary pages, Constant constant) { List results = new(); @@ -226,4 +188,11 @@ public class Wafer } return results.AsReadOnly(); } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Wafer))] +internal partial class WaferSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Adaptation/FileHandlers/pcl/WaferSummary.cs b/Adaptation/FileHandlers/pcl/WaferSummary.cs new file mode 100644 index 0000000..46b62b5 --- /dev/null +++ b/Adaptation/FileHandlers/pcl/WaferSummary.cs @@ -0,0 +1,43 @@ +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.pcl; + +#nullable enable + +public class WaferSummary +{ + + public WaferSummary(string id, string lPDCount, string lPDCM2, string areaCount, string areaTotal, string scratchCount, string scratchTotal, string sumOfDefects, string hazeRegion, string hazeAverage, string grade) + { + Id = id; + LPDCount = lPDCount; + LPDCM2 = lPDCM2; + AreaCount = areaCount; + AreaTotal = areaTotal; + ScratchCount = scratchCount; + ScratchTotal = scratchTotal; + SumOfDefects = sumOfDefects; + HazeRegion = hazeRegion; + HazeAverage = hazeAverage; + Grade = grade; + } + + public string Id { get; } + public string LPDCount { get; } + public string LPDCM2 { get; } + public string AreaCount { get; } + public string AreaTotal { get; } + public string ScratchCount { get; } + public string ScratchTotal { get; } + public string SumOfDefects { get; } + public string HazeRegion { get; } + public string HazeAverage { get; } + public string Grade { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(WaferSummary))] +internal partial class WaferSummarySourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Adaptation/_Tests/Extract/Staging/v2.57.0/TENCOR1.cs b/Adaptation/_Tests/Extract/Staging/v2.57.0/TENCOR1.cs index ba0cab8..3bcb1ab 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.57.0/TENCOR1.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.57.0/TENCOR1.cs @@ -37,7 +37,7 @@ public class TENCOR1 [TestMethod] public void Production__v2_57_0__TENCOR1__pcl() => _TENCOR1.Production__v2_57_0__TENCOR1__pcl(); -#if (!DEBUG) +#if DEBUG [Ignore] #endif [TestMethod] diff --git a/MET08DDUPSFS6420.csproj b/MET08DDUPSFS6420.csproj index c250228..9eefecc 100644 --- a/MET08DDUPSFS6420.csproj +++ b/MET08DDUPSFS6420.csproj @@ -129,6 +129,7 @@ +