Changes to support barcode scanner and

new CDE5 Windows 7 machine
This commit is contained in:
2022-06-27 18:32:46 -07:00
parent 044b0e2bcd
commit 94b06b7de5
14 changed files with 433 additions and 204 deletions

View File

@ -12,7 +12,6 @@ using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace Adaptation.FileHandlers.DownloadRsMFile;
@ -120,12 +119,13 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(string.Concat("See ", nameof(Callback)));
}
private async Task DownloadRsMFileAsync()
private void DownloadRsMFileAsync()
{
if (_HttpClient is null)
throw new Exception();
if (string.IsNullOrEmpty(_StaticFileServer))
throw new Exception();
string logUrl;
string logText;
string runJson;
string rootJson;
@ -141,6 +141,7 @@ public class FileRead : Shared.FileRead, IFileRead
string dateTimeFormat = "yy/MM/dd HH:mm:ss";
NginxFileSystem[] runNginxFileSystemCollection;
NginxFileSystem[] rootNginxFileSystemCollection;
NginxFileSystem[] innerNginxFileSystemCollection;
DateTime fileAgeThresholdDateTime = DateTime.Now;
string nginxFormat = "ddd, dd MMM yyyy HH:mm:ss zzz";
List<Tuple<DateTime, FileInfo, FileInfo, string>> possibleDownload = new();
@ -157,13 +158,30 @@ public class FileRead : Shared.FileRead, IFileRead
_ => throw new Exception(),
};
}
rootJson = await _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer));
rootJson = _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer)).Result;
rootNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(rootJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem rootNginxFileSystem in rootNginxFileSystemCollection)
{
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where rootNginxFileSystem.Name == l select false).Any())
continue;
logText = await _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name));
logUrl = string.Empty;
if (rootNginxFileSystem.Name.Contains("."))
logUrl = string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name);
else
{
rootJson = _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name)).Result;
innerNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(rootJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem innerNginxFileSystem in innerNginxFileSystemCollection)
{
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where innerNginxFileSystem.Name == l select false).Any())
continue;
logUrl = string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name, '/', innerNginxFileSystem.Name);
break;
}
}
if (string.IsNullOrEmpty(logUrl))
continue;
logText = _HttpClient.GetStringAsync(logUrl).Result;
logLines = logText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
foreach (string logLine in logLines)
{
@ -182,7 +200,7 @@ public class FileRead : Shared.FileRead, IFileRead
runFullFileNameSegments = runFullFileName.Split('\\').ToList();
runFileName = runFullFileNameSegments[runFullFileNameSegments.Count - 1];
runFullFileNameSegments.RemoveAt(runFullFileNameSegments.Count - 1);
runJson = await _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments)));
runJson = _HttpClient.GetStringAsync(string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments))).Result;
runFullFileNameSegments.Add(runFileName);
runNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(runJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem matchNginxFileSystem in runNginxFileSystemCollection)
@ -222,7 +240,7 @@ public class FileRead : Shared.FileRead, IFileRead
File.Delete(alternateFileInfo.FullName);
if (targetFileInfo.Exists)
File.Delete(targetFileInfo.FullName);
targetJson = await _HttpClient.GetStringAsync(targetFileName);
targetJson = _HttpClient.GetStringAsync(targetFileName).Result;
File.WriteAllText(targetFileInfo.FullName, targetJson);
targetFileInfo.LastWriteTime = matchNginxFileSystemDateTime;
File.Copy(targetFileInfo.FullName, alternateFileInfo.FullName);
@ -234,7 +252,7 @@ public class FileRead : Shared.FileRead, IFileRead
try
{
if (_IsEAFHosted)
_ = DownloadRsMFileAsync();
DownloadRsMFileAsync();
}
catch (Exception exception)
{

View File

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

View File

@ -90,24 +90,32 @@ public class ProcessData : IProcessData
{
if (segments.Length > 0)
{
Title = segments[0];
// Remove illegal characters \/:*?"<>| found in the Run.
Run = Regex.Replace(segments[0], @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
string[] parsedBatch = segments[0].Split('-');
if (parsedBatch.Length > 0)
Reactor = parsedBatch[0];
if (parsedBatch.Length > 1)
RDS = parsedBatch[1];
if (parsedBatch.Length > 2)
// Remove illegal characters \/:*?"<>| found in the title.
string title = Regex.Replace(segments[0], @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
if (title.StartsWith("1T") || title.StartsWith("1t"))
title = title.Substring(2);
Title = title;
Run = title;
string[] parsedBatch = title.Split('-');
if (parsedBatch.Length == 1)
RDS = title;
else
{
string[] parsedPSN = parsedBatch[2].Split('.');
if (parsedPSN.Length > 0)
PSN = parsedPSN[0];
if (parsedPSN.Length > 1)
Layer = parsedPSN[1];
if (parsedBatch.Length > 0)
Reactor = parsedBatch[0];
if (parsedBatch.Length > 1)
RDS = parsedBatch[1];
if (parsedBatch.Length > 2)
{
string[] parsedPSN = parsedBatch[2].Split('.');
if (parsedPSN.Length > 0)
PSN = parsedPSN[0];
if (parsedPSN.Length > 1)
Layer = parsedPSN[1];
}
if (parsedBatch.Length > 3)
Zone = parsedBatch[3];
}
if (parsedBatch.Length > 3)
Zone = parsedBatch[3];
}
}
@ -217,19 +225,19 @@ public class ProcessData : IProcessData
for (int i = 0; i < lines.Length; i++)
{
segments = lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries);
if (lines[i].Contains(",<Title>"))
if (lines[i].Contains("<Title>"))
SetTitleData(segments);
else if (lines[i].Contains(",<FileName, Proj,Rcpe, LotID,WfrID>"))
else if (lines[i].Contains("<FileName, Proj,Rcpe, LotID,WfrID"))
SetFileNameData(segments);
else if (lines[i].Contains(",<DateTime,Temp,TCR%,N|P>"))
else if (lines[i].Contains("<DateTime,Temp,TCR%,N|P>"))
SetDateTimeData(logistics, segments);
else if (lines[i].Contains(",<Operator, Epuipment>"))
else if (lines[i].Contains("<Operator, Epuipment>"))
SetOperatorData(segments);
else if (lines[i].Contains(",<Engineer>"))
else if (lines[i].Contains("<Engineer>"))
SetEngineerData(segments);
else if (lines[i].Contains(",<NumProbePoints, SingleOrDualProbeConfig, #ActPrbPts, Rsens,IdrvMx,VinGain, DataRejectSigma, MeritThreshold>"))
else if (lines[i].Contains("<NumProbePoints, SingleOrDualProbeConfig, #ActPrbPts, Rsens,IdrvMx,VinGain, DataRejectSigma, MeritThreshold"))
SetNumProbePointsData(segments);
else if (lines[i].Contains(",<R,Th,Data, Rs,RsA,RsB, #Smpl, x,y, Irng,Vrng,ChiSq,merit,DataIntegrity>"))
else if (lines[i].Contains("<R,Th,Data, Rs,RsA,RsB, #Smpl, x,y, Irng,Vrng"))
{
for (int z = i; z < lines.Length; z++)
{
@ -250,8 +258,6 @@ public class ProcessData : IProcessData
item.Pt = (i + 1).ToString();
item.UniqueId = string.Concat(item, "_Point-", item.Pt);
}
// Remove illegal characters \/:*?"<>| found in the Lot.
Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
StringBuilder stringBuilder = new();
string reportFileName = Path.GetFileName(logistics.ReportFullPath);
_ = stringBuilder.AppendLine($"RUN [{Title}]");

View File

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

View File

@ -278,7 +278,7 @@ public class ProcessData : IProcessData
_I = 0;
_Data = receivedData;
ScanPast("RUN:");
Run = GetToEOL();
string title = GetToEOL();
ScanPast("Recipe:");
Recipe = GetBefore("RESISTIVITY SPEC:");
if (string.IsNullOrEmpty(Recipe))
@ -286,18 +286,44 @@ public class ProcessData : IProcessData
_I = 0;
_Data = receivedData;
ScanPast("RUN:");
Run = GetToEOL();
title = GetToEOL();
ScanPast("DEVICE:");
Recipe = GetBefore("RESISTIVITY SPEC:");
}
// Remove illegal characters \/:*?"<>| found in the run.
title = Regex.Replace(title.Trim(), @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
if (title.StartsWith("1T") || title.StartsWith("1t"))
title = title.Substring(2);
Run = title;
string[] parsedBatch = title.Split('-');
if (parsedBatch.Length == 1)
RDS = title;
else
{
if (parsedBatch.Length > 0)
Reactor = parsedBatch[0];
if (parsedBatch.Length > 1)
RDS = parsedBatch[1];
if (parsedBatch.Length > 2)
{
string[] parsedPSN = parsedBatch[2].Split('.');
if (parsedPSN.Length >= 1)
PSN = parsedPSN[0];
if (parsedPSN.Length >= 2)
Layer = parsedPSN[1];
}
if (parsedBatch.Length > 3)
Zone = parsedBatch[3];
}
ResistivitySpec = GetToEOL();
ScanPast("EQUIP#:");
EquipId = GetBefore("Engineer:");
string equipId = GetBefore("Engineer:");
// Remove illegal characters \/:*?"<>| found in the equipId.
equipId = Regex.Replace(equipId, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
EquipId = equipId;
Engineer = GetToEOL();
ScanPast("LotID:");
Lot = GetBefore("D.L.RATIO:");
// Remove illegal characters \/:*?"<>| found in the Lot.
Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
DLRatio = GetToEOL();
ScanPast("OPERATOR:");
Employee = GetBefore("TEMP:");
@ -374,64 +400,18 @@ public class ProcessData : IProcessData
}
}
}
//Id = -1;
Run = Run.Trim();
if (!Run.StartsWith("[") && !Run.EndsWith("]"))
throw new Exception("Lot summary data is invalid or missing.");
Run = Run.Replace("[", "");
Run = Run.Replace("]", "");
Run = Regex.Replace(Run, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
_Log.Debug($"****ParseData - cde.Run:'{Run}'");
if (string.IsNullOrEmpty(Run))
throw new Exception("Batch (Run) information does not exist");
//parse out batch and validate
string[] parsedBatch = Run.Split('-');
if (parsedBatch.Length >= 1)
Reactor = parsedBatch[0];
if (parsedBatch.Length >= 2)
RDS = parsedBatch[1];
if (parsedBatch.Length >= 3)
{
string[] parsedPSN = parsedBatch[2].Split('.');
if (parsedPSN.Length >= 1)
PSN = parsedPSN[0];
if (parsedPSN.Length >= 2)
Layer = parsedPSN[1];
}
if (parsedBatch.Length >= 4)
Zone = parsedBatch[3];
//create filename / unique id
string timeFormat = "yyyyMMddHHmmss";
//fix equip
StringBuilder equipFixed = new();
foreach (char c in EquipId)
{
if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
{
_ = equipFixed.Append(c);
}
}
EquipId = equipFixed.ToString();
_Log.Debug($"****ParseData - cde.EquipId:'{EquipId}'");
// The "cde.Run" string is used as part of the SharePoint header unique ID. The "cde.Run" ID is typed
// at the tool by the users. The characters are not controlled and the user can type any characters like
// "\", "*", ".", " ", etc. Some of these characters are not valid and thus can't be used for the
// SharePoint header unique ID. Therefore, we need to filter out invalid characters and only keep the
// important ones.
StringBuilder runFixed = new();
foreach (char c in Run)
{
if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
_ = runFixed.Append(c);
}
Run = runFixed.ToString();
UniqueId = string.Concat(EquipId, "_", Run, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
_Log.Debug($"****ParseData - Title:{title}; EquipId:{equipId};");
if (string.IsNullOrEmpty(title))
throw new Exception("Batch (title) information does not exist");
UniqueId = string.Concat(equipId, "_", title, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
foreach (Detail item in _Details.Cast<Detail>())
{
item.HeaderUniqueId = UniqueId;
item.UniqueId = string.Concat(item, item.UniqueId);
}
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath));
fileInfoCollection.Add(logistics.FileInfo);
}
#nullable enable