Version Error Message

Using pattern ...
Tests passed
2023-01-24
Bug in yml
dotnet tool
PackageReference arrangement
nuget ^
Assembly Version
Not verified
Infineon.EAF.Runtime 2.49.0
MesEntity Placeholder
Not Tested
connectionCount
AssemblyVersion
SRP2100 = 53, //Largest
Better errror message
v2.49.2
IDescription.GetDescriptions with body
Viewer support
tasks.json
kanbn initialize
WSRequest alignment
Back to x64
mesfs.infineon.com
Infineon.EAF.Runtime 2.49.3
pool name
Kanban
net8.0
v2_52_0-Tests
editorconfig
dotnet_diagnostic
CA1862 and GetWeekOfYear for WritePDSF
gitignore
cellInstanceVersion.EdaConnection.PortNumber
Added Climatec to Test.cs
GetJobIdDirectory
Remove and
5-Other-Small
mesfs.infineon.com
Infineon.EAF.Runtime 2.49.3
pool name
Kanban
Back to x64
IDescription.GetDescriptions with body
Viewer support
tasks.json
kanbn initialize
WSRequest alignment
v2.49.2
Better errror message
SRP2100 = 53, //Largest
AssemblyVersion
connectionCount
MesEntity Placeholder
Infineon.EAF.Runtime 2.49.0
Assembly Version
dotnet tool
2023-01-24
This commit is contained in:
2024-05-22 07:49:57 -07:00
parent c32489b040
commit 255ccf4280
73 changed files with 2069 additions and 966 deletions

View File

@ -35,6 +35,8 @@ public class Description : IDescription, Shared.Properties.IDescription
public int TotalDelta { get; set; }
public string ClosestMatchFileName { get; set; }
public string RDS { get; set; }
string IDescription.GetEventDescription() => "File Has been read and parsed";
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
@ -136,7 +138,7 @@ public class Description : IDescription, Shared.Properties.IDescription
{
List<IDescription> results = new();
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
if (iProcessData is null || iProcessData.Details.Count == 0 || iProcessData is not ProcessData processData)
results.Add(GetDefault(fileRead, logistics));
else
{
@ -222,4 +224,6 @@ public class Description : IDescription, Shared.Properties.IDescription
return result;
}
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
}

View File

