147 lines
6.3 KiB
C#
147 lines
6.3 KiB
C#
using Adaptation.Shared;
|
|
using Adaptation.Shared.Metrology;
|
|
using log4net;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text.Json;
|
|
|
|
namespace Adaptation.Helpers
|
|
{
|
|
|
|
public partial class ProcessData : IProcessData
|
|
{
|
|
|
|
public class DiffusionLengthDetail
|
|
{
|
|
|
|
public string Reactor { get; set; }
|
|
public string Employee { get; set; }
|
|
public string Recipe { get; set; }
|
|
public string Slot { get; set; }
|
|
public string DiffusionLength { get; set; }
|
|
public string DiffusionLengthStandardDeviation { get; set; }
|
|
|
|
}
|
|
|
|
private readonly ILog _Log;
|
|
public List<DiffusionLengthDetail> Details { get; private set; }
|
|
|
|
public ProcessData(ILogic logic, ConfigData configData, List<FileInfo> fileInfoCollection, string lot, string pocketNumber)
|
|
{
|
|
_Log = LogManager.GetLogger(typeof(ProcessData));
|
|
Details = new List<DiffusionLengthDetail>();
|
|
DiffusionLengthDetail diffusionLengthDetail;
|
|
var data = ProcessDataStandardFormat.GetProcessDataStandardFormat(logic.Logistics.ReportFullPath);
|
|
Dictionary<Test, Dictionary<string, List<string>>> item2 = data.Item2;
|
|
if (item2.Any())
|
|
{
|
|
Dictionary<string, List<string>> keyValuePairs = item2.ElementAt(0).Value;
|
|
int count = keyValuePairs[Column.Time.ToString()].Count;
|
|
if (count > 0)
|
|
{
|
|
string key;
|
|
string carrier;
|
|
string[] segments;
|
|
string logistics = data.Item1;
|
|
key = "CARRIER=";
|
|
if (!logistics.Contains(key))
|
|
carrier = string.Empty;
|
|
else
|
|
{
|
|
segments = logistics.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
|
carrier = segments[1].Split(';')[0];
|
|
}
|
|
string mid;
|
|
key = "MID=";
|
|
if (!logistics.Contains(key))
|
|
mid = string.Empty;
|
|
else
|
|
{
|
|
segments = logistics.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
|
mid = segments[1].Split(';')[0];
|
|
}
|
|
string ppid;
|
|
key = "PPID=";
|
|
if (!logistics.Contains(key))
|
|
ppid = string.Empty;
|
|
else
|
|
{
|
|
segments = logistics.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
|
ppid = segments[1].Split(';')[0];
|
|
}
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
diffusionLengthDetail = new DiffusionLengthDetail
|
|
{
|
|
Reactor = string.Empty,
|
|
Employee = "AUTO",
|
|
Recipe = ppid,
|
|
Slot = keyValuePairs["SlotNumber"][i],
|
|
DiffusionLength = keyValuePairs["WW_SPV_DL_LBEF_AVG"][i],
|
|
DiffusionLengthStandardDeviation = keyValuePairs["WW_SPV_DL_LBEF_STD"][i]
|
|
};
|
|
if (!string.IsNullOrEmpty(mid))
|
|
diffusionLengthDetail.Reactor = mid.Substring(0, 3);
|
|
Details.Add(diffusionLengthDetail);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public Tuple<string, JsonElement?, List<FileInfo>> GetResults(ILogic logic, ConfigDataBase configDataBase, List<FileInfo> fileInfoCollection)
|
|
{
|
|
Tuple<string, JsonElement?, List<FileInfo>> results;
|
|
if (!(configDataBase is ConfigData configData))
|
|
throw new Exception();
|
|
List<Test> tests = new List<Test>();
|
|
List<IProcessDataDescription> descriptions;
|
|
EventName eventName = configData.GetEventNameValue();
|
|
if (eventName == EventName.FileRead && Details.Any())
|
|
{
|
|
foreach (var item in Details)
|
|
tests.Add(Test);
|
|
descriptions = configData.GetDescription(logic, tests, this);
|
|
}
|
|
else
|
|
throw new Exception();
|
|
if (!configData.EafHosted)
|
|
new FileRead.Description().GetDescription(logic, configData, tests, this);
|
|
if (tests.Count != descriptions.Count)
|
|
throw new Exception();
|
|
for (int i = 0; i < tests.Count; i++)
|
|
{
|
|
if (descriptions[i].Test != (int)tests[i])
|
|
throw new Exception();
|
|
}
|
|
string json;
|
|
if (descriptions[0] is Duplicator.Description)
|
|
{
|
|
List<Duplicator.Description> duplicatorDescriptions = (from l in descriptions select (Duplicator.Description)l).ToList();
|
|
json = JsonSerializer.Serialize(duplicatorDescriptions, duplicatorDescriptions.GetType());
|
|
}
|
|
else if (descriptions[0] is FileRead.Description)
|
|
{
|
|
List<FileRead.Description> fileReadDescriptions = (from l in descriptions select (FileRead.Description)l).ToList();
|
|
json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
|
|
}
|
|
else
|
|
throw new Exception();
|
|
object @object = JsonSerializer.Deserialize<object>(json);
|
|
if (!(@object is JsonElement jsonElement))
|
|
throw new Exception();
|
|
results = new Tuple<string, JsonElement?, List<FileInfo>>(logic.Logistics.Logistics1[0], jsonElement, fileInfoCollection);
|
|
return results;
|
|
}
|
|
|
|
public static Dictionary<Test, List<Duplicator.Description>> GetKeyValuePairs(ConfigData configData, JsonElement jsonElement, List<Duplicator.Description> processDataDescriptions, bool extra = false)
|
|
{
|
|
Dictionary<Test, List<Duplicator.Description>> results = configData.GetKeyValuePairs(processDataDescriptions);
|
|
configData.CheckProcessDataDescription(results, extra);
|
|
return results;
|
|
}
|
|
|
|
}
|
|
|
|
} |