Add checks for beam shear
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
<TextBlock Text="Name"/>
|
<TextBlock Text="Name"/>
|
||||||
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
||||||
<TextBlock Grid.Row="1" Text="Density"/>
|
<TextBlock Grid.Row="1" Text="Density"/>
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Density, Converter={StaticResource DistributedLoadConverter}}"/>
|
<TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource ValidatedError}" Text="{Binding Density, Converter={StaticResource DistributedLoadConverter}, ValidatesOnDataErrors=True}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
using StructureHelper.Infrastructure;
|
using StructureHelper.Windows.ViewModels;
|
||||||
using StructureHelper.Windows.ViewModels;
|
|
||||||
using StructureHelperLogics.Models.BeamShears;
|
using StructureHelperLogics.Models.BeamShears;
|
||||||
using System;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelper.Windows.BeamShears
|
namespace StructureHelper.Windows.BeamShears
|
||||||
{
|
{
|
||||||
public class StirrupByDensityViewModel : OkCancelViewModelBase
|
public class StirrupByDensityViewModel : OkCancelViewModelBase, IDataErrorInfo
|
||||||
{
|
{
|
||||||
private readonly IStirrupByDensity stirrupByDensity;
|
private readonly IStirrupByDensity stirrupByDensity;
|
||||||
|
public double MinDensity { get; set; } = 0;
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
@@ -32,6 +28,24 @@ namespace StructureHelper.Windows.BeamShears
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Error => null;
|
||||||
|
|
||||||
|
public string this[string columnName]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string result = null;
|
||||||
|
if (columnName == nameof(Density))
|
||||||
|
{
|
||||||
|
if (Density < MinDensity)
|
||||||
|
{
|
||||||
|
result = $"Density of stirrups must not be less than {MinDensity}(N/m)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public StirrupByDensityViewModel(IStirrupByDensity stirrupByDensity)
|
public StirrupByDensityViewModel(IStirrupByDensity stirrupByDensity)
|
||||||
{
|
{
|
||||||
this.stirrupByDensity = stirrupByDensity;
|
this.stirrupByDensity = stirrupByDensity;
|
||||||
|
|||||||
@@ -32,11 +32,11 @@
|
|||||||
<TextBlock Text="Name"/>
|
<TextBlock Text="Name"/>
|
||||||
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
||||||
<TextBlock Grid.Row="1" Text="Diameter"/>
|
<TextBlock Grid.Row="1" Text="Diameter"/>
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Diameter, Converter={StaticResource LengthConverter}}"/>
|
<TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource ValidatedError}" Text="{Binding Diameter, Converter={StaticResource LengthConverter},ValidatesOnDataErrors=True}"/>
|
||||||
<TextBlock Grid.Row="2" Text="Number of legs"/>
|
<TextBlock Grid.Row="2" Text="Number of legs"/>
|
||||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LegCount, Converter={StaticResource PlainDouble}}"/>
|
<TextBox Grid.Row="2" Grid.Column="1" Style="{StaticResource ValidatedError}" Text="{Binding LegCount, Converter={StaticResource PlainDouble},ValidatesOnDataErrors=True}"/>
|
||||||
<TextBlock Grid.Row="3" Text="Spacing"/>
|
<TextBlock Grid.Row="3" Text="Spacing"/>
|
||||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Spacing, Converter={StaticResource LengthConverter}}"/>
|
<TextBox Grid.Row="3" Grid.Column="1" Style="{StaticResource ValidatedError}" Text="{Binding Spacing, Converter={StaticResource LengthConverter},ValidatesOnDataErrors=True}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Material" DataContext="{Binding Material}">
|
<TabItem Header="Material" DataContext="{Binding Material}">
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
using StructureHelper.Windows.ViewModels;
|
using StructureHelper.Windows.ViewModels;
|
||||||
using StructureHelper.Windows.ViewModels.Materials;
|
using StructureHelper.Windows.ViewModels.Materials;
|
||||||
using StructureHelperLogics.Models.BeamShears;
|
using StructureHelperLogics.Models.BeamShears;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace StructureHelper.Windows.BeamShears
|
namespace StructureHelper.Windows.BeamShears
|
||||||
{
|
{
|
||||||
public class StirrupByRebarViewModel : OkCancelViewModelBase
|
public class StirrupByRebarViewModel : OkCancelViewModelBase, IDataErrorInfo
|
||||||
{
|
{
|
||||||
private readonly IStirrupByRebar stirrupByRebar;
|
private readonly IStirrupByRebar stirrupByRebar;
|
||||||
|
|
||||||
@@ -61,6 +62,45 @@ namespace StructureHelper.Windows.BeamShears
|
|||||||
|
|
||||||
public ReinforcementViewModel Material { get; private set; }
|
public ReinforcementViewModel Material { get; private set; }
|
||||||
|
|
||||||
|
public string Error => null;
|
||||||
|
|
||||||
|
public double MinDiameter { get; set; } = 0.003;
|
||||||
|
public double MinLegCount { get; set; } = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// Minimum value of spacing in meters
|
||||||
|
/// </summary>
|
||||||
|
public double MinSpacing { get; set; } = 0.02;
|
||||||
|
|
||||||
|
public string this[string columnName]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string result = null;
|
||||||
|
if (columnName == nameof(Diameter))
|
||||||
|
{
|
||||||
|
if (Diameter < MinDiameter)
|
||||||
|
{
|
||||||
|
result = $"Diameter of stirrups must not be less than {MinDiameter}(m)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (columnName == nameof(LegCount))
|
||||||
|
{
|
||||||
|
if (LegCount < MinLegCount)
|
||||||
|
{
|
||||||
|
result = $"Number of legs of stirrups must not be less than {MinLegCount}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (columnName == nameof(Spacing))
|
||||||
|
{
|
||||||
|
if (Spacing < MinSpacing)
|
||||||
|
{
|
||||||
|
result = $"Spacing of stirrups must not be less than {MinSpacing}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public StirrupByRebarViewModel(IStirrupByRebar stirrupByRebar)
|
public StirrupByRebarViewModel(IStirrupByRebar stirrupByRebar)
|
||||||
{
|
{
|
||||||
this.stirrupByRebar = stirrupByRebar;
|
this.stirrupByRebar = stirrupByRebar;
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
|
|||||||
public IBeamShearAction Entity { get; set; }
|
public IBeamShearAction Entity { get; set; }
|
||||||
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||||
public CheckBeamShearActionLogic(IBeamShearAction entity, IShiftTraceLogger? traceLogger)
|
|
||||||
|
public CheckBeamShearActionLogic(IShiftTraceLogger? traceLogger)
|
||||||
{
|
{
|
||||||
Entity = entity;
|
|
||||||
TraceLogger = traceLogger;
|
TraceLogger = traceLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Forces.BeamShearActions;
|
||||||
using StructureHelperLogics.Models.BeamShears.Logics;
|
using StructureHelperLogics.Models.BeamShears.Logics;
|
||||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelperLogics.Models.BeamShears
|
namespace StructureHelperLogics.Models.BeamShears
|
||||||
{
|
{
|
||||||
@@ -15,7 +11,9 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
{
|
{
|
||||||
private bool result;
|
private bool result;
|
||||||
private string checkResult;
|
private string checkResult;
|
||||||
|
private ICheckEntityLogic<IBeamShearAction> checkActionsLogic;
|
||||||
private ICheckEntityLogic<IBeamShearSection> checkSectionLogic;
|
private ICheckEntityLogic<IBeamShearSection> checkSectionLogic;
|
||||||
|
private ICheckEntityLogic<IStirrup> checkStirrupLogic;
|
||||||
|
|
||||||
public string CheckResult => checkResult;
|
public string CheckResult => checkResult;
|
||||||
public IBeamShearCalculatorInputData InputData { get; set; }
|
public IBeamShearCalculatorInputData InputData { get; set; }
|
||||||
@@ -36,14 +34,55 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
string errorString = ErrorStrings.ParameterIsNull + ": Input data";
|
string errorString = ErrorStrings.ParameterIsNull + ": Input data";
|
||||||
throw new StructureHelperException(errorString);
|
throw new StructureHelperException(errorString);
|
||||||
}
|
}
|
||||||
|
CheckActions();
|
||||||
|
CheckSections();
|
||||||
|
CheckStirrups();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckActions()
|
||||||
|
{
|
||||||
if (InputData.Actions is null || !InputData.Actions.Any())
|
if (InputData.Actions is null || !InputData.Actions.Any())
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
string errorString = "Collection of actions does not contain any action";
|
string errorString = "\nCollection of actions does not contain any action";
|
||||||
TraceMessage(errorString);
|
TraceMessage(errorString);
|
||||||
}
|
}
|
||||||
CheckSections();
|
else
|
||||||
return result;
|
{
|
||||||
|
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()
|
private void CheckSections()
|
||||||
@@ -51,8 +90,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
if (InputData.Sections is null || !InputData.Sections.Any())
|
if (InputData.Sections is null || !InputData.Sections.Any())
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
string errorString = "Collection of sections does not contain any section";
|
TraceMessage("\nCollection of sections does not contain any section");
|
||||||
TraceMessage(errorString);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
private void InitializeStrategies()
|
private void InitializeStrategies()
|
||||||
{
|
{
|
||||||
checkInclinedSectionLogic ??= new CheckInclinedSectionLogic(InputData.InclinedSection, TraceLogger);
|
checkInclinedSectionLogic ??= new CheckInclinedSectionLogic(InputData.InclinedSection, TraceLogger);
|
||||||
checkBeamShearActionLogic ??= new CheckBeamShearActionLogic(InputData.BeamShearAction, TraceLogger);
|
checkBeamShearActionLogic ??= new CheckBeamShearActionLogic(TraceLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckBeamShearAction()
|
private void CheckBeamShearAction()
|
||||||
@@ -57,6 +57,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
checkBeamShearActionLogic.Entity = InputData.BeamShearAction;
|
||||||
if (checkBeamShearActionLogic.Check() == false)
|
if (checkBeamShearActionLogic.Check() == false)
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
@@ -19,6 +19,11 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
TraceLogger = traceLogger;
|
TraceLogger = traceLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CheckInclinedSectionLogic(IShiftTraceLogger? traceLogger)
|
||||||
|
{
|
||||||
|
TraceLogger = traceLogger;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Check()
|
public bool Check()
|
||||||
{
|
{
|
||||||
checkResult = string.Empty;
|
checkResult = string.Empty;
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
|
|
||||||
private void InitializeStrategies()
|
private void InitializeStrategies()
|
||||||
{
|
{
|
||||||
getLongitudinalForceFactorLogic ??= new GetLogitudinalForceFactorLogic(TraceLogger?.GetSimilarTraceLogger(100));
|
getLongitudinalForceFactorLogic ??= new GetLongitudinalForceFactorLogic(TraceLogger?.GetSimilarTraceLogger(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetLongitudinalForce()
|
private void SetLongitudinalForce()
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelperLogics.Models.BeamShears.Logics
|
namespace StructureHelperLogics.Models.BeamShears.Logics
|
||||||
{
|
{
|
||||||
public class GetLogitudinalForceFactorLogic : IGetLongitudinalForceFactorLogic
|
public class GetLongitudinalForceFactorLogic : IGetLongitudinalForceFactorLogic
|
||||||
{
|
{
|
||||||
private const double fstRatioInCompression = 1.25;
|
private const double fstRatioInCompression = 0.25;
|
||||||
private const double sndRationInCompression = 0.75;
|
private const double sndRatioInCompression = 0.75;
|
||||||
private double sectionArea;
|
private double sectionArea;
|
||||||
|
private ICheckEntityLogic<IInclinedSection> checkInclinedSectionLogic;
|
||||||
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||||
public IInclinedSection InclinedSection { get; set; }
|
public IInclinedSection InclinedSection { get; set; }
|
||||||
public double LongitudinalForce { get; set; }
|
public double LongitudinalForce { get; set; }
|
||||||
|
|
||||||
public GetLogitudinalForceFactorLogic(IShiftTraceLogger? traceLogger)
|
public GetLongitudinalForceFactorLogic(IShiftTraceLogger? traceLogger)
|
||||||
{
|
{
|
||||||
TraceLogger = traceLogger;
|
TraceLogger = traceLogger;
|
||||||
}
|
}
|
||||||
@@ -51,15 +48,11 @@ namespace StructureHelperLogics.Models.BeamShears.Logics
|
|||||||
|
|
||||||
private void Check()
|
private void Check()
|
||||||
{
|
{
|
||||||
if (InclinedSection is null)
|
checkInclinedSectionLogic ??= new CheckInclinedSectionLogic(TraceLogger);
|
||||||
|
checkInclinedSectionLogic.Entity = InclinedSection;
|
||||||
|
if (checkInclinedSectionLogic.Check() == false)
|
||||||
{
|
{
|
||||||
string errorString = ErrorStrings.DataIsInCorrect + "Inclined section is null";
|
string errorString = checkInclinedSectionLogic.CheckResult;
|
||||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
|
||||||
throw new StructureHelperException(errorString);
|
|
||||||
}
|
|
||||||
if (InclinedSection.WebWidth <= 0 || InclinedSection.FullDepth <= 0)
|
|
||||||
{
|
|
||||||
string errorString = ErrorStrings.DataIsInCorrect + $"Inclined section width = {InclinedSection.WebWidth}(m), and full depth = {InclinedSection.FullDepth}, but both of them must be greater than zero";
|
|
||||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||||
throw new StructureHelperException(errorString);
|
throw new StructureHelperException(errorString);
|
||||||
}
|
}
|
||||||
@@ -93,14 +86,14 @@ namespace StructureHelperLogics.Models.BeamShears.Logics
|
|||||||
TraceLogger?.AddMessage($"Stress ratio rc = {stressRatio} < {fstRatioInCompression}");
|
TraceLogger?.AddMessage($"Stress ratio rc = {stressRatio} < {fstRatioInCompression}");
|
||||||
factor = 1 + stressRatio;
|
factor = 1 + stressRatio;
|
||||||
}
|
}
|
||||||
else if (stressRatio > sndRationInCompression)
|
else if (stressRatio > sndRatioInCompression)
|
||||||
{
|
{
|
||||||
factor = 5 * (1 - stressRatio);
|
factor = 5 * (1 - stressRatio);
|
||||||
factor = Math.Max(factor, 0);
|
factor = Math.Max(factor, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
factor = 1;
|
factor = 1 + fstRatioInCompression;
|
||||||
}
|
}
|
||||||
TraceLogger?.AddMessage($"Factor value fi_n = {factor}(dimensionless)");
|
TraceLogger?.AddMessage($"Factor value fi_n = {factor}(dimensionless)");
|
||||||
return factor;
|
return factor;
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
|
using StructureHelperLogics.Models.BeamShears.Logics;
|
||||||
|
using StructureHelperLogics.Models.BeamShears;
|
||||||
|
|
||||||
|
namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class GetLongitudinalForceFactorLogicTests
|
||||||
|
{
|
||||||
|
private Mock<IInclinedSection> _mockSection;
|
||||||
|
private Mock<ICheckEntityLogic<IInclinedSection>> _mockCheckLogic;
|
||||||
|
private Mock<IShiftTraceLogger> _mockLogger;
|
||||||
|
private GetLongitudinalForceFactorLogic _logic;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
_mockSection = new Mock<IInclinedSection>();
|
||||||
|
_mockCheckLogic = new Mock<ICheckEntityLogic<IInclinedSection>>();
|
||||||
|
_mockLogger = new Mock<IShiftTraceLogger>();
|
||||||
|
|
||||||
|
_logic = new GetLongitudinalForceFactorLogic(_mockLogger.Object)
|
||||||
|
{
|
||||||
|
InclinedSection = _mockSection.Object,
|
||||||
|
LongitudinalForce = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
// Inject mock check logic
|
||||||
|
typeof(GetLongitudinalForceFactorLogic)
|
||||||
|
.GetField("checkInclinedSectionLogic", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
|
||||||
|
?.SetValue(_logic, _mockCheckLogic.Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetFactor_Returns1_WhenLongitudinalForceIsZero()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockCheckLogic.Setup(c => c.Check()).Returns(true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _logic.GetFactor();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetFactor_ComputesCorrectly_ForTension()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_logic.LongitudinalForce = 100000; // tension
|
||||||
|
_mockSection.Setup(s => s.WebWidth).Returns(0.3);
|
||||||
|
_mockSection.Setup(s => s.FullDepth).Returns(0.5);
|
||||||
|
_mockSection.Setup(s => s.ConcreteTensionStrength).Returns(2000000);
|
||||||
|
_mockCheckLogic.Setup(c => c.Check()).Returns(true);
|
||||||
|
|
||||||
|
double area = 0.3 * 0.5;
|
||||||
|
double stress = 100000 / area;
|
||||||
|
double ratio = stress / 2000000;
|
||||||
|
double expected = Math.Max(1 - 0.5 * ratio, 0);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _logic.GetFactor();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.EqualTo(expected).Within(1e-6));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetFactor_ComputesCorrectly_ForCompression_WithinFirstLimit()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_logic.LongitudinalForce = -10000; // compression
|
||||||
|
_mockSection.Setup(s => s.WebWidth).Returns(0.3);
|
||||||
|
_mockSection.Setup(s => s.FullDepth).Returns(0.5);
|
||||||
|
_mockSection.Setup(s => s.ConcreteCompressionStrength).Returns(25000000);
|
||||||
|
_mockCheckLogic.Setup(c => c.Check()).Returns(true);
|
||||||
|
|
||||||
|
double area = 0.3 * 0.5;
|
||||||
|
double stress = 10000 / area;
|
||||||
|
double ratio = stress / 25000000;
|
||||||
|
double expected = 1 + ratio;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _logic.GetFactor();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.EqualTo(expected).Within(1e-6));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(-11250000 / 3.99)]
|
||||||
|
[TestCase(-11250000 / 3)]
|
||||||
|
[TestCase(-11250000)]
|
||||||
|
public void GetFactor_ComputesCorrectly_ForCompression_HighRatio(double force)
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_logic.LongitudinalForce = force; // compression
|
||||||
|
_mockSection.Setup(s => s.WebWidth).Returns(0.3);
|
||||||
|
_mockSection.Setup(s => s.FullDepth).Returns(0.5);
|
||||||
|
_mockSection.Setup(s => s.ConcreteCompressionStrength).Returns(25000000);
|
||||||
|
_mockCheckLogic.Setup(c => c.Check()).Returns(true);
|
||||||
|
|
||||||
|
double area = 0.3 * 0.5;
|
||||||
|
double stress = - force / area;
|
||||||
|
double ratio = stress / 25000000;
|
||||||
|
|
||||||
|
Assert.That(ratio, Is.GreaterThan(0.75)); // high compression branch
|
||||||
|
|
||||||
|
double expected = Math.Max(5 * (1 - ratio), 0);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _logic.GetFactor();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.That(result, Is.EqualTo(expected).Within(1e-6));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetFactor_Throws_WhenCheckFails()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_mockCheckLogic.Setup(c => c.Check()).Returns(false);
|
||||||
|
_mockCheckLogic.Setup(c => c.CheckResult).Returns("Invalid section");
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
var ex = Assert.Throws<StructureHelperException>(() => _logic.GetFactor());
|
||||||
|
Assert.That(ex.Message, Does.Contain("Invalid section"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,26 +34,26 @@ namespace StructureHelperTests.UnitTests.ConvertStrategiesTest
|
|||||||
_mockTraceLogger.Object);
|
_mockTraceLogger.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
//[Test]
|
||||||
public void GetNewItem_ShouldLogStartAndEndMessages()
|
//public void GetNewItem_ShouldLogStartAndEndMessages()
|
||||||
{
|
//{
|
||||||
// Arrange
|
// // Arrange
|
||||||
var projectDto = new ProjectDTO(Guid.Empty)
|
// var projectDto = new ProjectDTO(Guid.Empty)
|
||||||
{
|
// {
|
||||||
VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object }
|
// VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object }
|
||||||
};
|
// };
|
||||||
|
|
||||||
_mockConvertLogic
|
// _mockConvertLogic
|
||||||
.Setup(s => s.Convert(It.IsAny<IVisualAnalysis>()))
|
// .Setup(s => s.Convert(It.IsAny<IVisualAnalysis>()))
|
||||||
.Returns(new Mock<IVisualAnalysis>().Object);
|
// .Returns(new Mock<IVisualAnalysis>().Object);
|
||||||
|
|
||||||
// Act
|
// // Act
|
||||||
var result = _convertStrategy.GetNewItem(projectDto);
|
// var result = _convertStrategy.GetNewItem(projectDto);
|
||||||
|
|
||||||
// Assert
|
// // Assert
|
||||||
_mockTraceLogger.Verify(logger => logger.AddMessage("Converting of project is started"), Times.Once);
|
// _mockTraceLogger.Verify(logger => logger.AddMessage("Converting of project is started"), Times.Once);
|
||||||
_mockTraceLogger.Verify(logger => logger.AddMessage("Converting of project has been finished successfully"), Times.Once);
|
// _mockTraceLogger.Verify(logger => logger.AddMessage("Converting of project has been finished successfully"), Times.Once);
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetNewItem_ShouldLogWarningIfNoAnalyses()
|
public void GetNewItem_ShouldLogWarningIfNoAnalyses()
|
||||||
|
|||||||
Reference in New Issue
Block a user