MET08DDUPSFS6420 - v2.43.0 - Remove unit for IQS

Remove RecordStart
Update Mona
Logistics update
This commit is contained in:
Mike Phares 2022-06-16 12:40:15 -07:00
parent acbbb75404
commit b5244f1166
8 changed files with 288 additions and 327 deletions

View File

@ -135,7 +135,19 @@ public class FileRead : Shared.FileRead, IFileRead
if (!Directory.Exists(duplicateDirectory)) if (!Directory.Exists(duplicateDirectory))
_ = Directory.CreateDirectory(duplicateDirectory); _ = Directory.CreateDirectory(duplicateDirectory);
string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath)); string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath));
File.Copy(reportFullPath, duplicateFile, overwrite: true); string lines = File.ReadAllText(reportFullPath);
lines = lines
.Replace("ppm\t", "\t")
.Replace("mm2\t", "\t")
.Replace("um\t", "\t")
.Replace("mm\t", "\t")
.Replace("nm\t", "\t")
.Replace("\t[ ", "\t")
.Replace("\t*0", "\t")
.Replace("\t*", "\t")
.Replace("%\t", "\t")
.Replace("]\t", "\t");
File.WriteAllText(duplicateFile, lines);
WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile); WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
} }

View File

@ -103,8 +103,8 @@ public class FileRead : Shared.FileRead, IFileRead
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>()); Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true); _Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID(); SetFileParameterLotIDToLogisticsMID();
if (reportFullPath.Length < _MinFileLength) if (_Logistics.FileInfo.Length < _MinFileLength)
results.Item4.Add(new FileInfo(reportFullPath)); results.Item4.Add(_Logistics.FileInfo);
else else
{ {
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _GhostPCLFileName); IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _GhostPCLFileName);
@ -112,9 +112,8 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks)); throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN); string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN);
mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0]; mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
_Logistics.MID = mid;
SetFileParameterLotID(mid); SetFileParameterLotID(mid);
_Logistics.ProcessJobID = processData.Reactor; _Logistics.Update(mid, processData.Reactor);
if (!iProcessData.Details.Any()) if (!iProcessData.Details.Any())
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks)); throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4); results = iProcessData.GetResults(this, _Logistics, results.Item4);

View File

@ -626,7 +626,7 @@ public class ProcessData : IProcessData
// dataFiles[i].Date = DateTime.Parse(dataFiles[i].Date).ToString(); // dataFiles[i].Date = DateTime.Parse(dataFiles[i].Date).ToString();
foreach (string sourceFile in sourceFiles) foreach (string sourceFile in sourceFiles)
fileInfoCollection.Add(new FileInfo(sourceFile)); fileInfoCollection.Add(new FileInfo(sourceFile));
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath)); fileInfoCollection.Add(logistics.FileInfo);
} }
#nullable enable #nullable enable

View File

@ -62,7 +62,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="FFMpegCore" Version="4.8.0" /> <PackageReference Include="FFMpegCore" Version="4.8.0" />
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" /> <PackageReference Include="Infineon.Monitoring.MonA" Version="3.0.0" />
<PackageReference Include="Infineon.Yoda" Version="5.4.1" /> <PackageReference Include="Infineon.Yoda" Version="5.4.1" />
<PackageReference Include="Instances" Version="2.0.0" /> <PackageReference Include="Instances" Version="2.0.0" />
<PackageReference Include="RoboSharp" Version="1.2.7" /> <PackageReference Include="RoboSharp" Version="1.2.7" />

View File

