Force crack calculator was fixed

This commit is contained in:
RedikultsevEvg
2024-08-04 23:01:10 +05:00
parent e7c7211f54
commit 3eb5aa2b96
54 changed files with 1031 additions and 300 deletions

View File

@@ -0,0 +1,62 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Calculators
{
public class CheckAccuracyLogic : ICheckEntityLogic<IAccuracy>
{
private string checkResult;
private bool result;
public IAccuracy Entity { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckAccuracyLogic(IShiftTraceLogger traceLogger)
{
TraceLogger = traceLogger;
}
public CheckAccuracyLogic() : this (null)
{
}
public bool Check()
{
result = true;
if (Entity is null)
{
result = false;
string errorString = "\nAccuracy requirements is not assigned";
TraceMessage(errorString);
}
else
{
if (Entity.IterationAccuracy <= 0)
{
result = false;
TraceMessage($"\nValue of accuracy {Entity.IterationAccuracy} must be grater than zero");
}
if (Entity.MaxIterationCount <= 0)
{
result = false;
TraceMessage($"\nMax number of iteration {Entity.MaxIterationCount} must be grater than zero");
}
}
return result;
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
}
}
}