Enhance PCL and PDSF file handlers with new constants and refactor methods for improved readability and functionality

This commit is contained in:
2025-10-14 08:00:17 -07:00
parent 0a477c7ea1
commit 10a0662561
8 changed files with 64 additions and 26 deletions

View File

@ -9,5 +9,7 @@ internal class Constant
public string Date { get; } = "Date:";
public string StdDev { get; } = "Std Dev:";
public string Average { get; } = "Average:";
public string Statistics { get; } = "Statistics:";
public string DatabaseId { get; } = "Database ID:";
}

View File

@ -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;
@ -215,17 +216,35 @@ public class Header
return GetBefore(text, i, "\n", false);
}
internal static Header Get(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName)
private static string? GetText(ReadOnlyDictionary<string, string> pages, Constant constant)
{
string? text;
string? headerFileName = null;
foreach (KeyValuePair<string, string> keyValuePair in pages)
{
if (!pages.TryGetValue(keyValuePair.Key, out text))
throw new Exception();
if (!text.Contains(constant.Statistics))
continue;
headerFileName = keyValuePair.Key;
}
headerFileName ??= pages.Count == 0 ? string.Empty : pages.ElementAt(pages.Count - 1).Key;
if (pages.Count == 0 || !pages.TryGetValue(headerFileName, out text))
text = null;
return text;
}
internal static Header Get(ReadOnlyDictionary<string, string> pages, Constant constant)
{
Header? result;
string id;
string? text;
string[] segmentsB;
string[] segmentsC;
int[] i = new int[] { 0 };
WaferSummary waferSummary;
List<WaferSummary> collection = new();
if (!pages.TryGetValue(headerFileName, out text))
string? text = GetText(pages, constant);
if (string.IsNullOrEmpty(text))
throw new Exception();
ScanPast(text, i, constant.Date);
string date = GetToEOL(text, i);

View File

@ -24,13 +24,13 @@ internal class Run
Wafers = wafers;
}
private static ReadOnlyCollection<Wafer> GetLastWaferForEachSlot(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName, Header header)
private static ReadOnlyCollection<Wafer> GetLastWaferForEachSlot(ReadOnlyDictionary<string, string> pages, Constant constant, Header header)
{
List<Wafer> results = new();
string id;
Wafer wafer;
ReadOnlyCollection<Wafer>? wafers;
ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> keyValuePairs = Wafer.Get(pages, constant, headerFileName);
ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> keyValuePairs = Wafer.Get(pages, constant);
ReadOnlyCollection<string> waferIds = GetWaferIds(header);
for (int i = 0; i < waferIds.Count; i++)
{
@ -123,13 +123,12 @@ internal class Run
{
Run? result;
Constant constant = new();
string headerFileName = pages.ElementAt(pages.Count - 1).Key;
Header? header = Header.Get(pages, constant, headerFileName);
Header? header = Header.Get(pages, constant);
if (header is null)
result = null;
else
{
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, headerFileName, header);
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, header);
result = new(header, wafers);
WriteJson(logistics, fileInfoCollection, result);
WriteCommaSeparatedValues(logistics, result);

View File

@ -114,7 +114,7 @@ public class Wafer
public string Thruput { get; }
public string Recipe { get; }
internal static ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> Get(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName)
internal static ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> Get(ReadOnlyDictionary<string, string> pages, Constant constant)
{
Dictionary<string, ReadOnlyCollection<Wafer>> results = new();
Wafer wafer;
@ -124,15 +124,11 @@ public class Wafer
Dictionary<string, List<Wafer>> keyValuePairs = new();
foreach (KeyValuePair<string, string> keyValuePair in pages)
{
if (keyValuePair.Key == headerFileName)
continue;
if (!pages.ContainsKey(keyValuePair.Key))
throw new Exception();
i[0] = 0;
stringList = new();
if (!pages.TryGetValue(keyValuePair.Key, out text))
throw new Exception();
if (string.IsNullOrEmpty(text) || !text.Contains(constant.Id))
if (string.IsNullOrEmpty(text) || !text.Contains(constant.Id) || text.Contains(constant.Statistics) || text.Contains(constant.DatabaseId))
continue;
Header.ScanPast(text, i, constant.Date);
string date = Header.GetToEOL(text, i);

View File

@ -9,5 +9,7 @@ internal class Constant
public string Date { get; } = "Date:";
public string StdDev { get; } = "Std Dev:";
public string Average { get; } = "Average:";
public string Statistics { get; } = "Statistics:";
public string DatabaseId { get; } = "Database ID:";
}

View File

@ -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.pdsf;
@ -215,17 +216,35 @@ public class Header
return GetBefore(text, i, "\n", false);
}
internal static Header Get(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName)
private static string? GetText(ReadOnlyDictionary<string, string> pages, Constant constant)
{
string? text;
string? headerFileName = null;
foreach (KeyValuePair<string, string> keyValuePair in pages)
{
if (!pages.TryGetValue(keyValuePair.Key, out text))
throw new Exception();
if (!text.Contains(constant.Statistics))
continue;
headerFileName = keyValuePair.Key;
}
headerFileName ??= pages.Count == 0 ? string.Empty : pages.ElementAt(pages.Count - 1).Key;
if (pages.Count == 0 || !pages.TryGetValue(headerFileName, out text))
text = null;
return text;
}
internal static Header Get(ReadOnlyDictionary<string, string> pages, Constant constant)
{
Header? result;
string id;
string? text;
string[] segmentsB;
string[] segmentsC;
int[] i = new int[] { 0 };
WaferSummary waferSummary;
List<WaferSummary> collection = new();
if (!pages.TryGetValue(headerFileName, out text))
string? text = GetText(pages, constant);
if (string.IsNullOrEmpty(text))
throw new Exception();
ScanPast(text, i, constant.Date);
string date = GetToEOL(text, i);

View File

@ -24,13 +24,13 @@ internal class Run
Wafers = wafers;
}
private static ReadOnlyCollection<Wafer> GetLastWaferForEachSlot(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName, Header header)
private static ReadOnlyCollection<Wafer> GetLastWaferForEachSlot(ReadOnlyDictionary<string, string> pages, Constant constant, Header header)
{
List<Wafer> results = new();
string id;
Wafer wafer;
ReadOnlyCollection<Wafer>? wafers;
ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> keyValuePairs = Wafer.Get(pages, constant, headerFileName);
ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> keyValuePairs = Wafer.Get(pages, constant);
ReadOnlyCollection<string> waferIds = GetWaferIds(header);
for (int i = 0; i < waferIds.Count; i++)
{
@ -123,13 +123,12 @@ internal class Run
{
Run? result;
Constant constant = new();
string headerFileName = pages.ElementAt(pages.Count - 1).Key;
Header? header = Header.Get(pages, constant, headerFileName);
Header? header = Header.Get(pages, constant);
if (header is null)
result = null;
else
{
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, headerFileName, header);
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, header);
result = new(header, wafers);
WriteJson(logistics, fileInfoCollection, result);
WriteCommaSeparatedValues(logistics, result);

View File

@ -114,7 +114,7 @@ public class Wafer
public string Thruput { get; }
public string Recipe { get; }
internal static ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> Get(ReadOnlyDictionary<string, string> pages, Constant constant, string headerFileName)
internal static ReadOnlyDictionary<string, ReadOnlyCollection<Wafer>> Get(ReadOnlyDictionary<string, string> pages, Constant constant)
{
Dictionary<string, ReadOnlyCollection<Wafer>> results = new();
Wafer wafer;
@ -124,10 +124,12 @@ public class Wafer
Dictionary<string, List<Wafer>> keyValuePairs = new();
foreach (KeyValuePair<string, string> keyValuePair in pages)
{
if (keyValuePair.Key == headerFileName)
continue;
if (!pages.ContainsKey(keyValuePair.Key))
i[0] = 0;
stringList = new();
if (!pages.TryGetValue(keyValuePair.Key, out text))
throw new Exception();
if (string.IsNullOrEmpty(text) || !text.Contains(constant.Id) || text.Contains(constant.Statistics) || text.Contains(constant.DatabaseId))
continue;
i[0] = 0;
stringList = new();
if (!pages.TryGetValue(keyValuePair.Key, out text))