Enhance PCL and PDSF file handlers with new constants and refactor methods for improved readability and functionality
This commit is contained in:
@ -9,5 +9,7 @@ internal class Constant
|
|||||||
public string Date { get; } = "Date:";
|
public string Date { get; } = "Date:";
|
||||||
public string StdDev { get; } = "Std Dev:";
|
public string StdDev { get; } = "Std Dev:";
|
||||||
public string Average { get; } = "Average:";
|
public string Average { get; } = "Average:";
|
||||||
|
public string Statistics { get; } = "Statistics:";
|
||||||
|
public string DatabaseId { get; } = "Database ID:";
|
||||||
|
|
||||||
}
|
}
|
@ -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;
|
||||||
@ -215,17 +216,35 @@ public class Header
|
|||||||
return GetBefore(text, i, "\n", false);
|
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;
|
Header? result;
|
||||||
string id;
|
string id;
|
||||||
string? text;
|
|
||||||
string[] segmentsB;
|
string[] segmentsB;
|
||||||
string[] segmentsC;
|
string[] segmentsC;
|
||||||
int[] i = new int[] { 0 };
|
int[] i = new int[] { 0 };
|
||||||
WaferSummary waferSummary;
|
WaferSummary waferSummary;
|
||||||
List<WaferSummary> collection = new();
|
List<WaferSummary> collection = new();
|
||||||
if (!pages.TryGetValue(headerFileName, out text))
|
string? text = GetText(pages, constant);
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
ScanPast(text, i, constant.Date);
|
ScanPast(text, i, constant.Date);
|
||||||
string date = GetToEOL(text, i);
|
string date = GetToEOL(text, i);
|
||||||
|
@ -24,13 +24,13 @@ internal class Run
|
|||||||
Wafers = wafers;
|
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();
|
List<Wafer> results = new();
|
||||||
string id;
|
string id;
|
||||||
Wafer wafer;
|
Wafer wafer;
|
||||||
ReadOnlyCollection<Wafer>? wafers;
|
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);
|
ReadOnlyCollection<string> waferIds = GetWaferIds(header);
|
||||||
for (int i = 0; i < waferIds.Count; i++)
|
for (int i = 0; i < waferIds.Count; i++)
|
||||||
{
|
{
|
||||||
@ -123,13 +123,12 @@ internal class Run
|
|||||||
{
|
{
|
||||||
Run? result;
|
Run? result;
|
||||||
Constant constant = new();
|
Constant constant = new();
|
||||||
string headerFileName = pages.ElementAt(pages.Count - 1).Key;
|
Header? header = Header.Get(pages, constant);
|
||||||
Header? header = Header.Get(pages, constant, headerFileName);
|
|
||||||
if (header is null)
|
if (header is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, headerFileName, header);
|
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, header);
|
||||||
result = new(header, wafers);
|
result = new(header, wafers);
|
||||||
WriteJson(logistics, fileInfoCollection, result);
|
WriteJson(logistics, fileInfoCollection, result);
|
||||||
WriteCommaSeparatedValues(logistics, result);
|
WriteCommaSeparatedValues(logistics, result);
|
||||||
|
@ -114,7 +114,7 @@ public class Wafer
|
|||||||
public string Thruput { get; }
|
public string Thruput { get; }
|
||||||
public string Recipe { 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();
|
Dictionary<string, ReadOnlyCollection<Wafer>> results = new();
|
||||||
Wafer wafer;
|
Wafer wafer;
|
||||||
@ -124,15 +124,11 @@ public class Wafer
|
|||||||
Dictionary<string, List<Wafer>> keyValuePairs = new();
|
Dictionary<string, List<Wafer>> keyValuePairs = new();
|
||||||
foreach (KeyValuePair<string, string> keyValuePair in pages)
|
foreach (KeyValuePair<string, string> keyValuePair in pages)
|
||||||
{
|
{
|
||||||
if (keyValuePair.Key == headerFileName)
|
|
||||||
continue;
|
|
||||||
if (!pages.ContainsKey(keyValuePair.Key))
|
|
||||||
throw new Exception();
|
|
||||||
i[0] = 0;
|
i[0] = 0;
|
||||||
stringList = new();
|
stringList = new();
|
||||||
if (!pages.TryGetValue(keyValuePair.Key, out text))
|
if (!pages.TryGetValue(keyValuePair.Key, out text))
|
||||||
throw new Exception();
|
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;
|
continue;
|
||||||
Header.ScanPast(text, i, constant.Date);
|
Header.ScanPast(text, i, constant.Date);
|
||||||
string date = Header.GetToEOL(text, i);
|
string date = Header.GetToEOL(text, i);
|
||||||
|
@ -9,5 +9,7 @@ internal class Constant
|
|||||||
public string Date { get; } = "Date:";
|
public string Date { get; } = "Date:";
|
||||||
public string StdDev { get; } = "Std Dev:";
|
public string StdDev { get; } = "Std Dev:";
|
||||||
public string Average { get; } = "Average:";
|
public string Average { get; } = "Average:";
|
||||||
|
public string Statistics { get; } = "Statistics:";
|
||||||
|
public string DatabaseId { get; } = "Database ID:";
|
||||||
|
|
||||||
}
|
}
|
@ -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.pdsf;
|
namespace Adaptation.FileHandlers.pdsf;
|
||||||
@ -215,17 +216,35 @@ public class Header
|
|||||||
return GetBefore(text, i, "\n", false);
|
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;
|
Header? result;
|
||||||
string id;
|
string id;
|
||||||
string? text;
|
|
||||||
string[] segmentsB;
|
string[] segmentsB;
|
||||||
string[] segmentsC;
|
string[] segmentsC;
|
||||||
int[] i = new int[] { 0 };
|
int[] i = new int[] { 0 };
|
||||||
WaferSummary waferSummary;
|
WaferSummary waferSummary;
|
||||||
List<WaferSummary> collection = new();
|
List<WaferSummary> collection = new();
|
||||||
if (!pages.TryGetValue(headerFileName, out text))
|
string? text = GetText(pages, constant);
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
ScanPast(text, i, constant.Date);
|
ScanPast(text, i, constant.Date);
|
||||||
string date = GetToEOL(text, i);
|
string date = GetToEOL(text, i);
|
||||||
|
@ -24,13 +24,13 @@ internal class Run
|
|||||||
Wafers = wafers;
|
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();
|
List<Wafer> results = new();
|
||||||
string id;
|
string id;
|
||||||
Wafer wafer;
|
Wafer wafer;
|
||||||
ReadOnlyCollection<Wafer>? wafers;
|
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);
|
ReadOnlyCollection<string> waferIds = GetWaferIds(header);
|
||||||
for (int i = 0; i < waferIds.Count; i++)
|
for (int i = 0; i < waferIds.Count; i++)
|
||||||
{
|
{
|
||||||
@ -123,13 +123,12 @@ internal class Run
|
|||||||
{
|
{
|
||||||
Run? result;
|
Run? result;
|
||||||
Constant constant = new();
|
Constant constant = new();
|
||||||
string headerFileName = pages.ElementAt(pages.Count - 1).Key;
|
Header? header = Header.Get(pages, constant);
|
||||||
Header? header = Header.Get(pages, constant, headerFileName);
|
|
||||||
if (header is null)
|
if (header is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, headerFileName, header);
|
ReadOnlyCollection<Wafer> wafers = GetLastWaferForEachSlot(pages, constant, header);
|
||||||
result = new(header, wafers);
|
result = new(header, wafers);
|
||||||
WriteJson(logistics, fileInfoCollection, result);
|
WriteJson(logistics, fileInfoCollection, result);
|
||||||
WriteCommaSeparatedValues(logistics, result);
|
WriteCommaSeparatedValues(logistics, result);
|
||||||
|
@ -114,7 +114,7 @@ public class Wafer
|
|||||||
public string Thruput { get; }
|
public string Thruput { get; }
|
||||||
public string Recipe { 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();
|
Dictionary<string, ReadOnlyCollection<Wafer>> results = new();
|
||||||
Wafer wafer;
|
Wafer wafer;
|
||||||
@ -124,10 +124,12 @@ public class Wafer
|
|||||||
Dictionary<string, List<Wafer>> keyValuePairs = new();
|
Dictionary<string, List<Wafer>> keyValuePairs = new();
|
||||||
foreach (KeyValuePair<string, string> keyValuePair in pages)
|
foreach (KeyValuePair<string, string> keyValuePair in pages)
|
||||||
{
|
{
|
||||||
if (keyValuePair.Key == headerFileName)
|
i[0] = 0;
|
||||||
continue;
|
stringList = new();
|
||||||
if (!pages.ContainsKey(keyValuePair.Key))
|
if (!pages.TryGetValue(keyValuePair.Key, out text))
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
if (string.IsNullOrEmpty(text) || !text.Contains(constant.Id) || text.Contains(constant.Statistics) || text.Contains(constant.DatabaseId))
|
||||||
|
continue;
|
||||||
i[0] = 0;
|
i[0] = 0;
|
||||||
stringList = new();
|
stringList = new();
|
||||||
if (!pages.TryGetValue(keyValuePair.Key, out text))
|
if (!pages.TryGetValue(keyValuePair.Key, out text))
|
||||||
|
Reference in New Issue
Block a user