Added ClosestMatchFileName,
Changed dummy to match HgCV
This commit is contained in:
parent
7a94484d0e
commit
360d2ee4d8
@ -220,61 +220,47 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string pathSegment;
|
string sourceParentDirectory;
|
||||||
string monARessource;
|
string targetParentDirectory;
|
||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
if (!_FileConnectorConfiguration.TargetFileLocation.Contains(_FileConnectorConfiguration.SourceFileLocation))
|
if (!string.IsNullOrEmpty(Path.GetFileName(_FileConnectorConfiguration.SourceFileLocation)))
|
||||||
throw new Exception("Target must start with source!");
|
sourceParentDirectory = Path.GetDirectoryName(_FileConnectorConfiguration.SourceFileLocation);
|
||||||
|
else
|
||||||
|
sourceParentDirectory = Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.SourceFileLocation));
|
||||||
|
if (!string.IsNullOrEmpty(Path.GetFileName(_FileConnectorConfiguration.TargetFileLocation)))
|
||||||
|
targetParentDirectory = Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation);
|
||||||
|
else
|
||||||
|
targetParentDirectory = Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation));
|
||||||
|
if (sourceParentDirectory != targetParentDirectory)
|
||||||
|
throw new Exception("Target and source must have the same parent for Si Dummy FileConnectorConfiguration!");
|
||||||
bool check = dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday;
|
bool check = dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday;
|
||||||
if (!_IsEAFHosted || check)
|
if (!_IsEAFHosted || check)
|
||||||
{
|
{
|
||||||
string checkSegment;
|
string monARessource;
|
||||||
string checkDirectory;
|
|
||||||
string sourceFileFilter;
|
string sourceFileFilter;
|
||||||
string sourceArchiveFile;
|
string sourceArchiveFile;
|
||||||
string sourceFileLocation;
|
|
||||||
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||||
string traceDummyDirectory = Path.Combine(Path.GetPathRoot(_TracePath), "TracesDummy", _CellInstanceName, "Source", $"{dateTime:yyyy}___Week_{weekOfYear}");
|
string traceDummyDirectory = Path.Combine(Path.GetPathRoot(_TracePath), "TracesDummy", _CellInstanceName, "Source", $"{dateTime:yyyy}___Week_{weekOfYear}");
|
||||||
if (!Directory.Exists(traceDummyDirectory))
|
if (!Directory.Exists(traceDummyDirectory))
|
||||||
_ = Directory.CreateDirectory(traceDummyDirectory);
|
_ = Directory.CreateDirectory(traceDummyDirectory);
|
||||||
string traceDummyFile = Path.Combine(traceDummyDirectory, $"{dateTime.Ticks} - {_CellInstanceName}.txt");
|
string traceDummyFile = Path.Combine(traceDummyDirectory, $"{dateTime.Ticks} - {_CellInstanceName}.txt");
|
||||||
File.AppendAllText(traceDummyFile, string.Empty);
|
File.AppendAllText(traceDummyFile, string.Empty);
|
||||||
if (_FileConnectorConfiguration.SourceFileLocation.EndsWith("\\"))
|
|
||||||
sourceFileLocation = _FileConnectorConfiguration.SourceFileLocation;
|
|
||||||
else
|
|
||||||
sourceFileLocation = string.Concat(_FileConnectorConfiguration.SourceFileLocation, '\\');
|
|
||||||
for (int i = 0; i < _FileConnectorConfiguration.SourceFileFilters.Count; i++)
|
for (int i = 0; i < _FileConnectorConfiguration.SourceFileFilters.Count; i++)
|
||||||
{
|
{
|
||||||
_LastDummyRunIndex += 1;
|
_LastDummyRunIndex += 1;
|
||||||
if (_LastDummyRunIndex >= _FileConnectorConfiguration.SourceFileFilters.Count)
|
if (_LastDummyRunIndex >= _FileConnectorConfiguration.SourceFileFilters.Count)
|
||||||
_LastDummyRunIndex = 0;
|
_LastDummyRunIndex = 0;
|
||||||
sourceFileFilter = _FileConnectorConfiguration.SourceFileFilters[_LastDummyRunIndex];
|
sourceFileFilter = _FileConnectorConfiguration.SourceFileFilters[_LastDummyRunIndex];
|
||||||
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, sourceFileFilter));
|
sourceArchiveFile = Path.Combine(_FileConnectorConfiguration.SourceFileLocation, sourceFileFilter);
|
||||||
if (File.Exists(sourceArchiveFile))
|
if (File.Exists(sourceArchiveFile))
|
||||||
{
|
{
|
||||||
checkSegment = _FileConnectorConfiguration.TargetFileLocation.Substring(sourceFileLocation.Length);
|
|
||||||
checkDirectory = Path.GetDirectoryName(sourceArchiveFile);
|
|
||||||
for (int z = 0; z < int.MaxValue; z++)
|
|
||||||
{
|
|
||||||
if (checkDirectory.Length < sourceFileLocation.Length || !checkDirectory.StartsWith(sourceFileLocation))
|
|
||||||
break;
|
|
||||||
checkDirectory = Path.GetDirectoryName(checkDirectory);
|
|
||||||
if (Directory.Exists(Path.Combine(checkDirectory, checkSegment)))
|
|
||||||
{
|
|
||||||
checkDirectory = Path.Combine(checkDirectory, checkSegment);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!checkDirectory.EndsWith(checkSegment))
|
|
||||||
throw new Exception("Could not determine dummy target directory for extract!");
|
|
||||||
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
|
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
|
||||||
throw new Exception("Invalid file name for source archive file!");
|
throw new Exception("Invalid file name for source archive file!");
|
||||||
pathSegment = checkDirectory.Substring(sourceFileLocation.Length);
|
monARessource = GetCellName(sourceArchiveFile);
|
||||||
monARessource = GetCellName(pathSegment);
|
|
||||||
if (string.IsNullOrEmpty(monARessource))
|
if (string.IsNullOrEmpty(monARessource))
|
||||||
throw new Exception("Could not determine which cell archive file is associated with!");
|
throw new Exception("Could not determine which cell archive file is associated with!");
|
||||||
if (_IsEAFHosted)
|
if (_IsEAFHosted)
|
||||||
CallbackFileExists(sourceArchiveFile, traceDummyFile, checkDirectory, monARessource, sequence);
|
CallbackFileExists(sourceArchiveFile, traceDummyFile, _FileConnectorConfiguration.TargetFileLocation, monARessource, sequence);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ public class Description : IDescription, Shared.Properties.IDescription
|
|||||||
public int Red { get; set; }
|
public int Red { get; set; }
|
||||||
public int Green { get; set; }
|
public int Green { get; set; }
|
||||||
public int TotalDelta { get; set; }
|
public int TotalDelta { get; set; }
|
||||||
|
public string ClosestMatchFileName { get; set; }
|
||||||
|
|
||||||
string IDescription.GetEventDescription() => "File Has been read and parsed";
|
string IDescription.GetEventDescription() => "File Has been read and parsed";
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ public class Description : IDescription, Shared.Properties.IDescription
|
|||||||
nameof(Red),
|
nameof(Red),
|
||||||
nameof(Green),
|
nameof(Green),
|
||||||
nameof(TotalDelta),
|
nameof(TotalDelta),
|
||||||
|
nameof(ClosestMatchFileName),
|
||||||
};
|
};
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -169,11 +171,12 @@ public class Description : IDescription, Shared.Properties.IDescription
|
|||||||
Lot = processData.Text,
|
Lot = processData.Text,
|
||||||
PSN = string.Empty,
|
PSN = string.Empty,
|
||||||
Reactor = logistics.ProcessJobID,
|
Reactor = logistics.ProcessJobID,
|
||||||
Recipe = processData.Recipe,
|
Recipe = string.Empty,
|
||||||
//
|
//
|
||||||
Red = processData.Red,
|
Red = processData.Red,
|
||||||
Green = processData.Green,
|
Green = processData.Green,
|
||||||
TotalDelta = processData.TotalDelta,
|
TotalDelta = processData.TotalDelta,
|
||||||
|
ClosestMatchFileName = processData.ClosestMatchFileName,
|
||||||
};
|
};
|
||||||
results.Add(description);
|
results.Add(description);
|
||||||
}
|
}
|
||||||
@ -214,6 +217,7 @@ public class Description : IDescription, Shared.Properties.IDescription
|
|||||||
Red = -1,
|
Red = -1,
|
||||||
Green = -1,
|
Green = -1,
|
||||||
TotalDelta = -1,
|
TotalDelta = -1,
|
||||||
|
ClosestMatchFileName = nameof(ClosestMatchFileName),
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,12 @@ namespace Adaptation.FileHandlers.jpeg;
|
|||||||
public class FileRead : Shared.FileRead, IFileRead
|
public class FileRead : Shared.FileRead, IFileRead
|
||||||
{
|
{
|
||||||
|
|
||||||
protected int _EndX;
|
|
||||||
protected int _EndY;
|
|
||||||
protected int _StartX;
|
|
||||||
protected int _StartY;
|
|
||||||
protected int[] _Bounds;
|
|
||||||
protected long _LastChange;
|
protected long _LastChange;
|
||||||
protected string _LastText;
|
protected string _LastText;
|
||||||
|
protected readonly int _EndX;
|
||||||
|
protected readonly int _EndY;
|
||||||
|
protected readonly int _StartX;
|
||||||
|
protected readonly int _StartY;
|
||||||
protected string _TessDataDirectory;
|
protected string _TessDataDirectory;
|
||||||
protected List<int> _PreviousTotalDeltaCollection;
|
protected List<int> _PreviousTotalDeltaCollection;
|
||||||
protected readonly Dictionary<string, string> _Reactors;
|
protected readonly Dictionary<string, string> _Reactors;
|
||||||
|
@ -25,7 +25,7 @@ public class ProcessData : IProcessData
|
|||||||
public int Green { get; set; }
|
public int Green { get; set; }
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
public int TotalDelta { get; set; }
|
public int TotalDelta { get; set; }
|
||||||
public string Recipe { get; set; }
|
public string ClosestMatchFileName { get; set; }
|
||||||
|
|
||||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||||
|
|
||||||
@ -260,8 +260,8 @@ public class ProcessData : IProcessData
|
|||||||
totalDeltaCollection.Add(new(file, totalDelta));
|
totalDeltaCollection.Add(new(file, totalDelta));
|
||||||
}
|
}
|
||||||
totalDeltaCollection = (from l in totalDeltaCollection orderby l.TotalDelta select l).ToList();
|
totalDeltaCollection = (from l in totalDeltaCollection orderby l.TotalDelta select l).ToList();
|
||||||
Recipe = Path.GetFileNameWithoutExtension(totalDeltaCollection[0].File);
|
ClosestMatchFileName = Path.GetFileNameWithoutExtension(totalDeltaCollection[0].File);
|
||||||
string[] closestMatchFileNameSplit = Recipe.Split('-');
|
string[] closestMatchFileNameSplit = ClosestMatchFileName.Split('-');
|
||||||
Text = closestMatchFileNameSplit.Last().TrimStart();
|
Text = closestMatchFileNameSplit.Last().TrimStart();
|
||||||
TotalDelta = totalDeltaCollection[0].TotalDelta;
|
TotalDelta = totalDeltaCollection[0].TotalDelta;
|
||||||
string textFileName = Get(fileRead, ".txt", $"{TotalDelta} - {Text}");
|
string textFileName = Get(fileRead, ".txt", $"{TotalDelta} - {Text}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user