Added _ColorCollections
This commit is contained in:
@ -4,6 +4,7 @@ using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@ -14,9 +15,16 @@ namespace Adaptation.FileHandlers.jpeg;
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
protected string _LastText;
|
||||
protected int _EndX;
|
||||
protected int _EndY;
|
||||
protected int _StartX;
|
||||
protected int _StartY;
|
||||
protected int[] _Bounds;
|
||||
protected long _LastChange;
|
||||
protected string _LastText;
|
||||
protected string _TessDataDirectory;
|
||||
protected readonly Dictionary<string, string> _Reactors;
|
||||
protected readonly List<(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, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
|
||||
@ -44,11 +52,11 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
string x86 = Path.Combine(entryAssemblyLocationDirectory, "x86");
|
||||
if (!Directory.Exists(x86))
|
||||
_ = Directory.CreateDirectory(x86);
|
||||
string tessdata = Path.Combine(entryAssemblyLocationDirectory, "tessdata");
|
||||
if (!Directory.Exists(tessdata))
|
||||
_ = Directory.CreateDirectory(tessdata);
|
||||
_TessDataDirectory = Path.Combine(entryAssemblyLocationDirectory, "tessdata");
|
||||
if (!Directory.Exists(_TessDataDirectory))
|
||||
_ = Directory.CreateDirectory(_TessDataDirectory);
|
||||
string pdfttfSource = Path.Combine(entryAssemblyLocationDirectory, "pdf.ttf");
|
||||
string pdfttfDestination = Path.Combine(tessdata, Path.GetFileName(pdfttfSource));
|
||||
string pdfttfDestination = Path.Combine(_TessDataDirectory, Path.GetFileName(pdfttfSource));
|
||||
if (File.Exists(pdfttfSource) && !File.Exists(pdfttfDestination))
|
||||
File.Copy(pdfttfSource, pdfttfDestination);
|
||||
string tesseract41dllSource = Path.Combine(entryAssemblyLocationDirectory, "tesseract41.dll");
|
||||
@ -56,13 +64,24 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
if (File.Exists(tesseract41dllSource) && !File.Exists(tesseract41dllDestination))
|
||||
File.Copy(tesseract41dllSource, tesseract41dllDestination);
|
||||
string engtraineddataSource = Path.Combine(entryAssemblyLocationDirectory, "eng.traineddata");
|
||||
string engtraineddataDestination = Path.Combine(tessdata, Path.GetFileName(engtraineddataSource));
|
||||
string engtraineddataDestination = Path.Combine(_TessDataDirectory, Path.GetFileName(engtraineddataSource));
|
||||
if (File.Exists(engtraineddataSource) && !File.Exists(engtraineddataDestination))
|
||||
File.Copy(engtraineddataSource, engtraineddataDestination);
|
||||
string leptonica1800dllSource = Path.Combine(entryAssemblyLocationDirectory, "leptonica-1.80.0.dll");
|
||||
string leptonica1800dllDestination = Path.Combine(x86, Path.GetFileName(leptonica1800dllSource));
|
||||
if (File.Exists(leptonica1800dllSource) && !File.Exists(leptonica1800dllDestination))
|
||||
File.Copy(leptonica1800dllSource, leptonica1800dllDestination);
|
||||
ModelObjectParameterDefinition[] images = GetProperties(cellInstanceConnectionName, modelObjectParameters, "Image.");
|
||||
string startX = GetPropertyValue(cellInstanceConnectionName, images, "Image.StartX");
|
||||
string startY = GetPropertyValue(cellInstanceConnectionName, images, "Image.StartY");
|
||||
string endX = GetPropertyValue(cellInstanceConnectionName, images, "Image.EndX");
|
||||
string endY = GetPropertyValue(cellInstanceConnectionName, images, "Image.EndY");
|
||||
_StartX = int.Parse(startX);
|
||||
_StartY = int.Parse(startY);
|
||||
_EndX = int.Parse(endX);
|
||||
_EndY = int.Parse(endY);
|
||||
string masterImageDirectory = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory.Master.Images");
|
||||
_ColorCollections = ProcessData.GetColorCollections(_StartX, _StartY, _EndX, _EndY, masterImageDirectory);
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
|
||||
@ -141,7 +160,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
results.Item4.Add(new FileInfo(reportFullPath));
|
||||
else
|
||||
{
|
||||
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4);
|
||||
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _TessDataDirectory, _StartX, _StartY, _EndX, _EndY, _ColorCollections);
|
||||
if (iProcessData is ProcessData _)
|
||||
{
|
||||
if (!iProcessData.Details.Any())
|
||||
@ -156,7 +175,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
throw new Exception(string.Concat("C) No Data - ", dateTime.Ticks));
|
||||
if (_LastText != _Logistics.MID || _LastChange < DateTime.Now.AddMinutes(-30).Ticks)
|
||||
{
|
||||
_LastText = _Logistics.MesEntity;
|
||||
_LastText = _Logistics.MID;
|
||||
_LastChange = DateTime.Now.Ticks;
|
||||
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
||||
}
|
||||
|
Reference in New Issue
Block a user