process-data-standard-format with pipes
Test empty first pass when wafer data isn't present
This commit is contained in:
parent
954cdf7a26
commit
2b7573b33d
@ -301,6 +301,8 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
long preWait;
|
long preWait;
|
||||||
foreach (PreWith preWith in preWithCollection)
|
foreach (PreWith preWith in preWithCollection)
|
||||||
{
|
{
|
||||||
|
if (!_IsEAFHosted)
|
||||||
|
continue;
|
||||||
if (processDataStandardFormat is null)
|
if (processDataStandardFormat is null)
|
||||||
File.Move(preWith.MatchingFile, preWith.CheckFile);
|
File.Move(preWith.MatchingFile, preWith.CheckFile);
|
||||||
else
|
else
|
||||||
@ -350,6 +352,8 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||||
processDataStandardFormat = null;
|
processDataStandardFormat = null;
|
||||||
}
|
}
|
||||||
|
if (!_IsEAFHosted && processDataStandardFormat is not null)
|
||||||
|
ProcessDataStandardFormat.Write(".pdsf", processDataStandardFormat);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
int numberLength = 2;
|
int numberLength = 2;
|
||||||
long ticks = dateTime.Ticks;
|
long ticks = dateTime.Ticks;
|
||||||
|
@ -238,34 +238,6 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetJson(int columnsLine, string[] columns, string[] body)
|
|
||||||
{
|
|
||||||
#pragma warning disable CA1845, IDE0057
|
|
||||||
string result = "[\n";
|
|
||||||
string line;
|
|
||||||
string value;
|
|
||||||
string[] segments;
|
|
||||||
if (columns.Length == 0)
|
|
||||||
columns = body[columnsLine].Trim().Split('\t');
|
|
||||||
for (int i = columnsLine + 1; i < body.Length; i++)
|
|
||||||
{
|
|
||||||
line = "{";
|
|
||||||
segments = body[i].Trim().Split('\t');
|
|
||||||
if (segments.Length != columns.Length)
|
|
||||||
break;
|
|
||||||
for (int c = 1; c < segments.Length; c++)
|
|
||||||
{
|
|
||||||
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
|
||||||
line += '"' + columns[c].Trim('"') + '"' + ':' + '"' + value + '"' + ',';
|
|
||||||
}
|
|
||||||
line = line.Substring(0, line.Length - 1) + '}' + ',' + '\n';
|
|
||||||
result += line;
|
|
||||||
}
|
|
||||||
result = result.Substring(0, result.Length - 1) + ']';
|
|
||||||
return result;
|
|
||||||
#pragma warning restore CA1845, IDE0057
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, List<pcl.Description> descriptions, Test[] tests)
|
private void SaveOpenInsightFile(string reportFullPath, DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, List<pcl.Description> descriptions, Test[] tests)
|
||||||
{
|
{
|
||||||
bool isDummyRun = false;
|
bool isDummyRun = false;
|
||||||
|
@ -141,7 +141,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
if (iProcessData.Details.Count > 0)
|
if (iProcessData.Details.Count > 0)
|
||||||
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
||||||
else
|
else
|
||||||
results = new(string.Concat("C) No Data - ", dateTime.Ticks), Array.Empty<Test>(), Array.Empty<JsonElement>(), results.Item4);
|
results = new(string.Concat("LOGISTICS_1 - C) No Data - ", dateTime.Ticks), Array.Empty<Test>(), Array.Empty<JsonElement>(), results.Item4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
@ -26,19 +26,25 @@ internal class ProcessDataStandardFormat
|
|||||||
|
|
||||||
internal long? Sequence { get; private set; }
|
internal long? Sequence { get; private set; }
|
||||||
internal ReadOnlyCollection<string> Body { get; private set; }
|
internal ReadOnlyCollection<string> Body { get; private set; }
|
||||||
|
internal ReadOnlyCollection<string> Footer { get; private set; }
|
||||||
|
internal ReadOnlyCollection<string> Header { get; private set; }
|
||||||
internal ReadOnlyCollection<string> Columns { get; private set; }
|
internal ReadOnlyCollection<string> Columns { get; private set; }
|
||||||
|
internal ProcessDataStandardFormat? InputPDSF { get; private set; }
|
||||||
internal ReadOnlyCollection<string> Logistics { get; private set; }
|
internal ReadOnlyCollection<string> Logistics { get; private set; }
|
||||||
internal ReadOnlyCollection<string> InputLines { get; private set; }
|
|
||||||
|
|
||||||
internal ProcessDataStandardFormat(ReadOnlyCollection<string> body,
|
internal ProcessDataStandardFormat(ReadOnlyCollection<string> body,
|
||||||
ReadOnlyCollection<string> columns,
|
ReadOnlyCollection<string> columns,
|
||||||
ReadOnlyCollection<string> inputLines,
|
ReadOnlyCollection<string> footer,
|
||||||
|
ReadOnlyCollection<string> header,
|
||||||
|
ProcessDataStandardFormat? inputPDSF,
|
||||||
ReadOnlyCollection<string> logistics,
|
ReadOnlyCollection<string> logistics,
|
||||||
long? sequence)
|
long? sequence)
|
||||||
{
|
{
|
||||||
Body = body;
|
Body = body;
|
||||||
Columns = columns;
|
Columns = columns;
|
||||||
InputLines = inputLines;
|
Footer = footer;
|
||||||
|
Header = header;
|
||||||
|
InputPDSF = inputPDSF;
|
||||||
Logistics = logistics;
|
Logistics = logistics;
|
||||||
Sequence = sequence;
|
Sequence = sequence;
|
||||||
}
|
}
|
||||||
@ -56,7 +62,7 @@ internal class ProcessDataStandardFormat
|
|||||||
GetString(SearchFor.Archive, addSpaces, separator);
|
GetString(SearchFor.Archive, addSpaces, separator);
|
||||||
|
|
||||||
internal static ProcessDataStandardFormat GetEmpty() =>
|
internal static ProcessDataStandardFormat GetEmpty() =>
|
||||||
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null);
|
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null, new(Array.Empty<string>()), null);
|
||||||
|
|
||||||
internal static List<string> PDSFToFixedWidth(string reportFullPath)
|
internal static List<string> PDSFToFixedWidth(string reportFullPath)
|
||||||
{
|
{
|
||||||
@ -127,19 +133,26 @@ internal class ProcessDataStandardFormat
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ProcessDataStandardFormat GetProcessDataStandardFormat(string reportFullPath, string[]? lines = null)
|
internal static ProcessDataStandardFormat GetProcessDataStandardFormat(string reportFullPath, string[]? lines = null, int columnsLine = 6)
|
||||||
{
|
{
|
||||||
ProcessDataStandardFormat result;
|
ProcessDataStandardFormat result;
|
||||||
string segment;
|
string segment;
|
||||||
List<string> body = new();
|
|
||||||
List<string> logistics = new();
|
|
||||||
lines ??= File.ReadAllLines(reportFullPath);
|
|
||||||
string[] segments;
|
string[] segments;
|
||||||
if (lines.Length < 7)
|
bool addToFooter = false;
|
||||||
|
List<string> body = new();
|
||||||
|
List<string> header = new();
|
||||||
|
List<string> footer = new();
|
||||||
|
List<string> columns = new();
|
||||||
|
ReadOnlyCollection<string> logistics;
|
||||||
|
lines ??= File.ReadAllLines(reportFullPath);
|
||||||
|
if (lines.Length < columnsLine + 1)
|
||||||
segments = Array.Empty<string>();
|
segments = Array.Empty<string>();
|
||||||
else
|
else
|
||||||
segments = lines[6].Trim().Split('\t');
|
{
|
||||||
List<string> columns = new();
|
segments = lines[columnsLine].Trim().Split('\t');
|
||||||
|
for (int i = 0; i < columnsLine; i++)
|
||||||
|
header.Add(lines[i]);
|
||||||
|
}
|
||||||
for (int c = 0; c < segments.Length; c++)
|
for (int c = 0; c < segments.Length; c++)
|
||||||
{
|
{
|
||||||
segment = segments[c].Substring(1, segments[c].Length - 2);
|
segment = segments[c].Substring(1, segments[c].Length - 2);
|
||||||
@ -158,37 +171,49 @@ internal class ProcessDataStandardFormat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool lookForLogistics = false;
|
for (int r = columnsLine + 1; r < lines.Length; r++)
|
||||||
for (int r = 7; r < lines.Length; r++)
|
|
||||||
{
|
{
|
||||||
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
||||||
lookForLogistics = true;
|
addToFooter = true;
|
||||||
if (!lookForLogistics)
|
if (!addToFooter)
|
||||||
{
|
|
||||||
body.Add(lines[r]);
|
body.Add(lines[r]);
|
||||||
continue;
|
else
|
||||||
}
|
|
||||||
if (lines[r].StartsWith("LOGISTICS_1"))
|
|
||||||
{
|
{
|
||||||
for (int i = r; i < lines.Length; i++)
|
footer.Add(lines[r]);
|
||||||
{
|
if (lines[r].StartsWith("END_HEADER"))
|
||||||
if (!lines[i].StartsWith("LOGISTICS_") || lines[i].StartsWith("END_HEADER"))
|
|
||||||
break;
|
|
||||||
logistics.Add(lines[i]);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lines.Length > 0 && body.Count == 0 && columns.Count == 0 && logistics.Count == 0)
|
string? linesOne = lines.Length > 0 && body.Count == 0 && columns.Count == 0 ? lines[1] : null;
|
||||||
logistics.Add(lines[1]);
|
logistics = GetLogistics(footer, linesOne: linesOne);
|
||||||
result = new(body: body.AsReadOnly(),
|
result = new(body: body.AsReadOnly(),
|
||||||
columns: columns.AsReadOnly(),
|
columns: columns.AsReadOnly(),
|
||||||
inputLines: lines.ToList().AsReadOnly(),
|
footer: footer.AsReadOnly(),
|
||||||
logistics: logistics.AsReadOnly(),
|
header: header.AsReadOnly(),
|
||||||
|
inputPDSF: null,
|
||||||
|
logistics: logistics,
|
||||||
sequence: null);
|
sequence: null);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<string> GetLogistics(List<string> footer, string? linesOne)
|
||||||
|
{
|
||||||
|
List<string> results = new();
|
||||||
|
bool foundLogistics1 = false;
|
||||||
|
foreach (string line in footer)
|
||||||
|
{
|
||||||
|
if (line.StartsWith("END_HEADER"))
|
||||||
|
break;
|
||||||
|
if (line.StartsWith("LOGISTICS_1"))
|
||||||
|
foundLogistics1 = true;
|
||||||
|
if (foundLogistics1 && line.StartsWith("LOGISTICS_"))
|
||||||
|
results.Add(line);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(linesOne) && results.Count == 0)
|
||||||
|
results.Add(linesOne);
|
||||||
|
return results.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
internal static ProcessDataStandardFormat? GetProcessDataStandardFormat(string reportFullPath, ProcessDataStandardFormatMapping pdsfMapping)
|
internal static ProcessDataStandardFormat? GetProcessDataStandardFormat(string reportFullPath, ProcessDataStandardFormatMapping pdsfMapping)
|
||||||
{
|
{
|
||||||
ProcessDataStandardFormat? result;
|
ProcessDataStandardFormat? result;
|
||||||
@ -196,7 +221,7 @@ internal class ProcessDataStandardFormat
|
|||||||
FileInfo fileInfo = new(reportFullPath);
|
FileInfo fileInfo = new(reportFullPath);
|
||||||
ProcessDataStandardFormat processDataStandardFormat = GetProcessDataStandardFormat(fileInfo.LastWriteTime, pdsfMapping.NewColumnNames.Count, columnsLine, fileInfo.FullName, lines: null);
|
ProcessDataStandardFormat processDataStandardFormat = GetProcessDataStandardFormat(fileInfo.LastWriteTime, pdsfMapping.NewColumnNames.Count, columnsLine, fileInfo.FullName, lines: null);
|
||||||
JsonElement[]? jsonElements = GetArray(pdsfMapping.NewColumnNames.Count, processDataStandardFormat, lookForNumbers: false);
|
JsonElement[]? jsonElements = GetArray(pdsfMapping.NewColumnNames.Count, processDataStandardFormat, lookForNumbers: false);
|
||||||
if (jsonElements is null || pdsfMapping.OldColumnNames.Count != pdsfMapping.ColumnIndices.Count)
|
if (jsonElements is null || jsonElements.Length == 0 || pdsfMapping.OldColumnNames.Count != pdsfMapping.ColumnIndices.Count)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -212,9 +237,11 @@ internal class ProcessDataStandardFormat
|
|||||||
ProcessDataStandardFormat result;
|
ProcessDataStandardFormat result;
|
||||||
long sequence;
|
long sequence;
|
||||||
string[] segments;
|
string[] segments;
|
||||||
|
bool addToFooter = false;
|
||||||
List<string> body = new();
|
List<string> body = new();
|
||||||
bool lookForLogistics = false;
|
List<string> header = new();
|
||||||
List<string> logistics = new();
|
List<string> footer = new();
|
||||||
|
ReadOnlyCollection<string> logistics;
|
||||||
lines ??= File.ReadAllLines(path);
|
lines ??= File.ReadAllLines(path);
|
||||||
if (lines.Length <= columnsLine)
|
if (lines.Length <= columnsLine)
|
||||||
segments = Array.Empty<string>();
|
segments = Array.Empty<string>();
|
||||||
@ -223,28 +250,24 @@ internal class ProcessDataStandardFormat
|
|||||||
segments = lines[columnsLine].Split('\t');
|
segments = lines[columnsLine].Split('\t');
|
||||||
if (segments.Length != expectedColumns)
|
if (segments.Length != expectedColumns)
|
||||||
segments = Array.Empty<string>();
|
segments = Array.Empty<string>();
|
||||||
|
for (int i = 0; i < columnsLine; i++)
|
||||||
|
header.Add(lines[i]);
|
||||||
}
|
}
|
||||||
string[] columns = segments.Select(l => l.Trim('"')).ToArray();
|
string[] columns = segments.Select(l => l.Trim('"')).ToArray();
|
||||||
for (int r = columnsLine + 1; r < lines.Length; r++)
|
for (int r = columnsLine + 1; r < lines.Length; r++)
|
||||||
{
|
{
|
||||||
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
if (lines[r].StartsWith("NUM_DATA_ROWS"))
|
||||||
lookForLogistics = true;
|
addToFooter = true;
|
||||||
if (!lookForLogistics)
|
if (!addToFooter)
|
||||||
{
|
|
||||||
body.Add(lines[r]);
|
body.Add(lines[r]);
|
||||||
continue;
|
else
|
||||||
}
|
|
||||||
if (lines[r].StartsWith("LOGISTICS_1"))
|
|
||||||
{
|
{
|
||||||
for (int i = r; i < lines.Length; i++)
|
footer.Add(lines[r]);
|
||||||
{
|
if (lines[r].StartsWith("END_HEADER"))
|
||||||
if (!lines[i].StartsWith("LOGISTICS_") || lines[i].StartsWith("END_HEADER"))
|
|
||||||
break;
|
|
||||||
logistics.Add(lines[i]);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logistics = GetLogistics(footer, linesOne: null);
|
||||||
if (logistics.Count == 0)
|
if (logistics.Count == 0)
|
||||||
sequence = lastWriteTime.Ticks;
|
sequence = lastWriteTime.Ticks;
|
||||||
else
|
else
|
||||||
@ -254,8 +277,10 @@ internal class ProcessDataStandardFormat
|
|||||||
}
|
}
|
||||||
result = new(body: body.AsReadOnly(),
|
result = new(body: body.AsReadOnly(),
|
||||||
columns: new(columns),
|
columns: new(columns),
|
||||||
inputLines: lines.ToList().AsReadOnly(),
|
footer: footer.AsReadOnly(),
|
||||||
logistics: logistics.AsReadOnly(),
|
header: header.AsReadOnly(),
|
||||||
|
inputPDSF: null,
|
||||||
|
logistics: logistics,
|
||||||
sequence: sequence);
|
sequence: sequence);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -346,7 +371,9 @@ internal class ProcessDataStandardFormat
|
|||||||
}
|
}
|
||||||
result = new(body: new(results),
|
result = new(body: new(results),
|
||||||
columns: processDataStandardFormatMapping.OldColumnNames,
|
columns: processDataStandardFormatMapping.OldColumnNames,
|
||||||
inputLines: processDataStandardFormat.InputLines,
|
footer: processDataStandardFormat.Footer,
|
||||||
|
header: processDataStandardFormat.Header,
|
||||||
|
inputPDSF: processDataStandardFormat,
|
||||||
logistics: processDataStandardFormat.Logistics,
|
logistics: processDataStandardFormat.Logistics,
|
||||||
sequence: processDataStandardFormat.Sequence);
|
sequence: processDataStandardFormat.Sequence);
|
||||||
return result;
|
return result;
|
||||||
@ -379,7 +406,19 @@ internal class ProcessDataStandardFormat
|
|||||||
results.Add("LOGISTICS_COLUMN\tB_LOGISTICS");
|
results.Add("LOGISTICS_COLUMN\tB_LOGISTICS");
|
||||||
results.AddRange(processDataStandardFormat.Logistics);
|
results.AddRange(processDataStandardFormat.Logistics);
|
||||||
results.Add("EOF");
|
results.Add("EOF");
|
||||||
results.AddRange(processDataStandardFormat.InputLines.Select(l => l.Replace('\t', '|')));
|
if (processDataStandardFormat.InputPDSF is not null)
|
||||||
|
{
|
||||||
|
List<char> hyphens = new();
|
||||||
|
results.AddRange(processDataStandardFormat.InputPDSF.Header.Select(l => l.Replace('\t', '|')));
|
||||||
|
results.Add(string.Empty);
|
||||||
|
results.Add($"|{string.Join("|", processDataStandardFormat.InputPDSF.Columns)}|");
|
||||||
|
for (int i = 0; i < processDataStandardFormat.InputPDSF.Columns.Count; i++)
|
||||||
|
hyphens.Add('-');
|
||||||
|
results.Add($"|{string.Join("|", hyphens)}|");
|
||||||
|
results.AddRange(processDataStandardFormat.InputPDSF.Body.Select(l => l.Replace('\t', '|')));
|
||||||
|
results.Add(string.Empty);
|
||||||
|
results.AddRange(processDataStandardFormat.InputPDSF.Footer.Select(l => l.Replace('\t', '|')));
|
||||||
|
}
|
||||||
File.WriteAllText(path, string.Join(Environment.NewLine, results));
|
File.WriteAllText(path, string.Join(Environment.NewLine, results));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user