Wafer Summary

This commit is contained in:
2024-11-19 09:05:00 -07:00
parent 8ff877156d
commit 3a23304824
7 changed files with 109 additions and 73 deletions

View File

@ -19,10 +19,10 @@ internal class Complete
public Header Header { get; }
public Wafer[] Wafers { get; }
internal static Complete? Get(string headerFileName, Dictionary<string, string> pages, Dictionary<string, List<Detail>> slots, Constant constant)
internal static Complete? Get(string headerFileName, Dictionary<string, string> 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

View File

@ -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<string, string> pages, Dictionary<string, List<Detail>> slots, Constant constant)
internal static Header Get(string headerFileName, Dictionary<string, string> 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<WaferSummary> 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<Detail>());
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
{
}

View File

@ -604,11 +604,11 @@ public class ProcessData : IProcessData
#nullable enable
private static Complete? GetComplete(string headerFileName, Dictionary<string, string> pages, Dictionary<string, List<Detail>> slots)
private static Complete? GetComplete(string headerFileName, Dictionary<string, string> 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<string> sourceFiles = new();
List<string> missingSlots = new();
Dictionary<string, string> pages = new();
Dictionary<string, List<Detail>> 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<Tuple<string, string>> 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<string, List<Detail>> slots = new();
ParseLotSummary(fileRead, logistics, headerFileName, pages, slots);
foreach (KeyValuePair<string, string> 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

View File

@ -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<Wafer> Get(string headerFileName, Dictionary<string, string> pages, Constant constant)
{
List<Wafer> results = new();
@ -226,4 +188,11 @@ public class Wafer
}
return results.AsReadOnly();
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Wafer))]
internal partial class WaferSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -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
{
}

View File

@ -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]

View File

@ -129,6 +129,7 @@
<Compile Include="Adaptation\FileHandlers\pcl\Header.cs" />
<Compile Include="Adaptation\FileHandlers\pcl\ProcessData.cs" />
<Compile Include="Adaptation\FileHandlers\pcl\Wafer.cs" />
<Compile Include="Adaptation\FileHandlers\pcl\WaferSummary.cs" />
<Compile Include="Adaptation\FileHandlers\Processed\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\SPaCe\FileRead.cs" />
<Compile Include="Adaptation\Ifx\Eaf\Common\Configuration\ConnectionSetting.cs" />