Trace logger calls were adde in limit curve calculator
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -18,6 +19,8 @@ namespace StructureHelper.Models.Calculators
|
|||||||
|
|
||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using StructureHelper.Windows.ViewModels.Errors;
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Parameters;
|
using StructureHelperCommon.Models.Parameters;
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
@@ -35,6 +36,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
|||||||
|
|
||||||
public int StepCount => ValidTupleList.Count();
|
public int StepCount => ValidTupleList.Count();
|
||||||
|
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public CrackDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
|
public CrackDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
|
||||||
{
|
{
|
||||||
TupleList = tupleList;
|
TupleList = tupleList;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Parameters;
|
using StructureHelperCommon.Models.Parameters;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
@@ -40,6 +41,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
|
|
||||||
public Action<int> SetProgress { get; set; }
|
public Action<int> SetProgress { get; set; }
|
||||||
public bool Result { get; set; }
|
public bool Result { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public InteractionDiagramLogic(LimitCurveInputData inputData)
|
public InteractionDiagramLogic(LimitCurveInputData inputData)
|
||||||
{
|
{
|
||||||
@@ -57,8 +59,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
var convertLogic = InputData.SurroundData.ConvertLogicEntity;
|
var convertLogic = InputData.SurroundData.ConvertLogicEntity;
|
||||||
var calculator = new LimitCurvesCalculator()
|
var calculator = new LimitCurvesCalculator()
|
||||||
{
|
{
|
||||||
InputData = InputData
|
InputData = InputData,
|
||||||
};
|
};
|
||||||
|
if (TraceLogger is not null) { calculator.TraceLogger = TraceLogger; }
|
||||||
calculator.ActionToOutputResults = SetProgressByResult;
|
calculator.ActionToOutputResults = SetProgressByResult;
|
||||||
SafetyProcessor.RunSafeProcess(() =>
|
SafetyProcessor.RunSafeProcess(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using StructureHelper.Windows.ViewModels.Errors;
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Parameters;
|
using StructureHelperCommon.Models.Parameters;
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
@@ -27,6 +28,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
|
|
||||||
public Action<int> SetProgress { get; set; }
|
public Action<int> SetProgress { get; set; }
|
||||||
public bool Result { get; set; }
|
public bool Result { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public void WorkerDoWork(object sender, DoWorkEventArgs e)
|
public void WorkerDoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using StructureHelper.Windows.ViewModels.Calculations.Calculators;
|
|||||||
using StructureHelper.Windows.ViewModels.Errors;
|
using StructureHelper.Windows.ViewModels.Errors;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||||
@@ -33,7 +34,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
|||||||
{
|
{
|
||||||
NewItem = new ForceCalculator()
|
NewItem = new ForceCalculator()
|
||||||
{
|
{
|
||||||
Name = "New force calculator"
|
Name = "New force calculator",
|
||||||
|
TraceLogger = new TraceLogger(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (parameterType == CalculatorTypes.LimitCurveCalculator)
|
else if (parameterType == CalculatorTypes.LimitCurveCalculator)
|
||||||
@@ -42,7 +44,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
|||||||
NewItem = new LimitCurvesCalculator()
|
NewItem = new LimitCurvesCalculator()
|
||||||
{
|
{
|
||||||
Name = "New interaction diagram calculator",
|
Name = "New interaction diagram calculator",
|
||||||
InputData = inputData
|
InputData = inputData,
|
||||||
|
TraceLogger = new TraceLogger(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -133,7 +136,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
|||||||
{
|
{
|
||||||
var calculator = SelectedItem as LimitCurvesCalculator;
|
var calculator = SelectedItem as LimitCurvesCalculator;
|
||||||
var inputData = calculator.InputData;
|
var inputData = calculator.InputData;
|
||||||
ShowInteractionDiagramByInputData(inputData);
|
ShowInteractionDiagramByInputData(calculator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -151,9 +154,10 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowInteractionDiagramByInputData(LimitCurveInputData inputData)
|
private void ShowInteractionDiagramByInputData(LimitCurvesCalculator calculator)
|
||||||
{
|
{
|
||||||
interactionDiagramLogic = new(inputData);
|
interactionDiagramLogic = new(calculator.InputData);
|
||||||
|
interactionDiagramLogic.TraceLogger = calculator.TraceLogger;
|
||||||
showProgressLogic = new(interactionDiagramLogic)
|
showProgressLogic = new(interactionDiagramLogic)
|
||||||
{
|
{
|
||||||
WindowTitle = "Diagram creating...",
|
WindowTitle = "Diagram creating...",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -15,6 +16,8 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
Action<int> SetProgress { get; set; }
|
Action<int> SetProgress { get; set; }
|
||||||
bool Result { get; set; }
|
bool Result { get; set; }
|
||||||
|
|
||||||
|
ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
void WorkerDoWork(object sender, DoWorkEventArgs e);
|
void WorkerDoWork(object sender, DoWorkEventArgs e);
|
||||||
void WorkerProgressChanged(object sender, ProgressChangedEventArgs e);
|
void WorkerProgressChanged(object sender, ProgressChangedEventArgs e);
|
||||||
void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e);
|
void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -19,6 +20,7 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public FindParameterCalculator()
|
public FindParameterCalculator()
|
||||||
{
|
{
|
||||||
@@ -58,6 +60,7 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
int iterationNum = 0;
|
int iterationNum = 0;
|
||||||
while (step > precision)
|
while (step > precision)
|
||||||
{
|
{
|
||||||
|
TraceLogger?.AddMessage($"Iteration number {iterationNum}", TraceLoggerStatuses.Debug);
|
||||||
if (predicate(current) == true)
|
if (predicate(current) == true)
|
||||||
{
|
{
|
||||||
end = current;
|
end = current;
|
||||||
@@ -66,8 +69,8 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
{
|
{
|
||||||
start = current;
|
start = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = (start + end) / 2;
|
current = (start + end) / 2;
|
||||||
|
TraceLogger?.AddMessage($"Current value {current}", TraceLoggerStatuses.Debug);
|
||||||
step = (end - start) / 2;
|
step = (end - start) / 2;
|
||||||
iterationNum++;
|
iterationNum++;
|
||||||
|
|
||||||
@@ -78,11 +81,12 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
|
|
||||||
if (iterationNum > maxIterationCount)
|
if (iterationNum > maxIterationCount)
|
||||||
{
|
{
|
||||||
|
TraceLogger?.AddMessage($"Recuired precision was not achieved, current step {step}, required precision {precision}", TraceLoggerStatuses.Error);
|
||||||
result.Description = "Parameter was not found succefully: \n";
|
result.Description = "Parameter was not found succefully: \n";
|
||||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": violation of iteration count");
|
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": violation of iteration count");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TraceLogger?.AddMessage($"Parameter value {current} was obtained");
|
||||||
result.Parameter = current;
|
result.Parameter = current;
|
||||||
result.Description = "Parameter was found succefully";
|
result.Description = "Parameter was found succefully";
|
||||||
result.IsValid = true;
|
result.IsValid = true;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using LoaderCalculator.Data.ResultData;
|
using LoaderCalculator.Data.ResultData;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -11,6 +12,7 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
{
|
{
|
||||||
public interface ICalculator : ICloneable
|
public interface ICalculator : ICloneable
|
||||||
{
|
{
|
||||||
|
ITraceLogger? TraceLogger { get; set; }
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Method for calculating
|
/// Method for calculating
|
||||||
|
|||||||
13
StructureHelperCommon/Models/Loggers/ILogger.cs
Normal file
13
StructureHelperCommon/Models/Loggers/ILogger.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Loggers
|
||||||
|
{
|
||||||
|
public interface ILogger
|
||||||
|
{
|
||||||
|
void Fatal(string message);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
StructureHelperCommon/Models/Loggers/ITraceLogger.cs
Normal file
14
StructureHelperCommon/Models/Loggers/ITraceLogger.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Loggers
|
||||||
|
{
|
||||||
|
public interface ITraceLogger
|
||||||
|
{
|
||||||
|
List<ITraceLoggerEntry> TraceLoggerEntries { get; }
|
||||||
|
void AddMessage(string message, TraceLoggerStatuses status = TraceLoggerStatuses.Info);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
StructureHelperCommon/Models/Loggers/ITraceLoggerEntry.cs
Normal file
14
StructureHelperCommon/Models/Loggers/ITraceLoggerEntry.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Loggers
|
||||||
|
{
|
||||||
|
public interface ITraceLoggerEntry
|
||||||
|
{
|
||||||
|
DateTime TimeStamp { get;}
|
||||||
|
int Priority { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
20
StructureHelperCommon/Models/Loggers/StringLoggerEntry.cs
Normal file
20
StructureHelperCommon/Models/Loggers/StringLoggerEntry.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Loggers
|
||||||
|
{
|
||||||
|
public class StringLoggerEntry : ITraceLoggerEntry
|
||||||
|
{
|
||||||
|
public DateTime TimeStamp { get;}
|
||||||
|
public string Message { get; set; }
|
||||||
|
public int Priority { get; set; }
|
||||||
|
|
||||||
|
public StringLoggerEntry()
|
||||||
|
{
|
||||||
|
TimeStamp = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
57
StructureHelperCommon/Models/Loggers/TraceLogger.cs
Normal file
57
StructureHelperCommon/Models/Loggers/TraceLogger.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Loggers
|
||||||
|
{
|
||||||
|
public class TraceLogger : ITraceLogger
|
||||||
|
{
|
||||||
|
const int fatal = 0;
|
||||||
|
const int error = 1000;
|
||||||
|
const int warning = 200;
|
||||||
|
const int info = 300;
|
||||||
|
const int service = 400;
|
||||||
|
const int debug = 500;
|
||||||
|
|
||||||
|
public List<ITraceLoggerEntry> TraceLoggerEntries { get; }
|
||||||
|
|
||||||
|
public TraceLogger()
|
||||||
|
{
|
||||||
|
TraceLoggerEntries = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddMessage(string message, TraceLoggerStatuses status = TraceLoggerStatuses.Info)
|
||||||
|
{
|
||||||
|
TraceLoggerEntries.Add(new StringLoggerEntry()
|
||||||
|
{
|
||||||
|
Message = message,
|
||||||
|
Priority = GetPriorityByStatus(status)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public void AddMessage(string message, int priority)
|
||||||
|
{
|
||||||
|
TraceLoggerEntries.Add(new StringLoggerEntry()
|
||||||
|
{
|
||||||
|
Message = message,
|
||||||
|
Priority = priority
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetPriorityByStatus(TraceLoggerStatuses status)
|
||||||
|
{
|
||||||
|
if (status == TraceLoggerStatuses.Fatal) { return fatal; }
|
||||||
|
else if (status == TraceLoggerStatuses.Error) { return error; }
|
||||||
|
else if (status == TraceLoggerStatuses.Warning) { return warning; }
|
||||||
|
else if (status == TraceLoggerStatuses.Info) { return info; }
|
||||||
|
else if (status == TraceLoggerStatuses.Service) { return service; }
|
||||||
|
else if (status == TraceLoggerStatuses.Debug) { return debug; }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
StructureHelperCommon/Models/Loggers/TraceLoggerStatuses.cs
Normal file
18
StructureHelperCommon/Models/Loggers/TraceLoggerStatuses.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Loggers
|
||||||
|
{
|
||||||
|
public enum TraceLoggerStatuses
|
||||||
|
{
|
||||||
|
Fatal,
|
||||||
|
Error,
|
||||||
|
Warning,
|
||||||
|
Info,
|
||||||
|
Service,
|
||||||
|
Debug
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -20,6 +21,7 @@ namespace StructureHelperCommon.Models.Soils
|
|||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public AnchorCalculator(SoilAnchor soilAnchor, IAnchorSoilProperties anchorSoilProperties)
|
public AnchorCalculator(SoilAnchor soilAnchor, IAnchorSoilProperties anchorSoilProperties)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NLog" Version="5.2.8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="LoaderCalculator">
|
<Reference Include="LoaderCalculator">
|
||||||
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
|
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Sections;
|
using StructureHelperCommon.Models.Sections;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
@@ -25,6 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public IAccuracy Accuracy { get; set; }
|
public IAccuracy Accuracy { get; set; }
|
||||||
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
|
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using LoaderCalculator.Data.Matrix;
|
|||||||
using LoaderCalculator.Data.ResultData;
|
using LoaderCalculator.Data.ResultData;
|
||||||
using LoaderCalculator.Data.SourceData;
|
using LoaderCalculator.Data.SourceData;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
@@ -13,6 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public IResult Result { get; private set; }
|
public IResult Result { get; private set; }
|
||||||
|
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public ForceTupleCalculator(IForceTupleInputData inputData)
|
public ForceTupleCalculator(IForceTupleInputData inputData)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -14,6 +15,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
|
|||||||
public IEnumerable<INdm> Ndms { get; set; }
|
public IEnumerable<INdm> Ndms { get; set; }
|
||||||
public PredicateTypes PredicateType { get; set; }
|
public PredicateTypes PredicateType { get; set; }
|
||||||
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
|
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public Predicate<IPoint2D> GetPredicate()
|
public Predicate<IPoint2D> GetPredicate()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Loggers;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||||
{
|
{
|
||||||
public interface IGetPredicateLogic
|
public interface IGetPredicateLogic
|
||||||
{
|
{
|
||||||
|
string Name { get; set; }
|
||||||
Predicate<IPoint2D> GetPredicate();
|
Predicate<IPoint2D> GetPredicate();
|
||||||
|
ITraceLogger? TraceLogger { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -22,5 +23,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
/// <param name="points"></param>
|
/// <param name="points"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points);
|
List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points);
|
||||||
|
ITraceLogger? TraceLogger { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -8,10 +9,14 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Find parameter by point and predicate
|
||||||
|
/// </summary>
|
||||||
public interface ILimitCurveParameterLogic : IHasActionByResult, ICloneable
|
public interface ILimitCurveParameterLogic : IHasActionByResult, ICloneable
|
||||||
{
|
{
|
||||||
Predicate<Point2D> LimitPredicate { get; set; }
|
Predicate<Point2D> LimitPredicate { get; set; }
|
||||||
IPoint2D CurrentPoint { get; set; }
|
IPoint2D CurrentPoint { get; set; }
|
||||||
double GetParameter();
|
double GetParameter();
|
||||||
|
ITraceLogger? TraceLogger { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -25,6 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public LimitCurveCalculator(ILimitCurveLogic limitCurveLogic)
|
public LimitCurveCalculator(ILimitCurveLogic limitCurveLogic)
|
||||||
{
|
{
|
||||||
@@ -45,20 +47,27 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
|
if (TraceLogger is not null) { limitCurveLogic.TraceLogger = TraceLogger; }
|
||||||
|
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLoggerStatuses.Service);
|
||||||
|
TraceLogger?.AddMessage($"Start solution in calculator {Name}");
|
||||||
result = new LimitCurveResult();
|
result = new LimitCurveResult();
|
||||||
result.IsValid = true;
|
result.IsValid = true;
|
||||||
result.Name = Name;
|
result.Name = Name;
|
||||||
SurroundProcLogic.SurroundData = SurroundData;
|
SurroundProcLogic.SurroundData = SurroundData;
|
||||||
SurroundProcLogic.PointCount = PointCount;
|
SurroundProcLogic.PointCount = PointCount;
|
||||||
|
TraceLogger?.AddMessage($"Point count {PointCount}");
|
||||||
surroundList = SurroundProcLogic.GetPoints();
|
surroundList = SurroundProcLogic.GetPoints();
|
||||||
|
TraceLogger?.AddMessage($"There are {surroundList.Count()} point prepared for calculation");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
limitCurveLogic.ActionToOutputResults = GetCurrentStepNumber;
|
limitCurveLogic.ActionToOutputResults = GetCurrentStepNumber;
|
||||||
factoredList = limitCurveLogic.GetPoints(surroundList);
|
factoredList = limitCurveLogic.GetPoints(surroundList);
|
||||||
|
TraceLogger?.AddMessage($"Solution was successfully obtained for {factoredList.Count()} point");
|
||||||
result.Points = factoredList;
|
result.Points = factoredList;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLoggerStatuses.Error);
|
||||||
result.IsValid = false;
|
result.IsValid = false;
|
||||||
result.Description += ex.Message;
|
result.Description += ex.Message;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
|
|
||||||
private object lockObject = new object();
|
private object lockObject = new object();
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public LimitCurveLogic(ILimitCurveParameterLogic parameterLogic)
|
public LimitCurveLogic(ILimitCurveParameterLogic parameterLogic)
|
||||||
{
|
{
|
||||||
@@ -30,22 +32,25 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
||||||
{
|
{
|
||||||
|
if (TraceLogger is not null) { ParameterLogic.TraceLogger = TraceLogger; }
|
||||||
result = new();
|
result = new();
|
||||||
resultList = new();
|
resultList = new();
|
||||||
|
TraceLogger?.AddMessage($"Predicate name is {GetPredicateLogic.Name}");
|
||||||
Predicate<IPoint2D> limitPredicate = GetPredicateLogic.GetPredicate();
|
Predicate<IPoint2D> limitPredicate = GetPredicateLogic.GetPredicate();
|
||||||
|
//if predicate is true for point (0,0), then check other point is pointless
|
||||||
if (limitPredicate(new Point2D()) == true)
|
if (limitPredicate(new Point2D()) == true)
|
||||||
{
|
{
|
||||||
var range = points.Select(point => new Point2D { X = point.X * 0d, Y = point.Y * 0d }).ToList();
|
TraceLogger?.AddMessage($"Predicate is true for point (0d, 0d). All point will be skiped", TraceLoggerStatuses.Warning);
|
||||||
|
var range = points.Select(point => new Point2D { X = 0d, Y = 0d }).ToList();
|
||||||
resultList.AddRange(range);
|
resultList.AddRange(range);
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
pointCount = 0;
|
pointCount = 0;
|
||||||
MultyThreadProc(points);
|
MultiThreadProc(points);
|
||||||
//MonoThreadProc(points);
|
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MultyThreadProc(IEnumerable<IPoint2D> points)
|
private void MultiThreadProc(IEnumerable<IPoint2D> points)
|
||||||
{
|
{
|
||||||
Task<IPoint2D>[] tasks = new Task<IPoint2D>[points.Count()];
|
Task<IPoint2D>[] tasks = new Task<IPoint2D>[points.Count()];
|
||||||
for (int i = 0; i < points.Count(); i++)
|
for (int i = 0; i < points.Count(); i++)
|
||||||
@@ -63,53 +68,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MonoThreadProc(IEnumerable<IPoint2D> points)
|
|
||||||
{
|
|
||||||
foreach (var point in points)
|
|
||||||
{
|
|
||||||
FindParameter(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FindParameter(IPoint2D point)
|
|
||||||
{
|
|
||||||
IPoint2D resultPoint = FindResultPoint(point);
|
|
||||||
resultList.Add(resultPoint);
|
|
||||||
lock (lockObject)
|
|
||||||
{
|
|
||||||
pointCount++;
|
|
||||||
}
|
|
||||||
result.IterationNumber = pointCount;
|
|
||||||
ActionToOutputResults?.Invoke(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point2D FindResultPoint(IPoint2D point)
|
private Point2D FindResultPoint(IPoint2D point)
|
||||||
{
|
{
|
||||||
double parameter;
|
|
||||||
var locCurrentPoint = point.Clone() as IPoint2D;
|
|
||||||
Predicate<IPoint2D> limitPredicate;
|
Predicate<IPoint2D> limitPredicate;
|
||||||
lock (lockObject)
|
lock (lockObject)
|
||||||
{
|
{
|
||||||
limitPredicate = GetPredicateLogic.GetPredicate();
|
limitPredicate = GetPredicateLogic.GetPredicate();
|
||||||
}
|
}
|
||||||
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
|
var resultPoint = FindResultPointByPredicate(point, limitPredicate);
|
||||||
logic.CurrentPoint = locCurrentPoint;
|
|
||||||
logic.LimitPredicate = limitPredicate;
|
|
||||||
|
|
||||||
if (limitPredicate(locCurrentPoint) == false)
|
|
||||||
{
|
|
||||||
parameter = 1d;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parameter = logic.GetParameter();
|
|
||||||
}
|
|
||||||
|
|
||||||
var resultPoint = new Point2D()
|
|
||||||
{
|
|
||||||
X = locCurrentPoint.X * parameter,
|
|
||||||
Y = locCurrentPoint.Y * parameter
|
|
||||||
};
|
|
||||||
lock (lockObject)
|
lock (lockObject)
|
||||||
{
|
{
|
||||||
pointCount++;
|
pointCount++;
|
||||||
@@ -117,7 +83,39 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
result.IterationNumber = pointCount;
|
result.IterationNumber = pointCount;
|
||||||
ActionToOutputResults?.Invoke(result);
|
ActionToOutputResults?.Invoke(result);
|
||||||
return resultPoint;
|
return resultPoint;
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
private Point2D FindResultPointByPredicate(IPoint2D point, Predicate<IPoint2D> limitPredicate)
|
||||||
|
{
|
||||||
|
var localCurrentPoint = point.Clone() as IPoint2D;
|
||||||
|
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
|
||||||
|
logic.TraceLogger = new TraceLogger();
|
||||||
|
logic.CurrentPoint = localCurrentPoint;
|
||||||
|
logic.LimitPredicate = limitPredicate;
|
||||||
|
double parameter;
|
||||||
|
|
||||||
|
if (limitPredicate(localCurrentPoint) == false)
|
||||||
|
{
|
||||||
|
parameter = 1d;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parameter = logic.GetParameter();
|
||||||
|
}
|
||||||
|
|
||||||
|
var resultPoint = new Point2D()
|
||||||
|
{
|
||||||
|
X = localCurrentPoint.X * parameter,
|
||||||
|
Y = localCurrentPoint.Y * parameter
|
||||||
|
};
|
||||||
|
lock (lockObject)
|
||||||
|
{
|
||||||
|
TraceLogger?.AddMessage($"Source point (X = {localCurrentPoint.X}, Y = {localCurrentPoint.Y})");
|
||||||
|
TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries);
|
||||||
|
TraceLogger?.AddMessage($"Parameter value {parameter} was obtained");
|
||||||
|
TraceLogger?.AddMessage($"Calculated point (X={localCurrentPoint.X} * {parameter} = {resultPoint.X}, Y={localCurrentPoint.Y} * {parameter} = {resultPoint.Y})");
|
||||||
|
}
|
||||||
|
return resultPoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -15,6 +16,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public Predicate<Point2D> LimitPredicate { get; set; }
|
public Predicate<Point2D> LimitPredicate { get; set; }
|
||||||
public IPoint2D CurrentPoint { get; set; }
|
public IPoint2D CurrentPoint { get; set; }
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public LimitCurveParameterLogic()
|
public LimitCurveParameterLogic()
|
||||||
{
|
{
|
||||||
@@ -27,6 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
{
|
{
|
||||||
Predicate = GetFactorPredicate,
|
Predicate = GetFactorPredicate,
|
||||||
};
|
};
|
||||||
|
if (TraceLogger is not null) { parameterCalculator.TraceLogger = TraceLogger; }
|
||||||
parameterCalculator.Accuracy.IterationAccuracy = 0.001d;
|
parameterCalculator.Accuracy.IterationAccuracy = 0.001d;
|
||||||
parameterCalculator.Run();
|
parameterCalculator.Run();
|
||||||
if (parameterCalculator.Result.IsValid == false)
|
if (parameterCalculator.Result.IsValid == false)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperLogics.Models.Calculations.CalculationsResults;
|
using StructureHelperLogics.Models.Calculations.CalculationsResults;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
||||||
@@ -29,6 +30,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public LimitCurvesCalculator()
|
public LimitCurvesCalculator()
|
||||||
{
|
{
|
||||||
Name = "New calculator";
|
Name = "New calculator";
|
||||||
@@ -36,6 +39,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
}
|
}
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
|
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLoggerStatuses.Service);
|
||||||
|
TraceLogger?.AddMessage($"Start solution in calculator {Name}");
|
||||||
GetNewResult();
|
GetNewResult();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -46,7 +51,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
item.Run();
|
item.Run();
|
||||||
var locResult = item.Result as LimitCurveResult;
|
var locResult = item.Result as LimitCurveResult;
|
||||||
result.LimitCurveResults.Add(locResult);
|
result.LimitCurveResults.Add(locResult);
|
||||||
if (locResult.IsValid == false) { result.Description += locResult.Description; }
|
if (locResult.IsValid == false)
|
||||||
|
{
|
||||||
|
result.Description += locResult.Description;
|
||||||
|
}
|
||||||
result.IterationNumber = curvesIterationCount * InputData.PointCount + locResult.IterationNumber;
|
result.IterationNumber = curvesIterationCount * InputData.PointCount + locResult.IterationNumber;
|
||||||
ActionToOutputResults?.Invoke(result);
|
ActionToOutputResults?.Invoke(result);
|
||||||
curvesIterationCount++;
|
curvesIterationCount++;
|
||||||
@@ -54,6 +62,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLoggerStatuses.Error);
|
||||||
result.IsValid = false;
|
result.IsValid = false;
|
||||||
result.Description += ex;
|
result.Description += ex;
|
||||||
}
|
}
|
||||||
@@ -81,6 +90,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
{
|
{
|
||||||
string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}";
|
string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}";
|
||||||
LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry.PredicateType, calcName);
|
LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry.PredicateType, calcName);
|
||||||
|
if (TraceLogger is not null) { calculator.TraceLogger = TraceLogger; }
|
||||||
calculators.Add(calculator);
|
calculators.Add(calculator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,18 +101,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
|
|
||||||
private LimitCurveCalculator GetCalculator(List<INdm> ndms, PredicateTypes predicateType, string calcName)
|
private LimitCurveCalculator GetCalculator(List<INdm> ndms, PredicateTypes predicateType, string calcName)
|
||||||
{
|
{
|
||||||
var factory = new PredicateFactory()
|
|
||||||
{
|
|
||||||
Ndms = ndms,
|
|
||||||
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic
|
|
||||||
};
|
|
||||||
var predicate = factory.GetPredicate(predicateType);
|
|
||||||
var getPredicateLogic = new GetPredicateLogic()
|
var getPredicateLogic = new GetPredicateLogic()
|
||||||
{
|
{
|
||||||
|
Name = calcName,
|
||||||
Ndms = ndms,
|
Ndms = ndms,
|
||||||
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic,
|
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic,
|
||||||
PredicateType = predicateType
|
PredicateType = predicateType
|
||||||
};
|
};
|
||||||
|
if (TraceLogger is not null) { getPredicateLogic.TraceLogger = TraceLogger; }
|
||||||
var logic = new LimitCurveLogic(getPredicateLogic);
|
var logic = new LimitCurveLogic(getPredicateLogic);
|
||||||
var calculator = new LimitCurveCalculator(logic)
|
var calculator = new LimitCurveCalculator(logic)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -11,6 +12,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public class StabLimitCurveLogic : ILimitCurveLogic
|
public class StabLimitCurveLogic : ILimitCurveLogic
|
||||||
{
|
{
|
||||||
public Action<IResult> ActionToOutputResults { get; set; }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperLogics.Services.NdmCalculations;
|
using StructureHelperLogics.Services.NdmCalculations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -23,6 +24,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
|
|||||||
|
|
||||||
public int StepCount => interpolateTuplesResult.StepCount + 1;
|
public int StepCount => interpolateTuplesResult.StepCount + 1;
|
||||||
|
|
||||||
|
public ITraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
public void WorkerDoWork(object sender, DoWorkEventArgs e)
|
public void WorkerDoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
InterpolateCalculator = InterpolateService.InterpolateForceCalculator(forceCalculator, interpolateTuplesResult);
|
InterpolateCalculator = InterpolateService.InterpolateForceCalculator(forceCalculator, interpolateTuplesResult);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using LoaderCalculator.Data.Matrix;
|
using LoaderCalculator.Data.Matrix;
|
||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperLogics.Services.NdmPrimitives;
|
using StructureHelperLogics.Services.NdmPrimitives;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -19,6 +20,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry
|
|||||||
public IResult Result => geometryResult;
|
public IResult Result => geometryResult;
|
||||||
|
|
||||||
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public GeometryCalculator(IEnumerable<INdm> ndms, IStrainMatrix strainMatrix)
|
public GeometryCalculator(IEnumerable<INdm> ndms, IStrainMatrix strainMatrix)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using LoaderCalculator.Logics;
|
|||||||
using LoaderCalculator.Logics.Geometry;
|
using LoaderCalculator.Logics.Geometry;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperLogics.Models.Materials;
|
using StructureHelperLogics.Models.Materials;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||||
@@ -28,6 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
|
|||||||
|
|
||||||
public IAccuracy Accuracy { get; set; }
|
public IAccuracy Accuracy { get; set; }
|
||||||
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
private (double EtaAlongX, double EtaAlongY) GetBucklingCoefficients()
|
private (double EtaAlongX, double EtaAlongY) GetBucklingCoefficients()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Services;
|
using StructureHelperCommon.Services;
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
@@ -30,6 +31,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
|||||||
public Accuracy Accuracy {get;set; }
|
public Accuracy Accuracy {get;set; }
|
||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public CrackForceCalculator(IForceTupleCalculator forceTupleCalculator)
|
public CrackForceCalculator(IForceTupleCalculator forceTupleCalculator)
|
||||||
{
|
{
|
||||||
StartTuple ??= new ForceTuple();
|
StartTuple ??= new ForceTuple();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
@@ -24,6 +25,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
|||||||
public CrackWidthCalculatorInputData InputData { get; set; }
|
public CrackWidthCalculatorInputData InputData { get; set; }
|
||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
result = new() { IsValid = true, Description = ""};
|
result = new() { IsValid = true, Description = ""};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -16,6 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
|||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
|
|
||||||
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace StructureHelperTests.UnitTests.Calcuators
|
|||||||
var calculator = new LimitCurveCalculator(new StabLimitCurveLogic())
|
var calculator = new LimitCurveCalculator(new StabLimitCurveLogic())
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
calculator.PointCount = 12;
|
||||||
calculator.SurroundData.XMax = xmax;
|
calculator.SurroundData.XMax = xmax;
|
||||||
calculator.SurroundData.XMin = -xmax;
|
calculator.SurroundData.XMin = -xmax;
|
||||||
calculator.SurroundData.YMax = ymax;
|
calculator.SurroundData.YMax = ymax;
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ namespace StructureHelperTests.UnitTests.Calcuators
|
|||||||
public void GetPoints_ValidPoints_ReturnsTransformedPoints()
|
public void GetPoints_ValidPoints_ReturnsTransformedPoints()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parameterLogicMock = new Mock<ILimitCurveParameterLogic>();
|
|
||||||
parameterLogicMock.Setup(p => p.GetParameter()).Returns(2.0); // Mocking the GetParameter method
|
|
||||||
|
|
||||||
var getPredicateLogic = new Mock<IGetPredicateLogic>();
|
var getPredicateLogic = new Mock<IGetPredicateLogic>();
|
||||||
getPredicateLogic.Setup(p => p.GetPredicate()).Returns(point => point.X >= 0.5d);//
|
getPredicateLogic.Setup(p => p.GetPredicate()).Returns(point => point.X >= 0.5d);//
|
||||||
|
|
||||||
@@ -39,34 +36,9 @@ namespace StructureHelperTests.UnitTests.Calcuators
|
|||||||
|
|
||||||
for (int i = 0; i < inputPoints.Count; i++)
|
for (int i = 0; i < inputPoints.Count; i++)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(inputPoints[i].X * 0.5, result[i].X);
|
Assert.AreEqual(0.5d, result[i].X, 0.01d);
|
||||||
Assert.AreEqual(inputPoints[i].Y * 0.5, result[i].Y);
|
Assert.AreEqual(inputPoints[i].Y / inputPoints[i].X * 0.5d, result[i].Y, 0.01d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that GetParameter was called
|
|
||||||
parameterLogicMock.Verify(p => p.GetParameter(), Times.Exactly(inputPoints.Count));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void GetPoints_InvalidPredicate_ThrowsException()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var parameterLogicMock = new Mock<ILimitCurveParameterLogic>();
|
|
||||||
parameterLogicMock.Setup(p => p.GetParameter()).Returns(2.0);
|
|
||||||
|
|
||||||
var getPredicateLogic = new Mock<IGetPredicateLogic>();
|
|
||||||
getPredicateLogic.Setup(p => p.GetPredicate()).Returns(point => point.X >= 0.5d);//
|
|
||||||
|
|
||||||
var limitCurveLogic = new LimitCurveLogic(getPredicateLogic.Object);
|
|
||||||
|
|
||||||
var inputPoints = new List<IPoint2D>
|
|
||||||
{
|
|
||||||
new Point2D { X = 1, Y = 2 },
|
|
||||||
new Point2D { X = 3, Y = 4 }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act & Assert
|
|
||||||
Assert.Throws<StructureHelperException>(() => limitCurveLogic.GetPoints(inputPoints));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user