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-15 09:59:54 -07:00
parent f717c6cf91
commit 0dc57eb3d7
34 changed files with 1815 additions and 209 deletions

View File

@ -4,103 +4,104 @@ 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; }
[JsonPropertyName("Date")] public string Date { get; set; }
[JsonPropertyName("Employee")] 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("PSN")] public string PSN { get; set; }
[JsonPropertyName("Reactor")] public string Reactor { get; set; }
[JsonPropertyName("Recipe")] public string Recipe { get; set; }
//
public string Comments { get; set; }
public string Diameter { get; set; }
public string Exclusion { get; set; }
public string Gain { get; set; }
[JsonPropertyName("Comments")] public string Comments { get; set; }
[JsonPropertyName("Diameter")] public string Diameter { get; set; }
[JsonPropertyName("Exclusion")] public string Exclusion { get; set; }
[JsonPropertyName("Gain")] public string Gain { get; set; }
public string HeaderUniqueId { get; set; }
public string Laser { get; set; }
public string ParseErrorText { get; set; }
public string RDS { get; set; }
public string Slot { get; set; }
[JsonPropertyName("Laser")] public string Laser { get; set; }
[JsonPropertyName("ParseErrorText")] public string ParseErrorText { get; set; }
[JsonPropertyName("RDS")] public string RDS { get; set; }
[JsonPropertyName("WaferId")] public string Slot { get; set; }
public string UniqueId { get; set; }
//
public string AreaCount { get; set; }
public string AreaCountAvg { get; set; }
public string AreaCountMax { get; set; }
public string AreaCountMin { get; set; }
public string AreaCountStdDev { get; set; }
public string AreaTotal { get; set; }
public string AreaTotalAvg { get; set; }
public string AreaTotalMax { get; set; }
public string AreaTotalMin { get; set; }
public string AreaTotalStdDev { get; set; }
public string Bin1 { get; set; }
public string Bin2 { get; set; }
public string Bin3 { get; set; }
public string Bin4 { get; set; }
public string Bin5 { get; set; }
public string Bin6 { get; set; }
public string Bin7 { get; set; }
public string Bin8 { get; set; }
public string HazeAverage { get; set; }
public string HazeAverageAvg { get; set; }
public string HazeAverageMax { get; set; }
public string HazeAverageMin { get; set; }
public string HazeAverageStdDev { get; set; }
public string HazePeak { get; set; }
public string HazeRegion { get; set; }
public string HazeRegionAvg { get; set; }
public string HazeRegionMax { get; set; }
public string HazeRegionMin { get; set; }
public string HazeRegionStdDev { get; set; }
public string HazeRng { get; set; }
public string LPDCM2 { get; set; }
public string LPDCM2Avg { get; set; }
public string LPDCM2Max { get; set; }
public string LPDCM2Min { get; set; }
public string LPDCM2StdDev { get; set; }
public string LPDCount { get; set; }
public string LPDCountAvg { get; set; }
public string LPDCountMax { get; set; }
public string LPDCountMin { get; set; }
public string LPDCountStdDev { get; set; }
public string Mean { get; set; }
public string ScratchCount { get; set; }
public string ScratchCountAvg { get; set; }
public string ScratchCountMax { get; set; }
public string ScratchCountMin { get; set; }
public string ScratchCountStdDev { get; set; }
public string ScratchTotal { get; set; }
public string ScratchTotalAvg { get; set; }
public string ScratchTotalMax { get; set; }
public string ScratchTotalMin { get; set; }
public string ScratchTotalStdDev { get; set; }
public string Sort { get; set; }
public string StdDev { get; set; }
public string SumOfDefects { get; set; }
public string SumOfDefectsAvg { get; set; }
public string SumOfDefectsMax { get; set; }
public string SumOfDefectsMin { get; set; }
public string SumOfDefectsStdDev { get; set; }
public string Thresh { get; set; }
public string Thruput { get; set; }
[JsonPropertyName("AreaCount")] public string AreaCount { get; set; }
[JsonPropertyName("AreaCountAvg")] public string AreaCountAvg { get; set; }
[JsonPropertyName("AreaCountMax")] public string AreaCountMax { get; set; }
[JsonPropertyName("AreaCountMin")] public string AreaCountMin { get; set; }
[JsonPropertyName("AreaCountStdDev")] public string AreaCountStdDev { get; set; }
[JsonPropertyName("WaferAreaTotal")] public string AreaTotal { get; set; }
[JsonPropertyName("AreaTotalAvg")] public string AreaTotalAvg { get; set; }
[JsonPropertyName("AreaTotalMax")] public string AreaTotalMax { get; set; }
[JsonPropertyName("AreaTotalMin")] public string AreaTotalMin { get; set; }
[JsonPropertyName("AreaTotalStdDev")] public string AreaTotalStdDev { get; set; }
[JsonPropertyName("Bin1")] public string Bin1 { get; set; }
[JsonPropertyName("Bin2")] public string Bin2 { get; set; }
[JsonPropertyName("Bin3")] public string Bin3 { get; set; }
[JsonPropertyName("Bin4")] public string Bin4 { get; set; }
[JsonPropertyName("Bin5")] public string Bin5 { get; set; }
[JsonPropertyName("Bin6")] public string Bin6 { get; set; }
[JsonPropertyName("Bin7")] public string Bin7 { get; set; }
[JsonPropertyName("Bin8")] public string Bin8 { get; set; }
[JsonPropertyName("WaferHazeAverage")] public string HazeAverage { get; set; }
[JsonPropertyName("HazeAverageAvg")] public string HazeAverageAvg { get; set; }
[JsonPropertyName("HazeAverageMax")] public string HazeAverageMax { get; set; }
[JsonPropertyName("HazeAverageMin")] public string HazeAverageMin { get; set; }
[JsonPropertyName("HazeAverageStdDev")] public string HazeAverageStdDev { get; set; }
[JsonPropertyName("HazePeak")] public string HazePeak { get; set; }
[JsonPropertyName("WaferHazeRegion")] public string HazeRegion { get; set; }
[JsonPropertyName("HazeRegionAvg")] public string HazeRegionAvg { get; set; }
[JsonPropertyName("HazeRegionMax")] public string HazeRegionMax { get; set; }
[JsonPropertyName("HazeRegionMin")] public string HazeRegionMin { get; set; }
[JsonPropertyName("HazeRegionStdDev")] public string HazeRegionStdDev { get; set; }
[JsonPropertyName("HazeRng")] public string HazeRng { get; set; }
[JsonPropertyName("LPDCM2")] public string LPDCM2 { get; set; }
[JsonPropertyName("LPDCM2Avg")] public string LPDCM2Avg { get; set; }
[JsonPropertyName("LPDCM2Max")] public string LPDCM2Max { get; set; }
[JsonPropertyName("LPDCM2Min")] public string LPDCM2Min { get; set; }
[JsonPropertyName("LPDCM2StdDev")] public string LPDCM2StdDev { get; set; }
[JsonPropertyName("LPDCount")] public string LPDCount { get; set; }
[JsonPropertyName("LPDCountAvg")] public string LPDCountAvg { get; set; }
[JsonPropertyName("LPDCountMax")] public string LPDCountMax { get; set; }
[JsonPropertyName("LPDCountMin")] public string LPDCountMin { get; set; }
[JsonPropertyName("LPDCountStdDev")] public string LPDCountStdDev { get; set; }
[JsonPropertyName("Mean")] public string Mean { get; set; }
[JsonPropertyName("ScratchCount")] public string ScratchCount { get; set; }
[JsonPropertyName("ScratchCountAvg")] public string ScratchCountAvg { get; set; }
[JsonPropertyName("ScratchCountMax")] public string ScratchCountMax { get; set; }
[JsonPropertyName("ScratchCountMin")] public string ScratchCountMin { get; set; }
[JsonPropertyName("ScratchCountStdDev")] public string ScratchCountStdDev { get; set; }
[JsonPropertyName("WaferScratchTotal")] public string ScratchTotal { get; set; }
[JsonPropertyName("ScratchTotalAvg")] public string ScratchTotalAvg { get; set; }
[JsonPropertyName("ScratchTotalMax")] public string ScratchTotalMax { get; set; }
[JsonPropertyName("ScratchTotalMin")] public string ScratchTotalMin { get; set; }
[JsonPropertyName("ScratchTotalStdDev")] public string ScratchTotalStdDev { get; set; }
[JsonPropertyName("Sort")] public string Sort { get; set; }
[JsonPropertyName("StdDev")] public string StdDev { get; set; }
[JsonPropertyName("SumOfDefects")] public string SumOfDefects { get; set; }
[JsonPropertyName("SumOfDefectsAvg")] public string SumOfDefectsAvg { get; set; }
[JsonPropertyName("SumOfDefectsMax")] public string SumOfDefectsMax { get; set; }
[JsonPropertyName("SumOfDefectsMin")] public string SumOfDefectsMin { get; set; }
[JsonPropertyName("SumOfDefectsStdDev")] public string SumOfDefectsStdDev { get; set; }
[JsonPropertyName("Thresh")] public string Thresh { get; set; }
[JsonPropertyName("Thruput")] public string Thruput { get; set; }
string IDescription.GetEventDescription() => "File Has been read and parsed";
@ -492,4 +493,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,46 +1,60 @@
namespace Adaptation.FileHandlers.pcl;
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.pcl;
public class Detail
{
public long Id { get; set; }
public string AreaCount { get; set; }
public string AreaTotal { get; set; }
public string Bin1 { get; set; }
public string Bin2 { get; set; }
public string Bin3 { get; set; }
public string Bin4 { get; set; }
public string Bin5 { get; set; }
public string Bin6 { get; set; }
public string Bin7 { get; set; }
public string Bin8 { get; set; }
public string Comments { get; set; }
public string Date { get; set; }
public string Diameter { get; set; }
public string Exclusion { get; set; }
public string Gain { get; set; }
public string HazeAverage { get; set; }
public string HazePeak { get; set; }
public string HazeRegion { get; set; }
public string HazeRng { get; set; }
[JsonPropertyName("AreaCount")] public string AreaCount { get; set; }
[JsonPropertyName("WaferAreaTotal")] public string AreaTotal { get; set; } // different name
[JsonPropertyName("Bin1")] public string Bin1 { get; set; }
[JsonPropertyName("Bin2")] public string Bin2 { get; set; }
[JsonPropertyName("Bin3")] public string Bin3 { get; set; }
[JsonPropertyName("Bin4")] public string Bin4 { get; set; }
[JsonPropertyName("Bin5")] public string Bin5 { get; set; }
[JsonPropertyName("Bin6")] public string Bin6 { get; set; }
[JsonPropertyName("Bin7")] public string Bin7 { get; set; }
[JsonPropertyName("Bin8")] public string Bin8 { get; set; }
[JsonPropertyName("Comments")] public string Comments { get; set; }
[JsonPropertyName("Date")] public string Date { get; set; }
[JsonPropertyName("Diameter")] public string Diameter { get; set; }
[JsonPropertyName("Exclusion")] public string Exclusion { get; set; }
[JsonPropertyName("Gain")] public string Gain { get; set; }
[JsonPropertyName("WaferHazeAverage")] public string HazeAverage { get; set; } // different name
[JsonPropertyName("HazePeak")] public string HazePeak { get; set; }
[JsonPropertyName("WaferHazeRegion")] public string HazeRegion { get; set; } // different name
[JsonPropertyName("HazeRng")] public string HazeRng { get; set; }
public string HeaderUniqueId { get; set; }
public string LPDCM2 { get; set; }
public string LPDCount { get; set; }
public string Laser { get; set; }
public string Mean { get; set; }
public string Recipe { get; set; }
public string ScratchCount { get; set; }
public string ScratchTotal { get; set; }
public string Slot { get; set; }
public string Sort { get; set; }
public string StdDev { get; set; }
public string SumOfDefects { get; set; }
public string Thresh { get; set; }
public string Thruput { get; set; }
[JsonPropertyName("LPDCM2")] public string LPDCM2 { get; set; }
[JsonPropertyName("LPDCount")] public string LPDCount { get; set; }
[JsonPropertyName("Laser")] public string Laser { get; set; }
[JsonPropertyName("Mean")] public string Mean { get; set; }
[JsonPropertyName("Recipe")] public string Recipe { get; set; }
[JsonPropertyName("ScratchCount")] public string ScratchCount { get; set; }
[JsonPropertyName("WaferScratchTotal")] public string ScratchTotal { get; set; } // different name
[JsonPropertyName("WaferId")] public string Slot { get; set; } // different name
[JsonPropertyName("Sort")] public string Sort { get; set; }
[JsonPropertyName("StdDev")] public string StdDev { get; set; }
[JsonPropertyName("SumOfDefects")] public string SumOfDefects { get; set; }
[JsonPropertyName("Thresh")] public string Thresh { get; set; }
[JsonPropertyName("Thruput")] public string Thruput { get; set; }
public string Title { get; set; }
public string UniqueId { get; set; }
public string Data { get; set; }
#pragma warning disable IDE1006
public int i { get; set; }
}
[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

@ -317,6 +317,6 @@ public class Header
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Header))]
internal partial class HeaderSourceGenerationContext : JsonSerializerContext
internal partial class PCLHeaderSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -703,12 +703,11 @@ public 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

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

View File

@ -49,7 +49,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);
@ -141,6 +141,6 @@ internal class Run
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Run))]
internal partial class RunSourceGenerationContext : JsonSerializerContext
internal partial class PCLRunSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -235,6 +235,6 @@ public class Wafer
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Wafer))]
internal partial class WaferSourceGenerationContext : JsonSerializerContext
internal partial class PCLWaferSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -38,6 +38,6 @@ public class WaferSummary
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(WaferSummary))]
internal partial class WaferSummarySourceGenerationContext : JsonSerializerContext
internal partial class PCLWaferSummarySourceGenerationContext : JsonSerializerContext
{
}