Add checks for beam shear

This commit is contained in:
Evgeny Redikultsev
2025-06-19 22:32:41 +05:00
parent 976b6b5f68
commit 6168b93f3d
16 changed files with 498 additions and 64 deletions

View File

@@ -0,0 +1,116 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperLogics.Models.BeamShears.Logics;
namespace StructureHelperLogics.Models.BeamShears
{
public class CheckBeamShearCalculatorInputDataLogic : ICheckInputDataLogic<IBeamShearCalculatorInputData>
{
private bool result;
private string checkResult;
private ICheckEntityLogic<IBeamShearAction> checkActionsLogic;
private ICheckEntityLogic<IBeamShearSection> checkSectionLogic;
private ICheckEntityLogic<IStirrup> checkStirrupLogic;
public string CheckResult => checkResult;
public IBeamShearCalculatorInputData InputData { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckBeamShearCalculatorInputDataLogic(IBeamShearCalculatorInputData inputData, IShiftTraceLogger? traceLogger)
{
InputData = inputData;
TraceLogger = traceLogger;
}
public bool Check()
{
result = true;
checkResult = string.Empty;
if (InputData is null)
{
result = false;
string errorString = ErrorStrings.ParameterIsNull + ": Input data";
throw new StructureHelperException(errorString);
}
CheckActions();
CheckSections();
CheckStirrups();
return result;
}
private void CheckActions()
{
if (InputData.Actions is null || !InputData.Actions.Any())
{
result = false;
string errorString = "\nCollection of actions does not contain any action";
TraceMessage(errorString);
}
else
{
checkActionsLogic ??= new CheckBeamShearActionLogic(TraceLogger);
foreach (var action in InputData.Actions)
{
checkActionsLogic.Entity = action;
if (checkActionsLogic.Check() == false)
{
result = false;
checkResult += checkActionsLogic.CheckResult;
}
}
}
}
private void CheckStirrups()
{
if (InputData.Stirrups is null)
{
result = false;
TraceMessage("\nCollection of stirrups is null");
}
else
{
checkStirrupLogic ??= new CheckStirrupsLogic(TraceLogger);
foreach (var stirrup in InputData.Stirrups)
{
checkStirrupLogic.Entity = stirrup;
if (checkStirrupLogic.Check() == false)
{
result = false;
checkResult += checkStirrupLogic.CheckResult;
}
}
}
}
private void CheckSections()
{
if (InputData.Sections is null || !InputData.Sections.Any())
{
result = false;
TraceMessage("\nCollection of sections does not contain any section");
}
else
{
checkSectionLogic ??= new CheckBeamShearSectionLogic(TraceLogger);
foreach (var item in InputData.Sections)
{
checkSectionLogic.Entity = item;
if (checkSectionLogic.Check() == false)
{
result = false;
checkResult += checkSectionLogic.CheckResult;
}
}
}
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString);
}
}
}

View File

@@ -0,0 +1,94 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.Models.BeamShears.Logics
{
public class CheckBeamShearSectionLogic : ICheckEntityLogic<IBeamShearSection>
{
private const double minValueOfCenterCover = 0.01;
private const double minValueOfCrossSectionWidth = 0.05;
private const double minValueOfCrossSectionHeight = 0.05;
private bool result;
private string checkResult;
public CheckBeamShearSectionLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public IBeamShearSection Entity { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public bool Check()
{
checkResult = string.Empty;
result = true;
if (Entity is null)
{
result = false;
string errorString = "\nSection is not assigned";
TraceMessage(errorString);
}
else
{
if (Entity.Material is null)
{
result = false;
TraceMessage($"\nMaterial of cross-section is not assigned");
}
if (Entity.CenterCover < minValueOfCenterCover)
{
result = false;
TraceMessage($"\nValue of center cover c = {Entity.CenterCover}(m) must not be less than cmin = {minValueOfCenterCover}(m)");
}
CheckShape();
}
return result;
}
private void CheckShape()
{
if (Entity.Shape is null)
{
result = false;
TraceMessage($"\nShape of cross-section is null");
}
else
{
if (Entity.Shape is IRectangleShape rectangle)
{
CheckRectangleShape(rectangle);
}
else
{
result = false;
TraceMessage($"\nType of shape of cross-section is unknown");
}
}
}
private void CheckRectangleShape(IRectangleShape rectangle)
{
if (rectangle.Width < minValueOfCrossSectionWidth)
{
result = false;
TraceMessage($"\nValue of cross-section width b = {rectangle.Width}(m) must not be less than bmin = {minValueOfCrossSectionWidth}(m)");
}
if (rectangle.Height < minValueOfCrossSectionHeight)
{
result = false;
TraceMessage($"\nValue of cross-section height h = {rectangle.Height}(m) must not be less than hmin = {minValueOfCrossSectionHeight}(m)");
}
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString);
}
}
}

