Files
met08resihgcv/Adaptation/FileHandlers/pcl/ProcessData.cs

235 lines
8.3 KiB
C#

using Adaptation.Shared;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.pcl;
internal class ProcessData : IProcessData
{
public string JobID { get; set; }
public string MesEntity { get; set; }
public string Area { get; set; }
public string Ccomp { get; set; }
public string CondType { get; set; }
public DateTime Date { get; set; }
public string Employee { get; set; }
public string FlatZMean { get; set; }
public string FlatZRadialGradient { get; set; }
public string FlatZStdDev { get; set; }
public string Folder { get; set; }
public string GLimit { get; set; }
public string GradeMean { get; set; }
public string GradeRadialGradient { get; set; }
public string GradeStdDev { get; set; }
public string Layer { get; set; }
public string Lot { get; set; }
public string Model { get; set; }
public string NAvgMean { get; set; }
public string NAvgRadialGradient { get; set; }
public string NAvgStdDev { get; set; }
public string NslMean { get; set; }
public string NslRadialGradient { get; set; }
public string NslStdDev { get; set; }
public string PSN { get; set; }
public string Pattern { get; set; }
public string PhaseMean { get; set; }
public string PhaseRadialGradient { get; set; }
public string PhaseStdDev { get; set; }
public string Plan { get; set; }
public string RDS { get; set; }
public string RampRate { get; set; }
public string Reactor { get; set; }
public string RhoAvgMean { get; set; }
public string RhoAvgRadialGradient { get; set; }
public string RhoAvgStdDev { get; set; }
public string RhoMethod { 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 SetupFile { get; set; }
public string StartVoltage { get; set; }
public string StopVoltage { get; set; }
public string UniqueId { get; set; }
public string VdMean { get; set; }
public string VdRadialGradient { get; set; }
public string VdStdDev { get; set; }
public string Wafer { get; set; }
public string WaferSize { get; set; }
public string Zone { 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; }
List<object> Shared.Properties.IProcessData.Details { get; }
private static DateTime GetDateTime(Logistics logistics) =>
logistics.DateTimeFromSequence;
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) =>
throw new Exception(string.Concat("See ", nameof(IProcessData)));
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection) =>
throw new NotImplementedException();
private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments)
{
string rds;
string reactor;
if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText))
reactor = defaultReactor;
else
reactor = segments[0];
if (segments.Length <= 1 || !int.TryParse(segments[1], out int rdsValue) || rdsValue < 99)
rds = defaultRDS;
else
rds = segments[1];
if (reactor.Length > 3)
{
rds = reactor;
reactor = defaultReactor;
}
return new(reactor, rds);
}
private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments)
{
string psn;
string layer;
if (segments.Length <= 2)
{
psn = defaultPSN;
layer = defaultLayer;
}
else
{
string[] segmentsB = segments[2].Split('.');
psn = segmentsB[0];
if (segmentsB.Length <= 1)
layer = defaultLayer;
else
{
layer = segmentsB[1];
if (layer.Length > 1 && layer[0] == '0')
layer = layer.Substring(1);
}
}
return (layer, psn);
}
private static string GetZone(string[] segments)
{
string result;
if (segments.Length <= 3)
result = string.Empty;
else
{
result = segments[3];
if (result.Length > 1 && result[0] == '0')
result = result.Substring(1);
}
return result;
}
public static Descriptor GetDescriptor(string text)
{
Descriptor result;
string lot;
string psn;
string rds;
string zone;
string layer;
string reactor;
string employee;
string defaultPSN = string.Empty;
string defaultRDS = string.Empty;
string defaultZone = string.Empty;
string defaultLayer = string.Empty;
string defaultReactor = string.Empty;
string defaultEmployee = string.Empty;
if (Regex.IsMatch(text, @"^[a-zA-z][0-9]{2,4}$"))
{
lot = text.ToUpper();
psn = defaultPSN;
rds = defaultRDS;
zone = defaultZone;
layer = defaultLayer;
reactor = defaultReactor;
employee = defaultEmployee;
}
else if (string.IsNullOrEmpty(text) || (text.Length is 2 or 3 && Regex.IsMatch(text, "^[a-zA-z]{2,3}")))
{
lot = text;
employee = lot;
psn = defaultPSN;
rds = defaultRDS;
zone = defaultZone;
layer = defaultLayer;
reactor = defaultReactor;
}
else if (Regex.IsMatch(text, @"^[0-9]{2}[.][0-9]{1}[.]?[0-9]{0,1}"))
{
string[] segments = text.Split('.');
lot = text;
psn = defaultPSN;
rds = defaultRDS;
layer = segments[1];
reactor = segments[0];
employee = defaultEmployee;
if (segments.Length <= 2)
zone = defaultZone;
else
zone = segments[2];
}
else
{
// Remove illegal characters \/:*?"<>| found in the Lot.
lot = Regex.Replace(text, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
if (lot.Length > 2 && lot[0] == '1' && (lot[1] == 'T' || lot[1] == 't'))
lot = lot.Substring(2);
string[] segments = lot.Split('-');
// bool hasRDS = Regex.IsMatch(lot, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?");
(reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, lot, segments);
(layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments);
zone = GetZone(segments);
if (segments.Length <= 4)
employee = defaultEmployee;
else
employee = segments[4];
}
result = new(employee, layer, lot, psn, rds, reactor, zone);
return result;
}
#nullable enable
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
{
List<Description> results = new();
Description? description;
foreach (JsonElement jsonElement in jsonElements)
{
if (jsonElement.ValueKind != JsonValueKind.Object)
throw new Exception();
description = JsonSerializer.Deserialize(jsonElement.ToString(), DescriptionSourceGenerationContext.Default.Description);
if (description is null)
continue;
results.Add(description);
}
return results;
}
}