@ -9,34 +9,46 @@ namespace Adaptation.Shared;
public class Logistics : ILogistics public class Logistics : ILogistics
{ {
public object NullData { get; private set; } protected readonly DateTime _DateTimeFromSequence;
public string JobID { get; private set; } //CellName protected readonly FileInfo _FileInfo;
public long Sequence { get; private set; } //Ticks protected readonly string _JobID;
public DateTime DateTimeFromSequence { get; private set; } protected readonly List<string> _Logistics1;
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; } protected readonly List<Logistics2> _Logistics2;
public string MesEntity { get; private set; } //SPC protected string _MID;
public string ReportFullPath { get; private set; } //Extract file protected readonly string _MesEntity;
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics) protected readonly object _NullData;
public string MID { get; set; } //Lot & Pocket || Lot protected string _ProcessJobID;
public List<string> Tags { get; set; } protected readonly string _ReportFullPath;
public List<string> Logistics1 { get; set; } protected readonly long _Sequence;
public List<Logistics2> Logistics2 { get; set; } protected readonly double _TotalSecondsSinceLastWriteTimeFromSequence;
public DateTime DateTimeFromSequence => _DateTimeFromSequence;
public FileInfo FileInfo => _FileInfo;
public string JobID => _JobID;
public List<string> Logistics1 => _Logistics1;
public List<Logistics2> Logistics2 => _Logistics2;
public string MID => _MID;
public string MesEntity => _MesEntity;
public object NullData => _NullData;
public string ProcessJobID => _ProcessJobID;
public string ReportFullPath => _ReportFullPath;
public long Sequence => _Sequence;
public double TotalSecondsSinceLastWriteTimeFromSequence => _TotalSecondsSinceLastWriteTimeFromSequence;
public Logistics(IFileRead fileRead) public Logistics(IFileRead fileRead)
{ {
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
NullData = null; _NullData = null;
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
JobID = fileRead.CellInstanceName; _JobID = fileRead.CellInstanceName;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime); _MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = string.Empty; _ReportFullPath = string.Empty;
ProcessJobID = nameof(ProcessJobID); _ProcessJobID = nameof(ProcessJobID);
MID = nameof(MID); _MID = nameof(MID);
Tags = new List<string>(); _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
} }
public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null) public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
@ -45,19 +57,19 @@ public class Logistics : ILogistics
throw new Exception(); throw new Exception();
if (string.IsNullOrEmpty(fileRead.MesEntity)) if (string.IsNullOrEmpty(fileRead.MesEntity))
throw new Exception(); throw new Exception();
NullData = fileRead.NullData; _NullData = fileRead.NullData;
FileInfo fileInfo = new(reportFullPath); _FileInfo = new(reportFullPath);
DateTime dateTime = fileInfo.LastWriteTime; DateTime dateTime = _FileInfo.LastWriteTime;
if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value) if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value)
dateTime = dateTime.AddTicks(-1); dateTime = dateTime.AddTicks(-1);
JobID = fileRead.CellInstanceName; _JobID = fileRead.CellInstanceName;
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = fileRead.MesEntity; _MesEntity = fileRead.MesEntity;
ReportFullPath = fileInfo.FullName; _ReportFullPath = _FileInfo.FullName;
ProcessJobID = nameof(ProcessJobID); _ProcessJobID = nameof(ProcessJobID);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_FileInfo.FullName);
if (useSplitForMID) if (useSplitForMID)
{ {
if (fileNameWithoutExtension.IndexOf(".") > -1) if (fileNameWithoutExtension.IndexOf(".") > -1)
@ -67,10 +79,9 @@ public class Logistics : ILogistics
if (fileNameWithoutExtension.IndexOf("-") > -1) if (fileNameWithoutExtension.IndexOf("-") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim(); fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
} }
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower()); _MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
Tags = new List<string>(); _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
} }
public Logistics(string reportFullPath, string logistics) public Logistics(string reportFullPath, string logistics)
@ -78,57 +89,57 @@ public class Logistics : ILogistics
string key; string key;
DateTime dateTime; DateTime dateTime;
string[] segments; string[] segments;
Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); _FileInfo = new(reportFullPath);
_Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1")) if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
{ {
NullData = null; _NullData = null;
JobID = "null"; _JobID = "null";
dateTime = new FileInfo(reportFullPath).LastWriteTime; dateTime = _FileInfo.LastWriteTime;
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime); _MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = reportFullPath; _ReportFullPath = reportFullPath;
ProcessJobID = "R##"; _ProcessJobID = "R##";
MID = "null"; _MID = "null";
Tags = new List<string>(); _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
} }
else else
{ {
string logistics1Line1 = Logistics1[0]; string logistics1Line1 = Logistics1[0];
key = "NULL_DATA="; key = "NULL_DATA=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
NullData = null; _NullData = null;
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
NullData = segments[1].Split(';')[0]; _NullData = segments[1].Split(';')[0];
} }
key = "JOBID="; key = "JOBID=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
JobID = "null"; _JobID = "null";
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
JobID = segments[1].Split(';')[0]; _JobID = segments[1].Split(';')[0];
} }
key = "SEQUENCE="; key = "SEQUENCE=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
dateTime = new FileInfo(reportFullPath).LastWriteTime; dateTime = _FileInfo.LastWriteTime;
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks) if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
dateTime = new FileInfo(reportFullPath).LastWriteTime; dateTime = _FileInfo.LastWriteTime;
else else
dateTime = new DateTime(sequence); dateTime = new DateTime(sequence);
} }
Sequence = dateTime.Ticks; _Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; _DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime; DateTime lastWriteTime = _FileInfo.LastWriteTime;
if (TotalSecondsSinceLastWriteTimeFromSequence > 600) if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
{ {
if (lastWriteTime != dateTime) if (lastWriteTime != dateTime)
@ -138,33 +149,32 @@ public class Logistics : ILogistics
} }
key = "MES_ENTITY="; key = "MES_ENTITY=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
MesEntity = DefaultMesEntity(dateTime); _MesEntity = DefaultMesEntity(dateTime);
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MesEntity = segments[1].Split(';')[0]; _MesEntity = segments[1].Split(';')[0];
} }
ReportFullPath = reportFullPath; _ReportFullPath = reportFullPath;
key = "PROCESS_JOBID="; key = "PROCESS_JOBID=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
ProcessJobID = "R##"; _ProcessJobID = "R##";
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
ProcessJobID = segments[1].Split(';')[0]; _ProcessJobID = segments[1].Split(';')[0];
} }
key = "MID="; key = "MID=";
if (!logistics1Line1.Contains(key)) if (!logistics1Line1.Contains(key))
MID = "null"; _MID = "null";
else else
{ {
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MID = segments[1].Split(';')[0]; _MID = segments[1].Split(';')[0];
} }
} }
Logistics2 logistics2; Logistics2 logistics2;
Tags = new List<string>(); _Logistics2 = new List<Logistics2>();
Logistics2 = new List<Logistics2>();
for (int i = 1; i < Logistics1.Count; i++) for (int i = 1; i < Logistics1.Count; i++)
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) if (Logistics1[i].StartsWith("LOGISTICS_2"))
@ -180,29 +190,12 @@ public class Logistics : ILogistics
} }
} }
public Logistics ShallowCopy() => (Logistics)MemberwiseClone();
private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY"); private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2); internal void Update(string mid, string processJobID)
internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2);
internal void Update(string dateTime, string processJobID, string mid)
{ {
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted)) _MID = mid;
dateTimeCasted = DateTime.Now; _ProcessJobID = processJobID;
NullData = null;
//JobID = Description.GetCellName();
Sequence = dateTimeCasted.Ticks;
DateTimeFromSequence = dateTimeCasted;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds;
//MesEntity = DefaultMesEntity(dateTime);
//ReportFullPath = string.Empty;
ProcessJobID = processJobID;
MID = mid;
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
} }
} }

