158 lines
8.4 KiB
C#
158 lines
8.4 KiB
C#
using Adaptation.Shared;
|
|
using Adaptation.Shared.Metrology;
|
|
using Adaptation.Shared.Properties;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
|
|
namespace Adaptation.FileHandlers.MET08DDUPSP1TBI;
|
|
|
|
public class ProcessData
|
|
{
|
|
|
|
internal static List<Tuple<int, Enum, string>> HyphenTuples => new()
|
|
{
|
|
new Tuple<int, Enum, string>(0, Hyphen.IsNaEDA, @"\EC_EDA\Staging\Traces\~\Source"),
|
|
new Tuple<int, Enum, string>(15, Hyphen.IsXToOpenInsightMetrologyViewer, @"\EC_EAFLog\TracesMES\~\Source"),
|
|
new Tuple<int, Enum, string>(36, Hyphen.IsXToIQSSi, @"\EC_SPC_Si\Traces\~\PollPath"),
|
|
new Tuple<int, Enum, string>(36, Hyphen.IsXToOpenInsight, @"\\messa01ec.ec.local\APPS\Metrology\~\Source"),
|
|
new Tuple<int, Enum, string>(36, Hyphen.IsXToOpenInsightMetrologyViewerAttachments, @"\EC_Characterization_Si\In Process\~\Source"),
|
|
new Tuple<int, Enum, string>(360, Hyphen.IsXToAPC, @"\EC_APC\Staging\Traces\~\PollPath"),
|
|
new Tuple<int, Enum, string>(-36, Hyphen.IsXToSPaCe, @"\EC_SPC_Si\Traces\~\Source"),
|
|
new Tuple<int, Enum, string>(180, Hyphen.IsXToArchive, @"\EC_EAFLog\TracesArchive\~\Source"),
|
|
new Tuple<int, Enum, string>(36, Hyphen.IsArchive, @"\EC_Characterization_Si\Processed")
|
|
//new Tuple<int, Enum, string>("IsDummy"
|
|
};
|
|
|
|
internal static Tuple<string, string> GetLines(IFileRead fileRead, Logistics logistics, List<txt.Description> descriptions)
|
|
{
|
|
StringBuilder result = new();
|
|
if (fileRead is null)
|
|
{ }
|
|
if (logistics is null)
|
|
{ }
|
|
if (descriptions is null)
|
|
{ }
|
|
char del = '\t';
|
|
txt.Description x = descriptions[0];
|
|
_ = result.Append(x.DcnLpdMin).Append(del). // 001 -
|
|
Append(x.DcnLpdMax).Append(del). // 002 -
|
|
Append(x.DcnLpdMean).Append(del). // 003 - DCN LPD
|
|
Append(x.DcnAreaCountMin).Append(del). // 004 -
|
|
Append(x.DcnAreaCountMax).Append(del). // 005 -
|
|
Append(x.DcnAreaCountMean).Append(del).// 006 - DCN Area
|
|
Append(x.DcnAreaMin).Append(del). // 007 -
|
|
Append(x.DcnAreaMax).Append(del). // 008 -
|
|
Append(x.Date).Append(del). // 009 -
|
|
Append(x.DcnHazeAvgMean).Append(del). // 010 - Haze Average
|
|
Append(string.Empty).Append(del). // 011 -
|
|
Append(string.Empty).Append(del). // 012 -
|
|
Append(string.Empty).Append(del). // 013 -
|
|
Append(string.Empty).Append(del). // 014 -
|
|
Append(string.Empty).Append(del). // 015 -
|
|
Append(string.Empty).Append(del). // 016 -
|
|
Append(string.Empty).Append(del). // 017 -
|
|
Append(string.Empty).Append(del). // 018 -
|
|
Append(string.Empty).Append(del). // 019 -
|
|
Append(string.Empty).Append(del). // 020 -
|
|
Append(string.Empty).Append(del). // 021 -
|
|
Append(string.Empty).Append(del). // 022 -
|
|
Append(string.Empty).Append(del). // 023 -
|
|
Append(string.Empty).Append(del). // 024 -
|
|
Append(string.Empty).Append(del). // 025 -
|
|
Append(string.Empty).Append(del). // 026 -
|
|
Append(string.Empty).Append(del). // 027 -
|
|
Append(x.RDS).Append(del). // 028 - Lot
|
|
Append(x.Reactor).Append(del). // 029 - Process
|
|
Append(x.Recipe).Append(del). // 030 - Part
|
|
Append(x.DcnScrMean).Append(del). // 031 - Scratch Count
|
|
Append(string.Empty).Append(del). // 032 -
|
|
Append(string.Empty).Append(del). // 033 -
|
|
Append(string.Empty).Append(del). // 034 -
|
|
Append(x.DcnMicroScrMean).Append(del). // 035 - Scratch Length
|
|
Append(string.Empty).Append(del). // 036 -
|
|
Append(string.Empty).Append(del). // 037 -
|
|
Append(string.Empty).Append(del). // 038 -
|
|
Append(x.DcnAllMean).Append(del). // 039 - Average Sum of Defects
|
|
Append(x.DcnAllMax).Append(del). // 040 - Max Sum of defects
|
|
Append(x.DcnAllMin).Append(del). // 041 - Min Sum of Defects
|
|
Append(string.Empty).Append(del). // 042 -
|
|
Append(logistics.MesEntity).Append(del). // 043 -
|
|
Append(x.DcnAreaMean).Append(del). // 044 - DCN MM2
|
|
AppendLine();
|
|
return new Tuple<string, string>(result.ToString(), x.Date);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Convert the raw data file to parsable file format - in this case from PRN to PDF
|
|
/// </summary>
|
|
/// <param name="sourceFile">source file to be converted to PDF</param>
|
|
/// <returns></returns>
|
|
private static string ConvertSourceFileToPdf(string ghostPCLFileName, string sourceFile)
|
|
{
|
|
string result = Path.ChangeExtension(sourceFile, ".pdf");
|
|
if (!File.Exists(result))
|
|
{
|
|
//string arguments = string.Concat("-i \"", sourceFile, "\" -o \"", result, "\"");
|
|
string arguments = string.Concat("-dSAFER -dBATCH -dNOPAUSE -sOutputFile=\"", result, "\" -sDEVICE=pdfwrite \"", sourceFile, "\"");
|
|
//Process process = Process.Start(lincPDFCFileName, arguments);
|
|
Process process = Process.Start(ghostPCLFileName, arguments);
|
|
_ = process.WaitForExit(30000);
|
|
if (!File.Exists(result))
|
|
throw new Exception("PDF file wasn't created");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string ghostPCLFileName, DateTime dateTime, string logisticsSequenceMemoryDirectory, List<txt.Description> descriptions, string matchDirectory)
|
|
{
|
|
if (fileRead is null)
|
|
{ }
|
|
if (dateTime == DateTime.MinValue)
|
|
{ }
|
|
if (logisticsSequenceMemoryDirectory is null)
|
|
{ }
|
|
if (descriptions is null)
|
|
{ }
|
|
if (matchDirectory is null)
|
|
{ }
|
|
string[] summaryFiles = Directory.GetFiles(matchDirectory, "*.txt", SearchOption.TopDirectoryOnly);
|
|
if (summaryFiles.Length != 1)
|
|
throw new Exception("Invalid summary file count!");
|
|
string wsResultsMemoryFile = string.Concat(logisticsSequenceMemoryDirectory, @"\", nameof(WS.Results), ".json");
|
|
if (!File.Exists(wsResultsMemoryFile))
|
|
throw new Exception(string.Concat("Memory file <", wsResultsMemoryFile, "> doesn't exist!"));
|
|
string json = File.ReadAllText(wsResultsMemoryFile);
|
|
WS.Results metrologyWSRequest = JsonSerializer.Deserialize<WS.Results>(json);
|
|
long wsResultsHeaderID = metrologyWSRequest.HeaderID;
|
|
string[] prnFiles = Directory.GetFiles(matchDirectory, "WaferMap*.prn", SearchOption.TopDirectoryOnly);
|
|
if (prnFiles.Length == 0 || prnFiles.Length != descriptions.Count)
|
|
throw new Exception("Invalid WaferMap*.prn file count!");
|
|
List<string> pdfFiles = new();
|
|
foreach (string prnFile in prnFiles.OrderBy(l => l))
|
|
pdfFiles.Add(ConvertSourceFileToPdf(ghostPCLFileName, prnFile));
|
|
if (pdfFiles.Count == 0 || pdfFiles.Count != descriptions.Count)
|
|
throw new Exception("Invalid *.pdf file count!");
|
|
List<WS.Attachment> dataAttachments = new();
|
|
List<WS.Attachment> headerAttachments = new()
|
|
{ new WS.Attachment(descriptions[0].HeaderUniqueId, "Data.txt", summaryFiles[0]) };
|
|
int count;
|
|
if (pdfFiles.Count < descriptions.Count)
|
|
count = pdfFiles.Count;
|
|
else
|
|
count = descriptions.Count;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
if (!string.IsNullOrEmpty(pdfFiles[i]))
|
|
dataAttachments.Add(new WS.Attachment(descriptions[i].UniqueId, "Image.pdf", pdfFiles[i]));
|
|
}
|
|
if (dataAttachments.Count == 0 || dataAttachments.Count != descriptions.Count)
|
|
throw new Exception("Invalid attachment count!");
|
|
WS.AttachFiles(openInsightMetrologyViewerAPI, wsResultsHeaderID, headerAttachments, dataAttachments);
|
|
}
|
|
|
|
} |