View File

@@ -0,0 +1,92 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
namespace StructureHelperLogics.Models.BeamShears
{
public class CheckDirectForceInputDataLogic : ICheckInputDataLogic<IDirectShearForceLogicInputData>
{
private string checkResult;
private bool result;
private ICheckEntityLogic<IInclinedSection> checkInclinedSectionLogic;
private ICheckEntityLogic<IBeamShearAction> checkBeamShearActionLogic;
public string CheckResult => checkResult;
public IDirectShearForceLogicInputData InputData { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckDirectForceInputDataLogic(IDirectShearForceLogicInputData inputData, IShiftTraceLogger? traceLogger)
{
InputData = inputData;
TraceLogger = traceLogger;
}
public bool Check()
{
InitializeStrategies();
result = true;
if (InputData is null)
{
result = false;
string errorString = "\nInput data is not assigned";
TraceMessage(errorString);
}
else
{
CheckBeamShearAction();
CheckInclinedSection();
}
return result;
}
private void InitializeStrategies()
{
checkInclinedSectionLogic ??= new CheckInclinedSectionLogic(InputData.InclinedSection, TraceLogger);
checkBeamShearActionLogic ??= new CheckBeamShearActionLogic(TraceLogger);
}
private void CheckBeamShearAction()
{
if (InputData.BeamShearAction is null)
{
result = false;
TraceMessage($"\nBeam shear action is not assigned");
}
else
{
checkBeamShearActionLogic.Entity = InputData.BeamShearAction;
if (checkBeamShearActionLogic.Check() == false)
{
result = false;
checkResult += checkBeamShearActionLogic.CheckResult;
}
}
}
private void CheckInclinedSection()
{
if (InputData.InclinedSection is null)
{
result = false;
TraceMessage($"\nInclined section is not assigned");
}
else
{
if (checkInclinedSectionLogic.Check() == false)
{
result = false;
checkResult += checkInclinedSectionLogic.CheckResult;
}
}
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
}
}
}

View File

@@ -0,0 +1,69 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
namespace StructureHelperLogics.Models.BeamShears
{
public class CheckInclinedSectionLogic : ICheckEntityLogic<IInclinedSection>
{
private const double minValueOfEffectiveDepth = 0.05;
private const double minValueOfWebWidth = 0.05;
private string checkResult;
private bool result;
public IInclinedSection Entity { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckInclinedSectionLogic(IInclinedSection entity, IShiftTraceLogger? traceLogger)
{
Entity = entity;
TraceLogger = traceLogger;
}
public CheckInclinedSectionLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public bool Check()
{
checkResult = string.Empty;
result = true;
if (Entity is null)
{
result = false;
string errorString = "\nInclined section is not assigned";
TraceMessage(errorString);
}
else
{
if (Entity.StartCoord < 0)
{
result = false;
TraceMessage($"\nCoordinate of start of inclined section Xstart = {Entity.StartCoord}(m) must not be less than zero");
}
if (Entity.EndCoord < Entity.StartCoord)
{
result = false;
TraceMessage($"\nCoordinate of end of inclined section Xend = {Entity.EndCoord}(m) must not be less than Xstart = {Entity.StartCoord}(m)");
}
if (Entity.EffectiveDepth < minValueOfEffectiveDepth)
{
result = false;
TraceMessage($"\nEffective depth of inclined section d = {Entity.EffectiveDepth}(m) must be grater than dmin = {minValueOfEffectiveDepth}(m)");
}
if (Entity.WebWidth < minValueOfWebWidth)
{
result = false;
TraceMessage($"\nWidth of web of inclined section b = {Entity.WebWidth}(m) must be grater than bmin = {minValueOfWebWidth}(m)");
}
}
return result;
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
}
}
}

View File

@@ -0,0 +1,56 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
internal class CheckStirrupsByDensityLogic : ICheckEntityLogic<IStirrupByDensity>
{
private const int minDensity = 0;
private bool result;
private string checkResult;
public CheckStirrupsByDensityLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public IStirrupByDensity Entity { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public bool Check()
{
checkResult = string.Empty;
result = true;
if (Entity is null)
{
result = false;
string errorString = "\nStirrups by density is not assigned";
TraceMessage(errorString);
}
else
{
if (Entity.StirrupDensity < minDensity)
{
result = false;
TraceMessage($"\nStirrup {Entity.Name} density d = {Entity.StirrupDensity} must not be less than dmin = {minDensity}");
}
}
return result;
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
}
}
}

View File

@@ -0,0 +1,78 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
internal class CheckStirrupsByRebarLogic : ICheckEntityLogic<IStirrupByRebar>
{
private const double minDiameter = 0.003;
private const double maxDiameter = 0.025;
private const double minSpacing = 0.020;
private const double maxSpacing = 0.500;
private const int minLegCount = 0;
private bool result;
private string checkResult;
public CheckStirrupsByRebarLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public IStirrupByRebar Entity { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public bool Check()
{
checkResult = string.Empty;
result = true;
if (Entity is null)
{
result = false;
string errorString = "\nStirrups by density is not assigned";
TraceMessage(errorString);
}
else
{
if (Entity.Diameter < minDiameter)
{
result = false;
TraceMessage($"\nStirrup {Entity.Name} diameter d = {Entity.Diameter} must not be less than dmin = {minDiameter}");
}
if (Entity.Diameter > maxDiameter)
{
result = false;
TraceMessage($"\nStirrup {Entity.Name} diameter d = {Entity.Diameter} must be less or equal than dmax = {maxDiameter}");
}
if (Entity.Spacing < minSpacing)
{
result = false;
TraceMessage($"\nStirrup {Entity.Name} spacing s = {Entity.Spacing} must not be less than smin = {minSpacing}");
}
if (Entity.Spacing > maxSpacing)
{
result = false;
TraceMessage($"\nStirrup {Entity.Name} spacing s = {Entity.Spacing} must be less or equal than smax = {maxSpacing}");
}
if (Entity.LegCount < minLegCount)
{
result = false;
TraceMessage($"\nStirrup {Entity.Name} leg count n = {Entity.LegCount} must not be less than nmin = {minLegCount}");
}
}
return result;
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
}
}
}

View File

@@ -0,0 +1,72 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
namespace StructureHelperLogics.Models.BeamShears
{
public class CheckStirrupsLogic : ICheckEntityLogic<IStirrup>
{
private bool result;
private string checkResult;
private ICheckEntityLogic<IStirrupByDensity> checkDensityLogic;
private ICheckEntityLogic<IStirrupByRebar> checkRebarLogic;
public CheckStirrupsLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public IStirrup Entity { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public bool Check()
{
checkResult = string.Empty;
result = true;
if (Entity is null)
{
result = false;
string errorString = "\nStirrup is not assigned";
TraceMessage(errorString);
}
else
{
if (Entity is IStirrupByDensity density)
{
checkDensityLogic ??= new CheckStirrupsByDensityLogic(TraceLogger);
checkDensityLogic.Entity = density;
if (checkDensityLogic.Check() == false)
{
result = false;
checkResult += checkDensityLogic.CheckResult;
}
}
if (Entity is IStirrupByRebar rebar)
{
checkRebarLogic ??= new CheckStirrupsByRebarLogic(TraceLogger);
checkRebarLogic.Entity = rebar;
if (checkRebarLogic.Check() == false)
{
result = false;
checkResult += checkRebarLogic.CheckResult;
}
}
else
{
result = false;
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(Entity) + $": name = {Entity.Name}, id = {Entity.Id}";
TraceMessage(errorString);
}
}
return result;
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
}
}
}