Add Transmission Control Protocol file handling and update PCL serialization

- Introduced FileRead and Record classes for handling file reading in the Transmission Control Protocol.
- Enhanced Description, Detail, and other related classes with JSON serialization attributes for improved data handling.
- Implemented methods for reading and processing files, including network stream management.
- Updated unit tests to cover new functionality and ensure robust testing.
- Added new PDSF file handling classes and integrated them into the project structure.
- Refactored existing code to utilize source generation for JSON serialization, improving performance and maintainability.
This commit is contained in:
2025-09-11 16:57:12 -07:00
parent 7561a08adc
commit b88d79afde
33 changed files with 1571 additions and 193 deletions

View File

@ -4,111 +4,112 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.pcl;
public class Description : IDescription, Shared.Properties.IDescription
{
public int Test { get; set; }
public int Count { get; set; }
public int Index { get; set; }
[JsonPropertyName("EventId")] public int Test { get; set; }
[JsonPropertyName("Count")] public int Count { get; set; }
[JsonPropertyName("Index")] public int Index { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
[JsonPropertyName("MesEntity")] public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
//
public string Date { get; set; }
public string Employee { get; set; }
public string Lot { get; set; }
public string PSN { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
[JsonPropertyName("Date")] public string Date { get; set; }
[JsonPropertyName("Employee")] public string Employee { get; set; }
[JsonPropertyName("Lot")] public string Lot { get; set; }
[JsonPropertyName("PSN")] public string PSN { get; set; }
[JsonPropertyName("Reactor")] public string Reactor { get; set; }
[JsonPropertyName("Recipe")] public string Recipe { get; set; }
//
public string Area { get; set; }
public string Folder { get; set; }
[JsonPropertyName("Area")] public string Area { get; set; }
[JsonPropertyName("Folder")] public string Folder { get; set; }
public string HeaderUniqueId { get; set; }
public string Id { get; set; }
public string Layer { get; set; }
public string Model { get; set; }
public string Pattern { get; set; }
public string Phase { get; set; }
public string Plan { get; set; }
public string RampRate { get; set; }
public string RDS { get; set; }
public string SetupFile { get; set; }
public string StartVoltage { get; set; }
public string StopVoltage { get; set; }
[JsonPropertyName("Layer")] public string Layer { get; set; }
[JsonPropertyName("Model")] public string Model { get; set; }
[JsonPropertyName("Pattern")] public string Pattern { get; set; }
[JsonPropertyName("Phase")] public string Phase { get; set; }
[JsonPropertyName("Plan")] public string Plan { get; set; }
[JsonPropertyName("RampRate")] public string RampRate { get; set; }
[JsonPropertyName("RDS")] public string RDS { get; set; }
[JsonPropertyName("SetupFile")] public string SetupFile { get; set; }
[JsonPropertyName("StartVoltage")] public string StartVoltage { get; set; }
[JsonPropertyName("StopVoltage")] public string StopVoltage { get; set; }
public string UniqueId { get; set; }
public string Wafer { get; set; }
public string WaferSize { get; set; }
public string Zone { get; set; }
[JsonPropertyName("Wafer")] public string Wafer { get; set; }
[JsonPropertyName("WaferSize")] public string WaferSize { get; set; }
[JsonPropertyName("Zone")] public string Zone { get; set; }
//
public string Ccomp { get; set; }
public string CondType { get; set; }
public string FlatZ { get; set; }
public string FlatZMean { get; set; }
public string FlatZRadialGradient { get; set; }
public string FlatZStdDev { get; set; }
public string GLimit { get; set; }
public string Grade { get; set; }
public string GradeMean { get; set; }
public string GradeRadialGradient { get; set; }
public string GradeStdDev { get; set; }
public string NAvg { get; set; }
public string NAvgMean { get; set; }
public string NAvgRadialGradient { get; set; }
public string NAvgStdDev { get; set; }
public string Nsl { get; set; }
public string NslMean { get; set; }
public string NslRadialGradient { get; set; }
public string NslStdDev { get; set; }
public string PhaseMean { get; set; }
public string PhaseRadialGradient { get; set; }
public string PhaseStdDev { get; set; }
public string RhoAvg { get; set; }
public string RhoAvgMean { get; set; }
public string RhoAvgRadialGradient { get; set; }
public string RhoAvgStdDev { get; set; }
public string RhoMethod { get; set; }
public string Rhosl { get; set; }
public string RhoslMean { get; set; }
public string RhoslRadialGradient { get; set; }
public string RhoslStdDev { get; set; }
public string RsMean { get; set; }
public string RsRadialGradient { get; set; }
public string RsStdDev { get; set; }
public string Vd { get; set; }
public string VdMean { get; set; }
public string VdRadialGradient { get; set; }
public string VdStdDev { get; set; }
[JsonPropertyName("Ccomp")] public string Ccomp { get; set; }
[JsonPropertyName("CondType")] public string CondType { get; set; }
[JsonPropertyName("FlatZ")] public string FlatZ { get; set; }
[JsonPropertyName("MeanFlatZ")] public string FlatZMean { get; set; }
[JsonPropertyName("RadialGradientFlatZ")] public string FlatZRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageFlatZ")] public string FlatZStdDev { get; set; }
[JsonPropertyName("GLimit")] public string GLimit { get; set; }
[JsonPropertyName("Grade")] public string Grade { get; set; }
[JsonPropertyName("MeanGrade")] public string GradeMean { get; set; }
[JsonPropertyName("RadialGradientGrade")] public string GradeRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageGrade")] public string GradeStdDev { get; set; }
[JsonPropertyName("NAvg")] public string NAvg { get; set; }
[JsonPropertyName("MeanNAvg")] public string NAvgMean { get; set; }
[JsonPropertyName("RadialGradientNAvg")] public string NAvgRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageNAvg")] public string NAvgStdDev { get; set; }
[JsonPropertyName("Nsl")] public string Nsl { get; set; }
[JsonPropertyName("MeanNsl")] public string NslMean { get; set; }
[JsonPropertyName("RadialGradientNsl")] public string NslRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageNsl")] public string NslStdDev { get; set; }
[JsonPropertyName("MeanPhase")] public string PhaseMean { get; set; }
[JsonPropertyName("RadialGradientPhase")] public string PhaseRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentagePhase")] public string PhaseStdDev { get; set; }
[JsonPropertyName("RhoAvg")] public string RhoAvg { get; set; }
[JsonPropertyName("MeanRhoAvg")] public string RhoAvgMean { get; set; }
[JsonPropertyName("RadialGradientRhoAvg")] public string RhoAvgRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageRhoAvg")] public string RhoAvgStdDev { get; set; }
[JsonPropertyName("RhoMethod")] public string RhoMethod { get; set; }
[JsonPropertyName("Rhosl")] public string Rhosl { get; set; }
[JsonPropertyName("MeanRhosl")] public string RhoslMean { get; set; }
[JsonPropertyName("RadialGradientRhosl")] public string RhoslRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageRhosl")] public string RhoslStdDev { get; set; }
[JsonPropertyName("MeanRs")] public string RsMean { get; set; }
[JsonPropertyName("RadialGradientRs")] public string RsRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageRs")] public string RsStdDev { get; set; }
[JsonPropertyName("Vd")] public string Vd { get; set; }
[JsonPropertyName("MeanVd")] public string VdMean { get; set; }
[JsonPropertyName("RadialGradientVd")] public string VdRadialGradient { get; set; }
[JsonPropertyName("StandardDeviationPercentageVd")] public string VdStdDev { get; set; }
//
public string Variation { get; set; }
public string AreaDeltaFromLastRun { get; set; }
[JsonPropertyName("Variation")] public string Variation { get; set; }
[JsonPropertyName("AreaDeltaFromLastRun")] public string AreaDeltaFromLastRun { get; set; }
//
public string Nine10mmEdgeMean { get; set; }
public string Nine4mmEdgeMean { get; set; }
public string NineCriticalPointsAverage { get; set; }
public string NineCriticalPointsPhaseAngleAverage { get; set; }
public string NineCriticalPointsStdDev { get; set; }
public string NineEdgeMeanDelta { get; set; }
public string NineMean { get; set; }
public string NineResRangePercent { get; set; }
[JsonPropertyName("Nine10mmEdgeMean")] public string Nine10mmEdgeMean { get; set; }
[JsonPropertyName("Nine4mmEdgeMean")] public string Nine4mmEdgeMean { get; set; }
[JsonPropertyName("NineCriticalPointsAverage")] public string NineCriticalPointsAverage { get; set; }
[JsonPropertyName("NineCriticalPointsPhaseAngleAverage")] public string NineCriticalPointsPhaseAngleAverage { get; set; }
[JsonPropertyName("NineCriticalPointsStdDev")] public string NineCriticalPointsStdDev { get; set; }
[JsonPropertyName("NineEdgeMeanDelta")] public string NineEdgeMeanDelta { get; set; }
[JsonPropertyName("NineMean")] public string NineMean { get; set; }
[JsonPropertyName("NineResRangePercent")] public string NineResRangePercent { get; set; }
//
public string RhoAvg01 { get; set; }
public string RhoAvg02 { get; set; }
public string RhoAvg03 { get; set; }
public string RhoAvg04 { get; set; }
public string RhoAvg05 { get; set; }
public string RhoAvg06 { get; set; }
public string RhoAvg07 { get; set; }
public string RhoAvg08 { get; set; }
public string RhoAvg09 { get; set; }
[JsonPropertyName("RhoAvg01")] public string RhoAvg01 { get; set; }
[JsonPropertyName("RhoAvg02")] public string RhoAvg02 { get; set; }
[JsonPropertyName("RhoAvg03")] public string RhoAvg03 { get; set; }
[JsonPropertyName("RhoAvg04")] public string RhoAvg04 { get; set; }
[JsonPropertyName("RhoAvg05")] public string RhoAvg05 { get; set; }
[JsonPropertyName("RhoAvg06")] public string RhoAvg06 { get; set; }
[JsonPropertyName("RhoAvg07")] public string RhoAvg07 { get; set; }
[JsonPropertyName("RhoAvg08")] public string RhoAvg08 { get; set; }
[JsonPropertyName("RhoAvg09")] public string RhoAvg09 { get; set; }
string IDescription.GetEventDescription() => "File Has been read and parsed";
@ -511,4 +512,16 @@ public class Description : IDescription, Shared.Properties.IDescription
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
}
[JsonSourceGenerationOptions(WriteIndented = true, NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
[JsonSerializable(typeof(Description))]
internal partial class DescriptionSourceGenerationContext : JsonSerializerContext
{
}
[JsonSourceGenerationOptions(WriteIndented = true, NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
[JsonSerializable(typeof(Description[]))]
internal partial class DescriptionArraySourceGenerationContext : JsonSerializerContext
{
}

View File

@ -1,19 +1,33 @@
namespace Adaptation.FileHandlers.pcl;
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.pcl;
public class Detail
{
public string FlatZ { get; set; }
public string Grade { get; set; }
[JsonPropertyName("FlatZ")] public string FlatZ { get; set; }
[JsonPropertyName("Grade")] public string Grade { get; set; }
public string HeaderUniqueId { get; set; }
public string NAvg { get; set; }
public string Nsl { get; set; }
public string Phase { get; set; }
public string RhoAvg { get; set; }
public string Rhosl { get; set; }
[JsonPropertyName("NAvg")] public string NAvg { get; set; }
[JsonPropertyName("Nsl")] public string Nsl { get; set; }
[JsonPropertyName("Phase")] public string Phase { get; set; }
[JsonPropertyName("RhoAvg")] public string RhoAvg { get; set; }
[JsonPropertyName("Rhosl")] public string Rhosl { get; set; }
public string UniqueId { get; set; }
public string Vd { get; set; }
[JsonPropertyName("Vd")] public string Vd { get; set; }
public override string ToString() => string.Concat(FlatZ, ";", Grade);
}
[JsonSourceGenerationOptions(WriteIndented = true, NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
[JsonSerializable(typeof(Detail))]
internal partial class DetailSourceGenerationContext : JsonSerializerContext
{
}
[JsonSourceGenerationOptions(WriteIndented = true, NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
[JsonSerializable(typeof(Detail[]))]
internal partial class DetailArraySourceGenerationContext : JsonSerializerContext
{
}

View File

@ -155,7 +155,7 @@ internal class Header
else
{
json = JsonSerializer.Serialize(keyValuePairs);
result = JsonSerializer.Deserialize(json, HeaderSourceGenerationContext.Default.Header) ?? throw new NullReferenceException(nameof(result));
result = JsonSerializer.Deserialize(json, PCLHeaderSourceGenerationContext.Default.Header) ?? throw new NullReferenceException(nameof(result));
}
return result;
}
@ -164,6 +164,6 @@ internal class Header
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Header))]
internal partial class HeaderSourceGenerationContext : JsonSerializerContext
internal partial class PCLHeaderSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -138,6 +138,6 @@ internal class Point
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Point))]
internal partial class PointSourceGenerationContext : JsonSerializerContext
internal partial class PCLPointSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -615,12 +615,11 @@ internal class ProcessData : IProcessData
{
List<Description> results = new();
Description? description;
JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
foreach (JsonElement jsonElement in jsonElements)
{
if (jsonElement.ValueKind != JsonValueKind.Object)
throw new Exception();
description = JsonSerializer.Deserialize<Description>(jsonElement.ToString(), jsonSerializerOptions);
description = JsonSerializer.Deserialize(jsonElement.ToString(), DescriptionSourceGenerationContext.Default.Description);
if (description is null)
continue;
results.Add(description);

View File

@ -191,6 +191,6 @@ internal class Row
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Row))]
internal partial class RowSourceGenerationContext : JsonSerializerContext
internal partial class PCLRowSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -43,7 +43,7 @@ internal class Run
private static void WriteJson(Logistics logistics, List<FileInfo> fileInfoCollection, Run result)
{
FileInfo fileInfo = new($"{logistics.ReportFullPath}.run.json");
string json = JsonSerializer.Serialize(result, RunSourceGenerationContext.Default.Run);
string json = JsonSerializer.Serialize(result, PCLRunSourceGenerationContext.Default.Run);
File.WriteAllText(fileInfo.FullName, json);
File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence);
fileInfoCollection.Add(fileInfo);
@ -143,6 +143,6 @@ internal class Run
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Run))]
internal partial class RunSourceGenerationContext : JsonSerializerContext
internal partial class PCLRunSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -22,6 +22,6 @@ internal class Summary
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Summary))]
internal partial class SummarySourceGenerationContext : JsonSerializerContext
internal partial class PCLSummarySourceGenerationContext : JsonSerializerContext
{
}

