Refactor OpenInsight file handling to utilize JsonElement for data processing and enhance serialization with JsonSourceGeneration. Updated methods across multiple classes to improve data handling and reduce dependencies on ProcessDataStandardFormat.
This commit is contained in:
@ -4,54 +4,54 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.Stratus;
|
||||
|
||||
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 MID { get; set; } // [JsonPropertyName("Cassette")]
|
||||
//
|
||||
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("DateTime")] public string Date { get; set; }
|
||||
[JsonPropertyName("Employee")] public string Employee { get; set; }
|
||||
[JsonPropertyName("Batch")] 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 Cassette { get; set; }
|
||||
public string GradeStdDev { get; set; }
|
||||
[JsonPropertyName("Cassette")] public string Cassette { get; set; }
|
||||
[JsonPropertyName("GradeStdDev")] public string GradeStdDev { get; set; }
|
||||
public string HeaderUniqueId { get; set; }
|
||||
public string Layer { get; set; }
|
||||
public string MeanThickness { get; set; }
|
||||
public string PassFail { get; set; }
|
||||
public string RDS { get; set; }
|
||||
public string Slot { get; set; }
|
||||
public string Title { get; set; }
|
||||
[JsonPropertyName("Layer")] public string Layer { get; set; }
|
||||
[JsonPropertyName("GradeMean")] public string MeanThickness { get; set; }
|
||||
[JsonPropertyName("PassFail")] public string PassFail { get; set; }
|
||||
[JsonPropertyName("RDS")] public string RDS { get; set; }
|
||||
[JsonPropertyName("Slot")] public string Slot { get; set; }
|
||||
public string Title { get; set; } // [JsonPropertyName("Batch")]
|
||||
public string UniqueId { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
public string Zone { get; set; }
|
||||
[JsonPropertyName("Text")] public string Wafer { get; set; }
|
||||
[JsonPropertyName("Zone")] public string Zone { get; set; }
|
||||
//
|
||||
public string Mean { get; set; }
|
||||
public string Position { get; set; }
|
||||
public string StdDev { get; set; }
|
||||
public string Thickness { get; set; }
|
||||
[JsonPropertyName("Mean")] public string Mean { get; set; }
|
||||
[JsonPropertyName("StdDev")] public string StdDev { get; set; }
|
||||
[JsonPropertyName("Site")] public string Thickness { get; set; }
|
||||
//
|
||||
public string ThicknessSlotOne { get; set; }
|
||||
public string ThicknessSlotTwentyFive { get; set; }
|
||||
public string DeltaThicknessSlotsOneAndTwentyFive { get; set; }
|
||||
public string PercentDeltaThicknessSlotsOneAndTwentyFive { get; set; }
|
||||
[JsonPropertyName("ThicknessSlotOne")] public string ThicknessSlotOne { get; set; }
|
||||
[JsonPropertyName("ThicknessSlotTwentyFive")] public string ThicknessSlotTwentyFive { get; set; }
|
||||
[JsonPropertyName("Actual Delta Thick Pts 1 and 25")] public string DeltaThicknessSlotsOneAndTwentyFive { get; set; }
|
||||
[JsonPropertyName("% Delta Thick Pts 1 and 25")] public string PercentDeltaThicknessSlotsOneAndTwentyFive { get; set; }
|
||||
|
||||
string IDescription.GetEventDescription() => "File Has been read and parsed";
|
||||
|
||||
@ -113,7 +113,7 @@ public class Description : IDescription, Shared.Properties.IDescription
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(Mean),
|
||||
nameof(Position),
|
||||
nameof(Slot),
|
||||
nameof(StdDev),
|
||||
nameof(Thickness)
|
||||
};
|
||||
@ -218,7 +218,6 @@ public class Description : IDescription, Shared.Properties.IDescription
|
||||
Zone = processData.Zone,
|
||||
//
|
||||
Mean = detail.Mean,
|
||||
Position = detail.Position,
|
||||
StdDev = detail.StdDev,
|
||||
Thickness = detail.Thickness,
|
||||
//
|
||||
@ -278,7 +277,6 @@ public class Description : IDescription, Shared.Properties.IDescription
|
||||
Zone = nameof(Zone),
|
||||
//
|
||||
Mean = nameof(Mean),
|
||||
Position = nameof(Position),
|
||||
StdDev = nameof(StdDev),
|
||||
Thickness = nameof(Thickness),
|
||||
//
|
||||
@ -292,4 +290,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
|
||||
{
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.Stratus;
|
||||
|
||||
@ -6,15 +7,26 @@ public class Detail
|
||||
{
|
||||
|
||||
public string HeaderUniqueId { get; set; }
|
||||
public string Mean { get; set; }
|
||||
public string PassFail { get; set; }
|
||||
public string Position { get; set; }
|
||||
public string Recipe { get; set; }
|
||||
public string Slot { get; set; }
|
||||
public string StdDev { get; set; }
|
||||
[JsonPropertyName("Mean")] public string Mean { get; set; }
|
||||
[JsonPropertyName("PassFail")] public string PassFail { get; set; }
|
||||
[JsonPropertyName("Recipe")] public string Recipe { get; set; }
|
||||
[JsonPropertyName("Slot")] public string Slot { get; set; }
|
||||
[JsonPropertyName("StdDev")] public string StdDev { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string Thickness { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
[JsonPropertyName("Site")] public string Thickness { get; set; } // different name
|
||||
[JsonPropertyName("Text")] public string Wafer { get; set; } // different name
|
||||
public List<Point> Points { 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
|
||||
{
|
||||
}
|
||||
@ -577,7 +577,7 @@ public partial class ProcessData : IProcessData
|
||||
_Log.Debug("****ProcessData Removing stdDev");
|
||||
detail.StdDev = detail.StdDev.Remove(detail.StdDev.Length - 1, 1);
|
||||
}
|
||||
detail.UniqueId = string.Concat("_Wafer-", detail.Wafer, "_Slot-", detail.Slot, "_Point-", detail.Position);
|
||||
detail.UniqueId = string.Concat("_Wafer-", detail.Wafer, "_Slot-", detail.Slot);
|
||||
details.Add(detail);
|
||||
nextLine = PeekNextLine();
|
||||
if (nextLine.Contains(cassette))
|
||||
@ -630,11 +630,6 @@ public partial class ProcessData : IProcessData
|
||||
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
|
||||
detail.Thickness = stringBuilder.ToString();
|
||||
_ = stringBuilder.Clear();
|
||||
foreach (Point point in detail.Points)
|
||||
_ = stringBuilder.Append(point.Position).Append(',');
|
||||
if (stringBuilder.Length > 0)
|
||||
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
|
||||
detail.Position = stringBuilder.ToString();
|
||||
}
|
||||
if (details.Count != 2
|
||||
|| details[0].Slot != "1"
|
||||
@ -666,12 +661,11 @@ public partial 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);
|
||||
|
||||
Reference in New Issue
Block a user