diff --git a/Adaptation/FileHandlers/CellInstanceConnectionName.cs b/Adaptation/FileHandlers/CellInstanceConnectionName.cs index 1ef82ed..cab1973 100644 --- a/Adaptation/FileHandlers/CellInstanceConnectionName.cs +++ b/Adaptation/FileHandlers/CellInstanceConnectionName.cs @@ -17,6 +17,7 @@ public class CellInstanceConnectionName nameof(Archive) => new Archive.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), nameof(IQSSi) => new IQSSi.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), + nameof(MoveAllFiles) => new MoveAllFiles.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), nameof(MoveMatchingFiles) => new MoveMatchingFiles.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), nameof(OpenInsight) => new OpenInsight.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), nameof(OpenInsightMetrologyViewer) => new OpenInsightMetrologyViewer.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted), diff --git a/Adaptation/FileHandlers/TIBCO/Transport/Job.cs b/Adaptation/FileHandlers/TIBCO/Transport/Job.cs index 973f378..8c9d41c 100644 --- a/Adaptation/FileHandlers/TIBCO/Transport/Job.cs +++ b/Adaptation/FileHandlers/TIBCO/Transport/Job.cs @@ -3,8 +3,10 @@ using System.Collections.Generic; using System.Data.SqlClient; using System.Globalization; using System.IO; +using System.Linq; using System.Text; using System.Text.Json; +using System.Text.RegularExpressions; namespace Adaptation.FileHandlers.TIBCO.Transport; @@ -28,41 +30,82 @@ public class Job public DateTime DateTime { get; } public List Items { get; } - public Job(string oiContextDataPendingPath, string oiContextDataResultsPath, string oiContextDataSearchPath, string lsl2SQLConnectionString, string mid) + public Job(string oiContextDataPendingPath, string oiContextDataResultsPath, string oiContextDataSearchPath, string lsl2SQLConnectionString, Dictionary> _RDS, string mid) { Items = new List(); if (mid[0] != '{' || mid[mid.Length - 1] != '}' || !mid.Contains("\"Si\"")) IsAreaSi = false; else { - string[] segments; - const string hyphen = "-"; + string psn; + int rds = 0; + string reactor; Input input = JsonSerializer.Deserialize(mid); IsAreaSi = input.Area == "Si"; + if (input.MID is null) + input.MID = string.Empty; if (!long.TryParse(input.Sequence, out long sequence)) DateTime = DateTime.Now; else DateTime = new DateTime(sequence); - if (!string.IsNullOrEmpty(input.MID) && input.MID.Length > 9 && input.MID[2] == hyphen[0] && input.MID[9] == hyphen[0]) - segments = input.MID.Split(hyphen[0]); + string[] segments = Regex.Split(input.MID, @"[^0-9']"); + List> orderedMatches = new(); + if (segments.Length < 3 || (segments.Length > 1 && !int.TryParse(segments[1], out rds))) + { + psn = string.Empty; + reactor = string.Empty; + } + else if (rds > 0) + { + lock (_RDS) + { + if (!_RDS.ContainsKey(rds)) + _RDS.Add(rds, new()); + List<(string MID, int Count)> collection = _RDS[rds]; + if (collection.Count == 0) + _RDS[rds].Add(new(input.MID, 1)); + else + { + IEnumerable> grouped = collection.GroupBy(l => l.MID); + orderedMatches.AddRange(from l in grouped orderby l.Count() descending select l); + int length = (from l in orderedMatches where l.Key == input.MID select true).Count(); + _RDS[rds].Add(new(input.MID, length + 1)); + } + if (_RDS.Count > 1000) + _ = _RDS.Remove(_RDS.ElementAt(0).Key); + } + psn = segments[2]; + reactor = segments[0]; + } else - segments = new string[] { hyphen, hyphen, hyphen }; - // + { + psn = string.Empty; + reactor = string.Empty; + } AutomationMode = string.Concat(DateTime.Ticks, ".", input.MesEntity); - if (segments[1] == hyphen) - BasicType = hyphen; - else - BasicType = GetBasicType(lsl2SQLConnectionString, hyphen, segments[1]); Equipment = input.MesEntity; JobName = DateTime.Ticks.ToString(); - if (segments[0] == hyphen) + if (orderedMatches.Any() && (string.IsNullOrEmpty(reactor) || string.IsNullOrEmpty(psn))) + { + segments = Regex.Split(orderedMatches[0].Key, @"[^0-9']"); + psn = segments[2]; + reactor = segments[0]; + } + const string hyphen = "-"; + if (rds < 1) + { + BasicType = hyphen; LotName = input.MID; + } else - LotName = segments[1]; + { + LotName = rds.ToString(); + BasicType = GetBasicType(lsl2SQLConnectionString, hyphen, rds); + } PackageName = hyphen; //WAFER_ID WaferLot ProcessSpecName = hyphen; //WAFER_POS PocketNumber - ProcessType = segments[0]; - ProductName = segments[2].Split('.')[0]; + ProcessType = reactor; + ProductName = psn; Qty = "1"; RecipeName = input.Recipe; StateModel = input.EquipmentType; @@ -71,7 +114,7 @@ public class Job } } - public static string GetBasicType(string lsl2SQLConnectionString, string hyphen, string rds) + public static string GetBasicType(string lsl2SQLConnectionString, string hyphen, int rds) { string result; // string json; diff --git a/Adaptation/FileHandlers/TIBCO/Transport/Main.cs b/Adaptation/FileHandlers/TIBCO/Transport/Main.cs index 51e01e2..5bc49d4 100644 --- a/Adaptation/FileHandlers/TIBCO/Transport/Main.cs +++ b/Adaptation/FileHandlers/TIBCO/Transport/Main.cs @@ -19,10 +19,12 @@ internal partial class Main private static string _OIContextDataSearchPath; private static string _OIContextDataPendingPath; private static string _OIContextDataResultsPath; + private static Dictionary> _RDS; private static FileConnectorConfiguration _FileConnectorConfiguration; internal static void Initialize(ISMTP smtp, string cellInstanceName, FileConnectorConfiguration fileConnectorConfiguration, string oiContextDataPendingPath, string oiContextDataResultsPath, string oiContextDataSearchPath, string lsl2SQLConnectionString) { + _RDS = new(); _SMTP = smtp; _IfxTransport = null; _CellInstanceName = cellInstanceName; @@ -185,7 +187,7 @@ internal partial class Main if (!subject.EndsWith("GETJOBS")) throw new Exception(); mid = GetJobsMID(envelopeDocument); - Job job = new(_OIContextDataPendingPath, _OIContextDataResultsPath, _OIContextDataSearchPath, _LSL2SQLConnectionString, mid); + Job job = new(_OIContextDataPendingPath, _OIContextDataResultsPath, _OIContextDataSearchPath, _LSL2SQLConnectionString, _RDS, mid); if (job.IsAreaSi) { IfxDoc sendReply = GetJobsReply(job); diff --git a/Adaptation/MET08DDUPSP1TBI.Tests.csproj b/Adaptation/MET08DDUPSP1TBI.Tests.csproj index 1b1bd86..aed9446 100644 --- a/Adaptation/MET08DDUPSP1TBI.Tests.csproj +++ b/Adaptation/MET08DDUPSP1TBI.Tests.csproj @@ -62,7 +62,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index 33a248e..9dcdb0a 100644 --- a/Adaptation/Shared/ProcessDataStandardFormat.cs +++ b/Adaptation/Shared/ProcessDataStandardFormat.cs @@ -12,8 +12,6 @@ namespace Adaptation.Shared; public class ProcessDataStandardFormat { - public const string RecordStart = "RECORD_START"; - public enum SearchFor { EquipmentIntegration = 1,