Match TFS Changeset 303349
This commit is contained in:
34
Adaptation/FileHandlers/CellInstanceConnectionName.cs
Normal file
34
Adaptation/FileHandlers/CellInstanceConnectionName.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Adaptation.FileHandlers
|
||||
{
|
||||
|
||||
public class CellInstanceConnectionName
|
||||
{
|
||||
|
||||
internal static IFileRead Get(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted)
|
||||
{
|
||||
IFileRead result;
|
||||
int levelIsArchive = 7;
|
||||
int levelIsXToArchive = 6;
|
||||
bool isDuplicator = cellInstanceConnectionName.StartsWith(cellInstanceName);
|
||||
if (isDuplicator)
|
||||
result = new MET08THFTIRQS408M.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, levelIsXToArchive, levelIsArchive);
|
||||
else
|
||||
{
|
||||
result = cellInstanceConnectionName switch
|
||||
{
|
||||
nameof(QS408M) => new QS408M.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, levelIsXToArchive, levelIsArchive),
|
||||
_ => throw new Exception(),
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
552
Adaptation/FileHandlers/MET08THFTIRQS408M/FileRead.cs
Normal file
552
Adaptation/FileHandlers/MET08THFTIRQS408M/FileRead.cs
Normal file
@ -0,0 +1,552 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Duplicator;
|
||||
using Adaptation.Shared.Methods;
|
||||
using Adaptation.Shared.Metrology;
|
||||
using Infineon.Monitoring.MonA;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
|
||||
namespace Adaptation.FileHandlers.MET08THFTIRQS408M
|
||||
{
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
private readonly Timer _Timer;
|
||||
private int _LastDummyRunIndex;
|
||||
private readonly string _IqsFile;
|
||||
private readonly int _HyphenIsDummy;
|
||||
private readonly int _HyphenIsNaEDA;
|
||||
private readonly string _MemoryPath;
|
||||
private readonly int _HyphenIsXToAPC;
|
||||
private readonly int _HyphenIsXToIQSSi;
|
||||
private readonly int _HyphenIsXToSPaCe;
|
||||
private readonly int _HyphenIsXToOpenInsight;
|
||||
private readonly string _EventNameFileReadDaily;
|
||||
private readonly string _OpenInsightFilePattern;
|
||||
private readonly string _OpenInsightMetrologyViewerAPI;
|
||||
private readonly Dictionary<string, string> _CellNames;
|
||||
private readonly int _HyphenIsXToOpenInsightMetrologyViewer;
|
||||
private readonly int _HyphenIsXToOpenInsightMetrologyViewerAttachments;
|
||||
|
||||
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) :
|
||||
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new Logistics(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (!_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (hyphenIsArchive != (int)Hyphen.IsArchive)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (hyphenXToArchive != (int)Hyphen.IsXToArchive)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
_LastDummyRunIndex = -1;
|
||||
if (_HyphenIsNaEDA == 0)
|
||||
{ }
|
||||
if (_HyphenIsXToSPaCe == 0)
|
||||
{ }
|
||||
if (_HyphenIsXToIQSSi == 0)
|
||||
{ }
|
||||
_CellNames = new Dictionary<string, string>();
|
||||
_HyphenIsNaEDA = (int)Hyphen.IsNaEDA;
|
||||
_HyphenIsDummy = (int)Hyphen.IsDummy;
|
||||
_HyphenIsXToAPC = (int)Hyphen.IsXToAPC;
|
||||
_HyphenIsXToIQSSi = (int)Hyphen.IsXToIQSSi;
|
||||
_HyphenIsXToSPaCe = (int)Hyphen.IsXToSPaCe;
|
||||
_HyphenIsXToOpenInsight = (int)Hyphen.IsXToOpenInsight;
|
||||
_EventNameFileReadDaily = string.Concat(_EventNameFileRead, "Daily");
|
||||
_IqsFile = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.File");
|
||||
_MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory");
|
||||
_HyphenIsXToOpenInsightMetrologyViewer = (int)Hyphen.IsXToOpenInsightMetrologyViewer;
|
||||
_HyphenIsXToOpenInsightMetrologyViewerAttachments = (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments;
|
||||
_OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern");
|
||||
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
|
||||
ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path");
|
||||
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection)
|
||||
_CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value);
|
||||
if (_Hyphens == _HyphenIsDummy)
|
||||
{
|
||||
if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process)
|
||||
{
|
||||
_Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite);
|
||||
Callback(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
int milliSeconds;
|
||||
milliSeconds = (int)((fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000) / 2);
|
||||
_Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite);
|
||||
milliSeconds += 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
|
||||
{
|
||||
Move(this, extractResults, exception);
|
||||
}
|
||||
|
||||
void IFileRead.WaitForThread()
|
||||
{
|
||||
WaitForThread(thread: null, threadExceptions: null);
|
||||
}
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
throw new Exception();
|
||||
_ReportFullPath = reportFullPath;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
results = GetExtractResult(reportFullPath, dateTime);
|
||||
if (results.Item3 is null)
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, new Test[] { }, JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||
WritePDSF(this, results.Item3);
|
||||
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<string> headerNames = _Description.GetHeaderNames();
|
||||
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||
results = ReExtract(this, headerNames, keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
void IFileRead.CheckTests(Test[] tests, bool extra)
|
||||
{
|
||||
if (!(_Description is Description))
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
void IFileRead.Callback(object state)
|
||||
{
|
||||
Callback(state);
|
||||
}
|
||||
|
||||
void IFileRead.MoveArchive()
|
||||
{
|
||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
|
||||
string jobIdDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", _Logistics.JobID);
|
||||
if (!Directory.Exists(jobIdDirectory))
|
||||
Directory.CreateDirectory(jobIdDirectory);
|
||||
//string destinationArchiveDirectory = string.Concat(jobIdDirectory, @"\!Archive\", weekDirectory);
|
||||
string destinationArchiveDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\Archive\", _Logistics.JobID, @"\", weekDirectory);
|
||||
if (!Directory.Exists(destinationArchiveDirectory))
|
||||
Directory.CreateDirectory(destinationArchiveDirectory);
|
||||
string[] matchDirectories = new string[] { GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).FirstOrDefault() };
|
||||
if ((matchDirectories is null) || matchDirectories.Length != 1)
|
||||
throw new Exception("Didn't find directory by logistics sequence");
|
||||
string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]);
|
||||
destinationArchiveDirectory = string.Concat(destinationArchiveDirectory, @"\", Path.GetFileName(sourceDirectory));
|
||||
Directory.Move(sourceDirectory, destinationArchiveDirectory);
|
||||
}
|
||||
|
||||
protected List<QS408M.Description> GetDescriptions(JsonElement[] jsonElements)
|
||||
{
|
||||
List<QS408M.Description> results = new();
|
||||
QS408M.Description description;
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
|
||||
foreach (JsonElement jsonElement in jsonElements)
|
||||
{
|
||||
if (jsonElement.ValueKind != JsonValueKind.Object)
|
||||
throw new Exception();
|
||||
description = JsonSerializer.Deserialize<QS408M.Description>(jsonElement.ToString(), jsonSerializerOptions);
|
||||
results.Add(description);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
string duplicateDirectory;
|
||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
||||
List<QS408M.Description> descriptions = GetDescriptions(jsonElements);
|
||||
Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, from l in descriptions select (Shared.Properties.IDescription)l, extra: false);
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>());
|
||||
bool isNotUsedInsightMetrologyViewerAttachments = (!(_FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments);
|
||||
bool isDummyRun = (_DummyRuns.Any() && _DummyRuns.ContainsKey(_Logistics.JobID) && _DummyRuns[_Logistics.JobID].Any() && (from l in _DummyRuns[_Logistics.JobID] where l == _Logistics.Sequence select 1).Any());
|
||||
if (isDummyRun)
|
||||
{
|
||||
try
|
||||
{ File.SetLastWriteTime(reportFullPath, dateTime); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
|
||||
if (_Hyphens != _HyphenIsXToOpenInsight)
|
||||
duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]);
|
||||
else
|
||||
duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\Data");
|
||||
if (segments.Length > 2)
|
||||
duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
|
||||
if (!Directory.Exists(duplicateDirectory))
|
||||
Directory.CreateDirectory(duplicateDirectory);
|
||||
if ((isDummyRun || isNotUsedInsightMetrologyViewerAttachments || _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _Hyphens != _HyphenIsXToArchive && _Hyphens != _HyphenIsArchive)
|
||||
{
|
||||
if (!Directory.Exists(duplicateDirectory))
|
||||
Directory.CreateDirectory(duplicateDirectory);
|
||||
string successDirectory;
|
||||
if (_Hyphens != _HyphenIsXToAPC)
|
||||
successDirectory = string.Empty;
|
||||
else
|
||||
{
|
||||
successDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\ViewerPath");
|
||||
if (!Directory.Exists(successDirectory))
|
||||
Directory.CreateDirectory(successDirectory);
|
||||
}
|
||||
List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new();
|
||||
string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath));
|
||||
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
|
||||
string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence);
|
||||
if (!Directory.Exists(logisticsSequenceMemoryDirectory))
|
||||
Directory.CreateDirectory(logisticsSequenceMemoryDirectory);
|
||||
if (_Hyphens == _HyphenIsXToAPC)
|
||||
{
|
||||
if (!isDummyRun && _IsEAFHosted)
|
||||
File.Copy(reportFullPath, duplicateFile, overwrite: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewer)
|
||||
{
|
||||
WSRequest wsRequest = new(this, _Logistics, descriptions);
|
||||
if (!isDummyRun && _IsEAFHosted)
|
||||
{
|
||||
Tuple<string, WS.Results> wsResults = WS.SendData(_OpenInsightMetrologyViewerAPI, wsRequest);
|
||||
if (!wsResults.Item2.Success)
|
||||
throw new Exception(wsResults.ToString());
|
||||
_Log.Debug(wsResults.Item2.HeaderID);
|
||||
File.WriteAllText(string.Concat(logisticsSequenceMemoryDirectory, @"\", nameof(WS.Results), ".json"), wsResults.Item1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Test test;
|
||||
string lines;
|
||||
Shared.Properties.IScopeInfo scopeInfo;
|
||||
foreach (KeyValuePair<Test, List<Shared.Properties.IDescription>> keyValuePair in tuple.Item2)
|
||||
{
|
||||
test = keyValuePair.Key;
|
||||
//scopeInfo = new ScopeInfo(test);
|
||||
if (_Hyphens != _HyphenIsXToOpenInsight)
|
||||
scopeInfo = new ScopeInfo(test, _IqsFile);
|
||||
else
|
||||
scopeInfo = new ScopeInfo(test, _OpenInsightFilePattern);
|
||||
//lines = ProcessDataStandardFormat.GetLines(this, scopeInfo, names, values, dateFormat: "M/d/yyyy hh:mm:ss tt", timeFormat: string.Empty, pairedColumns: ExtractResultPairedColumns);
|
||||
lines = ProcessData.GetLines(this, _Logistics, descriptions);
|
||||
tuples.Add(new Tuple<Shared.Properties.IScopeInfo, string>(scopeInfo, lines));
|
||||
}
|
||||
}
|
||||
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments)
|
||||
{
|
||||
string[] matchDirectories = Shared1567(reportFullPath, tuples);
|
||||
if (!isDummyRun && _IsEAFHosted && !isNotUsedInsightMetrologyViewerAttachments)
|
||||
ProcessData.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, dateTime, logisticsSequenceMemoryDirectory, descriptions, matchDirectories[0]);
|
||||
}
|
||||
}
|
||||
if (_Hyphens != _HyphenIsXToOpenInsightMetrologyViewer && _Hyphens != _HyphenIsXToOpenInsightMetrologyViewerAttachments)
|
||||
Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
|
||||
}
|
||||
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments)
|
||||
{
|
||||
string destinationDirectory;
|
||||
//string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples);
|
||||
FileInfo fileInfo = new(reportFullPath);
|
||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
|
||||
File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime);
|
||||
string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID);
|
||||
if (!Directory.Exists(jobIdDirectory))
|
||||
Directory.CreateDirectory(jobIdDirectory);
|
||||
string[] matchDirectories;
|
||||
if (!_IsEAFHosted)
|
||||
matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) };
|
||||
else
|
||||
matchDirectories = Directory.GetDirectories(jobIdDirectory, string.Concat(_Logistics.MID, '*', logisticsSequence, '*'), SearchOption.TopDirectoryOnly);
|
||||
if ((matchDirectories is null) || matchDirectories.Length != 1)
|
||||
throw new Exception("Didn't find directory by logistics sequence");
|
||||
destinationDirectory = matchDirectories[0];
|
||||
if (isDummyRun)
|
||||
Shared0607(reportFullPath, duplicateDirectory, logisticsSequence, destinationDirectory);
|
||||
else
|
||||
{
|
||||
WSRequest wsRequest = new(this, _Logistics, descriptions);
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
string json = JsonSerializer.Serialize(wsRequest, wsRequest.GetType(), jsonSerializerOptions);
|
||||
if (_IsEAFHosted)
|
||||
Shared1277(reportFullPath, destinationDirectory, logisticsSequence, jobIdDirectory, json);
|
||||
else
|
||||
{
|
||||
string jsonFileName = Path.ChangeExtension(reportFullPath, ".json");
|
||||
string historicalText = File.ReadAllText(jsonFileName);
|
||||
if (json != historicalText)
|
||||
throw new Exception("File doesn't match historical!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private void CallbackIsDummy(string traceDummyFile, List<Tuple<string, string, string, string, int>> tuples, bool fileConnectorConfigurationIncludeSubDirectories, bool includeSubDirectoriesExtra)
|
||||
{
|
||||
int fileCount;
|
||||
string[] files;
|
||||
string monARessource;
|
||||
string checkDirectory;
|
||||
string sourceArchiveFile;
|
||||
string inProcessDirectory;
|
||||
const string site = "sjc";
|
||||
string stateName = string.Concat("Dummy_", _EventName);
|
||||
const string monInURL = "http://moninhttp.sjc.infineon.com/input/text";
|
||||
MonIn monIn = MonIn.GetInstance(monInURL);
|
||||
foreach (Tuple<string, string, string, string, int> item in tuples)
|
||||
{
|
||||
monARessource = item.Item1;
|
||||
sourceArchiveFile = item.Item2;
|
||||
inProcessDirectory = item.Item3;
|
||||
checkDirectory = item.Item4;
|
||||
fileCount = item.Item5;
|
||||
try
|
||||
{
|
||||
if (fileCount > 0 || string.IsNullOrEmpty(checkDirectory))
|
||||
{
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() });
|
||||
monIn.SendStatus(site, monARessource, stateName, State.Warning);
|
||||
for (int i = 1; i < 12; i++)
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
else if (inProcessDirectory == checkDirectory)
|
||||
continue;
|
||||
if (!_IsEAFHosted)
|
||||
continue;
|
||||
if (!File.Exists(sourceArchiveFile))
|
||||
continue;
|
||||
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
|
||||
continue;
|
||||
ZipFile.ExtractToDirectory(sourceArchiveFile, inProcessDirectory);
|
||||
if (fileConnectorConfigurationIncludeSubDirectories && includeSubDirectoriesExtra)
|
||||
{
|
||||
if (_EventName == _EventNameFileRead)
|
||||
checkDirectory = string.Concat(checkDirectory, @"\", sequence);
|
||||
else if (_EventName == _EventNameFileReadDaily)
|
||||
checkDirectory = string.Concat(checkDirectory, @"\Source\", sequence);
|
||||
else
|
||||
throw new Exception();
|
||||
}
|
||||
if (fileConnectorConfigurationIncludeSubDirectories)
|
||||
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories);
|
||||
else
|
||||
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
if (files.Length > 250)
|
||||
throw new Exception("Safety net!");
|
||||
foreach (string file in files)
|
||||
File.SetLastWriteTime(file, new DateTime(sequence));
|
||||
if (!fileConnectorConfigurationIncludeSubDirectories)
|
||||
{
|
||||
foreach (string file in files)
|
||||
File.Move(file, string.Concat(checkDirectory, @"\", Path.GetFileName(file)));
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
|
||||
foreach (string directory in directories)
|
||||
Directory.CreateDirectory(string.Concat(checkDirectory, directory.Substring(inProcessDirectory.Length)));
|
||||
foreach (string file in files)
|
||||
File.Move(file, string.Concat(checkDirectory, file.Substring(inProcessDirectory.Length)));
|
||||
}
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Ok.ToString() });
|
||||
monIn.SendStatus(site, monARessource, stateName, State.Ok);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
|
||||
monIn.SendStatus(site, monARessource, stateName, State.Critical);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Callback(object state)
|
||||
{
|
||||
if (_Hyphens != _HyphenIsDummy)
|
||||
throw new Exception();
|
||||
try
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
bool check = (dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday);
|
||||
if (check)
|
||||
{
|
||||
int fileCount;
|
||||
string[] files;
|
||||
string monARessource;
|
||||
string checkDirectory;
|
||||
string sourceArchiveFile;
|
||||
string sourceFileLocation;
|
||||
string inProcessDirectory;
|
||||
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string traceDummyDirectory = string.Concat(Path.GetPathRoot(_TracePath), @"\TracesDummy\", _CellInstanceName, @"\Source\", dateTime.ToString("yyyy"), "___Week_", weekOfYear);
|
||||
if (!Directory.Exists(traceDummyDirectory))
|
||||
Directory.CreateDirectory(traceDummyDirectory);
|
||||
string traceDummyFile = string.Concat(traceDummyDirectory, @"\", dateTime.Ticks, " - ", _CellInstanceName, ".txt");
|
||||
File.AppendAllText(traceDummyFile, string.Empty);
|
||||
List<Tuple<string, string, string, string, int>> tuples = new();
|
||||
string progressDirectory = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\_ Progress"));
|
||||
if (progressDirectory != _ProgressPath || !Directory.Exists(progressDirectory))
|
||||
throw new Exception("Invalid progress path");
|
||||
foreach (KeyValuePair<string, string> keyValuePair in _CellNames)
|
||||
{
|
||||
monARessource = keyValuePair.Key;
|
||||
if (!keyValuePair.Value.Contains(@"\"))
|
||||
continue;
|
||||
foreach (string sourceFileFilter in _FileConnectorConfiguration.SourceFileFilter.Split('|'))
|
||||
{
|
||||
if (sourceFileFilter.ToLower().StartsWith(keyValuePair.Value.Replace(@"\", string.Empty)))
|
||||
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
|
||||
else if (_FileConnectorConfiguration.SourceFileLocation.ToLower().EndsWith(keyValuePair.Value))
|
||||
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
|
||||
else
|
||||
sourceFileLocation = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\", keyValuePair.Value));
|
||||
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, @"\", sourceFileFilter));
|
||||
if (!File.Exists(sourceArchiveFile))
|
||||
continue;
|
||||
if (!_DummyRuns.ContainsKey(monARessource))
|
||||
_DummyRuns.Add(monARessource, new List<long>());
|
||||
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceFileFilter, sourceFileLocation, sourceArchiveFile, 0));
|
||||
}
|
||||
}
|
||||
File.AppendAllLines(traceDummyFile, from l in tuples select l.Item4);
|
||||
if (tuples.Any())
|
||||
{
|
||||
_LastDummyRunIndex += 1;
|
||||
if (_LastDummyRunIndex >= tuples.Count)
|
||||
_LastDummyRunIndex = 0;
|
||||
monARessource = tuples[_LastDummyRunIndex].Item1;
|
||||
string sourceFileFilter = tuples[_LastDummyRunIndex].Item2;
|
||||
sourceFileLocation = tuples[_LastDummyRunIndex].Item3;
|
||||
sourceArchiveFile = tuples[_LastDummyRunIndex].Item4;
|
||||
//fileCount = tuples[_LastDummyRunIndex].Item5;
|
||||
tuples.Clear();
|
||||
if (long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
|
||||
{
|
||||
if (!_DummyRuns[monARessource].Contains(sequence))
|
||||
_DummyRuns[monARessource].Add(sequence);
|
||||
inProcessDirectory = string.Concat(progressDirectory, @"\Dummy_in process\", sequence);
|
||||
checkDirectory = inProcessDirectory;
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
Directory.CreateDirectory(checkDirectory);
|
||||
files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories);
|
||||
fileCount = files.Length;
|
||||
if (files.Any())
|
||||
{
|
||||
if (files.Length > 250)
|
||||
throw new Exception("Safety net!");
|
||||
try
|
||||
{
|
||||
foreach (string file in files)
|
||||
File.Delete(file);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
|
||||
checkDirectory = sourceFileLocation;
|
||||
files = Directory.GetFiles(checkDirectory, string.Concat("*", sequence, "*"), SearchOption.TopDirectoryOnly);
|
||||
fileCount = files.Length;
|
||||
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
|
||||
}
|
||||
}
|
||||
if (tuples.Any())
|
||||
//CallbackIsDummy(traceDummyFile, tuples, FileConnectorConfiguration.IncludeSubDirectories.Value, includeSubDirectoriesExtra: false);
|
||||
CallbackIsDummy(traceDummyFile, tuples, fileConnectorConfigurationIncludeSubDirectories: true, includeSubDirectoriesExtra: true);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
try
|
||||
{
|
||||
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
|
||||
_Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
18
Adaptation/FileHandlers/MET08THFTIRQS408M/Hyphen.cs
Normal file
18
Adaptation/FileHandlers/MET08THFTIRQS408M/Hyphen.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace Adaptation.FileHandlers.MET08THFTIRQS408M
|
||||
{
|
||||
|
||||
public enum Hyphen
|
||||
{
|
||||
IsXToOpenInsightMetrologyViewer, //MetrologyWS.SendData(file, string.Concat("http://", serverName, "/api/inbound/BioRad"));
|
||||
IsXToIQSSi, //NA <d7p1:FileScanningIntervalInSeconds>-361</d7p1:FileScanningIntervalInSeconds>
|
||||
IsXToOpenInsight, //bool WriteFileOpenInsight(BioRadFile
|
||||
IsXToOpenInsightMetrologyViewerAttachments, //Site-None <d7p1:FileScanningIntervalInSeconds>-362</d7p1:FileScanningIntervalInSeconds>
|
||||
IsXToAPC,
|
||||
IsXToSPaCe,
|
||||
IsXToArchive,
|
||||
IsArchive,
|
||||
IsDummy,
|
||||
IsNaEDA
|
||||
}
|
||||
|
||||
}
|
72
Adaptation/FileHandlers/MET08THFTIRQS408M/ProcessData.cs
Normal file
72
Adaptation/FileHandlers/MET08THFTIRQS408M/ProcessData.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.MET08THFTIRQS408M
|
||||
{
|
||||
|
||||
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 string GetLines(IFileRead fileRead, Logistics logistics, List<QS408M.Description> descriptions)
|
||||
{
|
||||
StringBuilder results = new();
|
||||
char del = '\t';
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
if (logistics is null)
|
||||
{ }
|
||||
QS408M.Description x = descriptions[0];
|
||||
results.Append(x.UniqueId).Append(del).
|
||||
Append(x.Date).Append(del).
|
||||
Append(x.Employee).Append(del).
|
||||
Append(x.Recipe).Append(del).
|
||||
Append(x.Reactor).Append(del).
|
||||
Append(x.RDS).Append(del).
|
||||
Append(x.PSN).Append(del).
|
||||
Append(x.Layer).Append(del).
|
||||
Append(x.Zone).Append(del).
|
||||
Append(x.Cassette).Append(del).
|
||||
Append(x.Wafer).Append(del).
|
||||
Append(x.RVThickness);
|
||||
return results.ToString();
|
||||
}
|
||||
|
||||
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, DateTime dateTime, string logisticsSequenceMemoryDirectory, List<QS408M.Description> descriptions, string matchDirectory)
|
||||
{
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
if (logistics is null)
|
||||
{ }
|
||||
if (openInsightMetrologyViewerAPI is null)
|
||||
{ }
|
||||
if (dateTime == DateTime.MinValue)
|
||||
{ }
|
||||
if (logisticsSequenceMemoryDirectory is null)
|
||||
{ }
|
||||
if (descriptions is null)
|
||||
{ }
|
||||
if (matchDirectory is null)
|
||||
{ }
|
||||
//Not used
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
89
Adaptation/FileHandlers/MET08THFTIRQS408M/WSRequest.cs
Normal file
89
Adaptation/FileHandlers/MET08THFTIRQS408M/WSRequest.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Adaptation.FileHandlers.MET08THFTIRQS408M
|
||||
{
|
||||
|
||||
public class WSRequest
|
||||
{
|
||||
public bool SentToMetrology { get; set; }
|
||||
public bool SentToSPC { get; set; }
|
||||
//
|
||||
public long Id { get; set; }
|
||||
public string Batch { get; set; }
|
||||
public string Cassette { get; set; }
|
||||
public string CellName { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public string Layer { get; set; }
|
||||
public string MeanThickness { get; set; }
|
||||
public string Op { get; set; }
|
||||
public string PSN { get; set; }
|
||||
public string PassFail { get; set; }
|
||||
public string RDS { get; set; }
|
||||
public string RVThickness { get; set; }
|
||||
public string Reactor { get; set; }
|
||||
public string Recipe { get; set; }
|
||||
public string StdDev { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
public string Zone { get; set; }
|
||||
public List<QS408M.Detail> Details { get; protected set; }
|
||||
|
||||
[Obsolete("For json")] public WSRequest() { }
|
||||
|
||||
internal WSRequest(IFileRead fileRead, Logistics logistics, List<QS408M.Description> descriptions)
|
||||
{
|
||||
Id = 0;
|
||||
FilePath = string.Empty;
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
CellName = logistics.MesEntity;
|
||||
if (descriptions[0] is not QS408M.Description x)
|
||||
throw new Exception();
|
||||
Details = new List<QS408M.Detail>();
|
||||
//Header
|
||||
{
|
||||
Batch = x.Lot;
|
||||
Cassette = x.Cassette;
|
||||
Date = x.Date;
|
||||
Op = x.Employee;
|
||||
Layer = x.Layer;
|
||||
MeanThickness = x.MeanThickness;
|
||||
PSN = x.PSN;
|
||||
PassFail = x.PassFail;
|
||||
RDS = x.RDS;
|
||||
RVThickness = x.RVThickness;
|
||||
Reactor = x.Reactor;
|
||||
Recipe = x.Recipe;
|
||||
StdDev = x.StdDev;
|
||||
Title = x.Title;
|
||||
UniqueId = x.UniqueId;
|
||||
Wafer = x.Wafer;
|
||||
Zone = x.Zone;
|
||||
}
|
||||
QS408M.Detail detail;
|
||||
foreach (QS408M.Description description in descriptions)
|
||||
{
|
||||
detail = new QS408M.Detail
|
||||
{
|
||||
HeaderUniqueId = description.HeaderUniqueId,
|
||||
Position = description.Position,
|
||||
Thickness = description.Thickness,
|
||||
UniqueId = description.UniqueId
|
||||
};
|
||||
Details.Add(detail);
|
||||
}
|
||||
if (Date is null)
|
||||
Date = logistics.DateTimeFromSequence.ToString();
|
||||
if (UniqueId is null && Details.Any())
|
||||
UniqueId = Details[0].HeaderUniqueId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
276
Adaptation/FileHandlers/QS408M/Description.cs
Normal file
276
Adaptation/FileHandlers/QS408M/Description.cs
Normal file
@ -0,0 +1,276 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.QS408M
|
||||
{
|
||||
|
||||
public class Description : IDescription, Shared.Properties.IDescription
|
||||
{
|
||||
|
||||
|
||||
public int Test { get; set; }
|
||||
public int Count { get; set; }
|
||||
public int Index { get; set; }
|
||||
//
|
||||
public string EventName { get; set; }
|
||||
public string NullData { get; set; }
|
||||
public string JobID { get; set; }
|
||||
public string Sequence { get; set; }
|
||||
public string MesEntity { get; set; }
|
||||
public string ReportFullPath { get; set; }
|
||||
public string ProcessJobID { get; set; }
|
||||
public string MID { get; set; }
|
||||
//
|
||||
public string Date { get; set; }
|
||||
public string Employee { get; set; }
|
||||
public string Lot { get; set; }
|
||||
public string PSN { get; set; }
|
||||
public string Reactor { get; set; }
|
||||
public string Recipe { get; set; }
|
||||
//
|
||||
public string Cassette { get; set; }
|
||||
public string HeaderUniqueId { get; set; }
|
||||
public string Layer { get; set; }
|
||||
public string PassFail { get; set; }
|
||||
public string Position { get; set; }
|
||||
public string RDS { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
public string Zone { get; set; }
|
||||
//
|
||||
public string MeanThickness { get; set; }
|
||||
public string RVThickness { get; set; }
|
||||
public string StdDev { get; set; }
|
||||
public string Thickness { get; set; }
|
||||
|
||||
string IDescription.GetEventDescription()
|
||||
{
|
||||
return "File Has been read and parsed";
|
||||
}
|
||||
|
||||
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
List<string> results = new();
|
||||
IDescription description = GetDefault(fileRead, logistics);
|
||||
string json = JsonSerializer.Serialize(description, description.GetType());
|
||||
object @object = JsonSerializer.Deserialize<object>(json);
|
||||
if (@object is not JsonElement jsonElement)
|
||||
throw new Exception();
|
||||
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
|
||||
results.Add(jsonProperty.Name);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetDetailNames()
|
||||
{
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(Cassette),
|
||||
nameof(HeaderUniqueId),
|
||||
nameof(Layer),
|
||||
nameof(PassFail),
|
||||
nameof(Position),
|
||||
nameof(RDS),
|
||||
nameof(Title),
|
||||
nameof(UniqueId),
|
||||
nameof(Wafer),
|
||||
nameof(Zone)
|
||||
};
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetHeaderNames()
|
||||
{
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(Date),
|
||||
nameof(Employee),
|
||||
nameof(Lot),
|
||||
nameof(PSN),
|
||||
nameof(Reactor),
|
||||
nameof(Recipe)
|
||||
};
|
||||
return results;
|
||||
}
|
||||
|
||||
IDescription IDescription.GetDisplayNames()
|
||||
{
|
||||
Description result = GetDisplayNames();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetParameterNames()
|
||||
{
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(MeanThickness),
|
||||
nameof(RVThickness),
|
||||
nameof(StdDev),
|
||||
nameof(Thickness)
|
||||
};
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
JsonProperty[] results;
|
||||
IDescription description = GetDefault(fileRead, logistics);
|
||||
string json = JsonSerializer.Serialize(description, description.GetType());
|
||||
object @object = JsonSerializer.Deserialize<object>(json);
|
||||
results = ((JsonElement)@object).EnumerateObject().ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetPairedParameterNames()
|
||||
{
|
||||
List<string> results = new();
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetIgnoreParameterNames(Test test)
|
||||
{
|
||||
List<string> results = new();
|
||||
return results;
|
||||
}
|
||||
|
||||
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
Description result = GetDefault(fileRead, logistics);
|
||||
return result;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
|
||||
{
|
||||
Dictionary<string, string> results = new();
|
||||
IDescription description = GetDisplayNames();
|
||||
string json = JsonSerializer.Serialize(description, description.GetType());
|
||||
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
||||
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
|
||||
{
|
||||
if (!results.ContainsKey(jsonProperty.Name))
|
||||
results.Add(jsonProperty.Name, string.Empty);
|
||||
if (jsonProperty.Value is JsonElement jsonPropertyValue)
|
||||
results[jsonProperty.Name] = jsonPropertyValue.ToString();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
|
||||
{
|
||||
List<IDescription> results = new();
|
||||
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
|
||||
results.Add(GetDefault(fileRead, logistics));
|
||||
else
|
||||
{
|
||||
string nullData;
|
||||
Description description;
|
||||
object configDataNullData = fileRead.NullData;
|
||||
if (configDataNullData is null)
|
||||
nullData = string.Empty;
|
||||
else
|
||||
nullData = configDataNullData.ToString();
|
||||
for (int i = 0; i < iProcessData.Details.Count; i++)
|
||||
{
|
||||
if (iProcessData.Details[i] is not Detail detail)
|
||||
continue;
|
||||
description = new Description
|
||||
{
|
||||
Test = (int)tests[i],
|
||||
Count = tests.Count,
|
||||
Index = i,
|
||||
//
|
||||
EventName = fileRead.EventName,
|
||||
NullData = nullData,
|
||||
JobID = fileRead.CellInstanceName,
|
||||
Sequence = logistics.Sequence.ToString(),
|
||||
MesEntity = logistics.MesEntity,
|
||||
ReportFullPath = logistics.ReportFullPath,
|
||||
ProcessJobID = logistics.ProcessJobID,
|
||||
MID = logistics.MID,
|
||||
//
|
||||
Date = processData.Date,
|
||||
Employee = processData.Employee,
|
||||
Lot = processData.Batch,
|
||||
PSN = processData.PSN,
|
||||
Reactor = processData.Reactor,
|
||||
Recipe = processData.Recipe,
|
||||
//
|
||||
Cassette = processData.Cassette,
|
||||
HeaderUniqueId = detail.HeaderUniqueId,
|
||||
Layer = processData.Layer,
|
||||
PassFail = processData.PassFail,
|
||||
Position = detail.Position,
|
||||
RDS = processData.RDS,
|
||||
Title = processData.Title,
|
||||
UniqueId = detail.UniqueId,
|
||||
Wafer = processData.Wafer,
|
||||
Zone = processData.Zone,
|
||||
//
|
||||
MeanThickness = processData.MeanThickness,
|
||||
RVThickness = processData.RVThickness,
|
||||
StdDev = processData.StdDev,
|
||||
Thickness = detail.Thickness
|
||||
};
|
||||
results.Add(description);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private Description GetDisplayNames()
|
||||
{
|
||||
Description result = new();
|
||||
return result;
|
||||
}
|
||||
|
||||
private Description GetDefault(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
Description result = new()
|
||||
{
|
||||
Test = -1,
|
||||
Count = 0,
|
||||
Index = -1,
|
||||
//
|
||||
EventName = fileRead.EventName,
|
||||
NullData = fileRead.NullData,
|
||||
JobID = fileRead.CellInstanceName,
|
||||
Sequence = logistics.Sequence.ToString(),
|
||||
MesEntity = fileRead.MesEntity,
|
||||
ReportFullPath = logistics.ReportFullPath,
|
||||
ProcessJobID = logistics.ProcessJobID,
|
||||
MID = logistics.MID,
|
||||
//
|
||||
Date = nameof(Date),
|
||||
Employee = nameof(Employee),
|
||||
Lot = nameof(Lot),
|
||||
PSN = nameof(PSN),
|
||||
Reactor = nameof(Reactor),
|
||||
Recipe = nameof(Recipe),
|
||||
//
|
||||
Cassette = nameof(Cassette),
|
||||
HeaderUniqueId = nameof(HeaderUniqueId),
|
||||
Layer = nameof(Layer),
|
||||
PassFail = nameof(PassFail),
|
||||
Position = nameof(Position),
|
||||
RDS = nameof(RDS),
|
||||
Title = nameof(Title),
|
||||
UniqueId = nameof(UniqueId),
|
||||
Wafer = nameof(Wafer),
|
||||
Zone = nameof(Zone),
|
||||
//
|
||||
MeanThickness = nameof(MeanThickness),
|
||||
RVThickness = nameof(RVThickness),
|
||||
StdDev = nameof(StdDev),
|
||||
Thickness = nameof(Thickness)
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
19
Adaptation/FileHandlers/QS408M/Detail.cs
Normal file
19
Adaptation/FileHandlers/QS408M/Detail.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace Adaptation.FileHandlers.QS408M
|
||||
{
|
||||
|
||||
public class Detail
|
||||
{
|
||||
|
||||
public string HeaderUniqueId { get; set; }
|
||||
public string Position { get; set; }
|
||||
public string Thickness { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Concat(Position, ";", Thickness, ";");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
150
Adaptation/FileHandlers/QS408M/FileRead.cs
Normal file
150
Adaptation/FileHandlers/QS408M/FileRead.cs
Normal file
@ -0,0 +1,150 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Adaptation.FileHandlers.QS408M
|
||||
{
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
private readonly string _OriginalDataBioRad;
|
||||
private readonly ProcessData _LastProcessData;
|
||||
|
||||
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) :
|
||||
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new Logistics(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
_OriginalDataBioRad = "OriginalDataBioRad_";
|
||||
_LastProcessData = new();
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
|
||||
{
|
||||
Move(this, extractResults, exception);
|
||||
}
|
||||
|
||||
void IFileRead.WaitForThread()
|
||||
{
|
||||
WaitForThread(thread: null, threadExceptions: null);
|
||||
}
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
throw new Exception();
|
||||
_ReportFullPath = reportFullPath;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
results = GetExtractResult(reportFullPath, dateTime);
|
||||
if (results.Item3 is null)
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, new Test[] { }, JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||
WritePDSF(this, results.Item3);
|
||||
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<string> headerNames = _Description.GetHeaderNames();
|
||||
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||
results = ReExtract(this, headerNames, keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
void IFileRead.CheckTests(Test[] tests, bool extra)
|
||||
{
|
||||
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
|
||||
}
|
||||
|
||||
void IFileRead.MoveArchive()
|
||||
{
|
||||
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
|
||||
}
|
||||
|
||||
void IFileRead.Callback(object state)
|
||||
{
|
||||
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
|
||||
}
|
||||
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
|
||||
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
if (reportFullPath.Length < _MinFileLength)
|
||||
results.Item4.Add(new FileInfo(reportFullPath));
|
||||
else
|
||||
{
|
||||
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _OriginalDataBioRad, lastProcessData: _LastProcessData);
|
||||
if (iProcessData is ProcessData processData)
|
||||
{
|
||||
string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN);
|
||||
mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
|
||||
_Logistics.MID = mid;
|
||||
SetFileParameterLotID(mid);
|
||||
_Logistics.ProcessJobID = processData.Reactor;
|
||||
}
|
||||
if (!iProcessData.Details.Any())
|
||||
throw new Exception(string.Concat("No Data - ", dateTime.Ticks));
|
||||
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
435
Adaptation/FileHandlers/QS408M/ProcessData.cs
Normal file
435
Adaptation/FileHandlers/QS408M/ProcessData.cs
Normal file
@ -0,0 +1,435 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Adaptation.FileHandlers.QS408M
|
||||
{
|
||||
|
||||
public partial class ProcessData : IProcessData
|
||||
{
|
||||
|
||||
private readonly List<object> _Details;
|
||||
|
||||
public string JobID { get; set; }
|
||||
public string MesEntity { get; set; }
|
||||
public string Batch { get; set; }
|
||||
public string Cassette { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Employee { get; set; }
|
||||
public string Layer { get; set; }
|
||||
public string MeanThickness { get; set; }
|
||||
public string PSN { get; set; }
|
||||
public string PassFail { get; set; }
|
||||
public string RDS { get; set; }
|
||||
public string RVThickness { get; set; }
|
||||
public string Reactor { get; set; }
|
||||
public string Recipe { get; set; }
|
||||
public string StdDev { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
public string Zone { get; set; }
|
||||
|
||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||
|
||||
private int _I;
|
||||
private string _Data;
|
||||
private readonly ILog _Log;
|
||||
|
||||
public ProcessData()
|
||||
{
|
||||
}
|
||||
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData)
|
||||
{
|
||||
JobID = logistics.JobID;
|
||||
fileInfoCollection.Clear();
|
||||
_Details = new List<object>();
|
||||
MesEntity = logistics.MesEntity;
|
||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||
Parse(fileRead, logistics, fileInfoCollection, originalDataBioRad, lastProcessData);
|
||||
}
|
||||
|
||||
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors)
|
||||
{
|
||||
throw new Exception(string.Concat("See ", nameof(Parse)));
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<Test> tests = new();
|
||||
foreach (object item in _Details)
|
||||
tests.Add(Test.BioRadQS408M);
|
||||
List<IDescription> descriptions = fileRead.GetDescriptions(fileRead, tests, this);
|
||||
if (tests.Count != descriptions.Count)
|
||||
throw new Exception();
|
||||
for (int i = 0; i < tests.Count; i++)
|
||||
{
|
||||
if (descriptions[i] is not Description description)
|
||||
throw new Exception();
|
||||
if (description.Test != (int)tests[i])
|
||||
throw new Exception();
|
||||
}
|
||||
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
|
||||
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
|
||||
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
|
||||
return results;
|
||||
}
|
||||
|
||||
private string GetBefore(string text)
|
||||
{
|
||||
string str;
|
||||
string str1;
|
||||
int num = _Data.IndexOf(text, _I);
|
||||
if (num <= -1)
|
||||
{
|
||||
str = _Data.Substring(_I);
|
||||
_I = _Data.Length;
|
||||
str1 = str.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
str = _Data.Substring(_I, num - _I);
|
||||
_I = num + text.Length;
|
||||
str1 = str.Trim();
|
||||
}
|
||||
return str1;
|
||||
}
|
||||
|
||||
private string GetBefore(string text, bool trim)
|
||||
{
|
||||
string str;
|
||||
string before;
|
||||
if (!trim)
|
||||
{
|
||||
int num = _Data.IndexOf(text, _I);
|
||||
if (num <= -1)
|
||||
{
|
||||
str = _Data.Substring(_I);
|
||||
_I = _Data.Length;
|
||||
before = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = _Data.Substring(_I, num - _I);
|
||||
_I = num + text.Length;
|
||||
before = str;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
before = GetBefore(text);
|
||||
}
|
||||
return before;
|
||||
}
|
||||
|
||||
private string GetToEOL()
|
||||
{
|
||||
string result;
|
||||
if (_Data.IndexOf("\n", _I) > -1)
|
||||
result = GetBefore("\n");
|
||||
else
|
||||
result = GetBefore(Environment.NewLine);
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetToEOL(bool trim)
|
||||
{
|
||||
string str;
|
||||
if (_Data.IndexOf("\n", _I) > -1)
|
||||
str = (!trim ? GetBefore("\n", false) : GetToEOL());
|
||||
else
|
||||
str = (!trim ? GetBefore(Environment.NewLine, false) : GetToEOL());
|
||||
return str;
|
||||
}
|
||||
|
||||
private string GetToken()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (_I >= _Data.Length || !IsNullOrWhiteSpace(_Data.Substring(_I, 1)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
_I++;
|
||||
}
|
||||
int num = _I;
|
||||
while (true)
|
||||
{
|
||||
if (num >= _Data.Length || IsNullOrWhiteSpace(_Data.Substring(num, 1)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
string str = _Data.Substring(_I, num - _I);
|
||||
_I = num;
|
||||
return str.Trim();
|
||||
}
|
||||
|
||||
private string GetToText(string text)
|
||||
{
|
||||
string str = _Data.Substring(_I, _Data.IndexOf(text, _I) - _I).Trim();
|
||||
return str;
|
||||
}
|
||||
|
||||
private bool IsBlankLine()
|
||||
{
|
||||
int num = _Data.IndexOf("\n", _I);
|
||||
return IsNullOrWhiteSpace((num > -1 ? _Data.Substring(_I, num - _I) : _Data.Substring(_I)));
|
||||
}
|
||||
|
||||
private bool IsNullOrWhiteSpace(string text)
|
||||
{
|
||||
bool flag;
|
||||
int num = 0;
|
||||
while (true)
|
||||
{
|
||||
if (num >= text.Length)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
else if (char.IsWhiteSpace(text[num]))
|
||||
{
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private string PeekNextLine()
|
||||
{
|
||||
int num = _I;
|
||||
string toEOL = GetToEOL();
|
||||
_I = num;
|
||||
return toEOL;
|
||||
}
|
||||
|
||||
private void ScanPast(string text)
|
||||
{
|
||||
int num = _Data.IndexOf(text, _I);
|
||||
if (num <= -1)
|
||||
{
|
||||
_I = _Data.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
_I = num + text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
internal static DateTime GetDateTime(Logistics logistics, string dateTimeText)
|
||||
{
|
||||
DateTime result;
|
||||
string inputDateFormat = "ddd mmm dd HH:mm:ss yyyy";
|
||||
if (dateTimeText.Length != inputDateFormat.Length)
|
||||
result = logistics.DateTimeFromSequence;
|
||||
else
|
||||
{
|
||||
if (!DateTime.TryParseExact(dateTimeText, inputDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed))
|
||||
result = logistics.DateTimeFromSequence;
|
||||
else
|
||||
{
|
||||
if (dateTimeParsed < logistics.DateTimeFromSequence.AddDays(1) && dateTimeParsed > logistics.DateTimeFromSequence.AddDays(-1))
|
||||
result = dateTimeParsed;
|
||||
else
|
||||
result = logistics.DateTimeFromSequence;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData)
|
||||
{
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
_I = 0;
|
||||
_Data = string.Empty;
|
||||
List<Detail> details = new();
|
||||
string receivedData = File.ReadAllText(logistics.ReportFullPath);
|
||||
_Log.Debug($"****ParseData - Source file contents:");
|
||||
_Log.Debug(receivedData);
|
||||
string[] files = Directory.GetFiles(Path.GetDirectoryName(logistics.ReportFullPath), string.Concat(originalDataBioRad, logistics.Sequence, "*"), SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
fileInfoCollection.Add(new FileInfo(file));
|
||||
// occasionally there are multiple blocks of results, get the last one as earlier ones may be aborted runs.
|
||||
int index = receivedData.LastIndexOf("Bio-Rad");
|
||||
if (index > -1)
|
||||
receivedData = receivedData.Substring(index);
|
||||
_Log.Debug($"****ParseData - Source file contents to be parsed:");
|
||||
_Log.Debug(receivedData);
|
||||
if (!string.IsNullOrEmpty(receivedData))
|
||||
{
|
||||
_I = 0;
|
||||
_Data = receivedData;
|
||||
Title = GetBefore("Recipe:");
|
||||
Recipe = GetToken();
|
||||
string dateTimeText = GetToEOL();
|
||||
if (dateTimeText.EndsWith("."))
|
||||
dateTimeText = dateTimeText.Remove(dateTimeText.Length - 1, 1);
|
||||
DateTime dateTime = GetDateTime(logistics, dateTimeText);
|
||||
Date = dateTime.ToString();
|
||||
ScanPast("operator:");
|
||||
Employee = GetBefore("batch:");
|
||||
Batch = GetToEOL();
|
||||
// Remove illegal characters \/:*?"<>| found in the Batch
|
||||
Batch = Regex.Replace(Batch, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
|
||||
ScanPast("cassette:");
|
||||
Cassette = GetBefore("wafer:");
|
||||
if (string.IsNullOrEmpty(Batch))
|
||||
{
|
||||
_I = 0;
|
||||
_Data = receivedData;
|
||||
ScanPast("wafer:");
|
||||
}
|
||||
Wafer = GetToEOL();
|
||||
GetToEOL();
|
||||
GetToEOL();
|
||||
string token = GetToken();
|
||||
int counter = 1;
|
||||
while (true)
|
||||
{
|
||||
if ((string.IsNullOrEmpty(token) || !char.IsDigit(token[0])))
|
||||
break;
|
||||
Detail detail = new()
|
||||
{
|
||||
Position = token,
|
||||
Thickness = GetToken(),
|
||||
UniqueId = string.Concat("_Point-", counter)
|
||||
};
|
||||
details.Add(detail);
|
||||
token = GetToken();
|
||||
counter++;
|
||||
}
|
||||
ScanPast("mean thickness =");
|
||||
MeanThickness = GetBefore(", std. dev =");
|
||||
StdDev = GetToken();
|
||||
PassFail = GetToEOL();
|
||||
ScanPast("thickness");
|
||||
RVThickness = GetToEOL();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Wafer))
|
||||
throw new Exception("Wafer field is missing.");
|
||||
|
||||
//parse out batch and validate
|
||||
string[] parsedBatch = Wafer.Split('-');
|
||||
if (parsedBatch.Length >= 1)
|
||||
Reactor = parsedBatch[0];
|
||||
if (parsedBatch.Length >= 2)
|
||||
RDS = parsedBatch[1];
|
||||
if (parsedBatch.Length >= 3)
|
||||
{
|
||||
string[] parsedPSN = parsedBatch[2].Split('.');
|
||||
if (parsedPSN.Length >= 1)
|
||||
PSN = parsedPSN[0];
|
||||
if (parsedPSN.Length >= 2)
|
||||
Layer = parsedPSN[1];
|
||||
}
|
||||
if (parsedBatch.Length >= 4)
|
||||
Zone = parsedBatch[3];
|
||||
|
||||
JobID = logistics.JobID;
|
||||
|
||||
if (logistics.DateTimeFromSequence > DateTime.Now.AddHours(-24))
|
||||
{
|
||||
if (string.IsNullOrEmpty(lastProcessData.Wafer))
|
||||
{
|
||||
lastProcessData.Batch = JobID;
|
||||
lastProcessData.Cassette = JobID;
|
||||
lastProcessData.Employee = JobID;
|
||||
lastProcessData.Recipe = JobID;
|
||||
lastProcessData.Title = JobID;
|
||||
}
|
||||
lastProcessData.Wafer = Wafer;
|
||||
lastProcessData.Reactor = Reactor;
|
||||
lastProcessData.RDS = RDS;
|
||||
|
||||
string check = "--------";
|
||||
if (string.IsNullOrEmpty(Batch) || Batch.Contains(check))
|
||||
Batch = lastProcessData.Batch;
|
||||
else
|
||||
lastProcessData.Batch = Batch;
|
||||
if (string.IsNullOrEmpty(Cassette) || Cassette.Contains(check))
|
||||
Cassette = lastProcessData.Cassette;
|
||||
else
|
||||
lastProcessData.Cassette = Cassette;
|
||||
if (string.IsNullOrEmpty(Employee) || Employee.Contains(check))
|
||||
Employee = lastProcessData.Employee;
|
||||
else
|
||||
lastProcessData.Employee = Employee;
|
||||
if (string.IsNullOrEmpty(Recipe) || Recipe.Contains(check))
|
||||
Recipe = lastProcessData.Recipe;
|
||||
else
|
||||
lastProcessData.Recipe = Recipe;
|
||||
if (string.IsNullOrEmpty(Title) || Title.Contains(check))
|
||||
Title = lastProcessData.Title;
|
||||
else
|
||||
lastProcessData.Title = Title;
|
||||
}
|
||||
|
||||
//fix title
|
||||
StringBuilder titleFixed = new();
|
||||
foreach (char c in Title)
|
||||
{
|
||||
if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
|
||||
titleFixed.Append(c);
|
||||
}
|
||||
Title = titleFixed.ToString();
|
||||
|
||||
//fix wafer
|
||||
StringBuilder waferFixed = new();
|
||||
foreach (char c in Wafer)
|
||||
{
|
||||
if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
|
||||
waferFixed.Append(c);
|
||||
}
|
||||
Wafer = waferFixed.ToString();
|
||||
|
||||
//create filename / unique id
|
||||
UniqueId = string.Concat(Title, "_", Wafer, "_", logistics.DateTimeFromSequence.ToString("yyyyMMddHHmmssffff"));
|
||||
foreach (Detail detail in details)
|
||||
{
|
||||
detail.HeaderUniqueId = UniqueId;
|
||||
detail.UniqueId = string.Concat(UniqueId, detail.UniqueId);
|
||||
}
|
||||
|
||||
//trace datatype
|
||||
_Log.Debug("BioRad parsed infomation:");
|
||||
_Log.Debug(string.Format("Batch: {0}", Batch));
|
||||
_Log.Debug(string.Format("Cassette: {0}", Cassette));
|
||||
_Log.Debug(string.Format("Date: {0}", Date));
|
||||
foreach (Detail bioRadDetail in details)
|
||||
_Log.Debug(string.Format("Details: {0} - {1}", bioRadDetail.Position, bioRadDetail.Thickness));
|
||||
_Log.Debug(string.Format("Mean Thickness: {0}", MeanThickness));
|
||||
_Log.Debug(string.Format("Operator: {0}", Employee));
|
||||
_Log.Debug(string.Format("Pass/Fail: {0}", PassFail));
|
||||
_Log.Debug(string.Format("Recipe: {0}", Recipe));
|
||||
_Log.Debug(string.Format("RV Thickness: {0}", RVThickness));
|
||||
_Log.Debug(string.Format("Std Dev: {0}", StdDev));
|
||||
_Log.Debug(string.Format("Title: {0}", Title));
|
||||
_Log.Debug(string.Format("Wafer: {0}", Wafer));
|
||||
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath));
|
||||
_Details.AddRange(details);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user