diff --git a/Adaptation/.vscode/tasks.json b/Adaptation/.vscode/tasks.json index 87a52c4..dc311a3 100644 --- a/Adaptation/.vscode/tasks.json +++ b/Adaptation/.vscode/tasks.json @@ -86,6 +86,18 @@ ], "problemMatcher": "$msCompile" }, + { + "label": "Project", + "type": "shell", + "command": "code ../MET08RESIHGCV.csproj", + "problemMatcher": [] + }, + { + "label": "Git Config", + "type": "shell", + "command": "code ../.git/config", + "problemMatcher": [] + }, { "label": "Kanbn Console", "type": "npm", diff --git a/Adaptation/FileHandlers/pcl/Complete.cs b/Adaptation/FileHandlers/pcl/Complete.cs deleted file mode 100644 index 17adda1..0000000 --- a/Adaptation/FileHandlers/pcl/Complete.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.IO; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Adaptation.FileHandlers.pcl; - -#nullable enable - -internal class Complete -{ - - public Complete(Header header, Summary summary, ReadOnlyCollection points) - { - Header = header; - Summary = summary; - Points = points; - } - - public Header Header { get; } - public Summary Summary { get; } - public ReadOnlyCollection Points { get; } - - private static ReadOnlyCollection FilterLines(ReadOnlyCollection collection) - { - List results = new(); - foreach (string line in collection) - { - if (string.IsNullOrEmpty(line) || line is "*" or "@") - continue; - if (line.Length < 3 || line[0] is not '*' and not '@' || line[1] != ' ') - results.Add(line); - else - results.Add(line.Substring(2)); - } - return new(results); - } - - public static Complete? Get(Shared.Logistics logistics, List fileInfoCollection, ReadOnlyCollection collection) - { - Complete? result; - Constant constant = new(); - ReadOnlyCollection lines = FilterLines(collection); - if (collection.Count <= constant.Take) - result = null; - else - { - Header? header = Header.Get(constant, lines); - if (header is null) - result = null; - else - { - Summary? summary = SummarySegment.Get(constant, lines); - if (summary is null) - result = null; - else - { - ReadOnlyCollection points = Point.GetCollection(constant, lines) ?? throw new NullReferenceException(nameof(summary)); - if (points.Count == 0) - result = null; - else - { - result = new(header, summary, points); - FileInfo fileInfo = new($"{logistics.ReportFullPath}.json"); - string json = JsonSerializer.Serialize(result, CompleteSourceGenerationContext.Default.Complete); - File.WriteAllText(fileInfo.FullName, json); - File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence); - fileInfoCollection.Add(fileInfo); - } - } - } - } - return result; - } - -} - -[JsonSourceGenerationOptions(WriteIndented = true)] -[JsonSerializable(typeof(Complete))] -internal partial class CompleteSourceGenerationContext : JsonSerializerContext -{ -} \ No newline at end of file diff --git a/Adaptation/FileHandlers/pcl/FileRead.cs b/Adaptation/FileHandlers/pcl/FileRead.cs index 578da8c..c556f18 100644 --- a/Adaptation/FileHandlers/pcl/FileRead.cs +++ b/Adaptation/FileHandlers/pcl/FileRead.cs @@ -118,8 +118,8 @@ public class FileRead : Shared.FileRead, IFileRead else { ReadOnlyCollection lines = Convert.PDF(_Logistics, _GhostPCLFileName, _PDFTextStripperFileName, results.Item4); - Complete? complete = Complete.Get(_Logistics, results.Item4, lines); - if (complete is null) + Run? run = Run.Get(_Logistics, results.Item4, lines); + if (run is null) throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks)); IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, lines); if (iProcessData is not ProcessData processData) diff --git a/Adaptation/FileHandlers/pcl/ProcessData.cs b/Adaptation/FileHandlers/pcl/ProcessData.cs index df4dd0f..2a29039 100644 --- a/Adaptation/FileHandlers/pcl/ProcessData.cs +++ b/Adaptation/FileHandlers/pcl/ProcessData.cs @@ -13,7 +13,7 @@ using System.Text.RegularExpressions; namespace Adaptation.FileHandlers.pcl; -public class ProcessData : IProcessData +internal class ProcessData : IProcessData { private int _I; diff --git a/Adaptation/FileHandlers/pcl/Row.cs b/Adaptation/FileHandlers/pcl/Row.cs new file mode 100644 index 0000000..c625a9c --- /dev/null +++ b/Adaptation/FileHandlers/pcl/Row.cs @@ -0,0 +1,192 @@ +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.pcl; + +#nullable enable + +internal class Row +{ + + public Row(Run run, int i) + { + Operator = run.Header.Operator; + StartVoltage = run.Header.StartVoltage; + Wafer = run.Header.Wafer; + StopVoltage = run.Header.StopVoltage; + Lot = run.Header.Lot; + RampRate = run.Header.RampRate; + Plan = run.Header.Plan; + GLimit = run.Header.GLimit; + Date = run.Header.Date; + Time = run.Header.Time; + SetupFile = run.Header.SetupFile; + WaferSize = run.Header.WaferSize; + Folder = run.Header.Folder; + Ccomp = run.Header.Ccomp; + Pattern = run.Header.Pattern; + Area = run.Header.Area; + CondType = run.Header.CondType; + RhoMethod = run.Header.RhoMethod; + Model = run.Header.Model; + if (run.Summary.Mean is null) + { + MeanNAvg = string.Empty; + MeanNsl = string.Empty; + MeanVd = string.Empty; + MeanFlatZ = string.Empty; + MeanRhoAvg = string.Empty; + MeanRhosl = string.Empty; + MeanPhase = string.Empty; + MeanGrade = string.Empty; + MeanRs = string.Empty; + } + else + { + MeanNAvg = run.Summary.Mean.NAvg; + MeanNsl = run.Summary.Mean.Nsl; + MeanVd = run.Summary.Mean.Vd; + MeanFlatZ = run.Summary.Mean.FlatZ; + MeanRhoAvg = run.Summary.Mean.RhoAvg; + MeanRhosl = run.Summary.Mean.Rhosl; + MeanPhase = run.Summary.Mean.Phase; + MeanGrade = run.Summary.Mean.Grade; + MeanRs = run.Summary.Mean.Rs; + } + if (run.Summary.StandardDeviationPercentage is null) + { + StandardDeviationPercentageNAvg = string.Empty; + StandardDeviationPercentageNsl = string.Empty; + StandardDeviationPercentageVd = string.Empty; + StandardDeviationPercentageFlatZ = string.Empty; + StandardDeviationPercentageRhoAvg = string.Empty; + StandardDeviationPercentageRhosl = string.Empty; + StandardDeviationPercentagePhase = string.Empty; + StandardDeviationPercentageGrade = string.Empty; + StandardDeviationPercentageRs = string.Empty; + } + else + { + StandardDeviationPercentageNAvg = run.Summary.StandardDeviationPercentage.NAvg; + StandardDeviationPercentageNsl = run.Summary.StandardDeviationPercentage.Nsl; + StandardDeviationPercentageVd = run.Summary.StandardDeviationPercentage.Vd; + StandardDeviationPercentageFlatZ = run.Summary.StandardDeviationPercentage.FlatZ; + StandardDeviationPercentageRhoAvg = run.Summary.StandardDeviationPercentage.RhoAvg; + StandardDeviationPercentageRhosl = run.Summary.StandardDeviationPercentage.Rhosl; + StandardDeviationPercentagePhase = run.Summary.StandardDeviationPercentage.Phase; + StandardDeviationPercentageGrade = run.Summary.StandardDeviationPercentage.Grade; + StandardDeviationPercentageRs = run.Summary.StandardDeviationPercentage.Rs; + } + if (run.Summary.RadialGradient is null) + { + RadialGradientNAvg = string.Empty; + RadialGradientNsl = string.Empty; + RadialGradientVd = string.Empty; + RadialGradientFlatZ = string.Empty; + RadialGradientRhoAvg = string.Empty; + RadialGradientRhosl = string.Empty; + RadialGradientPhase = string.Empty; + RadialGradientGrade = string.Empty; + RadialGradientRs = string.Empty; + } + else + { + RadialGradientNAvg = run.Summary.RadialGradient.NAvg; + RadialGradientNsl = run.Summary.RadialGradient.Nsl; + RadialGradientVd = run.Summary.RadialGradient.Vd; + RadialGradientFlatZ = run.Summary.RadialGradient.FlatZ; + RadialGradientRhoAvg = run.Summary.RadialGradient.RhoAvg; + RadialGradientRhosl = run.Summary.RadialGradient.Rhosl; + RadialGradientPhase = run.Summary.RadialGradient.Phase; + RadialGradientGrade = run.Summary.RadialGradient.Grade; + RadialGradientRs = run.Summary.RadialGradient.Rs; + } + Site = run.Points[i].Site; + X = run.Points[i].X; + Y = run.Points[i].Y; + NAvg = run.Points[i].NAvg; + RhoAvg = run.Points[i].RhoAvg; + Nsl = run.Points[i].Nsl; + Rhosl = run.Points[i].Rhosl; + Vd = run.Points[i].Vd; + Phase = run.Points[i].Phase; + FlatZ = run.Points[i].FlatZ; + Grade = run.Points[i].Grade; + XLeft = run.Points[i].XLeft; + XRight = run.Points[i].XRight; + BottomY = run.Points[i].BottomY; + TopY = run.Points[i].TopY; + } + + public string Operator { get; } + public string StartVoltage { get; } + public string Wafer { get; } + public string StopVoltage { get; } + public string Lot { get; } + public string RampRate { get; } + public string Plan { get; } + public string GLimit { get; } + public string Date { get; } + public string Time { get; } + public string SetupFile { get; } + public string WaferSize { get; } + public string Folder { get; } + public string Ccomp { get; } + public string Pattern { get; } + public string Area { get; } + public string CondType { get; } + public string RhoMethod { get; } + public string Model { get; } + // + public string MeanNAvg { get; } + public string MeanNsl { get; } + public string MeanVd { get; } + public string MeanFlatZ { get; } + public string MeanRhoAvg { get; } + public string MeanRhosl { get; } + public string MeanPhase { get; } + public string MeanGrade { get; } + public string MeanRs { get; } + // + public string StandardDeviationPercentageNAvg { get; } + public string StandardDeviationPercentageNsl { get; } + public string StandardDeviationPercentageVd { get; } + public string StandardDeviationPercentageFlatZ { get; } + public string StandardDeviationPercentageRhoAvg { get; } + public string StandardDeviationPercentageRhosl { get; } + public string StandardDeviationPercentagePhase { get; } + public string StandardDeviationPercentageGrade { get; } + public string StandardDeviationPercentageRs { get; } + // + public string RadialGradientNAvg { get; } + public string RadialGradientNsl { get; } + public string RadialGradientVd { get; } + public string RadialGradientFlatZ { get; } + public string RadialGradientRhoAvg { get; } + public string RadialGradientRhosl { get; } + public string RadialGradientPhase { get; } + public string RadialGradientGrade { get; } + public string RadialGradientRs { get; } + // + public string Site { get; } + public string X { get; } + public string Y { get; } + public string NAvg { get; } + public string RhoAvg { get; } + public string Nsl { get; } + public string Rhosl { get; } + public string Vd { get; } + public string Phase { get; } + public string FlatZ { get; } + public string Grade { get; } + public string XLeft { get; } + public string XRight { get; } + public string BottomY { get; } + public string TopY { get; } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Row))] +internal partial class RowSourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/pcl/Run.cs b/Adaptation/FileHandlers/pcl/Run.cs new file mode 100644 index 0000000..c7f3889 --- /dev/null +++ b/Adaptation/FileHandlers/pcl/Run.cs @@ -0,0 +1,161 @@ +using Adaptation.Shared; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Adaptation.FileHandlers.pcl; + +#nullable enable + +internal class Run +{ + + public Run(Header header, Summary summary, ReadOnlyCollection points) + { + Header = header; + Summary = summary; + Points = points; + } + + public Header Header { get; } + public Summary Summary { get; } + public ReadOnlyCollection Points { get; } + + private static ReadOnlyCollection FilterLines(ReadOnlyCollection collection) + { + List results = new(); + foreach (string line in collection) + { + if (string.IsNullOrEmpty(line) || line is "*" or "@") + continue; + if (line.Length < 3 || line[0] is not '*' and not '@' || line[1] != ' ') + results.Add(line); + else + results.Add(line.Substring(2)); + } + return new(results); + } + + private static void WriteJson(Logistics logistics, List fileInfoCollection, Run? result) + { + FileInfo fileInfo = new($"{logistics.ReportFullPath}.json"); + string json = JsonSerializer.Serialize(result, RunSourceGenerationContext.Default.Run); + File.WriteAllText(fileInfo.FullName, json); + File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence); + fileInfoCollection.Add(fileInfo); + } + + private static ReadOnlyCollection GetLines(JsonElement[]? jsonElements) + { + List results = new(); + int columns = 0; + StringBuilder stringBuilder = new(); + for (int i = 0; i < jsonElements?.Length;) + { + foreach (JsonProperty jsonProperty in jsonElements[0].EnumerateObject()) + { + columns += 1; + _ = stringBuilder.Append('"').Append(jsonProperty.Name).Append('"').Append('\t'); + } + break; + } + if (jsonElements?.Length != 0) + _ = stringBuilder.Remove(stringBuilder.Length - 1, 1); + results.Add(stringBuilder.ToString()); + for (int i = 0; i < jsonElements?.Length; i++) + { + _ = stringBuilder.Clear(); + foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject()) + { + if (jsonProperty.Value.ValueKind == JsonValueKind.Object) + _ = stringBuilder.Append('\t'); + else if (jsonProperty.Value.ValueKind != JsonValueKind.String) + _ = stringBuilder.Append(jsonProperty.Value).Append('\t'); + else + _ = stringBuilder.Append('"').Append(jsonProperty.Value).Append('"').Append('\t'); + } + _ = stringBuilder.Remove(stringBuilder.Length - 1, 1); + results.Add(stringBuilder.ToString()); + } + return results.AsReadOnly(); + } + + private static ReadOnlyCollection GetLines(JsonElement jsonElement) => + GetLines(new JsonElement[] { jsonElement }); + + private static void WriteTabSeparatedValues(Logistics logistics, List fileInfoCollection, Run run) + { + List results = new(); + Row row; + FileInfo fileInfo = new($"{logistics.ReportFullPath}.tsv"); + for (int i = 0; i < run.Points.Count; i++) + { + row = new(run, i); + results.Add(row); + } + string json = JsonSerializer.Serialize(results); + JsonElement[]? jsonElements = JsonSerializer.Deserialize(json); + ReadOnlyCollection lines = GetLines(jsonElements); + File.WriteAllText(fileInfo.FullName, string.Join(Environment.NewLine, lines)); + File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence); + fileInfoCollection.Add(fileInfo); + } + + private static void WriteException(Logistics logistics, Exception ex) + { + FileInfo fileInfo = new($"{logistics.ReportFullPath}.{nameof(Exception)}.txt"); + File.WriteAllText(fileInfo.FullName, $"{ex.Message}{Environment.NewLine}{ex.StackTrace}"); + } + + public static Run? Get(Logistics logistics, List fileInfoCollection, ReadOnlyCollection collection) + { + Run? result; + Constant constant = new(); + ReadOnlyCollection lines = FilterLines(collection); + if (collection.Count <= constant.Take) + result = null; + else + { + Header? header = Header.Get(constant, lines); + if (header is null) + result = null; + else + { + Summary? summary = SummarySegment.Get(constant, lines); + if (summary is null) + result = null; + else + { + ReadOnlyCollection points = Point.GetCollection(constant, lines) ?? throw new NullReferenceException(nameof(summary)); + if (points.Count == 0) + result = null; + else + { + result = new(header, summary, points); + WriteJson(logistics, fileInfoCollection, result); + try + { + WriteTabSeparatedValues(logistics, fileInfoCollection, result); + } + catch (Exception ex) + { + WriteException(logistics, ex); + } + } + } + } + } + return result; + } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Run))] +internal partial class RunSourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Adaptation/MET08RESIHGCV.Tests.csproj b/Adaptation/MET08RESIHGCV.Tests.csproj index 747bae7..09e9603 100644 --- a/Adaptation/MET08RESIHGCV.Tests.csproj +++ b/Adaptation/MET08RESIHGCV.Tests.csproj @@ -35,7 +35,7 @@ - + NU1701 NU1701 @@ -44,41 +44,39 @@ NU1701 NU1701 NU1701 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + NU1701 - - - + + + - - - - - - - + + NU1701 - NU1701 - NU1701 - NU1701 + + + + + diff --git a/MET08RESIHGCV.csproj b/MET08RESIHGCV.csproj index 6602de1..7f453e2 100644 --- a/MET08RESIHGCV.csproj +++ b/MET08RESIHGCV.csproj @@ -116,7 +116,6 @@ - @@ -126,6 +125,8 @@ + +