@ -15,6 +15,7 @@ namespace Adaptation.FileHandlers.jpeg;
public class FileRead : Shared.FileRead, IFileRead
{
private long? _TickOffset;
protected long _LastChange;
protected string _LastText;
protected readonly int _EndX;
@ -29,8 +30,8 @@ public class FileRead : Shared.FileRead, IFileRead
protected readonly Dictionary<string, string> _Reactors;
protected readonly List<Tuple<string, Color[]>> _ColorCollections;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted)
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), true, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{
_MinFileLength = 36790;
_NullData = string.Empty;
@ -157,7 +158,8 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
_TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
if (_Logistics.FileInfo.Length < _MinFileLength)
results.Item4.Add(_Logistics.FileInfo);
@ -174,7 +176,7 @@ public class FileRead : Shared.FileRead, IFileRead
SetFileParameterLotID(mid);
string processJobID = iProcessData.GetCurrentReactor(this, _Logistics, _Reactors);
_Logistics.Update(mid, processJobID);
if (!iProcessData.Details.Any())
if (iProcessData.Details.Count == 0)
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
if (processData.Text == _LastText && _LastChange > DateTime.Now.AddMinutes(-30).Ticks)
File.Delete(reportFullPath);

View File

@ -7,8 +7,10 @@ using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Tesseract;
namespace Adaptation.FileHandlers.jpeg;
@ -32,8 +34,6 @@ public class ProcessData : IProcessData
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, Size size, List<Tuple<string, Color[]>> colorCollections)
{
if (logistics is null)
{ }
JobID = logistics.JobID;
fileInfoCollection.Clear();
_Details = new List<object>();
@ -330,4 +330,157 @@ public class ProcessData : IProcessData
return results;
}
#pragma warning disable CA1416
private static MemoryStream GetMemoryStream(System.Drawing.Imaging.ImageFormat imageFormat, Bitmap bitmap, int startX, int startY, int endX, int endY, int offSetX, int offSetY)
{
Color color;
int negitiveGrayScale;
MemoryStream result = new();
int startXValue = startX + offSetX;
int startYValue = startY + offSetY;
int endXValue = endX + offSetX;
int endYValue = endY + offSetY;
using Bitmap selectedBitmap = new(endXValue - startXValue, endYValue - startYValue);
for (int x = startXValue; x < endXValue; x++)
{
for (int y = startYValue; y < endYValue; y++)
{
color = bitmap.GetPixel(x, y);
negitiveGrayScale = 255 - (int)((color.R * 0.3) + (color.G * 0.59) + (color.B * 0.11));
if (negitiveGrayScale < 162)
selectedBitmap.SetPixel(x - startXValue, y - startYValue, Color.FromArgb(color.A, 0, 0, 0));
else
selectedBitmap.SetPixel(x - startXValue, y - startYValue, Color.FromArgb(color.A, 255, 255, 255));
}
}
selectedBitmap.Save(result, imageFormat);
return result;
}
private static List<MemoryStream> GetMemoryStreams(string reportFullPath, string extension)
{
List<MemoryStream> results = new();
System.Drawing.Imaging.ImageFormat imageFormat = Get(extension);
using Bitmap? bitmap = Image.FromFile(reportFullPath) as Bitmap;
if (bitmap is null)
throw new Exception($"Couldn't load image from <{reportFullPath}>");
results.Add(GetMemoryStream(imageFormat, bitmap, 6, 130, 791, 953, 0, 0));
results.Add(GetMemoryStream(imageFormat, bitmap, 48, 795, 359, 869, 0, 0));
results.Add(GetMemoryStream(imageFormat, bitmap, 376, 814, 430, 832, 0, 0));
results.Add(GetMemoryStream(imageFormat, bitmap, 373, 793, 433, 874, 0, 0));
return results;
}
public static List<(float, string, List<string>)> Parse(string reportFullPath)
{
List<(float, string, List<string>)> results = new();
string text;
float pageMeanConfidence;
MemoryStream memoryStream;
List<string> blocks = new();
const string extension = ".tiff";
StringBuilder stringBuilder = new();
using TesseractEngine engine = new(string.Empty, "eng", EngineMode.Default);
List<MemoryStream> memoryStreams = GetMemoryStreams(reportFullPath, extension);
for (int i = 0; i < memoryStreams.Count; i++)
{
_ = stringBuilder.Clear();
memoryStream = memoryStreams[i];
using Pix img = Pix.LoadFromMemory(memoryStream.GetBuffer());
using Page page = engine.Process(img);
text = page.GetText();
pageMeanConfidence = page.GetMeanConfidence();
using ResultIterator iter = page.GetIterator();
iter.Begin();
do
{
do
{
do
{
do
{
_ = stringBuilder.Append(iter.GetText(PageIteratorLevel.Word)).Append(' ');
if (iter.IsAtFinalOf(PageIteratorLevel.TextLine, PageIteratorLevel.Word) && stringBuilder.Length > 0)
{
blocks.Add(stringBuilder.ToString());
_ = stringBuilder.Clear();
}
} while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word));
if (iter.IsAtFinalOf(PageIteratorLevel.Para, PageIteratorLevel.TextLine))
_ = stringBuilder.AppendLine();
} while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine));
} while (iter.Next(PageIteratorLevel.Block, PageIteratorLevel.Para));
} while (iter.Next(PageIteratorLevel.Block));
if (stringBuilder.Length > 0)
blocks.Add(stringBuilder.ToString());
results.Add(new(pageMeanConfidence, text, blocks));
// if (!fileRead.IsEAFHosted)
// {
// fileInfoCollection.Add(new FileInfo(saveFileName));
SaveToFile(extension, $"{reportFullPath}{i}{extension}", memoryStream);
// }
}
return results;
}
#pragma warning restore CA1416
public static (float, string, List<string>) Parse(string reportFullPath, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY)
{
(float, string, List<string>) result;
List<string> blocks = new();
StringBuilder stringBuilder = new();
using TesseractEngine engine = new(string.Empty, "eng", EngineMode.Default);
using Pix img = Pix.LoadFromFile(reportFullPath);
using Page page = engine.Process(img);
string text = page.GetText();
float pageMeanConfidence = page.GetMeanConfidence();
using ResultIterator iter = page.GetIterator();
iter.Begin();
do
{
do
{
do
{
do
{
_ = stringBuilder.Append(iter.GetText(PageIteratorLevel.Word)).Append(' ');
if (iter.IsAtFinalOf(PageIteratorLevel.TextLine, PageIteratorLevel.Word) && stringBuilder.Length > 0)
{
blocks.Add(stringBuilder.ToString());
_ = stringBuilder.Clear();
}
} while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word));
if (iter.IsAtFinalOf(PageIteratorLevel.Para, PageIteratorLevel.TextLine))
_ = stringBuilder.AppendLine();
} while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine));
} while (iter.Next(PageIteratorLevel.Block, PageIteratorLevel.Para));
} while (iter.Next(PageIteratorLevel.Block));
if (stringBuilder.Length > 0)
blocks.Add(stringBuilder.ToString());
result = new(pageMeanConfidence, text, blocks);
return result;
}
private void Parse(IFileRead fileRead, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY)
{
(float pageMeanConfidence, string text, List<string> blocks) = Parse(fileRead.ReportFullPath, fileInfoCollection, startX, startY, endX, endY, offSetX, offSetY);
_Log.Debug(string.Format("Mean confidence: {0}", pageMeanConfidence));
_Log.Debug(string.Format("Text (GetText): \r\n{0}", text));
_Log.Debug("Text (iterator):");
if (blocks.Count == 0)
_Details.Add(text);
else
{
blocks = (from l in blocks where l.Split(':').Length == 3 select l).ToList();
if (blocks.Count == 0)
_Details.Add(text);
else
_Details.Add(blocks[0]);
}
}
}