diff --git a/Adaptation/.editorconfig b/Adaptation/.editorconfig
index 69ecc38..d117dc5 100644
--- a/Adaptation/.editorconfig
+++ b/Adaptation/.editorconfig
@@ -121,6 +121,7 @@ dotnet_diagnostic.IDE0290.severity = none # Use primary constructor [Distance]cs
dotnet_diagnostic.IDE0300.severity = none # IDE0300: Collection initialization can be simplified
dotnet_diagnostic.IDE0301.severity = none #IDE0301: Collection initialization can be simplified
dotnet_diagnostic.IDE0305.severity = none # IDE0305: Collection initialization can be simplified
+dotnet_diagnostic.MSTEST0037.severity = error # MSTEST0037: Use proper 'Assert' methods
dotnet_diagnostic.SYSLIB1045.severity = none # SYSLIB1045: diagnostics for regex source generation
dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
diff --git a/Adaptation/.vscode/tasks.json b/Adaptation/.vscode/tasks.json
index 0a0e079..11ce68d 100644
--- a/Adaptation/.vscode/tasks.json
+++ b/Adaptation/.vscode/tasks.json
@@ -92,6 +92,26 @@
"command": "code ../DEP08CEPIEPSILON.csproj",
"problemMatcher": []
},
+ {
+ "label": "Readme",
+ "type": "shell",
+ "command": "code ../README.md",
+ "problemMatcher": []
+ },
+ {
+ "label": "File-Folder-Helper AOT s X Day-Helper-2025-03-20",
+ "type": "shell",
+ "command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
+ "args": [
+ "s",
+ "X",
+ "L:/DevOps/EAF-Mesa-Integration/DEP08CEPIEPSILON",
+ "Day-Helper-2025-03-20",
+ "false",
+ "4"
+ ],
+ "problemMatcher": []
+ },
{
"label": "Git Config",
"type": "shell",
diff --git a/Adaptation/DEP08CEPIEPSILON.Tests.csproj b/Adaptation/DEP08CEPIEPSILON.Tests.csproj
index 5c5b13b..9e4ed5a 100644
--- a/Adaptation/DEP08CEPIEPSILON.Tests.csproj
+++ b/Adaptation/DEP08CEPIEPSILON.Tests.csproj
@@ -69,7 +69,7 @@
- NU1701
+ NU1701
diff --git a/Adaptation/FileHandlers/CellInstanceConnectionName.cs b/Adaptation/FileHandlers/CellInstanceConnectionName.cs
index 8d952e0..1551e83 100644
--- a/Adaptation/FileHandlers/CellInstanceConnectionName.cs
+++ b/Adaptation/FileHandlers/CellInstanceConnectionName.cs
@@ -9,14 +9,16 @@ namespace Adaptation.FileHandlers;
public class CellInstanceConnectionName
{
- internal static IFileRead Get(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, int? connectionCount)
+ internal static IFileRead Get(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, int? connectionCount)
{
IFileRead result = cellInstanceConnectionName switch
{
nameof(R32) => new R32.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
- nameof(R62) => new R62.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(R55) => new R55.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(R57) => new R57.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
+ nameof(R61) => new R61.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
+ nameof(R62) => new R62.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
+ nameof(R65) => new R65.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(R75) => new R75.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(R77) => new R77.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
nameof(Dummy) => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null),
diff --git a/Adaptation/FileHandlers/Dummy/FileRead.cs b/Adaptation/FileHandlers/Dummy/FileRead.cs
index 916f5d7..3b777eb 100644
--- a/Adaptation/FileHandlers/Dummy/FileRead.cs
+++ b/Adaptation/FileHandlers/Dummy/FileRead.cs
@@ -23,7 +23,7 @@ public class FileRead : Shared.FileRead, IFileRead
private int _LastDummyRunIndex;
private readonly string[] _CellNames;
- public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
diff --git a/Adaptation/FileHandlers/R32/FileRead.cs b/Adaptation/FileHandlers/R32/FileRead.cs
index 648e516..3346bc7 100644
--- a/Adaptation/FileHandlers/R32/FileRead.cs
+++ b/Adaptation/FileHandlers/R32/FileRead.cs
@@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
private readonly string _TimestampFormat;
private readonly ReadOnlyDictionary _SystemStateToNames;
- public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
@@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple> GetExtractResult(string reportFullPath, DateTime _)
{
Tuple> results;
- Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
- _Logistics = new Logistics(reportFullPath, pdsf.Item1);
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
SetFileParameterLotIDToLogisticsMID();
- JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
List descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
MoveFile(reportFullPath);
- results = new Tuple>(pdsf.Item1, tests, jsonElements, new List());
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
return results;
}
diff --git a/Adaptation/FileHandlers/R55/FileRead.cs b/Adaptation/FileHandlers/R55/FileRead.cs
index 5e064eb..18b1401 100644
--- a/Adaptation/FileHandlers/R55/FileRead.cs
+++ b/Adaptation/FileHandlers/R55/FileRead.cs
@@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
private readonly string _TimestampFormat;
private readonly ReadOnlyDictionary _SystemStateToNames;
- public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
@@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple> GetExtractResult(string reportFullPath, DateTime _)
{
Tuple> results;
- Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
- _Logistics = new Logistics(reportFullPath, pdsf.Item1);
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
SetFileParameterLotIDToLogisticsMID();
- JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
List descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
MoveFile(reportFullPath);
- results = new Tuple>(pdsf.Item1, tests, jsonElements, new List());
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
return results;
}
diff --git a/Adaptation/FileHandlers/R57/FileRead.cs b/Adaptation/FileHandlers/R57/FileRead.cs
index a0d1262..7c42a99 100644
--- a/Adaptation/FileHandlers/R57/FileRead.cs
+++ b/Adaptation/FileHandlers/R57/FileRead.cs
@@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
private readonly string _TimestampFormat;
private readonly ReadOnlyDictionary _SystemStateToNames;
- public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
@@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple> GetExtractResult(string reportFullPath, DateTime _)
{
Tuple> results;
- Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
- _Logistics = new Logistics(reportFullPath, pdsf.Item1);
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
SetFileParameterLotIDToLogisticsMID();
- JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
List descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
MoveFile(reportFullPath);
- results = new Tuple>(pdsf.Item1, tests, jsonElements, new List());
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
return results;
}
diff --git a/Adaptation/FileHandlers/R61/FileRead.cs b/Adaptation/FileHandlers/R61/FileRead.cs
new file mode 100644
index 0000000..e2c6ddd
--- /dev/null
+++ b/Adaptation/FileHandlers/R61/FileRead.cs
@@ -0,0 +1,238 @@
+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 System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text.Json;
+
+namespace Adaptation.FileHandlers.R61;
+
+public class FileRead : Shared.FileRead, IFileRead
+{
+
+ private readonly string _KeyColumn;
+ private readonly string _TimestampFormat;
+ private readonly ReadOnlyDictionary _SystemStateToNames;
+
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
+ {
+ _MinFileLength = 10;
+ _NullData = string.Empty;
+ _Logistics = new(this);
+ if (_FileParameter is null)
+ throw new Exception(cellInstanceConnectionName);
+ if (_ModelObjectParameterDefinitions is null)
+ throw new Exception(cellInstanceConnectionName);
+ if (!_IsDuplicator)
+ throw new Exception(cellInstanceConnectionName);
+ string[] segments;
+ Dictionary systemStateToNames = new();
+ _KeyColumn = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.KeyColumn");
+ _TimestampFormat = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.TimestampFormat");
+ ModelObjectParameterDefinition[] systemStates = GetProperties(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.SystemState");
+ foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in systemStates)
+ {
+ segments = modelObjectParameterDefinition.Value.Split('|');
+ if (segments.Length != 2)
+ continue;
+ systemStateToNames.Add(segments[0], segments[1]);
+ }
+ _SystemStateToNames = new(systemStateToNames);
+ }
+
+ void IFileRead.Move(Tuple> extractResults, Exception exception)
+ {
+ bool isErrorFile = exception is not null;
+ if (!isErrorFile && !string.IsNullOrEmpty(_Logistics.ReportFullPath))
+ {
+ FileInfo fileInfo = new(_Logistics.ReportFullPath);
+ if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
+ File.SetLastWriteTime(_Logistics.ReportFullPath, fileInfo.CreationTime);
+ }
+ Move(extractResults);
+ }
+
+ void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
+
+ string IFileRead.GetEventDescription()
+ {
+ string result = _Description.GetEventDescription();
+ return result;
+ }
+
+ List IFileRead.GetHeaderNames()
+ {
+ List results = _Description.GetHeaderNames();
+ return results;
+ }
+
+ string[] IFileRead.Move(Tuple> 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 IFileRead.GetDisplayNamesJsonElement()
+ {
+ Dictionary results = _Description.GetDisplayNamesJsonElement(this);
+ return results;
+ }
+
+ List IFileRead.GetDescriptions(IFileRead fileRead, List tests, IProcessData processData)
+ {
+ List results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
+ return results;
+ }
+
+ Tuple> IFileRead.GetExtractResult(string reportFullPath, string eventName)
+ {
+ Tuple> 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>(results.Item1, Array.Empty(), JsonSerializer.Deserialize("[]"), results.Item4);
+ if (results.Item3.Length > 0 && _IsEAFHosted)
+ WritePDSF(this, results.Item3);
+ UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
+ return results;
+ }
+
+ Tuple> IFileRead.ReExtract()
+ {
+ Tuple> results;
+ List headerNames = _Description.GetHeaderNames();
+ Dictionary keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
+ results = ReExtract(this, headerNames, keyValuePairs);
+ return results;
+ }
+
+ private static int? GetKeyColumnIndex(string[] columns, string keyColumn)
+ {
+#nullable enable
+ int? result = null;
+ for (int i = 0; i < columns.Length; i++)
+ {
+ if (columns[i] != keyColumn)
+ continue;
+ result = i;
+ break;
+ }
+ return result;
+ }
+
+ private ReadOnlyCollection GetSystemStateValues(List lines, string[] columns, int keyColumnIndex)
+ {
+ List results = new();
+ string[] values;
+ string? systemState;
+ string keyColumnValue;
+ for (int i = 7; i < lines.Count; i++)
+ {
+ values = lines[i].Split('\t');
+ if (values.Length != columns.Length)
+ continue;
+ keyColumnValue = values[keyColumnIndex];
+ if (string.IsNullOrEmpty(keyColumnValue))
+ continue;
+ if (!_SystemStateToNames.TryGetValue(keyColumnValue, out systemState))
+ continue;
+ if (results.Contains(systemState))
+ continue;
+ results.Add(systemState);
+ }
+ return new(results);
+ }
+
+ private void MoveFile(string reportFullPath)
+ {
+ string equipment;
+ string timestamp;
+ string[] columns;
+ DateTime dateTime;
+ List lines;
+ string systemState;
+ int? keyColumnIndex;
+ string checkFileName;
+ List headerLines = new();
+ ReadOnlyCollection systemStateValues;
+ string missingKeyDirectory = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, "Missing-Key");
+ if (!Directory.Exists(missingKeyDirectory))
+ _ = Directory.CreateDirectory(missingKeyDirectory);
+ string fileName = Path.GetFileName(reportFullPath);
+ string[] segments = fileName.Split('_');
+ for (int z = 0; z < 1; z++)
+ {
+ if (segments.Length != 2)
+ continue;
+ equipment = segments[0];
+ timestamp = segments[1].Split('.')[0];
+ if (timestamp.Length != _TimestampFormat.Length)
+ continue;
+ headerLines.Clear();
+ lines = File.ReadAllLines(reportFullPath).ToList();
+ if (lines.Count < 8)
+ continue;
+ for (int i = 0; i < 6; i++)
+ {
+ headerLines.Add(lines[0]);
+ lines.RemoveAt(0);
+ }
+ if (lines[0].Length < 1 || lines[0][0] != '"' || !lines[0].StartsWith("\"Time\""))
+ continue;
+ columns = lines[0].Split('\t');
+ if (columns.Length < 3)
+ continue;
+ keyColumnIndex = GetKeyColumnIndex(columns, _KeyColumn);
+ if (keyColumnIndex is null)
+ {
+ File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
+ continue;
+ }
+ systemStateValues = GetSystemStateValues(lines, columns, keyColumnIndex.Value);
+ if (systemStateValues.Count == 0)
+ {
+ File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
+ continue;
+ }
+ lines.AddRange(headerLines);
+ systemState = string.Join("-", systemStateValues);
+ checkFileName = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, $"{equipment}-{timestamp}-{systemState}.pdsf");
+ File.WriteAllLines(checkFileName, lines);
+ // File.Delete(reportFullPath);
+ if (DateTime.TryParseExact(timestamp, _TimestampFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
+ File.SetLastWriteTime(checkFileName, dateTime);
+ }
+ }
+
+ private Tuple> GetExtractResult(string reportFullPath, DateTime _)
+ {
+ Tuple> results;
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
+ SetFileParameterLotIDToLogisticsMID();
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
+ List descriptions = GetDuplicatorDescriptions(jsonElements);
+ Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
+ if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
+ MoveFile(reportFullPath);
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
+ return results;
+ }
+
+}
\ No newline at end of file
diff --git a/Adaptation/FileHandlers/R62/FileRead.cs b/Adaptation/FileHandlers/R62/FileRead.cs
index 34a1be6..7883c34 100644
--- a/Adaptation/FileHandlers/R62/FileRead.cs
+++ b/Adaptation/FileHandlers/R62/FileRead.cs
@@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
private readonly string _TimestampFormat;
private readonly ReadOnlyDictionary _SystemStateToNames;
- public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
@@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple> GetExtractResult(string reportFullPath, DateTime _)
{
Tuple> results;
- Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
- _Logistics = new Logistics(reportFullPath, pdsf.Item1);
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
SetFileParameterLotIDToLogisticsMID();
- JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
List descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
MoveFile(reportFullPath);
- results = new Tuple>(pdsf.Item1, tests, jsonElements, new List());
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
return results;
}
diff --git a/Adaptation/FileHandlers/R65/FileRead.cs b/Adaptation/FileHandlers/R65/FileRead.cs
new file mode 100644
index 0000000..f5022e3
--- /dev/null
+++ b/Adaptation/FileHandlers/R65/FileRead.cs
@@ -0,0 +1,238 @@
+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 System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text.Json;
+
+namespace Adaptation.FileHandlers.R65;
+
+public class FileRead : Shared.FileRead, IFileRead
+{
+
+ private readonly string _KeyColumn;
+ private readonly string _TimestampFormat;
+ private readonly ReadOnlyDictionary _SystemStateToNames;
+
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
+ {
+ _MinFileLength = 10;
+ _NullData = string.Empty;
+ _Logistics = new(this);
+ if (_FileParameter is null)
+ throw new Exception(cellInstanceConnectionName);
+ if (_ModelObjectParameterDefinitions is null)
+ throw new Exception(cellInstanceConnectionName);
+ if (!_IsDuplicator)
+ throw new Exception(cellInstanceConnectionName);
+ string[] segments;
+ Dictionary systemStateToNames = new();
+ _KeyColumn = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.KeyColumn");
+ _TimestampFormat = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.TimestampFormat");
+ ModelObjectParameterDefinition[] systemStates = GetProperties(cellInstanceConnectionName, modelObjectParameters, "ProcessDataStandardFormat.SystemState");
+ foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in systemStates)
+ {
+ segments = modelObjectParameterDefinition.Value.Split('|');
+ if (segments.Length != 2)
+ continue;
+ systemStateToNames.Add(segments[0], segments[1]);
+ }
+ _SystemStateToNames = new(systemStateToNames);
+ }
+
+ void IFileRead.Move(Tuple> extractResults, Exception exception)
+ {
+ bool isErrorFile = exception is not null;
+ if (!isErrorFile && !string.IsNullOrEmpty(_Logistics.ReportFullPath))
+ {
+ FileInfo fileInfo = new(_Logistics.ReportFullPath);
+ if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
+ File.SetLastWriteTime(_Logistics.ReportFullPath, fileInfo.CreationTime);
+ }
+ Move(extractResults);
+ }
+
+ void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
+
+ string IFileRead.GetEventDescription()
+ {
+ string result = _Description.GetEventDescription();
+ return result;
+ }
+
+ List IFileRead.GetHeaderNames()
+ {
+ List results = _Description.GetHeaderNames();
+ return results;
+ }
+
+ string[] IFileRead.Move(Tuple> 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 IFileRead.GetDisplayNamesJsonElement()
+ {
+ Dictionary results = _Description.GetDisplayNamesJsonElement(this);
+ return results;
+ }
+
+ List IFileRead.GetDescriptions(IFileRead fileRead, List tests, IProcessData processData)
+ {
+ List results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
+ return results;
+ }
+
+ Tuple> IFileRead.GetExtractResult(string reportFullPath, string eventName)
+ {
+ Tuple> 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>(results.Item1, Array.Empty(), JsonSerializer.Deserialize("[]"), results.Item4);
+ if (results.Item3.Length > 0 && _IsEAFHosted)
+ WritePDSF(this, results.Item3);
+ UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
+ return results;
+ }
+
+ Tuple> IFileRead.ReExtract()
+ {
+ Tuple> results;
+ List headerNames = _Description.GetHeaderNames();
+ Dictionary keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
+ results = ReExtract(this, headerNames, keyValuePairs);
+ return results;
+ }
+
+ private static int? GetKeyColumnIndex(string[] columns, string keyColumn)
+ {
+#nullable enable
+ int? result = null;
+ for (int i = 0; i < columns.Length; i++)
+ {
+ if (columns[i] != keyColumn)
+ continue;
+ result = i;
+ break;
+ }
+ return result;
+ }
+
+ private ReadOnlyCollection GetSystemStateValues(List lines, string[] columns, int keyColumnIndex)
+ {
+ List results = new();
+ string[] values;
+ string? systemState;
+ string keyColumnValue;
+ for (int i = 7; i < lines.Count; i++)
+ {
+ values = lines[i].Split('\t');
+ if (values.Length != columns.Length)
+ continue;
+ keyColumnValue = values[keyColumnIndex];
+ if (string.IsNullOrEmpty(keyColumnValue))
+ continue;
+ if (!_SystemStateToNames.TryGetValue(keyColumnValue, out systemState))
+ continue;
+ if (results.Contains(systemState))
+ continue;
+ results.Add(systemState);
+ }
+ return new(results);
+ }
+
+ private void MoveFile(string reportFullPath)
+ {
+ string equipment;
+ string timestamp;
+ string[] columns;
+ DateTime dateTime;
+ List lines;
+ string systemState;
+ int? keyColumnIndex;
+ string checkFileName;
+ List headerLines = new();
+ ReadOnlyCollection systemStateValues;
+ string missingKeyDirectory = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, "Missing-Key");
+ if (!Directory.Exists(missingKeyDirectory))
+ _ = Directory.CreateDirectory(missingKeyDirectory);
+ string fileName = Path.GetFileName(reportFullPath);
+ string[] segments = fileName.Split('_');
+ for (int z = 0; z < 1; z++)
+ {
+ if (segments.Length != 2)
+ continue;
+ equipment = segments[0];
+ timestamp = segments[1].Split('.')[0];
+ if (timestamp.Length != _TimestampFormat.Length)
+ continue;
+ headerLines.Clear();
+ lines = File.ReadAllLines(reportFullPath).ToList();
+ if (lines.Count < 8)
+ continue;
+ for (int i = 0; i < 6; i++)
+ {
+ headerLines.Add(lines[0]);
+ lines.RemoveAt(0);
+ }
+ if (lines[0].Length < 1 || lines[0][0] != '"' || !lines[0].StartsWith("\"Time\""))
+ continue;
+ columns = lines[0].Split('\t');
+ if (columns.Length < 3)
+ continue;
+ keyColumnIndex = GetKeyColumnIndex(columns, _KeyColumn);
+ if (keyColumnIndex is null)
+ {
+ File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
+ continue;
+ }
+ systemStateValues = GetSystemStateValues(lines, columns, keyColumnIndex.Value);
+ if (systemStateValues.Count == 0)
+ {
+ File.Move(reportFullPath, Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, missingKeyDirectory, fileName));
+ continue;
+ }
+ lines.AddRange(headerLines);
+ systemState = string.Join("-", systemStateValues);
+ checkFileName = Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, $"{equipment}-{timestamp}-{systemState}.pdsf");
+ File.WriteAllLines(checkFileName, lines);
+ // File.Delete(reportFullPath);
+ if (DateTime.TryParseExact(timestamp, _TimestampFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
+ File.SetLastWriteTime(checkFileName, dateTime);
+ }
+ }
+
+ private Tuple> GetExtractResult(string reportFullPath, DateTime _)
+ {
+ Tuple> results;
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
+ SetFileParameterLotIDToLogisticsMID();
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
+ List descriptions = GetDuplicatorDescriptions(jsonElements);
+ Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
+ if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
+ MoveFile(reportFullPath);
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
+ return results;
+ }
+
+}
\ No newline at end of file
diff --git a/Adaptation/FileHandlers/R75/FileRead.cs b/Adaptation/FileHandlers/R75/FileRead.cs
index 3ca5c28..4ddb3c6 100644
--- a/Adaptation/FileHandlers/R75/FileRead.cs
+++ b/Adaptation/FileHandlers/R75/FileRead.cs
@@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
private readonly string _TimestampFormat;
private readonly ReadOnlyDictionary _SystemStateToNames;
- public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
@@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple> GetExtractResult(string reportFullPath, DateTime _)
{
Tuple> results;
- Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
- _Logistics = new Logistics(reportFullPath, pdsf.Item1);
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
SetFileParameterLotIDToLogisticsMID();
- JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
List descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
MoveFile(reportFullPath);
- results = new Tuple>(pdsf.Item1, tests, jsonElements, new List());
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
return results;
}
diff --git a/Adaptation/FileHandlers/R77/FileRead.cs b/Adaptation/FileHandlers/R77/FileRead.cs
index b0400ff..4f6fc0c 100644
--- a/Adaptation/FileHandlers/R77/FileRead.cs
+++ b/Adaptation/FileHandlers/R77/FileRead.cs
@@ -20,7 +20,7 @@ public class FileRead : Shared.FileRead, IFileRead
private readonly string _TimestampFormat;
private readonly ReadOnlyDictionary _SystemStateToNames;
- public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
+ public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 10;
@@ -223,15 +223,15 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple> GetExtractResult(string reportFullPath, DateTime _)
{
Tuple> results;
- Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
- _Logistics = new Logistics(reportFullPath, pdsf.Item1);
+ ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
+ _Logistics = new Logistics(reportFullPath, processDataStandardFormat);
SetFileParameterLotIDToLogisticsMID();
- JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
+ JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
List descriptions = GetDuplicatorDescriptions(jsonElements);
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
MoveFile(reportFullPath);
- results = new Tuple>(pdsf.Item1, tests, jsonElements, new List());
+ results = new Tuple>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics[0]), tests, jsonElements, new List());
return results;
}
diff --git a/Adaptation/Shared/Duplicator/Description.cs b/Adaptation/Shared/Duplicator/Description.cs
index f725b29..964612e 100644
--- a/Adaptation/Shared/Duplicator/Description.cs
+++ b/Adaptation/Shared/Duplicator/Description.cs
@@ -12,7 +12,7 @@ public class Description : IDescription, Properties.IDescription
public int Test { get; set; }
public int Count { get; set; }
public int Index { get; set; }
- public string Lot { get; set; }
+ public string RDS { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
@@ -141,7 +141,7 @@ public class Description : IDescription, Properties.IDescription
MID = logistics.MID,
//
Date = DateTime.Now.ToString(GetDateFormat()),
- Lot = string.Empty,
+ RDS = string.Empty,
};
results.Add(description);
}
diff --git a/Adaptation/Shared/FileRead.cs b/Adaptation/Shared/FileRead.cs
index 4b6f3fc..49a4526 100644
--- a/Adaptation/Shared/FileRead.cs
+++ b/Adaptation/Shared/FileRead.cs
@@ -44,9 +44,9 @@ public class FileRead : Properties.IFileRead
protected readonly string _CellInstanceConnectionNameBase;
protected readonly Dictionary> _DummyRuns;
protected readonly Dictionary _FileParameter;
- protected readonly Dictionary> _StaticRuns;
protected readonly string _ParameterizedModelObjectDefinitionType;
protected readonly FileConnectorConfiguration _FileConnectorConfiguration;
+ protected readonly Dictionary> _StaticRuns;
protected readonly IList _ModelObjectParameterDefinitions;
bool Properties.IFileRead.IsEvent => _IsEvent;
@@ -63,203 +63,6 @@ public class FileRead : Properties.IFileRead
string Properties.IFileRead.CellInstanceConnectionName => _CellInstanceConnectionName;
string Properties.IFileRead.ParameterizedModelObjectDefinitionType => _ParameterizedModelObjectDefinitionType;
- public FileRead(IDescription description, bool isEvent, ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted)
- {
- _SMTP = smtp;
- _IsEvent = isEvent;
- _DummyRuns = dummyRuns;
- _LastTicksDuration = 0;
- _StaticRuns = staticRuns;
- _IsEAFHosted = isEAFHosted;
- _Description = description;
- _FileParameter = fileParameter;
- _ReportFullPath = string.Empty;
- _CellInstanceName = cellInstanceName;
- _Calendar = new CultureInfo("en-US").Calendar;
- _Log = LogManager.GetLogger(typeof(FileRead));
- _UseCyclicalForDescription = useCyclicalForDescription;
- _CellInstanceConnectionName = cellInstanceConnectionName;
- _ModelObjectParameterDefinitions = modelObjectParameters;
- _FileConnectorConfiguration = fileConnectorConfiguration;
- _ParameterizedModelObjectDefinitionType = parameterizedModelObjectDefinitionType;
- _IsSourceTimer = fileConnectorConfiguration.SourceFileFilter.StartsWith("*Timer.txt");
- string cellInstanceConnectionNameBase = cellInstanceConnectionName.Replace("-", string.Empty);
- _Hyphens = cellInstanceConnectionName.Length - cellInstanceConnectionNameBase.Length;
- _TracePath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Trace");
- _ExceptionSubject = string.Concat("Exception:", _CellInstanceConnectionName, _FileConnectorConfiguration?.SourceDirectoryCloaking);
- string suffix;
- string[] segments = _ParameterizedModelObjectDefinitionType.Split('.');
- string @namespace = segments[0];
- string eventNameFileRead = "FileRead";
- string eventName = segments[segments.Length - 1];
- bool isDuplicator = segments[0] == cellInstanceName;
- _IsDuplicator = isDuplicator;
- _CellInstanceConnectionNameBase = cellInstanceConnectionNameBase;
- if (eventName == eventNameFileRead)
- suffix = string.Empty;
- else
- suffix = string.Concat('_', eventName.Split(new string[] { eventNameFileRead }, StringSplitOptions.RemoveEmptyEntries)[1]);
- string parameterizedModelObjectDefinitionTypeAppended = string.Concat(@namespace, suffix);
- if (!isEAFHosted)
- {
- if (string.IsNullOrEmpty(equipmentTypeName) || equipmentTypeName != parameterizedModelObjectDefinitionTypeAppended)
- throw new Exception(cellInstanceConnectionName);
- if (string.IsNullOrEmpty(equipmentDictionaryName) && isEvent)
- throw new Exception(cellInstanceConnectionName);
- if (!string.IsNullOrEmpty(equipmentDictionaryName) && !isEvent && connectionCount > 1)
- throw new Exception(cellInstanceConnectionName);
- // if (string.IsNullOrEmpty(equipmentDictionaryName) && !isEvent)
- // throw new Exception(cellInstanceConnectionName);
- // if (!string.IsNullOrEmpty(equipmentDictionaryName) && isEvent)
- // throw new Exception(cellInstanceConnectionName);
- }
- if (isDuplicator)
- _MesEntity = string.Empty;
- else
- _MesEntity = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, string.Concat("CellInstance.", cellInstanceName, ".Alias"));
- _EventName = eventName;
- _EventNameFileRead = eventNameFileRead;
- _EquipmentType = parameterizedModelObjectDefinitionTypeAppended;
- long breakAfterSeconds;
- if (_FileConnectorConfiguration is null)
- breakAfterSeconds = 360;
- else
- {
- if (_FileConnectorConfiguration.FileScanningOption == FileConnectorConfiguration.FileScanningOptionEnum.TimeBased)
- breakAfterSeconds = Math.Abs(_FileConnectorConfiguration.FileHandleTimeout.Value);
- else if (_FileConnectorConfiguration.FileScanningOption == FileConnectorConfiguration.FileScanningOptionEnum.FileWatcher)
- breakAfterSeconds = Math.Abs(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value);
- else
- throw new Exception();
- }
- _BreakAfterSeconds = breakAfterSeconds;
- UpdateLastTicksDuration(breakAfterSeconds * 10000000);
- if (_IsDuplicator)
- {
- if (string.IsNullOrEmpty(_FileConnectorConfiguration.TargetFileLocation) || string.IsNullOrEmpty(_FileConnectorConfiguration.ErrorTargetFileLocation))
- throw new Exception("_Configuration is empty?");
- if (_FileConnectorConfiguration.TargetFileLocation.Contains('%') || _FileConnectorConfiguration.ErrorTargetFileLocation.Contains('%'))
- throw new Exception("_Configuration is incorrect for a duplicator!");
- // if (_FileConnectorConfiguration is not null)
- // {
- // if (string.IsNullOrEmpty(_FileConnectorConfiguration.SourceDirectoryCloaking))
- // throw new Exception("SourceDirectoryCloaking is empty?");
- // if (!_FileConnectorConfiguration.SourceDirectoryCloaking.StartsWith("~"))
- // throw new Exception("SourceDirectoryCloaking is incorrect for a duplicator!");
- // }
- }
- }
-
- protected static string GetPropertyValue(string cellInstanceConnectionName, IList modelObjectParameters, string propertyName)
- {
- string result;
- List results = (from l in modelObjectParameters where l.Name == propertyName select l.Value).ToList();
- if (results.Count != 1)
- throw new Exception(cellInstanceConnectionName);
- result = results[0];
- return result;
- }
-
- protected static ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList modelObjectParameters, string propertyNamePrefix)
- {
- ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) select l).ToArray();
- if (results.Length == 0)
- throw new Exception(cellInstanceConnectionName);
- return results;
- }
-
- protected static ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList modelObjectParameters, string propertyNamePrefix, string propertyNameSuffix)
- {
- ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) && l.Name.EndsWith(propertyNameSuffix) select l).ToArray();
- if (results.Length == 0)
- throw new Exception(cellInstanceConnectionName);
- return results;
- }
-
- protected void UpdateLastTicksDuration(long ticksDuration)
- {
- if (ticksDuration < 50000000)
- ticksDuration = 50000000;
- _LastTicksDuration = (long)Math.Ceiling(ticksDuration * .667);
- _Log.Info($"{new TimeSpan(ticksDuration).TotalMilliseconds} TotalMillisecond(s) to process{Environment.NewLine}{_CellInstanceConnectionName}{Environment.NewLine}<{_ReportFullPath}>");
- }
-
- protected void WaitForThread(Thread thread, List threadExceptions)
- {
- if (thread is not null)
- {
- ThreadState threadState;
- for (short i = 0; i < short.MaxValue; i++)
- {
- if (thread is null)
- break;
- else
- {
- threadState = thread.ThreadState;
- if (threadState is not ThreadState.Running and not ThreadState.WaitSleepJoin)
- break;
- }
- Thread.Sleep(500);
- }
- lock (threadExceptions)
- {
- if (threadExceptions.Count != 0)
- {
- foreach (Exception item in threadExceptions)
- _Log.Error(string.Concat(item.Message, Environment.NewLine, Environment.NewLine, item.StackTrace));
- Exception exception = threadExceptions[0];
- threadExceptions.Clear();
- throw exception;
- }
- }
- }
- }
-
- private void WriteAllLines(string to, string[] exceptionLines)
- {
- string fileName = string.Concat(to, @"\readme.txt");
- try
- {
- if (!Directory.Exists(to))
- _ = Directory.CreateDirectory(to);
- File.WriteAllLines(fileName, exceptionLines);
- }
- catch (Exception ex) { _Log.Error(ex.Message); }
- }
-
- protected string[] Move(Tuple> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
- {
- string[] results;
- bool isErrorFile = exception is not null;
- if (!to.EndsWith(@"\"))
- _ = string.Concat(to, @"\");
- if (!isErrorFile)
- results = Array.Empty();
- else
- {
- results = new string[] { _Logistics.Sequence.ToString(), _Logistics.ReportFullPath, from, resolvedFileLocation, to, string.Empty, string.Empty, exception.Message, string.Empty, string.Empty, exception.StackTrace };
- if (!_IsDuplicator)
- WriteAllLines(to, results);
- }
- if (extractResults is not null && extractResults.Item4 is not null && extractResults.Item4.Count != 0)
- {
- string itemFile;
- List directories = new();
- foreach (FileInfo sourceFile in extractResults.Item4)
- {
- if (sourceFile.FullName != _Logistics.ReportFullPath)
- {
- itemFile = sourceFile.FullName.Replace(from, to);
- Shared1880(itemFile, directories, sourceFile, isErrorFile);
- }
- else if (!isErrorFile && _Logistics is not null)
- Shared1811(to, sourceFile);
- }
- Shared0231(directories);
- }
- return results;
- }
-
protected static string GetTupleFile(Logistics logistics, List descriptions, Properties.IScopeInfo scopeInfo, string duplicateDirectory, string duplicateFile) where T : Properties.IDescription
{
string result;
@@ -268,10 +71,10 @@ public class FileRead : Properties.IFileRead
string dateValue;
string rdsPlaceholder = "%RDS%";
string mesEntityPlaceholder = "%MesEntity%";
- if (descriptions.Count == 0 || string.IsNullOrEmpty(descriptions[0].Lot))
+ if (descriptions.Count == 0 || string.IsNullOrEmpty(descriptions[0].RDS))
rds = logistics.MID;
else
- rds = descriptions[0].Lot;
+ rds = descriptions[0].RDS;
string[] segments = scopeInfo.FileName.Split(new string[] { "DateTime:" }, StringSplitOptions.RemoveEmptyEntries);
if (segments.Length == 0)
result = string.Concat(duplicateDirectory, @"\", scopeInfo.FileNameWithoutExtension.Replace(rdsPlaceholder, rds).Replace(mesEntityPlaceholder, logistics.MesEntity));
@@ -384,217 +187,131 @@ public class FileRead : Properties.IFileRead
}
}
- protected void SetFileParameter(string key, string value)
+ protected void WaitForFileConsumption(DateTime dateTime, List descriptions, bool isDummyRun, string successDirectory, string duplicateDirectory, List<(Properties.IScopeInfo, string)> collection, string duplicateFile) where T : Properties.IDescription
{
- if (_FileConnectorConfiguration is null || _FileConnectorConfiguration.TargetFileLocation.Contains(string.Concat("%", key, "%")) || _FileConnectorConfiguration.ErrorTargetFileLocation.Contains(string.Concat("%", key, "%")) || _FileConnectorConfiguration.TargetFileName.Contains(string.Concat("%", key, "%")) || _FileConnectorConfiguration.ErrorTargetFileName.Contains(string.Concat("%", key, "%")))
- {
- if (_FileParameter.ContainsKey(key))
- _FileParameter[key] = value;
- else
- _FileParameter.Add(key, value);
- }
- }
-
- protected void SetFileParameterLotIDToLogisticsMID(bool includeLogisticsSequence = true)
- {
- string key;
- if (!includeLogisticsSequence)
- key = "LotID";
- else
- key = "LotIDWithLogisticsSequence";
- string value = string.Concat(_Logistics.MID, "_", _Logistics.Sequence, "_", DateTime.Now.Ticks - _Logistics.Sequence);
- SetFileParameter(key, value);
- }
-
- protected void SetFileParameterLotID(string value, bool includeLogisticsSequence = true)
- {
- string key;
- if (!includeLogisticsSequence)
- key = "LotID";
+ if (!isDummyRun && _IsEAFHosted)
+ WaitForFileConsumption(_FileConnectorConfiguration.SourceDirectoryCloaking, _Logistics, dateTime, descriptions, successDirectory, duplicateDirectory, duplicateFile, collection);
else
{
- key = "LotIDWithLogisticsSequence";
- value = string.Concat(value, "_", _Logistics.Sequence, "_", DateTime.Now.Ticks - _Logistics.Sequence);
- }
- SetFileParameter(key, value);
- }
-
- protected void WritePDSF(IFileRead fileRead, JsonElement[] jsonElements)
- {
- string directory;
- string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
- string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}";
- if (!_CellInstanceConnectionName.StartsWith(_CellInstanceName) && _CellInstanceConnectionNameBase == _EquipmentType)
- directory = Path.Combine(_TracePath, _EquipmentType, "Target", weekDirectory, _CellInstanceName, _CellInstanceConnectionName);
- else
- directory = Path.Combine(_TracePath, _EquipmentType, "Source", weekDirectory, _CellInstanceName, _CellInstanceConnectionName);
- if (!Directory.Exists(directory))
- _ = Directory.CreateDirectory(directory);
- string file = Path.Combine(directory, string.Concat(_Logistics.MesEntity, "_", _Logistics.Sequence, ".ipdsf"));
- string lines = ProcessDataStandardFormat.GetPDSFText(fileRead, _Logistics, jsonElements, logisticsText: string.Empty);
- File.WriteAllText(file, lines);
- if (_Logistics.TotalSecondsSinceLastWriteTimeFromSequence > 600)
- {
- try
- { File.SetLastWriteTime(file, _Logistics.DateTimeFromSequence); }
- catch (Exception) { }
- }
- }
-
- protected void Move(Tuple> extractResults)
- {
- if (!_IsEAFHosted)
- {
- string to;
- if (!_FileConnectorConfiguration.TargetFileLocation.EndsWith(Path.DirectorySeparatorChar.ToString()))
- to = _FileConnectorConfiguration.TargetFileLocation;
- else
- to = Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation);
- foreach (KeyValuePair keyValuePair in _FileParameter)
- to = to.Replace(string.Concat('%', keyValuePair.Key, '%'), keyValuePair.Value);
- if (to.Contains('%'))
- _Log.Debug("Can't debug without EAF Hosting");
- else
- _ = Move(extractResults, to, _FileConnectorConfiguration.SourceFileLocation, resolvedFileLocation: string.Empty, exception: null);
- }
- }
-
- protected void TriggerEvents(Tuple> extractResults, List headerNames, Dictionary keyValuePairs)
- {
- object value;
- string segments;
- string description;
- List