CrossSection view model was improved

This commit is contained in:
Evgeny Redikultsev
2024-02-02 22:27:18 +05:00
parent b1fc0c763f
commit 165a2846bb
22 changed files with 307 additions and 170 deletions

View File

@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
@@ -10,7 +11,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
public PredicateTypes PredicateType { get; set; }
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
public string Name { get; set; }
public ITraceLogger? TraceLogger { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public Predicate<IPoint2D> GetPredicate()
{
@@ -19,6 +25,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
Ndms = Ndms,
ConvertLogic = ConvertLogic
};
if (TraceLogger is not null)
{
factory.TraceLogger = TraceLogger;
}
TraceLogger?.AddMessage($"Predicate factory was obtained succsefully", TraceLogStatuses.Debug);
var predicateType = PredicateType;
var predicate = factory.GetPredicate(predicateType);
return predicate;

View File

@@ -1,12 +1,12 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
{
public interface IGetPredicateLogic
public interface IGetPredicateLogic : ILogic, ICloneable
{
string Name { get; set; }
Predicate<IPoint2D> GetPredicate();
ITraceLogger? TraceLogger { get; set; }
}
}

View File

@@ -1,5 +1,8 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator;
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Cracking;
@@ -14,13 +17,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
Strength,
Cracking
}
public class PredicateFactory
public class PredicateFactory : ILogic
{
private ForceTupleCalculator calculator;
private ForceTuple tuple;
private ForceTupleInputData inputData;
private IShiftTraceLogger logger;
public IEnumerable<INdm> Ndms { get; set; }
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public PredicateFactory()
{
inputData = new();
@@ -28,6 +35,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
}
public Predicate<IPoint2D> GetPredicate(PredicateTypes predicateType)
{
if (TraceLogger is not null)
{
logger = new ShiftTraceLogger() { ShiftPriority = 500, KeepErrorStatus = false };
//calculator.TraceLogger = logger; // too much results
//ConvertLogic.TraceLogger = logger; //wrong work in different threads
}
if (predicateType == PredicateTypes.Strength)
{
return point2D => IsSectionFailure(point2D);
@@ -44,6 +57,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private bool IsSectionFailure(IPoint2D point2D)
{
logger?.TraceLoggerEntries.Clear();
var point3D = ConvertLogic.GetPoint3D(point2D);
tuple = new()
{
@@ -54,12 +68,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
inputData.Tuple = tuple;
inputData.NdmCollection = Ndms;
calculator.Run();
if (logger is not null)
{
TraceLogger?.TraceLoggerEntries.AddRange(logger.TraceLoggerEntries);
}
var result = calculator.Result;
return !result.IsValid;
}
private bool IsSectionCracked(IPoint2D point2D)
{
logger?.TraceLoggerEntries.Clear();
var logic = new HoleSectionCrackedLogic();
var point3D = ConvertLogic.GetPoint3D(point2D);
tuple = new()
@@ -72,6 +91,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
logic.NdmCollection = Ndms;
try
{
if (logger is not null)
{
TraceLogger?.TraceLoggerEntries.AddRange(logger.TraceLoggerEntries);
}
var result = logic.IsSectionCracked();
return result;
}

View File

@@ -33,7 +33,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
/// <inheritdoc/>
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
{
if (TraceLogger is not null) { ParameterLogic.TraceLogger = TraceLogger; }
if (TraceLogger is not null)
{
ParameterLogic.TraceLogger = TraceLogger;
}
result = new();
resultList = new();
TraceLogger?.AddMessage($"Predicate name is {GetPredicateLogic.Name}");
@@ -74,12 +77,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private Point2D FindResultPoint(IPoint2D point)
{
Predicate<IPoint2D> limitPredicate;
lock (lockObject)
{
limitPredicate = GetPredicateLogic.GetPredicate();
}
var resultPoint = FindResultPointByPredicate(point, limitPredicate);
var resultPoint = FindResultPointByPredicate(point);
lock (lockObject)
{
pointCount++;
@@ -89,14 +87,23 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
return resultPoint;
}
private Point2D FindResultPointByPredicate(IPoint2D point, Predicate<IPoint2D> limitPredicate)
private Point2D FindResultPointByPredicate(IPoint2D point)
{
ShiftTraceLogger newLogger;
Predicate<IPoint2D> limitPredicate;
lock (lockObject)
{
newLogger = new ShiftTraceLogger()
{
ShiftPriority = 100
};
GetPredicateLogic.TraceLogger = newLogger;
limitPredicate = GetPredicateLogic.GetPredicate();
}
var localCurrentPoint = point.Clone() as IPoint2D;
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
logic.TraceLogger = new ShiftTraceLogger()
{
ShiftPriority=100
};
logic.TraceLogger = newLogger;
logic.CurrentPoint = localCurrentPoint;
logic.LimitPredicate = limitPredicate;
double parameter;
@@ -119,7 +126,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
TraceLogger?.AddMessage($"Source point");
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(localCurrentPoint));
TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries);
TraceLogger?.TraceLoggerEntries.AddRange(newLogger.TraceLoggerEntries);
TraceLogger?.AddMessage($"Parameter value {parameter} was obtained");
TraceLogger?.AddMessage($"Calculated point\n(X={localCurrentPoint.X} * {parameter} = {resultPoint.X},\nY={localCurrentPoint.Y} * {parameter} = {resultPoint.Y})");
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(resultPoint));

View File

@@ -106,7 +106,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic,
PredicateType = predicateType
};
if (TraceLogger is not null) { getPredicateLogic.TraceLogger = TraceLogger; }
if (TraceLogger is not null)
{
//getPredicateLogic.TraceLogger = TraceLogger;
}
var logic = new LimitCurveLogic(getPredicateLogic);
var calculator = new LimitCurveCalculator(logic)
{

View File

@@ -6,6 +6,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Cracking
{
public class ExpSofteningLogic : ICrackSofteningLogic
@@ -25,6 +28,9 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
powerFactor = value;
}
}
/// <summary>
/// Factor betta in exponential softening model of reinforced concrete
/// </summary>
public double BettaFactor { get; set; }
public double ForceRatio
{
@@ -42,6 +48,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
forceRatio = value;
}
}
/// <inheritdoc/>
public double PsiSMin {get;set;}
public IShiftTraceLogger? TraceLogger { get; set; }
@@ -51,6 +58,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
PowerFactor = 2d;
BettaFactor = 0.8d;
}
/// <inheritdoc/>
public double GetSofteningFactor()
{
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
@@ -59,7 +67,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
TraceLogger?.AddMessage($"But not less than psi_s_min = {PsiSMin}");
TraceLogger?.AddMessage($"BettaFactor = {BettaFactor}");
TraceLogger?.AddMessage($"ForceRatio = {ForceRatio}");
TraceLogger?.AddMessage($"PowerFactor = {BettaFactor}");
TraceLogger?.AddMessage($"PowerFactor = {PowerFactor}");
double psi;
psi = 1 - BettaFactor * Math.Pow(ForceRatio, PowerFactor);
TraceLogger?.AddMessage($"psi_s = 1 - BettaFactor * ForceRatio ^ PowerFactor = 1 - {BettaFactor} * {ForceRatio} ^ {PowerFactor} = {psi}");