View File

@ -12,8 +12,6 @@ namespace Adaptation.Shared;
public class ProcessDataStandardFormat public class ProcessDataStandardFormat
{ {
public const string RecordStart = "RECORD_START";
public enum SearchFor public enum SearchFor
{ {
EquipmentIntegration = 1, EquipmentIntegration = 1,

View File

@ -1,22 +1,23 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace Adaptation.Shared.Properties; namespace Adaptation.Shared.Properties;
public interface ILogistics public interface ILogistics
{ {
public object NullData { get; }
public string JobID { get; } //CellName
public long Sequence { get; } //Ticks
public DateTime DateTimeFromSequence { get; } public DateTime DateTimeFromSequence { get; }
public FileInfo FileInfo { get; }
public string JobID { get; }
public List<string> Logistics1 { get; }
public List<Logistics2> Logistics2 { get; }
public string MID { get; }
public string MesEntity { get; }
public object NullData { get; }
public string ProcessJobID { get; }
public string ReportFullPath { get; }
public long Sequence { get; }
public double TotalSecondsSinceLastWriteTimeFromSequence { get; } public double TotalSecondsSinceLastWriteTimeFromSequence { get; }
public string MesEntity { get; } //SPC
public string ReportFullPath { get; } //Extract file
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics)
public string MID { get; set; } //Lot & Pocket || Lot
public List<string> Tags { get; set; }
public List<string> Logistics1 { get; set; }
public List<Logistics2> Logistics2 { get; set; }
} }

View File

@ -1,243 +1,201 @@
using System; using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
namespace Shared namespace Adaptation.Shared;
public class Logistics : ILogistics
{ {
public class Logistics protected readonly DateTime _DateTimeFromSequence;
protected readonly FileInfo _FileInfo;
protected readonly string _JobID;
protected readonly List<string> _Logistics1;
protected readonly List<Logistics2> _Logistics2;
protected string _MID;
protected readonly string _MesEntity;
protected readonly object _NullData;
protected string _ProcessJobID;
protected readonly string _ReportFullPath;
protected readonly long _Sequence;
protected readonly double _TotalSecondsSinceLastWriteTimeFromSequence;
public DateTime DateTimeFromSequence => _DateTimeFromSequence;
public FileInfo FileInfo => _FileInfo;
public string JobID => _JobID;
public List<string> Logistics1 => _Logistics1;
public List<Logistics2> Logistics2 => _Logistics2;
public string MID => _MID;
public string MesEntity => _MesEntity;
public object NullData => _NullData;
public string ProcessJobID => _ProcessJobID;
public string ReportFullPath => _ReportFullPath;
public long Sequence => _Sequence;
public double TotalSecondsSinceLastWriteTimeFromSequence => _TotalSecondsSinceLastWriteTimeFromSequence;
public Logistics(IFileRead fileRead)
{ {
DateTime dateTime = DateTime.Now;
_NullData = null;
_Sequence = dateTime.Ticks;
_DateTimeFromSequence = dateTime;
_JobID = fileRead.CellInstanceName;
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
_MesEntity = DefaultMesEntity(dateTime);
_ReportFullPath = string.Empty;
_ProcessJobID = nameof(ProcessJobID);
_MID = nameof(MID);
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
_Logistics2 = new List<Logistics2>();
}
public object NullData { get; private set; } public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
public string JobID { get; private set; } //CellName {
public long Sequence { get; private set; } //Ticks if (string.IsNullOrEmpty(fileRead.CellInstanceName))
public DateTime DateTimeFromSequence { get; private set; } throw new Exception();
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; } if (string.IsNullOrEmpty(fileRead.MesEntity))
public string MesEntity { get; private set; } //SPC throw new Exception();
public string ReportFullPath { get; private set; } //Extract file _NullData = fileRead.NullData;
public string ProcessJobID { get; internal set; } //Reactor (duplicate but I want it in the logistics) _FileInfo = new(reportFullPath);
public string MID { get; internal set; } //Lot & Pocket || Lot DateTime dateTime = _FileInfo.LastWriteTime;
public List<string> Tags { get; internal set; } if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value)
public List<string> Logistics1 { get; internal set; } dateTime = dateTime.AddTicks(-1);
public List<Logistics2> Logistics2 { get; internal set; } _JobID = fileRead.CellInstanceName;
_Sequence = dateTime.Ticks;
public Logistics() _DateTimeFromSequence = dateTime;
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
_MesEntity = fileRead.MesEntity;
_ReportFullPath = _FileInfo.FullName;
_ProcessJobID = nameof(ProcessJobID);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_FileInfo.FullName);
if (useSplitForMID)
{ {
DateTime dateTime = DateTime.Now; if (fileNameWithoutExtension.IndexOf(".") > -1)
NullData = null; fileNameWithoutExtension = fileNameWithoutExtension.Split('.')[0].Trim();
JobID = Description.GetCellName(); if (fileNameWithoutExtension.IndexOf("_") > -1)
Sequence = dateTime.Ticks; fileNameWithoutExtension = fileNameWithoutExtension.Split('_')[0].Trim();
DateTimeFromSequence = dateTime; if (fileNameWithoutExtension.IndexOf("-") > -1)
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = string.Empty;
ProcessJobID = nameof(ProcessJobID);
MID = nameof(MID);
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
} }
_MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
_Logistics2 = new List<Logistics2>();
}
public Logistics(object nullData, Dictionary<string, string> cellNames, Dictionary<string, string> mesEntities, FileInfo fileInfo, bool useSplitForMID, int? fileInfoLength = null) public Logistics(string reportFullPath, string logistics)
{
string key;
DateTime dateTime;
string[] segments;
_FileInfo = new(reportFullPath);
_Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
{ {
NullData = nullData; _NullData = null;
string mesEntity = string.Empty; _JobID = "null";
string jobID = Description.GetCellName(); dateTime = _FileInfo.LastWriteTime;
DateTime dateTime = fileInfo.LastWriteTime; _Sequence = dateTime.Ticks;
if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value) _DateTimeFromSequence = dateTime;
dateTime = dateTime.AddTicks(-1); _TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
if (string.IsNullOrEmpty(jobID)) _MesEntity = DefaultMesEntity(dateTime);
{ _ReportFullPath = reportFullPath;
if (cellNames.Count == 1) _ProcessJobID = "R##";
jobID = cellNames.ElementAt(0).Key; _MID = "null";
else _Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
{ _Logistics2 = new List<Logistics2>();
string reportFullPathLower = fileInfo.FullName.ToLower();
foreach (var element in cellNames)
{
if (reportFullPathLower.Contains(element.Key) || reportFullPathLower.Contains(element.Value))
{
jobID = element.Key;
break;
}
}
}
}
if (string.IsNullOrEmpty(jobID))
throw new Exception();
if (mesEntities.ContainsKey(jobID))
mesEntity = mesEntities[jobID];
else if (mesEntities.Count == 1)
mesEntity = mesEntities.ElementAt(0).Value;
//
if (string.IsNullOrEmpty(mesEntity))
throw new Exception();
JobID = jobID;
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = mesEntity;
ReportFullPath = fileInfo.FullName;
ProcessJobID = nameof(ProcessJobID);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
if (useSplitForMID)
{
if (fileNameWithoutExtension.IndexOf(".") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('.')[0].Trim();
if (fileNameWithoutExtension.IndexOf("_") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('_')[0].Trim();
if (fileNameWithoutExtension.IndexOf("-") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
}
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
} }
else
public Logistics(string reportFullPath, string logistics)
{ {
string key; string logistics1Line1 = Logistics1[0];
DateTime dateTime; key = "NULL_DATA=";
string[] segments; if (!logistics1Line1.Contains(key))
Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); _NullData = null;
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
{
NullData = null;
JobID = "null";
dateTime = new FileInfo(reportFullPath).LastWriteTime;
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = reportFullPath;
ProcessJobID = "R##";
MID = "null";
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
else else
{ {
string logistics1Line1 = Logistics1[0]; segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
key = "NULL_DATA="; _NullData = segments[1].Split(';')[0];
if (!logistics1Line1.Contains(key))
NullData = null;
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
NullData = segments[1].Split(';')[0];
}
key = "JOBID=";
if (!logistics1Line1.Contains(key))
JobID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
JobID = segments[1].Split(';')[0];
}
key = "SEQUENCE=";
if (!logistics1Line1.Contains(key))
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
if (!long.TryParse(segments[1].Split(';')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
dateTime = new DateTime(sequence);
}
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime;
if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
{
if (lastWriteTime != dateTime)
try { File.SetLastWriteTime(reportFullPath, dateTime); } catch (Exception) { }
}
key = "MES_ENTITY=";
if (!logistics1Line1.Contains(key))
MesEntity = DefaultMesEntity(dateTime);
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MesEntity = segments[1].Split(';')[0];
}
ReportFullPath = reportFullPath;
key = "PROCESS_JOBID=";
if (!logistics1Line1.Contains(key))
ProcessJobID = "R##";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
ProcessJobID = segments[1].Split(';')[0];
}
key = "MID=";
if (!logistics1Line1.Contains(key))
MID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MID = segments[1].Split(';')[0];
}
} }
Logistics2 logistics2; key = "JOBID=";
Tags = new List<string>(); if (!logistics1Line1.Contains(key))
Logistics2 = new List<Logistics2>(); _JobID = "null";
for (int i = 1; i < Logistics1.Count(); i++) else
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
{ _JobID = segments[1].Split(';')[0];
logistics2 = new Logistics2(Logistics1[i]);
Logistics2.Add(logistics2);
}
} }
for (int i = Logistics1.Count() - 1; i >= 0; i--) key = "SEQUENCE=";
if (!logistics1Line1.Contains(key))
dateTime = _FileInfo.LastWriteTime;
else
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
Logistics1.RemoveAt(i); if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
dateTime = _FileInfo.LastWriteTime;
else
dateTime = new DateTime(sequence);
}
_Sequence = dateTime.Ticks;
_DateTimeFromSequence = dateTime;
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
DateTime lastWriteTime = _FileInfo.LastWriteTime;
if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
{
if (lastWriteTime != dateTime)
try
{ File.SetLastWriteTime(reportFullPath, dateTime); }
catch (Exception) { }
}
key = "MES_ENTITY=";
if (!logistics1Line1.Contains(key))
_MesEntity = DefaultMesEntity(dateTime);
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
_MesEntity = segments[1].Split(';')[0];
}
_ReportFullPath = reportFullPath;
key = "PROCESS_JOBID=";
if (!logistics1Line1.Contains(key))
_ProcessJobID = "R##";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
_ProcessJobID = segments[1].Split(';')[0];
}
key = "MID=";
if (!logistics1Line1.Contains(key))
_MID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
_MID = segments[1].Split(';')[0];
} }
} }
Logistics2 logistics2;
public Logistics ShallowCopy() _Logistics2 = new List<Logistics2>();
for (int i = 1; i < Logistics1.Count; i++)
{ {
return (Logistics)this.MemberwiseClone(); if (Logistics1[i].StartsWith("LOGISTICS_2"))
{
logistics2 = new Logistics2(Logistics1[i]);
Logistics2.Add(logistics2);
}
} }
for (int i = Logistics1.Count - 1; i > -1; i--)
private string DefaultMesEntity(DateTime dateTime)
{ {
return string.Concat(dateTime.Ticks, "_MES_ENTITY"); if (Logistics1[i].StartsWith("LOGISTICS_2"))
} Logistics1.RemoveAt(i);
internal string GetLotViaMostCommonMethod()
{
return MID.Substring(0, MID.Length - 2);
}
internal string GetPocketNumberViaMostCommonMethod()
{
return MID.Substring(MID.Length - 2);
}
internal void Update(string dateTime, string processJobID, string mid)
{
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted))
dateTimeCasted = DateTime.Now;
NullData = null;
//JobID = Description.GetCellName();
Sequence = dateTimeCasted.Ticks;
DateTimeFromSequence = dateTimeCasted;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds;
//MesEntity = DefaultMesEntity(dateTime);
//ReportFullPath = string.Empty;
ProcessJobID = processJobID;
MID = mid;
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
} }
} }
private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
internal void Update(string mid, string processJobID)
{
_MID = mid;
_ProcessJobID = processJobID;
}
} }