169 lines
5.8 KiB
C#
169 lines
5.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Adaptation.FileHandlers.pcl;
|
|
|
|
#nullable enable
|
|
|
|
internal class Header
|
|
{
|
|
|
|
[JsonConstructor]
|
|
public Header(string @operator, string startVoltage, string wafer, string stopVoltage, string lot, string rampRate, string plan, string gLimit, string date, string time, string setupFile, string waferSize, string folder, string ccomp, string pattern, string area, string condType, string rhoMethod, string model)
|
|
{
|
|
Operator = @operator;
|
|
StartVoltage = startVoltage;
|
|
Wafer = wafer;
|
|
StopVoltage = stopVoltage;
|
|
Lot = lot;
|
|
RampRate = rampRate;
|
|
Plan = plan;
|
|
GLimit = gLimit;
|
|
Date = date;
|
|
Time = time;
|
|
SetupFile = setupFile;
|
|
WaferSize = waferSize;
|
|
Folder = folder;
|
|
Ccomp = ccomp;
|
|
Pattern = pattern;
|
|
Area = area;
|
|
CondType = condType;
|
|
RhoMethod = rhoMethod;
|
|
Model = model;
|
|
}
|
|
|
|
[JsonPropertyName("Operator")] public string Operator { get; }
|
|
[JsonPropertyName("Start Voltage")] public string StartVoltage { get; }
|
|
[JsonPropertyName("Wafer")] public string Wafer { get; }
|
|
[JsonPropertyName("Stop Voltage")] public string StopVoltage { get; }
|
|
[JsonPropertyName("Lot")] public string Lot { get; }
|
|
[JsonPropertyName("Ramp Rate")] public string RampRate { get; }
|
|
[JsonPropertyName("Plan")] public string Plan { get; }
|
|
[JsonPropertyName("G limit")] public string GLimit { get; }
|
|
[JsonPropertyName("Date")] public string Date { get; }
|
|
[JsonPropertyName("Time")] public string Time { get; }
|
|
[JsonPropertyName("Setup File")] public string SetupFile { get; }
|
|
[JsonPropertyName("Wafer size")] public string WaferSize { get; }
|
|
[JsonPropertyName("Folder")] public string Folder { get; }
|
|
[JsonPropertyName("Ccomp")] public string Ccomp { get; }
|
|
[JsonPropertyName("Pattern")] public string Pattern { get; }
|
|
[JsonPropertyName("Area")] public string Area { get; }
|
|
[JsonPropertyName("Cond Type")] public string CondType { get; }
|
|
[JsonPropertyName("Rho Method")] public string RhoMethod { get; }
|
|
[JsonPropertyName("Model")] public string Model { get; }
|
|
|
|
private static string[] GetRemove() =>
|
|
new string[]
|
|
{
|
|
" L L",
|
|
" O O",
|
|
" G G",
|
|
" C C",
|
|
" O O",
|
|
" N N",
|
|
" C C",
|
|
" E E",
|
|
" N N",
|
|
" T T",
|
|
" R R",
|
|
" A A",
|
|
" T T",
|
|
" I I",
|
|
" O O",
|
|
" N N"
|
|
};
|
|
|
|
public static Header Get() =>
|
|
new(string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty,
|
|
string.Empty);
|
|
|
|
private static ReadOnlyCollection<JsonProperty> GetJsonProperties()
|
|
{
|
|
JsonProperty[] results;
|
|
string json;
|
|
Header header = Get();
|
|
json = JsonSerializer.Serialize(header);
|
|
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
|
results = jsonElement.EnumerateObject().ToArray();
|
|
return new(results);
|
|
}
|
|
|
|
public static Header? Get(Constant constant, ReadOnlyCollection<string> lines)
|
|
{
|
|
Header? result;
|
|
string json;
|
|
string check;
|
|
string[] segments;
|
|
string[] segmentsB;
|
|
string[] segmentsC;
|
|
bool found = false;
|
|
string[] remove = GetRemove();
|
|
Dictionary<string, string> keyValuePairs = new();
|
|
ReadOnlyCollection<JsonProperty> jsonProperties = GetJsonProperties();
|
|
foreach (string line in lines)
|
|
{
|
|
if (line.Contains(constant.Site))
|
|
found = true;
|
|
if (!found)
|
|
continue;
|
|
if (line == constant.SummaryLine)
|
|
break;
|
|
foreach (JsonProperty jsonProperty in jsonProperties)
|
|
{
|
|
segments = line.Split(new string[] { $"{jsonProperty.Name}:", $"{jsonProperty.Name} :" }, StringSplitOptions.None);
|
|
if (segments.Length < 2)
|
|
continue;
|
|
check = segments[1].Trim();
|
|
foreach (JsonProperty jsonPropertyB in jsonProperties)
|
|
{
|
|
segmentsB = check.Split(new string[] { $"{jsonPropertyB.Name}:", $"{jsonPropertyB.Name} :" }, StringSplitOptions.None);
|
|
if (segmentsB.Length > 1)
|
|
check = segmentsB[0].Trim();
|
|
}
|
|
foreach (string r in remove)
|
|
{
|
|
segmentsC = check.Split(new string[] { r }, StringSplitOptions.None);
|
|
if (segmentsC.Length > 1)
|
|
check = segmentsC[0].Trim();
|
|
}
|
|
keyValuePairs.Add(jsonProperty.Name, check);
|
|
}
|
|
}
|
|
if (keyValuePairs.Count != jsonProperties.Count)
|
|
result = null;
|
|
else
|
|
{
|
|
json = JsonSerializer.Serialize(keyValuePairs);
|
|
result = JsonSerializer.Deserialize(json, HeaderSourceGenerationContext.Default.Header) ?? throw new NullReferenceException(nameof(result));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Header))]
|
|
internal partial class HeaderSourceGenerationContext : JsonSerializerContext
|
|
{
|
|
} |