FlagDuplicates
CA1510 Complete
This commit is contained in:
297
Adaptation/FileHandlers/pcl/Header.cs
Normal file
297
Adaptation/FileHandlers/pcl/Header.cs
Normal file
@ -0,0 +1,297 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Adaptation.FileHandlers.pcl;
|
||||
|
||||
#nullable enable
|
||||
|
||||
public class Header
|
||||
{
|
||||
|
||||
public Header(string date,
|
||||
string recipe,
|
||||
string id,
|
||||
string lPDCountMin,
|
||||
string lPDCM2Min,
|
||||
string areaCountMin,
|
||||
string areaTotalMin,
|
||||
string scratchCountMin,
|
||||
string scratchTotalMin,
|
||||
string sumOfDefectsMin,
|
||||
string hazeRegionMin,
|
||||
string hazeAverageMin,
|
||||
string lPDCountMax,
|
||||
string lPDCM2Max,
|
||||
string areaCountMax,
|
||||
string areaTotalMax,
|
||||
string scratchCountMax,
|
||||
string scratchTotalMax,
|
||||
string sumOfDefectsMax,
|
||||
string hazeRegionMax,
|
||||
string hazeAverageMax,
|
||||
string lPDCountAvg,
|
||||
string lPDCM2Avg,
|
||||
string areaCountAvg,
|
||||
string areaTotalAvg,
|
||||
string scratchCountAvg,
|
||||
string scratchTotalAvg,
|
||||
string sumOfDefectsAvg,
|
||||
string hazeRegionAvg,
|
||||
string hazeAverageAvg,
|
||||
string lPDCountStdDev,
|
||||
string lPDCM2StdDev,
|
||||
string areaCountStdDev,
|
||||
string areaTotalStdDev,
|
||||
string scratchCountStdDev,
|
||||
string scratchTotalStdDev,
|
||||
string sumOfDefectsStdDev,
|
||||
string hazeRegionStdDev,
|
||||
string hazeAverageStdDev)
|
||||
{
|
||||
Date = date;
|
||||
Recipe = recipe;
|
||||
Id = id;
|
||||
LPDCountMin = lPDCountMin;
|
||||
LPDCM2Min = lPDCM2Min;
|
||||
AreaCountMin = areaCountMin;
|
||||
AreaTotalMin = areaTotalMin;
|
||||
ScratchCountMin = scratchCountMin;
|
||||
ScratchTotalMin = scratchTotalMin;
|
||||
SumOfDefectsMin = sumOfDefectsMin;
|
||||
HazeRegionMin = hazeRegionMin;
|
||||
HazeAverageMin = hazeAverageMin;
|
||||
LPDCountMax = lPDCountMax;
|
||||
LPDCM2Max = lPDCM2Max;
|
||||
AreaCountMax = areaCountMax;
|
||||
AreaTotalMax = areaTotalMax;
|
||||
ScratchCountMax = scratchCountMax;
|
||||
ScratchTotalMax = scratchTotalMax;
|
||||
SumOfDefectsMax = sumOfDefectsMax;
|
||||
HazeRegionMax = hazeRegionMax;
|
||||
HazeAverageMax = hazeAverageMax;
|
||||
LPDCountAvg = lPDCountAvg;
|
||||
LPDCM2Avg = lPDCM2Avg;
|
||||
AreaCountAvg = areaCountAvg;
|
||||
AreaTotalAvg = areaTotalAvg;
|
||||
ScratchCountAvg = scratchCountAvg;
|
||||
ScratchTotalAvg = scratchTotalAvg;
|
||||
SumOfDefectsAvg = sumOfDefectsAvg;
|
||||
HazeRegionAvg = hazeRegionAvg;
|
||||
HazeAverageAvg = hazeAverageAvg;
|
||||
LPDCountStdDev = lPDCountStdDev;
|
||||
LPDCM2StdDev = lPDCM2StdDev;
|
||||
AreaCountStdDev = areaCountStdDev;
|
||||
AreaTotalStdDev = areaTotalStdDev;
|
||||
ScratchCountStdDev = scratchCountStdDev;
|
||||
ScratchTotalStdDev = scratchTotalStdDev;
|
||||
SumOfDefectsStdDev = sumOfDefectsStdDev;
|
||||
HazeRegionStdDev = hazeRegionStdDev;
|
||||
HazeAverageStdDev = hazeAverageStdDev;
|
||||
}
|
||||
|
||||
public string Date { get; }
|
||||
public string Recipe { get; }
|
||||
public string Id { get; }
|
||||
public string LPDCountMin { get; }
|
||||
public string LPDCM2Min { get; }
|
||||
public string AreaCountMin { get; }
|
||||
public string AreaTotalMin { get; }
|
||||
public string ScratchCountMin { get; }
|
||||
public string ScratchTotalMin { get; }
|
||||
public string SumOfDefectsMin { get; }
|
||||
public string HazeRegionMin { get; }
|
||||
public string HazeAverageMin { get; }
|
||||
public string LPDCountMax { get; }
|
||||
public string LPDCM2Max { get; }
|
||||
public string AreaCountMax { get; }
|
||||
public string AreaTotalMax { get; }
|
||||
public string ScratchCountMax { get; }
|
||||
public string ScratchTotalMax { get; }
|
||||
public string SumOfDefectsMax { get; }
|
||||
public string HazeRegionMax { get; }
|
||||
public string HazeAverageMax { get; }
|
||||
public string LPDCountAvg { get; }
|
||||
public string LPDCM2Avg { get; }
|
||||
public string AreaCountAvg { get; }
|
||||
public string AreaTotalAvg { get; }
|
||||
public string ScratchCountAvg { get; }
|
||||
public string ScratchTotalAvg { get; }
|
||||
public string SumOfDefectsAvg { get; }
|
||||
public string HazeRegionAvg { get; }
|
||||
public string HazeAverageAvg { get; }
|
||||
public string LPDCountStdDev { get; }
|
||||
public string LPDCM2StdDev { get; }
|
||||
public string AreaCountStdDev { get; }
|
||||
public string AreaTotalStdDev { get; }
|
||||
public string ScratchCountStdDev { get; }
|
||||
public string ScratchTotalStdDev { get; }
|
||||
public string SumOfDefectsStdDev { get; }
|
||||
public string HazeRegionStdDev { get; }
|
||||
public string HazeAverageStdDev { get; }
|
||||
|
||||
private static ReadOnlyCollection<string> FixToEolArray(string[] toEol)
|
||||
{
|
||||
List<string> results = new();
|
||||
const int MAX_COLUMNS = 9;
|
||||
int[] mColumnWidths = new int[MAX_COLUMNS] { 8, 6, 6, 6, 6, 7, 7, 5, 7 };
|
||||
if (toEol.Length < MAX_COLUMNS)
|
||||
{
|
||||
string leftVal, rightVal;
|
||||
List<string> toEolList = new(toEol);
|
||||
if (string.IsNullOrEmpty(toEolList[toEolList.Count - 1]))
|
||||
toEolList.RemoveAt(toEolList.Count - 1);
|
||||
for (int i = toEolList.Count; i < MAX_COLUMNS; i++)
|
||||
toEolList.Insert(0, "");
|
||||
for (int i = MAX_COLUMNS - 1; i >= 0; i--)
|
||||
{
|
||||
if (toEolList[i].Length > mColumnWidths[i])
|
||||
{
|
||||
leftVal = toEolList[i].Substring(0, toEolList[i].Length - mColumnWidths[i]);
|
||||
rightVal = toEolList[i].Substring(leftVal.Length);
|
||||
toEolList[i] = rightVal;
|
||||
toEolList.Insert(i, leftVal);
|
||||
if (string.IsNullOrEmpty(toEolList[0]))
|
||||
toEolList.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
results.AddRange(toEolList);
|
||||
}
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
internal static void ScanPast(string text, int[] i, string search)
|
||||
{
|
||||
int num = text.IndexOf(search, i[0]);
|
||||
if (num > -1)
|
||||
i[0] = num + search.Length;
|
||||
else
|
||||
i[0] = text.Length;
|
||||
}
|
||||
|
||||
internal static string GetBefore(string text, int[] i, string search)
|
||||
{
|
||||
int num = text.IndexOf(search, i[0]);
|
||||
if (num > -1)
|
||||
{
|
||||
string str = text.Substring(i[0], num - i[0]);
|
||||
i[0] = num + search.Length;
|
||||
return str.Trim();
|
||||
}
|
||||
string str1 = text.Substring(i[0]);
|
||||
i[0] = text.Length;
|
||||
return str1.Trim();
|
||||
}
|
||||
|
||||
private static string GetBefore(string text, int[] i, string search, bool trim)
|
||||
{
|
||||
if (trim)
|
||||
return GetBefore(text, i, search);
|
||||
int num = text.IndexOf(search, i[0]);
|
||||
if (num > -1)
|
||||
{
|
||||
string str = text.Substring(i[0], num - i[0]);
|
||||
i[0] = num + search.Length;
|
||||
return str;
|
||||
}
|
||||
string str1 = text.Substring(i[0]);
|
||||
i[0] = text.Length;
|
||||
return str1;
|
||||
}
|
||||
|
||||
internal static string GetToEOL(string text, int[] i) =>
|
||||
GetBefore(text, i, "\n");
|
||||
|
||||
private static string GetToEOL(string text, int[] i, bool trim)
|
||||
{
|
||||
if (trim)
|
||||
return GetToEOL(text, i);
|
||||
return GetBefore(text, i, "\n", false);
|
||||
}
|
||||
|
||||
internal static Header Get(string headerFileName, Dictionary<string, string> pages, Dictionary<string, List<Detail>> slots, Constant constant)
|
||||
{
|
||||
Header? result;
|
||||
string id;
|
||||
string slot;
|
||||
string toEOL;
|
||||
string? text;
|
||||
int[] i = new int[] { 0 };
|
||||
if (!pages.TryGetValue(headerFileName, out text))
|
||||
throw new Exception();
|
||||
ScanPast(text, i, constant.Date);
|
||||
string date = GetToEOL(text, i);
|
||||
ScanPast(text, i, "Recipe ID:");
|
||||
string recipe = GetBefore(text, i, "LotID:");
|
||||
recipe = recipe.Replace(";", "");
|
||||
if (text.Contains("[]"))
|
||||
id = GetBefore(text, i, "[]");
|
||||
else if (text.Contains("[7]"))
|
||||
id = GetBefore(text, i, "[7]");
|
||||
else
|
||||
id = GetBefore(text, i, "[");
|
||||
int slotCount = text.Substring(i[0]).Split('*').Length - 1;
|
||||
for (int j = 0; j < slotCount; j++)
|
||||
{
|
||||
i[0] = j;
|
||||
ScanPast(text, i, "*");
|
||||
toEOL = GetToEOL(text, i, false);
|
||||
slot = string.Concat("*", toEOL.Substring(0, 2));
|
||||
if (!slots.ContainsKey(slot))
|
||||
slots.Add(slot, new List<Detail>());
|
||||
}
|
||||
ScanPast(text, i, constant.Min);
|
||||
string[] preToEol1 = GetToEOL(text, i, false).Trim().Split(' ');
|
||||
ReadOnlyCollection<string> toEol1 = FixToEolArray(preToEol1);
|
||||
ScanPast(text, i, constant.Max);
|
||||
string[] preToEol2 = GetToEOL(text, i, false).Trim().Split(' ');
|
||||
ReadOnlyCollection<string> toEol2 = FixToEolArray(preToEol2);
|
||||
ScanPast(text, i, constant.Average);
|
||||
string[] preToEol3 = GetToEOL(text, i, false).Trim().Split(' ');
|
||||
ReadOnlyCollection<string> toEol3 = FixToEolArray(preToEol3);
|
||||
ScanPast(text, i, constant.StdDev);
|
||||
string[] preToEol4 = GetToEOL(text, i, false).Trim().Split(' ');
|
||||
ReadOnlyCollection<string> toEol4 = FixToEolArray(preToEol4);
|
||||
result = new(date: date,
|
||||
recipe: recipe,
|
||||
id: id,
|
||||
lPDCountMin: toEol1[0].Trim(),
|
||||
lPDCM2Min: toEol1[1].Trim(),
|
||||
areaCountMin: toEol1[2].Trim(),
|
||||
areaTotalMin: toEol1[3].Trim(),
|
||||
scratchCountMin: toEol1[4].Trim(),
|
||||
scratchTotalMin: toEol1[5].Trim(),
|
||||
sumOfDefectsMin: toEol1[6].Trim(),
|
||||
hazeRegionMin: toEol1[7].Trim(),
|
||||
hazeAverageMin: toEol1[8].Trim(),
|
||||
lPDCountMax: toEol2[0].Trim(),
|
||||
lPDCM2Max: toEol2[1].Trim(),
|
||||
areaCountMax: toEol2[2].Trim(),
|
||||
areaTotalMax: toEol2[3].Trim(),
|
||||
scratchCountMax: toEol2[4].Trim(),
|
||||
scratchTotalMax: toEol2[5].Trim(),
|
||||
sumOfDefectsMax: toEol2[6].Trim(),
|
||||
hazeRegionMax: toEol2[7].Trim(),
|
||||
hazeAverageMax: toEol2[8].Trim(),
|
||||
lPDCountAvg: toEol3[0].Trim(),
|
||||
lPDCM2Avg: toEol3[1].Trim(),
|
||||
areaCountAvg: toEol3[2].Trim(),
|
||||
areaTotalAvg: toEol3[3].Trim(),
|
||||
scratchCountAvg: toEol3[4].Trim(),
|
||||
scratchTotalAvg: toEol3[5].Trim(),
|
||||
sumOfDefectsAvg: toEol3[6].Trim(),
|
||||
hazeRegionAvg: toEol3[7].Trim(),
|
||||
hazeAverageAvg: toEol3[8].Trim(),
|
||||
lPDCountStdDev: toEol4[0].Trim(),
|
||||
lPDCM2StdDev: toEol4[1].Trim(),
|
||||
areaCountStdDev: toEol4[2].Trim(),
|
||||
areaTotalStdDev: toEol4[3].Trim(),
|
||||
scratchCountStdDev: toEol4[4].Trim(),
|
||||
scratchTotalStdDev: toEol4[5].Trim(),
|
||||
sumOfDefectsStdDev: toEol4[6].Trim(),
|
||||
hazeRegionStdDev: toEol4[7].Trim(),
|
||||
hazeAverageStdDev: toEol4[8].Trim());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user