View File

@ -100,11 +100,11 @@ internal class SummarySegment
else
{
json = JsonSerializer.Serialize(keyValuePairs);
SummarySegment? mean = JsonSerializer.Deserialize(json, SummarySegmentSourceGenerationContext.Default.SummarySegment);
SummarySegment? mean = JsonSerializer.Deserialize(json, PCLSummarySegmentSourceGenerationContext.Default.SummarySegment);
json = JsonSerializer.Serialize(keyValuePairsB);
SummarySegment? standardDeviationPercentage = JsonSerializer.Deserialize(json, SummarySegmentSourceGenerationContext.Default.SummarySegment);
SummarySegment? standardDeviationPercentage = JsonSerializer.Deserialize(json, PCLSummarySegmentSourceGenerationContext.Default.SummarySegment);
json = JsonSerializer.Serialize(keyValuePairsC);
SummarySegment? radialGradient = JsonSerializer.Deserialize(json, SummarySegmentSourceGenerationContext.Default.SummarySegment);
SummarySegment? radialGradient = JsonSerializer.Deserialize(json, PCLSummarySegmentSourceGenerationContext.Default.SummarySegment);
result = new(mean, standardDeviationPercentage, radialGradient);
}
return result;
@ -114,6 +114,6 @@ internal class SummarySegment
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(SummarySegment))]
internal partial class SummarySegmentSourceGenerationContext : JsonSerializerContext
internal partial class PCLSummarySegmentSourceGenerationContext : JsonSerializerContext
{
}