Moved standardDeviation
This commit is contained in:
@ -8,8 +8,6 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using Tesseract;
|
||||
|
||||
namespace Adaptation.FileHandlers.jpeg;
|
||||
|
||||
@ -31,7 +29,7 @@ public class ProcessData : IProcessData
|
||||
|
||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, List<(string, Color[])> colorCollections, List<int> previousTotalDeltaCollection, string lastText)
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, List<(string, Color[])> colorCollections)
|
||||
{
|
||||
if (logistics is null)
|
||||
{ }
|
||||
@ -40,7 +38,7 @@ public class ProcessData : IProcessData
|
||||
_Details = new List<object>();
|
||||
MesEntity = logistics.MesEntity;
|
||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||
Parse(fileRead, fileInfoCollection, startX, startY, endX, endY, colorCollections, previousTotalDeltaCollection, lastText);
|
||||
Parse(fileRead, fileInfoCollection, startX, startY, endX, endY, colorCollections);
|
||||
}
|
||||
|
||||
private static string Get(string value, bool useSplitForMID)
|
||||
@ -220,7 +218,7 @@ public class ProcessData : IProcessData
|
||||
return results;
|
||||
}
|
||||
|
||||
private void Parse(IFileRead fileRead, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, List<(string, Color[])> colorCollections, List<int> previousTotalDeltaCollection, string lastText)
|
||||
private void Parse(IFileRead fileRead, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, List<(string, Color[])> colorCollections)
|
||||
{
|
||||
Red = 0;
|
||||
Green = 0;
|
||||
@ -269,25 +267,10 @@ public class ProcessData : IProcessData
|
||||
string textFileName = Get(fileRead, ".txt", $"{TotalDelta} - {Text}");
|
||||
if (!fileRead.IsEAFHosted)
|
||||
{
|
||||
_Log.Debug(textFileName);
|
||||
fileInfoCollection.Add(new FileInfo(textFileName));
|
||||
SaveText(Red, Green, Text, textFileName, totalDeltaCollection);
|
||||
}
|
||||
if (Text != lastText && previousTotalDeltaCollection.Count > 50)
|
||||
{
|
||||
double average = previousTotalDeltaCollection.Average();
|
||||
double sum = previousTotalDeltaCollection.Sum(l => Math.Pow(l - average, 2));
|
||||
double standardDeviation = Math.Sqrt(sum / previousTotalDeltaCollection.Count);
|
||||
double deviation = standardDeviation * 3;
|
||||
double upper = average + deviation;
|
||||
double lower = average - deviation;
|
||||
string message = $"average:{average};sum:{sum};standardDeviation:{standardDeviation};upper:{upper};lower:{lower};TotalDelta:{TotalDelta};Text:{Text};previousTotalDeltaCollection.Count:{previousTotalDeltaCollection.Count};";
|
||||
_Log.Debug(message);
|
||||
if (TotalDelta > upper)
|
||||
throw new Exception(message);
|
||||
if (TotalDelta < lower)
|
||||
throw new Exception(message);
|
||||
}
|
||||
previousTotalDeltaCollection.Add(TotalDelta);
|
||||
_Details.Add(Text);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user