Force crack calculator was fixed
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,46 +13,77 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
internal class CheckForceCalculatorInputData : ICheckInputDataLogic<ForceInputData>
|
||||
internal class CheckForceCalculatorInputData : ICheckInputDataLogic<IForceInputData>
|
||||
{
|
||||
|
||||
public ForceInputData InputData { get; set; }
|
||||
private bool result;
|
||||
private string checkResult;
|
||||
private ICheckEntityLogic<IAccuracy> checkAccuracyLogic;
|
||||
|
||||
public string CheckResult { get; private set; }
|
||||
public IForceInputData InputData { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public CheckForceCalculatorInputData(ForceInputData inputData)
|
||||
public CheckForceCalculatorInputData(ICheckEntityLogic<IAccuracy> checkAccuracyLogic)
|
||||
{
|
||||
InputData = inputData;
|
||||
CheckResult = string.Empty;
|
||||
this.checkAccuracyLogic = checkAccuracyLogic;
|
||||
}
|
||||
|
||||
public CheckForceCalculatorInputData() : this(new CheckAccuracyLogic())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
bool result = true;
|
||||
CheckResult = string.Empty;
|
||||
if (!InputData.Primitives.Any())
|
||||
result = true;
|
||||
checkResult = string.Empty;
|
||||
if (InputData is null)
|
||||
{
|
||||
CheckResult += "Calculator does not contain any primitives \n";
|
||||
string errorString = ErrorStrings.ParameterIsNull + ": input data";
|
||||
TraceMessage(errorString);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
if (InputData.Primitives is null || !InputData.Primitives.Any())
|
||||
{
|
||||
TraceMessage("Calculator does not contain any primitives");
|
||||
result = false;
|
||||
}
|
||||
if (!InputData.ForceActions.Any())
|
||||
if (InputData.ForceActions is null || !InputData.ForceActions.Any())
|
||||
{
|
||||
CheckResult += "Calculator does not contain any forces \n";
|
||||
TraceMessage("Calculator does not contain any forces");
|
||||
result = false;
|
||||
}
|
||||
if (!InputData.LimitStatesList.Any())
|
||||
if (InputData.LimitStatesList is null || !InputData.LimitStatesList.Any())
|
||||
{
|
||||
CheckResult += "Calculator does not contain any limit states \n";
|
||||
TraceMessage("Calculator does not contain any limit states");
|
||||
result = false;
|
||||
}
|
||||
if (!InputData.CalcTermsList.Any())
|
||||
if (InputData.CalcTermsList is null || !InputData.CalcTermsList.Any())
|
||||
{
|
||||
CheckResult += "Calculator does not contain any calc term \n";
|
||||
TraceMessage("Calculator does not contain any calc term");
|
||||
result = false;
|
||||
}
|
||||
CheckAccuracy();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CheckAccuracy()
|
||||
{
|
||||
checkAccuracyLogic.Entity = InputData.Accuracy;
|
||||
checkAccuracyLogic.TraceLogger = TraceLogger;
|
||||
if (checkAccuracyLogic.Check() == false)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
TraceMessage(checkAccuracyLogic.CheckResult);
|
||||
}
|
||||
|
||||
private void TraceMessage(string errorString)
|
||||
{
|
||||
checkResult += errorString + "\n";
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user