From 79ef8c5304cb4c75ef75244bf1ddeb9edd7685fb Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Thu, 1 Feb 2024 07:36:44 +0500 Subject: [PATCH 01/14] Trace view model was changed --- .../Calculators/LimitCurveVisualCalculator.cs | 6 +- .../CalculatorsViews/CrackDiagramLogic.cs | 7 +- .../InteractionDiagramLogic.cs | 6 +- .../ForceResultLogic/ShowCrackResultLogic.cs | 4 +- .../ForceResultLogic/ShowCrackWidthLogic.cs | 2 +- .../ForceResultLogic/ShowDiagramLogic.cs | 2 +- .../ProgressViews/TraceDocumentVM.cs | 195 +++++++++--------- .../ProgressViews/TraceDocumentView.xaml.cs | 13 +- .../NdmCrossSections/AnalysisVewModelLogic.cs | 6 +- .../Infrastructures/Interfaces/ILogic.cs | 15 ++ .../Interfaces/ILongProcessLogic.cs | 2 +- .../Calculators/FindParameterCalculator.cs | 17 +- .../Models/Calculators/ICalculator.cs | 14 +- .../Models/Forces/DesignForceTuple.cs | 2 +- .../Models/Forces/IDesignForceTuple.cs | 2 +- .../Loggers/Factories/TraceTablesFactory.cs | 184 ++++++++++++++--- .../Models/Loggers/ILogger.cs | 2 +- .../Models/Loggers/IShiftTraceLogger.cs | 2 +- .../Models/Loggers/ITraceLogger.cs | 4 +- .../Models/Loggers/ITraceLoggerEntry.cs | 2 +- .../Models/Loggers/LoggerService.cs | 16 +- .../Models/Loggers/ShiftTraceLogger.cs | 11 +- ...StringLoggerEntry.cs => StringLogEntry.cs} | 6 +- .../{TableLoggerEntry.cs => TableLogEntry.cs} | 6 +- ...eLoggerStatuses.cs => TraceLogStatuses.cs} | 4 +- .../Models/Loggers/TraceLogger.cs | 14 +- .../Models/Soils/AnchorCalculator.cs | 2 +- .../Models/Tables/ShTable.cs | 8 + .../Analyses/ByForces/ForceCalculator.cs | 2 +- .../Analyses/ByForces/ForceTupleCalculator.cs | 2 +- .../LimitCurve/Factories/GetPredicateLogic.cs | 8 +- .../Factories/IGetPredicateLogic.cs | 2 +- .../ByForces/LimitCurve/ILimitCurveLogic.cs | 12 +- .../LimitCurve/ILimitCurveParameterLogic.cs | 2 +- .../LimitCurve/LimitCurveCalculator.cs | 22 +- .../ByForces/LimitCurve/LimitCurveLogic.cs | 21 +- .../LimitCurve/LimitCurveParameterLogic.cs | 9 +- .../LimitCurve/LimitCurvesCalculator.cs | 15 +- .../LimitCurve/StabLimitCurveLogic.cs | 9 +- .../Logics/InterpolationProgressLogic.cs | 7 +- .../Analyses/Geometry/GeometryCalculator.cs | 7 +- .../Buckling/ConcreteBucklingCalculator.cs | 3 +- .../Cracking/CrackForceCalculator.cs | 13 +- .../Cracking/CrackWidthCalculator.cs | 3 +- .../Cracking/CrackWidthCalculatorInputData.cs | 2 +- .../Cracking/CrackWidthSimpleCalculator.cs | 9 +- .../ShTables/TraceTablesFactoryTests.cs | 102 +++++++++ 47 files changed, 480 insertions(+), 324 deletions(-) create mode 100644 StructureHelperCommon/Infrastructures/Interfaces/ILogic.cs rename StructureHelperCommon/Models/Loggers/{StringLoggerEntry.cs => StringLogEntry.cs} (70%) rename StructureHelperCommon/Models/Loggers/{TableLoggerEntry.cs => TableLogEntry.cs} (81%) rename StructureHelperCommon/Models/Loggers/{TraceLoggerStatuses.cs => TraceLogStatuses.cs} (73%) create mode 100644 StructureHelperTests/Infrastructures/ShTables/TraceTablesFactoryTests.cs diff --git a/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs b/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs index 0330cc8..c106fc6 100644 --- a/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs +++ b/StructureHelper/Models/Calculators/LimitCurveVisualCalculator.cs @@ -1,12 +1,8 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelper.Models.Calculators { diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs index c3025d0..9e11df7 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs @@ -1,10 +1,9 @@ -using LoaderCalculator; -using StructureHelper.Windows.Graphs; +using StructureHelper.Windows.Graphs; using StructureHelper.Windows.ViewModels.Errors; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Settings; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Services.Units; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; @@ -15,8 +14,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs index a4e48d2..138d6ca 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs @@ -4,15 +4,11 @@ using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Settings; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Parameters; -using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Units; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; -using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; -using StructureHelperLogics.NdmCalculations.Primitives; -using StructureHelperLogics.Services.NdmPrimitives; using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs index 797ce0a..d1c2a27 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs @@ -17,7 +17,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu public static GeometryNames GeometryNames => ProgramSetting.GeometryNames; public LimitStates LimitState { get; set; } public CalcTerms CalcTerm { get; set; } - public ForceTuple ForceTuple { get; set; } + public IForceTuple ForceTuple { get; set; } public IEnumerable ndmPrimitives { get; set; } public void Show(IDesignForceTuple finishDesignTuple) { @@ -31,7 +31,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu FindCrackFactor(endDesignTuple, startDesignTuple); } - private void FindCrackFactor(ForceTuple finishDesignTuple, ForceTuple startDesignTuple) + private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple) { var calculator = new CrackForceCalculator(); calculator.StartTuple = startDesignTuple; diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs index 950f84c..4410f59 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs @@ -15,7 +15,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu public List ndmPrimitives { get; set; } public LimitStates LimitState { get; set; } public CalcTerms CalcTerm { get; set; } - public ForceTuple ForceTuple { get; set; } + public IForceTuple ForceTuple { get; set; } internal void Show() { diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs index 89a6d65..9ce58de 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs @@ -3,7 +3,7 @@ using StructureHelper.Windows.ViewModels.Errors; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Settings; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Services.Units; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; diff --git a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs index e4ea30a..cc6c3ce 100644 --- a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs +++ b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs @@ -1,16 +1,11 @@ using StructureHelper.Infrastructure; -using StructureHelper.Windows.AddMaterialWindow; using StructureHelper.Windows.ViewModels.Errors; -using StructureHelper.Windows.ViewModels.Materials; using StructureHelperCommon.Infrastructures.Exceptions; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Tables; using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.ConstrainedExecution; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; @@ -21,9 +16,10 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews { public class TraceDocumentVM : ViewModelBase { - IEnumerable loggerEntries; - IEnumerable selectedLoggerEntries; - FlowDocument document; + const int tabFactor = 500; + private readonly IEnumerable loggerEntries; + private IEnumerable selectedLoggerEntries; + private FlowDocument document; private ICommand rebuildCommand; private ICommand printDocumentCommand; private int maxPriority; @@ -66,7 +62,7 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews { this.loggerEntries = loggerEntries; maxPriority = 350; - tabGap = 50; + tabGap = 30; } public ICommand RebuildCommand => @@ -81,40 +77,82 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews SafetyProcessor.RunSafeProcess(DocumentReader.Print, "Error of printing document"); }); + + public void Prepare() + { + document = new(); + selectedLoggerEntries = loggerEntries.Where(x => x.Priority <= MaxPriority); + var blocks = selectedLoggerEntries.Select(x => GetBlockByEntry(x)); + document.Blocks.AddRange(blocks); + } + public void ShowPrepared() + { + DocumentReader.Document = document; + } public void Show() { Prepare(); ShowPrepared(); } - public void Prepare() + private Block GetBlockByEntry(ITraceLoggerEntry traceEntry) { - document = new(); - selectedLoggerEntries = loggerEntries.Where(x => x.Priority <= MaxPriority); - foreach (var item in selectedLoggerEntries) + Block block; + if (traceEntry is StringLogEntry stringEntry) { - ProcessLoggerEntries(item); + block = GetBlockByStringEntry(stringEntry); } - } - - private void ProcessLoggerEntries(ITraceLoggerEntry item) - { - if (item is StringLoggerEntry stringEntry) + else if (traceEntry is TableLogEntry tableEntry) { - ProcessStringEntry(stringEntry); - } - else if (item is TableLoggerEntry tableEntry) - { - ProcessTableEntry(tableEntry); + block = GetBlockByTableEntry(tableEntry); } else { - throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(item)); + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(traceEntry)); } + return block; } - private void ProcessTableEntry(TableLoggerEntry tableEntry) + private Block GetBlockByStringEntry(StringLogEntry stringEntry) { + var paragraph = new Paragraph(new Run(stringEntry.Message)); + paragraph.Margin = new Thickness(stringEntry.Priority / tabFactor * tabGap, 7, 0, 7); + if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Fatal)) + { + paragraph.FontSize = 14; + paragraph.Background = Brushes.Red; + paragraph.Foreground = Brushes.Black; + paragraph.FontStyle = FontStyles.Italic; + } + else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Error)) + { + paragraph.FontSize = 14; + paragraph.Background = Brushes.Pink; + paragraph.Foreground = Brushes.Black; + } + else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Warning)) + { + paragraph.FontSize = 14; + paragraph.Background = Brushes.Yellow; + paragraph.Foreground = Brushes.Black; + } + else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Debug)) + { + paragraph.FontSize = 12; + paragraph.Foreground = Brushes.Black; + } + else + { + paragraph.FontSize = 10; + paragraph.Foreground = Brushes.Gray; + } + + return paragraph; + } + + private Table GetBlockByTableEntry(TableLogEntry tableEntry) + { + const int columnWidth = 150; var rows = tableEntry.Table.GetAllRows(); int rowCount = rows.Count(); int columnCount = tableEntry.Table.RowSize; @@ -122,96 +160,53 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews for (int x = 0; x < columnCount; x++) { var tableColumn = new TableColumn(); - tableColumn.Width = new GridLength(150); + tableColumn.Width = new GridLength(columnWidth); table.Columns.Add(tableColumn); } foreach (var row in rows) { - var newRow = new TableRow(); - foreach (var cell in row.Elements) - { - TableCell tableCell; - if (cell is null) - { - tableCell = new TableCell(new Paragraph(new Run(string.Empty))); - } - else - { - if (cell.Value is StringLoggerEntry stringEntry) - { - tableCell = new TableCell(GetParagraphByStringEntry(stringEntry)); - tableCell.ColumnSpan = cell.ColumnSpan; - if (cell.Role == CellRole.Regular) - { - tableCell.TextAlignment = TextAlignment.Left; - tableCell.Background = Brushes.LightYellow; - } - else if (cell.Role == CellRole.Header) - { - tableCell.TextAlignment = TextAlignment.Center; - tableCell.Background = Brushes.AliceBlue; - } - } - else - { - throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(cell)); - } - } - newRow.Cells.Add(tableCell); - } + TableRow newRow = GetTableRow(row); table.RowGroups.Add(new TableRowGroup()); table.RowGroups[0].Rows.Add(newRow); } - document.Blocks.Add(table); + return table; } - private void ProcessStringEntry(StringLoggerEntry stringEntry) + private TableRow GetTableRow(IShTableRow row) { - var paragraph = GetParagraphByStringEntry(stringEntry); - document.Blocks.Add(paragraph); + var newRow = new TableRow(); + foreach (var cell in row.Elements) + { + TableCell tableCell; + if (cell is null) + { + tableCell = new TableCell(new Paragraph(new Run(string.Empty))); + } + else + { + var cellvalue = GetBlockByEntry(cell.Value); + tableCell = new TableCell(cellvalue); + AdjustTableCell(cell, tableCell); + } + newRow.Cells.Add(tableCell); + } + + return newRow; } - private Paragraph GetParagraphByStringEntry(StringLoggerEntry stringEntry) + private static void AdjustTableCell(IShTableCell? cell, TableCell tableCell) { - var paragraph = new Paragraph(new Run(stringEntry.Message)); - paragraph.Margin = new Thickness(stringEntry.Priority / tabGap); - if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Fatal)) + tableCell.ColumnSpan = cell.ColumnSpan; + if (cell.Role == CellRole.Regular) { - paragraph.FontSize = 14; - paragraph.Background = Brushes.Red; - paragraph.Foreground = Brushes.Black; - paragraph.FontStyle = FontStyles.Italic; + tableCell.TextAlignment = TextAlignment.Left; + tableCell.Background = Brushes.LightYellow; } - else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Error)) + else if (cell.Role == CellRole.Header) { - paragraph.FontSize = 14; - paragraph.Background = Brushes.Pink; - paragraph.Foreground = Brushes.Black; + tableCell.TextAlignment = TextAlignment.Center; + tableCell.Background = Brushes.AliceBlue; } - else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Warning)) - { - paragraph.FontSize = 14; - paragraph.Background = Brushes.Yellow; - paragraph.Foreground = Brushes.Black; - } - else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Debug)) - { - paragraph.FontSize = 12; - paragraph.Foreground = Brushes.Black; - } - else - { - paragraph.FontSize = 8; - paragraph.Foreground = Brushes.Gray; - - } - - return paragraph; - } - - public void ShowPrepared() - { - DocumentReader.Document = document; } } } diff --git a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs index 497e819..655eb25 100644 --- a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs +++ b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml.cs @@ -1,17 +1,6 @@ -using StructureHelperCommon.Models.Loggers; -using System; +using StructureHelperCommon.Models; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace StructureHelper.Windows.CalculationWindows.ProgressViews { diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisVewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisVewModelLogic.cs index c333f63..c11101e 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisVewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisVewModelLogic.cs @@ -1,19 +1,15 @@ using StructureHelper.Infrastructure; using StructureHelper.Infrastructure.Enums; using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews; -using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic; using StructureHelper.Windows.CalculationWindows.ProgressViews; using StructureHelper.Windows.ViewModels.Calculations.Calculators; using StructureHelper.Windows.ViewModels.Errors; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; -using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; using StructureHelperLogics.NdmCalculations.Analyses.Logics; -using StructureHelperLogics.NdmCalculations.Primitives; -using System; using System.Windows; using System.Windows.Forms; using MessageBox = System.Windows.Forms.MessageBox; diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ILogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/ILogic.cs new file mode 100644 index 0000000..04d2d98 --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/ILogic.cs @@ -0,0 +1,15 @@ +using StructureHelperCommon.Models; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + /// + /// Base interface for logic + /// + public interface ILogic + { + /// + /// Logger for tracing of actions + /// + IShiftTraceLogger? TraceLogger { get; set; } + } +} diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs index 0f9d74f..e255ccf 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs @@ -1,5 +1,5 @@ using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs b/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs index 524d478..88b543d 100644 --- a/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs +++ b/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Exceptions; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; using System; using System.Collections.Generic; using System.Diagnostics; @@ -51,7 +52,7 @@ namespace StructureHelperCommon.Models.Calculators TraceLogger?.AddMessage($"Calculating parameter by iterations is started,\nrequired precision {Accuracy.IterationAccuracy}"); if (predicate(end) == false) { - TraceLogger?.AddMessage($"Predicate for end value must be true", TraceLoggerStatuses.Error); + TraceLogger?.AddMessage($"Predicate for end value must be true", TraceLogStatuses.Error); throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": predicate for end value must be true"); } double precision = Accuracy.IterationAccuracy; @@ -61,21 +62,21 @@ namespace StructureHelperCommon.Models.Calculators int iterationNum = 0; while (step > precision) { - TraceLogger?.AddMessage($"Iteration number {iterationNum} is started", TraceLoggerStatuses.Debug); + TraceLogger?.AddMessage($"Iteration number {iterationNum} is started", TraceLogStatuses.Debug); if (predicate(current) == true) { - TraceLogger?.AddMessage($"Predicate value in {current} is true", TraceLoggerStatuses.Debug, 50); + TraceLogger?.AddMessage($"Predicate value in {current} is true", TraceLogStatuses.Debug, 50); end = current; } else { - TraceLogger?.AddMessage($"Predicate value in {current} is false", TraceLoggerStatuses.Debug, 50); + TraceLogger?.AddMessage($"Predicate value in {current} is false", TraceLogStatuses.Debug, 50); start = current; } - TraceLogger?.AddMessage($"New current value Cur=({start}+{end})/2={current}", TraceLoggerStatuses.Debug); + TraceLogger?.AddMessage($"New current value Cur=({start}+{end})/2={current}", TraceLogStatuses.Debug); current = (start + end) / 2d; step = (end - start) / 2d; - TraceLogger?.AddMessage($"New step S={current}", TraceLoggerStatuses.Debug, 50); + TraceLogger?.AddMessage($"New step S={current}", TraceLogStatuses.Debug, 50); iterationNum++; result.IsValid = false; @@ -85,7 +86,7 @@ namespace StructureHelperCommon.Models.Calculators if (iterationNum > maxIterationCount) { - TraceLogger?.AddMessage($"Recuired precision was not achieved, current step {step}, required precision {precision}", TraceLoggerStatuses.Error); + TraceLogger?.AddMessage($"Recuired precision was not achieved, current step {step}, required precision {precision}", TraceLogStatuses.Error); result.Description = "Parameter was not found succefully: \n"; throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": violation of iteration count"); } diff --git a/StructureHelperCommon/Models/Calculators/ICalculator.cs b/StructureHelperCommon/Models/Calculators/ICalculator.cs index 1a74a03..a1b0482 100644 --- a/StructureHelperCommon/Models/Calculators/ICalculator.cs +++ b/StructureHelperCommon/Models/Calculators/ICalculator.cs @@ -1,18 +1,10 @@ -using LoaderCalculator.Data.ResultData; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Infrastructures.Interfaces; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using TaskManager; namespace StructureHelperCommon.Models.Calculators { - public interface ICalculator : ICloneable - { - IShiftTraceLogger? TraceLogger { get; set; } + public interface ICalculator : ILogic, ICloneable + { string Name { get; set; } /// /// Method for calculating diff --git a/StructureHelperCommon/Models/Forces/DesignForceTuple.cs b/StructureHelperCommon/Models/Forces/DesignForceTuple.cs index 99d0d91..27ff4e6 100644 --- a/StructureHelperCommon/Models/Forces/DesignForceTuple.cs +++ b/StructureHelperCommon/Models/Forces/DesignForceTuple.cs @@ -6,7 +6,7 @@ namespace StructureHelperCommon.Models.Forces { public LimitStates LimitState { get; set; } public CalcTerms CalcTerm { get; set; } - public ForceTuple ForceTuple { get; set; } + public IForceTuple ForceTuple { get; set; } public DesignForceTuple(LimitStates limitState, CalcTerms calcTerm) : this() { diff --git a/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs b/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs index d090d24..e2144d4 100644 --- a/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs +++ b/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs @@ -8,6 +8,6 @@ namespace StructureHelperCommon.Models.Forces { LimitStates LimitState { get; set; } CalcTerms CalcTerm { get; set; } - ForceTuple ForceTuple { get; set; } + IForceTuple ForceTuple { get; set; } } } diff --git a/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs b/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs index 60aec50..aded8a1 100644 --- a/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs +++ b/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs @@ -1,4 +1,5 @@ -using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Tables; using System; using System.Collections.Generic; @@ -6,60 +7,195 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { + /// + /// Factory for creating trace table entries + /// public class TraceTablesFactory { public int Priority { get; set; } - public TraceTablesFactory(TraceLoggerStatuses status = TraceLoggerStatuses.Info, int priorityShift = 0) + /// + /// Generates table entry for Point2D (2 columns, 2 rows) + /// + /// Point fo creating a table + /// Table entry + public TableLogEntry GetByPoint2D(IPoint2D point2D) { - Priority = LoggerService.GetPriorityByStatus(status) + priorityShift; - } - public TableLoggerEntry GetTableByPoint2D(IPoint2D point2D) - { - var table = new TableLoggerEntry(2); + var table = new TableLogEntry(2); table.Priority = Priority; - table.Table.AddRow(GetHeaderRow()); + table.Table.AddRow(GetPointHeaderRow()); table.Table.AddRow(GetPointRow(point2D)); return table; } - public TableLoggerEntry GetTableByPoint2D(IEnumerable points) + /// + /// Generates a table representation for the provided force tuple + /// + /// Force tuple to create the table for + /// Table entry + public TableLogEntry GetByForceTuple(IForceTuple forceTuple) { - var table = new TableLoggerEntry(2); + var table = new TableLogEntry(6); table.Priority = Priority; - table.Table.AddRow(GetHeaderRow()); + table.Table.AddRow(GetForceTupleHeaderRow()); + table.Table.AddRow(GetForceTupleRow(forceTuple)); + return table; + } + /// + /// Generates table entry for Point2D (2 columns, (number of poins + 1) rows) + /// + /// Collection of points for creating a table + /// Table entry + public TableLogEntry GetByPoint2D(IEnumerable points) + { + var table = new TableLogEntry(2); + table.Priority = Priority; + table.Table.AddRow(GetPointHeaderRow()); foreach (var item in points) { table.Table.AddRow(GetPointRow(item)); } return table; } - - private ShTableRow GetHeaderRow() + /// + /// Generates a table representation for the provided force tuple collection + /// + /// Force tuple collection to create the table for + /// Table entry + public TableLogEntry GetByForceTuple(IEnumerable forceTuples) { + var table = new TableLogEntry(6); + table.Priority = Priority; + table.Table.AddRow(GetForceTupleHeaderRow()); + foreach (var forceTuple in forceTuples) + { + table.Table.AddRow(GetForceTupleRow(forceTuple)); + } + return table; + } + /// + /// Generates new trace table entry + /// + /// Default status = info + public TraceTablesFactory(TraceLogStatuses status = TraceLogStatuses.Info) + { + Priority = LoggerService.GetPriorityByStatus(status); + } + private ShTableRow GetForceTupleHeaderRow() + { + var forceTupleRow = new ShTableRow(6); + + forceTupleRow.Elements[0].Value = new StringLogEntry() + { + Message = "Mx", + Priority = Priority + }; + + forceTupleRow.Elements[1].Value = new StringLogEntry() + { + Message = "My", + Priority = Priority + }; + + forceTupleRow.Elements[2].Value = new StringLogEntry() + { + Message = "Nz", + Priority = Priority + }; + + forceTupleRow.Elements[3].Value = new StringLogEntry() + { + Message = "Qx", + Priority = Priority + }; + + forceTupleRow.Elements[4].Value = new StringLogEntry() + { + Message = "Qy", + Priority = Priority + }; + + forceTupleRow.Elements[5].Value = new StringLogEntry() + { + Message = "Mz", + Priority = Priority + }; + + return forceTupleRow; + } + private ShTableRow GetForceTupleRow(IForceTuple forceTuple) + { + var forceTupleRow = new ShTableRow(6); + + forceTupleRow.Elements[0].Value = new StringLogEntry() + { + Message = forceTuple.Mx.ToString(), + Priority = Priority + }; + + forceTupleRow.Elements[1].Value = new StringLogEntry() + { + Message = forceTuple.My.ToString(), + Priority = Priority + }; + + + forceTupleRow.Elements[2].Value = new StringLogEntry() + { + Message = forceTuple.Nz.ToString(), + Priority = Priority + }; + + + forceTupleRow.Elements[3].Value = new StringLogEntry() + { + Message = forceTuple.Qx.ToString(), + Priority = Priority + }; + + + forceTupleRow.Elements[4].Value = new StringLogEntry() + { + Message = forceTuple.Qy.ToString(), + Priority = Priority + }; + + forceTupleRow.Elements[5].Value = new StringLogEntry() + { + Message = forceTuple.Mz.ToString(), + Priority = Priority + }; + + return forceTupleRow; + } + + private ShTableRow GetPointHeaderRow() + { + const CellRole cellRole = CellRole.Header; + var headerRow = new ShTableRow(2); IShTableCell tableCell; ITraceLoggerEntry loggerEntry; - loggerEntry = new StringLoggerEntry() + loggerEntry = new StringLogEntry() { Message = "X", - Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info) + Priority = Priority }; tableCell = new ShTableCell() { Value = loggerEntry, - Role = CellRole.Header, + Role = cellRole, }; headerRow.Elements[0] = tableCell; - loggerEntry = new StringLoggerEntry() + loggerEntry = new StringLogEntry() { Message = "Y", - Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info) + Priority = Priority }; tableCell = new ShTableCell() { Value = loggerEntry, - Role = CellRole.Header, + Role = cellRole, }; headerRow.Elements[1] = tableCell; return headerRow; @@ -67,15 +203,15 @@ namespace StructureHelperCommon.Models.Loggers private ShTableRow GetPointRow(IPoint2D point2D) { var pointRow = new ShTableRow(2); - pointRow.Elements[0].Value = new StringLoggerEntry() + pointRow.Elements[0].Value = new StringLogEntry() { Message = Convert.ToString(point2D.X), - Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info) + Priority = LoggerService.GetPriorityByStatus(TraceLogStatuses.Info) }; - pointRow.Elements[1].Value = new StringLoggerEntry() + pointRow.Elements[1].Value = new StringLogEntry() { Message = Convert.ToString(point2D.Y), - Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info) + Priority = LoggerService.GetPriorityByStatus(TraceLogStatuses.Info) }; return pointRow; } diff --git a/StructureHelperCommon/Models/Loggers/ILogger.cs b/StructureHelperCommon/Models/Loggers/ILogger.cs index 2af24d5..593e779 100644 --- a/StructureHelperCommon/Models/Loggers/ILogger.cs +++ b/StructureHelperCommon/Models/Loggers/ILogger.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { public interface ILogger { diff --git a/StructureHelperCommon/Models/Loggers/IShiftTraceLogger.cs b/StructureHelperCommon/Models/Loggers/IShiftTraceLogger.cs index 91a0454..c866ae9 100644 --- a/StructureHelperCommon/Models/Loggers/IShiftTraceLogger.cs +++ b/StructureHelperCommon/Models/Loggers/IShiftTraceLogger.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { public interface IShiftTraceLogger : ITraceLogger { diff --git a/StructureHelperCommon/Models/Loggers/ITraceLogger.cs b/StructureHelperCommon/Models/Loggers/ITraceLogger.cs index 36128c8..f4f8a4f 100644 --- a/StructureHelperCommon/Models/Loggers/ITraceLogger.cs +++ b/StructureHelperCommon/Models/Loggers/ITraceLogger.cs @@ -4,12 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { public interface ITraceLogger { List TraceLoggerEntries { get; } - void AddMessage(string message, TraceLoggerStatuses status = TraceLoggerStatuses.Info, int shiftPriority = 0); + void AddMessage(string message, TraceLogStatuses status = TraceLogStatuses.Info, int shiftPriority = 0); void AddMessage(string message, int priority); } } diff --git a/StructureHelperCommon/Models/Loggers/ITraceLoggerEntry.cs b/StructureHelperCommon/Models/Loggers/ITraceLoggerEntry.cs index 7342376..735fd04 100644 --- a/StructureHelperCommon/Models/Loggers/ITraceLoggerEntry.cs +++ b/StructureHelperCommon/Models/Loggers/ITraceLoggerEntry.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { public interface ITraceLoggerEntry { diff --git a/StructureHelperCommon/Models/Loggers/LoggerService.cs b/StructureHelperCommon/Models/Loggers/LoggerService.cs index 9b02c22..261e3ec 100644 --- a/StructureHelperCommon/Models/Loggers/LoggerService.cs +++ b/StructureHelperCommon/Models/Loggers/LoggerService.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { public static class LoggerService { @@ -16,14 +16,14 @@ namespace StructureHelperCommon.Models.Loggers const int info = 300; const int service = 400; const int debug = 500; - public static int GetPriorityByStatus(TraceLoggerStatuses status) + public static int GetPriorityByStatus(TraceLogStatuses 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; } + if (status == TraceLogStatuses.Fatal) { return fatal; } + else if (status == TraceLogStatuses.Error) { return error; } + else if (status == TraceLogStatuses.Warning) { return warning; } + else if (status == TraceLogStatuses.Info) { return info; } + else if (status == TraceLogStatuses.Service) { return service; } + else if (status == TraceLogStatuses.Debug) { return debug; } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(status)); diff --git a/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs b/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs index 8270eed..8638ae0 100644 --- a/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs +++ b/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { public class ShiftTraceLogger : IShiftTraceLogger { @@ -17,10 +17,10 @@ namespace StructureHelperCommon.Models.Loggers Logger = logger; } public ShiftTraceLogger() : this(new TraceLogger()) { } - public void AddMessage(string message, TraceLoggerStatuses status = TraceLoggerStatuses.Info, int shiftPrioriry = 0) + public void AddMessage(string message, TraceLogStatuses status = TraceLogStatuses.Info, int shiftPrioriry = 0) { // if status in (fatal, error, warning) they must be kept as they are - if (status <= TraceLoggerStatuses.Warning) + if (status <= TraceLogStatuses.Warning) { Logger.AddMessage(message, status); } @@ -48,7 +48,10 @@ namespace StructureHelperCommon.Models.Loggers public void AddEntry(ITraceLoggerEntry loggerEntry) { - loggerEntry.Priority += ShiftPriority; + if (loggerEntry.Priority >= LoggerService.GetPriorityByStatus(TraceLogStatuses.Warning)) + { + loggerEntry.Priority += ShiftPriority; + } Logger.TraceLoggerEntries.Add(loggerEntry); } } diff --git a/StructureHelperCommon/Models/Loggers/StringLoggerEntry.cs b/StructureHelperCommon/Models/Loggers/StringLogEntry.cs similarity index 70% rename from StructureHelperCommon/Models/Loggers/StringLoggerEntry.cs rename to StructureHelperCommon/Models/Loggers/StringLogEntry.cs index ba1b484..085c4f0 100644 --- a/StructureHelperCommon/Models/Loggers/StringLoggerEntry.cs +++ b/StructureHelperCommon/Models/Loggers/StringLogEntry.cs @@ -4,15 +4,15 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { - public class StringLoggerEntry : ITraceLoggerEntry + public class StringLogEntry : ITraceLoggerEntry { public DateTime TimeStamp { get;} public string Message { get; set; } public int Priority { get; set; } - public StringLoggerEntry() + public StringLogEntry() { TimeStamp = DateTime.Now; } diff --git a/StructureHelperCommon/Models/Loggers/TableLoggerEntry.cs b/StructureHelperCommon/Models/Loggers/TableLogEntry.cs similarity index 81% rename from StructureHelperCommon/Models/Loggers/TableLoggerEntry.cs rename to StructureHelperCommon/Models/Loggers/TableLogEntry.cs index d9f8077..9720073 100644 --- a/StructureHelperCommon/Models/Loggers/TableLoggerEntry.cs +++ b/StructureHelperCommon/Models/Loggers/TableLogEntry.cs @@ -5,16 +5,16 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { - public class TableLoggerEntry : ITraceLoggerEntry + public class TableLogEntry : ITraceLoggerEntry { private ShTable table; public ShTable Table {get => table;} public DateTime TimeStamp { get; } public int Priority { get; set; } - public TableLoggerEntry(int rowSize) + public TableLogEntry(int rowSize) { if (rowSize <= 0) { diff --git a/StructureHelperCommon/Models/Loggers/TraceLoggerStatuses.cs b/StructureHelperCommon/Models/Loggers/TraceLogStatuses.cs similarity index 73% rename from StructureHelperCommon/Models/Loggers/TraceLoggerStatuses.cs rename to StructureHelperCommon/Models/Loggers/TraceLogStatuses.cs index 28aebbc..8dc5789 100644 --- a/StructureHelperCommon/Models/Loggers/TraceLoggerStatuses.cs +++ b/StructureHelperCommon/Models/Loggers/TraceLogStatuses.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { - public enum TraceLoggerStatuses + public enum TraceLogStatuses { Fatal, Error, diff --git a/StructureHelperCommon/Models/Loggers/TraceLogger.cs b/StructureHelperCommon/Models/Loggers/TraceLogger.cs index 3e18d5f..b2397d3 100644 --- a/StructureHelperCommon/Models/Loggers/TraceLogger.cs +++ b/StructureHelperCommon/Models/Loggers/TraceLogger.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace StructureHelperCommon.Models.Loggers +namespace StructureHelperCommon.Models { public class TraceLogger : ITraceLogger { @@ -17,12 +17,12 @@ namespace StructureHelperCommon.Models.Loggers TraceLoggerEntries = new(); } - public void AddMessage(string message, TraceLoggerStatuses status = TraceLoggerStatuses.Info, int shiftPrioriry = 0) + public void AddMessage(string message, TraceLogStatuses status = TraceLogStatuses.Info, int shiftPrioriry = 0) { - if (status == TraceLoggerStatuses.Fatal) { message = $"Fatal error! {message}"; } - if (status == TraceLoggerStatuses.Error) { message = $"Error! {message}"; } - if (status == TraceLoggerStatuses.Warning) { message = $"Warning! {message}"; } - TraceLoggerEntries.Add(new StringLoggerEntry() + if (status == TraceLogStatuses.Fatal) { message = $"Fatal error! {message}"; } + if (status == TraceLogStatuses.Error) { message = $"Error! {message}"; } + if (status == TraceLogStatuses.Warning) { message = $"Warning! {message}"; } + TraceLoggerEntries.Add(new StringLogEntry() { Message = message, Priority = LoggerService.GetPriorityByStatus(status) @@ -30,7 +30,7 @@ namespace StructureHelperCommon.Models.Loggers } public void AddMessage(string message, int priority) { - TraceLoggerEntries.Add(new StringLoggerEntry() + TraceLoggerEntries.Add(new StringLogEntry() { Message = message, Priority = priority diff --git a/StructureHelperCommon/Models/Soils/AnchorCalculator.cs b/StructureHelperCommon/Models/Soils/AnchorCalculator.cs index aab8339..fee8d7f 100644 --- a/StructureHelperCommon/Models/Soils/AnchorCalculator.cs +++ b/StructureHelperCommon/Models/Soils/AnchorCalculator.cs @@ -1,6 +1,6 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using System; using System.Collections.Generic; using System.Linq; diff --git a/StructureHelperCommon/Models/Tables/ShTable.cs b/StructureHelperCommon/Models/Tables/ShTable.cs index 22bf908..09d570f 100644 --- a/StructureHelperCommon/Models/Tables/ShTable.cs +++ b/StructureHelperCommon/Models/Tables/ShTable.cs @@ -54,6 +54,14 @@ namespace StructureHelperCommon.Models.Tables } } + public int RowCount => GetAllRows().Count(); + public IShTableCell GetCell(int rowIndex, int columnIndex) + { + var row = GetElementsFromRow(rowIndex); + var cell = row[columnIndex]; + return cell; + } + /// /// Set a value at the specified column and row index /// diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs index 6c79543..3c5140a 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs @@ -1,8 +1,8 @@ using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Sections; using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Forces; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs index 55cc646..0d25c9f 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs @@ -2,8 +2,8 @@ using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.ResultData; using LoaderCalculator.Data.SourceData; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs index c22de18..e3aa211 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/GetPredicateLogic.cs @@ -1,12 +1,6 @@ using LoaderCalculator.Data.Ndms; -using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories { diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs index 331982c..acd1739 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/IGetPredicateLogic.cs @@ -1,4 +1,4 @@ -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Shapes; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveLogic.cs index 5c54dc4..6f0b5ab 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveLogic.cs @@ -1,11 +1,7 @@ -using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; //Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia //All rights reserved. @@ -15,7 +11,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces /// /// Logic for build collection of points by surround points /// - public interface ILimitCurveLogic : IHasActionByResult + public interface ILimitCurveLogic : ILogic, IHasActionByResult { /// /// Returns list of points by source collection diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs index 8117539..e3e80dd 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/ILimitCurveParameterLogic.cs @@ -1,5 +1,5 @@ using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Shapes; using System; using System.Collections.Generic; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs index ab2dae6..00ac052 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveCalculator.cs @@ -1,13 +1,7 @@ using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Diagnostics.Eventing.Reader; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { @@ -48,7 +42,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces public void Run() { if (TraceLogger is not null) { limitCurveLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); } - TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLoggerStatuses.Service); + TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); TraceLogger?.AddMessage($"Start solution in calculator {Name}"); result = new LimitCurveResult(); result.IsValid = true; @@ -58,24 +52,18 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces TraceLogger?.AddMessage($"Point count {PointCount}"); surroundList = SurroundProcLogic.GetPoints(); TraceLogger?.AddMessage($"There are {surroundList.Count()} point prepared for calculation"); - TraceLogger?.AddEntry( - new TraceTablesFactory( - TraceLoggerStatuses.Info, TraceLogger.ShiftPriority) - .GetTableByPoint2D(surroundList)); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByPoint2D(surroundList)); try { limitCurveLogic.ActionToOutputResults = GetCurrentStepNumber; factoredList = limitCurveLogic.GetPoints(surroundList); TraceLogger?.AddMessage($"Solution was successfully obtained for {factoredList.Count()} point"); - TraceLogger?.AddEntry( - new TraceTablesFactory( - TraceLoggerStatuses.Info, TraceLogger.ShiftPriority) - .GetTableByPoint2D(factoredList)); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByPoint2D(factoredList)); result.Points = factoredList; } catch (Exception ex) { - TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLoggerStatuses.Error); + TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLogStatuses.Error); result.IsValid = false; result.Description += ex.Message; } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs index 4a4e603..9c1f024 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs @@ -1,5 +1,5 @@ using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories; using System.Windows.Media.Media3D; @@ -42,12 +42,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces var zeroPoint = new Point2D(); if (limitPredicate(zeroPoint) == true) { - TraceLogger?.AddMessage($"Predicate is true for point. All point will be skiped", TraceLoggerStatuses.Warning); - TraceLogger?.AddEntry( - new TraceTablesFactory( - TraceLoggerStatuses.Warning, 0) - .GetTableByPoint2D(zeroPoint)); - TraceLogger?.AddMessage($"All point will be skiped", TraceLoggerStatuses.Warning); + TraceLogger?.AddMessage($"Predicate is true for point. All point will be skiped", TraceLogStatuses.Warning); + TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Warning).GetByPoint2D(zeroPoint)); + TraceLogger?.AddMessage($"All point will be skiped", TraceLogStatuses.Warning); var range = points.Select(point => new Point2D { X = 0d, Y = 0d }).ToList(); resultList.AddRange(range); return resultList; @@ -121,17 +118,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces lock (lockObject) { TraceLogger?.AddMessage($"Source point"); - TraceLogger?.AddEntry( - new TraceTablesFactory( - TraceLoggerStatuses.Info, TraceLogger.ShiftPriority) - .GetTableByPoint2D(localCurrentPoint)); + TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(localCurrentPoint)); TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries); TraceLogger?.AddMessage($"Parameter value {parameter} was obtained"); TraceLogger?.AddMessage($"Calculated point\n(X={localCurrentPoint.X} * {parameter} = {resultPoint.X},\nY={localCurrentPoint.Y} * {parameter} = {resultPoint.Y})"); - TraceLogger?.AddEntry( - new TraceTablesFactory( - TraceLoggerStatuses.Info, TraceLogger.ShiftPriority) - .GetTableByPoint2D(resultPoint)); + TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(resultPoint)); } return resultPoint; } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs index 840d2ac..57ebf48 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveParameterLogic.cs @@ -1,12 +1,7 @@ using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { @@ -45,7 +40,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces if (parameter < limitparamValue) { var newAccuracy = limitparamValue / 10d; - TraceLogger?.AddMessage($"Since current parameter value {parameter} has a low accuracy (value less than {limitparamValue}) new parameter calculating is started", TraceLoggerStatuses.Warning); + TraceLogger?.AddMessage($"Since current parameter value {parameter} has a low accuracy (value less than {limitparamValue}) new parameter calculating is started", TraceLogStatuses.Warning); parameterCalculator.Accuracy.IterationAccuracy = 0.0001d; parameterCalculator.Run(); result = parameterCalculator.Result as FindParameterResult; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs index 4b260f5..cbb0425 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs @@ -1,17 +1,10 @@ using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; -using StructureHelperCommon.Models.Shapes; -using StructureHelperLogics.Models.Calculations.CalculationsResults; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; using StructureHelperLogics.Services.NdmPrimitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; //Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia //All rights reserved. @@ -39,7 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces } public void Run() { - TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLoggerStatuses.Service); + TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); TraceLogger?.AddMessage($"Start solution in calculator {Name}"); GetNewResult(); try @@ -62,7 +55,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces } catch (Exception ex) { - TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLoggerStatuses.Error); + TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLogStatuses.Error); result.IsValid = false; result.Description += ex; } @@ -87,7 +80,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { var ndms = NdmPrimitivesService.GetNdms(primitiveSeries.Collection, limitState, calcTerm); TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded succesfully"); - TraceLogger?.AddMessage($"Summary area of elementary parts Asum={ndms.Sum(x=>x.Area)}", TraceLoggerStatuses.Debug); + TraceLogger?.AddMessage($"Summary area of elementary parts Asum={ndms.Sum(x=>x.Area * x.StressScale)}", TraceLogStatuses.Debug); foreach (var predicateEntry in InputData.PredicateEntries) { string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}"; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/StabLimitCurveLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/StabLimitCurveLogic.cs index ec64dba..3ac5319 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/StabLimitCurveLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/StabLimitCurveLogic.cs @@ -1,11 +1,6 @@ -using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/InterpolationProgressLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/InterpolationProgressLogic.cs index ff1e8c0..84f2dbe 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/InterpolationProgressLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/InterpolationProgressLogic.cs @@ -1,14 +1,9 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Services.NdmCalculations; -using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics { diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Geometry/GeometryCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/Geometry/GeometryCalculator.cs index 6d6761e..7e34ca8 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Geometry/GeometryCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Geometry/GeometryCalculator.cs @@ -1,13 +1,8 @@ using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Services.NdmPrimitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry { diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs index d824b1c..96fafe5 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs @@ -1,12 +1,11 @@ using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; using LoaderCalculator.Logics.Geometry; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.Materials; -using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.Services.NdmPrimitives; diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs index cdd22a8..462a56d 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs @@ -1,17 +1,12 @@ using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Services; using StructureHelperCommon.Services.Forces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Cracking { @@ -25,8 +20,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking private CrackForceResult result; public string Name { get; set; } - public ForceTuple StartTuple { get; set; } - public ForceTuple EndTuple { get; set; } + public IForceTuple StartTuple { get; set; } + public IForceTuple EndTuple { get; set; } public IEnumerable NdmCollection { get; set; } public Accuracy Accuracy {get;set; } public IResult Result => result; @@ -146,7 +141,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking result.SofteningFactors = GetSofteningFactors(result.ReducedStrainTuple); result.Description = "Section is not cracked"; } - private StrainTuple GetStrainTuple(ForceTuple forceTuple) + private StrainTuple GetStrainTuple(IForceTuple forceTuple) { ForceTupleInputData inputData = new(); inputData.NdmCollection = NdmCollection; diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculator.cs index 8960e37..4188174 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculator.cs @@ -1,12 +1,11 @@ using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Services.Forces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Primitives; -using StructureHelperLogics.NdmCalculations.Triangulations; using StructureHelperLogics.Services.NdmPrimitives; namespace StructureHelperLogics.NdmCalculations.Cracking diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorInputData.cs index 4f0c346..607ad35 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorInputData.cs @@ -13,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking { public LimitStates LimitState { get; set; } public CalcTerms CalcTerm { get; set; } - public ForceTuple ForceTuple { get; set; } + public IForceTuple ForceTuple { get; set; } public List NdmPrimitives {get;set;} } } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculator.cs index 4262d77..03b423c 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculator.cs @@ -1,10 +1,5 @@ -using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Loggers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Calculators; namespace StructureHelperLogics.NdmCalculations.Cracking { diff --git a/StructureHelperTests/Infrastructures/ShTables/TraceTablesFactoryTests.cs b/StructureHelperTests/Infrastructures/ShTables/TraceTablesFactoryTests.cs new file mode 100644 index 0000000..859074c --- /dev/null +++ b/StructureHelperTests/Infrastructures/ShTables/TraceTablesFactoryTests.cs @@ -0,0 +1,102 @@ +using NUnit.Framework; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models; +using System; +using System.Collections.Generic; + +namespace StructureHelperTests.Infrastructures.ShTables +{ + [TestFixture] + public class TraceTablesFactoryTests + { + [Test] + public void GetByPoint2D_WithSinglePoint_ShouldReturnTableWithHeaderAndSinglePointRow() + { + // Arrange + var factory = new TraceTablesFactory(); + var mockPoint = new MockPoint2D(1.0, 2.0); + + // Act + var result = factory.GetByPoint2D(mockPoint); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(2, result.Table.RowCount); + Assert.AreEqual("X", (result.Table.GetCell(0, 0).Value as StringLogEntry).Message); + Assert.AreEqual("Y", (result.Table.GetCell(0, 1).Value as StringLogEntry).Message); + Assert.AreEqual("1", (result.Table.GetCell(1, 0).Value as StringLogEntry).Message); + Assert.AreEqual("2", (result.Table.GetCell(1, 1).Value as StringLogEntry).Message); + } + + [Test] + public void GetByPoint2D_WithMultiplePoints_ShouldReturnTableWithHeaderAndMultiplePointRows() + { + // Arrange + var factory = new TraceTablesFactory(); + var mockPoints = new List + { + new MockPoint2D(1.0, 2.0), + new MockPoint2D(3.0, 4.0), + new MockPoint2D(5.0, 6.0) + }; + + // Act + var result = factory.GetByPoint2D(mockPoints); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(4, result.Table.RowCount); // Header + 3 Point rows + Assert.AreEqual("X", (result.Table.GetCell(0, 0).Value as StringLogEntry).Message); + Assert.AreEqual("Y", (result.Table.GetCell(0, 1).Value as StringLogEntry).Message); + Assert.AreEqual("1", (result.Table.GetCell(1, 0).Value as StringLogEntry).Message); + Assert.AreEqual("2", (result.Table.GetCell(1, 1).Value as StringLogEntry).Message); + Assert.AreEqual("3", (result.Table.GetCell(2, 0).Value as StringLogEntry).Message); + Assert.AreEqual("4", (result.Table.GetCell(2, 1).Value as StringLogEntry).Message); + Assert.AreEqual("5", (result.Table.GetCell(3, 0).Value as StringLogEntry).Message); + Assert.AreEqual("6", (result.Table.GetCell(3, 1).Value as StringLogEntry).Message); + } + + [Test] + public void GetByPoint2D_WithEmptyPointsCollection_ShouldReturnTableWithHeaderOnly() + { + // Arrange + var factory = new TraceTablesFactory(); + var emptyPoints = new List(); + + // Act + var result = factory.GetByPoint2D(emptyPoints); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Table.RowCount); // Only Header row + Assert.AreEqual("X", (result.Table.GetCell(0, 0).Value as StringLogEntry).Message); + Assert.AreEqual("Y", (result.Table.GetCell(0, 1).Value as StringLogEntry).Message); + } + + // Add more test cases for different scenarios and edge cases + } + + // Define a mock implementation of IPoint2D for testing purposes + public class MockPoint2D : IPoint2D + { + public MockPoint2D(double x, double y) + { + X = x; + Y = y; + } + + public double X { get; set; } + + public double Y { get; set; } + + public Guid Id => throw new NotImplementedException(); + + public object Clone() + { + throw new NotImplementedException(); + } + } +} + + + From 783d5e059144abe83c798124f29206d7eba2142f Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Thu, 1 Feb 2024 23:01:50 +0500 Subject: [PATCH 02/14] Trace logging for sorce of cracking was added --- .../ForceResultLogic/ShowCrackResultLogic.cs | 22 ++++++- .../ForcesResultsViewModel.cs | 2 - .../ProgressViews/TraceDocumentVM.cs | 4 +- .../Windows/Forces/InterpolateTuplesView.xaml | 2 +- .../Calculators/FindParameterCalculator.cs | 4 +- .../Loggers/Factories/TraceTablesFactory.cs | 29 ++++++--- .../Models/Loggers/ShiftTraceLogger.cs | 2 +- .../Analyses/ByForces/ForceTupleCalculator.cs | 46 +++++++++++--- .../ByForces/Logics/SofteningFactorLogic.cs | 24 +++++-- .../Cracking/CrackForceCalculator.cs | 62 ++++++++++++++----- .../NdmCalculations/Cracking/CrackedLogic.cs | 10 ++- .../Cracking/ExpSofteningLogic.cs | 24 +++++-- .../Cracking/HoleSectionCrackedLogic.cs | 29 ++++++++- .../Cracking/ICrackSofteningLogic.cs | 5 +- .../NdmCalculations/Cracking/ICrackedLogic.cs | 3 +- .../Cracking/ISectionCrackedLogic.cs | 3 +- 16 files changed, 212 insertions(+), 59 deletions(-) diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs index d1c2a27..280dd22 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs @@ -1,8 +1,11 @@ -using StructureHelper.Windows.Errors; +using LoaderCalculator; +using StructureHelper.Windows.CalculationWindows.ProgressViews; +using StructureHelper.Windows.Errors; using StructureHelper.Windows.Forces; using StructureHelper.Windows.ViewModels.Errors; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Settings; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Forces; using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Primitives; @@ -14,6 +17,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { internal class ShowCrackResultLogic { + private CrackForceCalculator calculator; + public static GeometryNames GeometryNames => ProgramSetting.GeometryNames; public LimitStates LimitState { get; set; } public CalcTerms CalcTerm { get; set; } @@ -33,7 +38,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple) { - var calculator = new CrackForceCalculator(); + calculator = new CrackForceCalculator(); + calculator.TraceLogger = new ShiftTraceLogger(); calculator.StartTuple = startDesignTuple; calculator.EndTuple = finishDesignTuple; calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitState, CalcTerm); @@ -41,7 +47,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu var result = (CrackForceResult)calculator.Result; if (result.IsValid) { - ShowResult(result); + ShowTraceResult(); + //ShowResult(result); } else { @@ -80,5 +87,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu MessageBoxButtons.OK, MessageBoxIcon.Information); } + + private void ShowTraceResult() + { + if (calculator.TraceLogger is not null) + { + var wnd = new TraceDocumentView(calculator.TraceLogger.TraceLoggerEntries); + wnd.ShowDialog(); + } + } } } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index 5062bfe..a2b438e 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -12,7 +12,6 @@ using StructureHelper.Windows.Forces; using StructureHelper.Windows.PrimitivePropertiesWindow; using StructureHelper.Windows.ViewModels.Calculations.Calculators; using StructureHelper.Windows.ViewModels.Errors; -using StructureHelper.Windows.ViewModels.PrimitiveProperties; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; @@ -22,7 +21,6 @@ using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Forces; using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; -using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; using StructureHelperLogics.NdmCalculations.Analyses.Geometry; using StructureHelperLogics.NdmCalculations.Primitives; diff --git a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs index cc6c3ce..7fa11e6 100644 --- a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs +++ b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentVM.cs @@ -16,7 +16,7 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews { public class TraceDocumentVM : ViewModelBase { - const int tabFactor = 500; + const double tabFactor = 500d; private readonly IEnumerable loggerEntries; private IEnumerable selectedLoggerEntries; private FlowDocument document; @@ -110,13 +110,13 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(traceEntry)); } + block.Margin = new Thickness(traceEntry.Priority / tabFactor * tabGap, 7, 0, 7); return block; } private Block GetBlockByStringEntry(StringLogEntry stringEntry) { var paragraph = new Paragraph(new Run(stringEntry.Message)); - paragraph.Margin = new Thickness(stringEntry.Priority / tabFactor * tabGap, 7, 0, 7); if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLogStatuses.Fatal)) { paragraph.FontSize = 14; diff --git a/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml b/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml index 5823dfc..5fa2abe 100644 --- a/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml +++ b/StructureHelper/Windows/Forces/InterpolateTuplesView.xaml @@ -101,7 +101,7 @@ - + diff --git a/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs b/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs index 88b543d..fbfa38d 100644 --- a/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs +++ b/StructureHelperCommon/Models/Calculators/FindParameterCalculator.cs @@ -58,7 +58,7 @@ namespace StructureHelperCommon.Models.Calculators double precision = Accuracy.IterationAccuracy; int maxIterationCount = Accuracy.MaxIterationCount; double current = start; - double step = (end - start) / 2; + double step = (end - start) / 2d; int iterationNum = 0; while (step > precision) { @@ -73,8 +73,8 @@ namespace StructureHelperCommon.Models.Calculators TraceLogger?.AddMessage($"Predicate value in {current} is false", TraceLogStatuses.Debug, 50); start = current; } - TraceLogger?.AddMessage($"New current value Cur=({start}+{end})/2={current}", TraceLogStatuses.Debug); current = (start + end) / 2d; + TraceLogger?.AddMessage($"New current value Cur=({start}+{end})/2={current}", TraceLogStatuses.Debug); step = (end - start) / 2d; TraceLogger?.AddMessage($"New step S={current}", TraceLogStatuses.Debug, 50); iterationNum++; diff --git a/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs b/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs index aded8a1..d101094 100644 --- a/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs +++ b/StructureHelperCommon/Models/Loggers/Factories/TraceTablesFactory.cs @@ -37,7 +37,7 @@ namespace StructureHelperCommon.Models { var table = new TableLogEntry(6); table.Priority = Priority; - table.Table.AddRow(GetForceTupleHeaderRow()); + table.Table.AddRow(GetForceTupleHeaderRow(forceTuple)); table.Table.AddRow(GetForceTupleRow(forceTuple)); return table; } @@ -66,7 +66,7 @@ namespace StructureHelperCommon.Models { var table = new TableLogEntry(6); table.Priority = Priority; - table.Table.AddRow(GetForceTupleHeaderRow()); + table.Table.AddRow(GetForceTupleHeaderRow(new ForceTuple())); foreach (var forceTuple in forceTuples) { table.Table.AddRow(GetForceTupleRow(forceTuple)); @@ -81,43 +81,54 @@ namespace StructureHelperCommon.Models { Priority = LoggerService.GetPriorityByStatus(status); } - private ShTableRow GetForceTupleHeaderRow() + private ShTableRow GetForceTupleHeaderRow(IForceTuple forceTuple) { + const CellRole cellRole = CellRole.Header; + string[] ColumnList = new string[] { "Mx", "My", "Nz", "Qx", "Qy", "Mz" }; + if (forceTuple is StrainTuple) + { + ColumnList = new string[] { "Kx", "Ky", "EpsZ", "GammaX", "GammaY", "Kz" }; + } + var forceTupleRow = new ShTableRow(6); + foreach (var item in forceTupleRow.Elements) + { + item.Role = cellRole; + } forceTupleRow.Elements[0].Value = new StringLogEntry() { - Message = "Mx", + Message = ColumnList[0], Priority = Priority }; forceTupleRow.Elements[1].Value = new StringLogEntry() { - Message = "My", + Message = ColumnList[1], Priority = Priority }; forceTupleRow.Elements[2].Value = new StringLogEntry() { - Message = "Nz", + Message = ColumnList[2], Priority = Priority }; forceTupleRow.Elements[3].Value = new StringLogEntry() { - Message = "Qx", + Message = ColumnList[3], Priority = Priority }; forceTupleRow.Elements[4].Value = new StringLogEntry() { - Message = "Qy", + Message = ColumnList[4], Priority = Priority }; forceTupleRow.Elements[5].Value = new StringLogEntry() { - Message = "Mz", + Message = ColumnList[5], Priority = Priority }; diff --git a/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs b/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs index 8638ae0..a6ea08e 100644 --- a/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs +++ b/StructureHelperCommon/Models/Loggers/ShiftTraceLogger.cs @@ -41,7 +41,7 @@ namespace StructureHelperCommon.Models { var newLogger = new ShiftTraceLogger(Logger) { - ShiftPriority = shiftPriority + ShiftPriority = ShiftPriority + shiftPriority }; return newLogger; } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs index 0d25c9f..fcb7545 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs @@ -14,7 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces public IResult Result { get; private set; } public Action ActionToOutputResults { get; set; } - public IShiftTraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public IShiftTraceLogger? TraceLogger { get; set; } public ForceTupleCalculator(IForceTupleInputData inputData) { @@ -31,14 +31,24 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces private IForcesTupleResult CalculateResult() { + TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); + TraceLogger?.AddMessage($"Calculator logic based on calculating strain in plain section by elementary parts of finished size"); var ndmCollection = InputData.NdmCollection; + TraceLogger?.AddMessage($"Collection of elementary parts contains {ndmCollection.Count()} parts"); + TraceLogger?.AddMessage($"Summary area of elementary part collection = {ndmCollection.Sum(x => x.Area * x.StressScale)}", TraceLogStatuses.Service); + TraceLogger?.AddMessage($"Minimum x = {ndmCollection.Min(x => x.CenterX)}", TraceLogStatuses.Debug); + TraceLogger?.AddMessage($"Maximum x = {ndmCollection.Max(x => x.CenterX)}", TraceLogStatuses.Debug); + TraceLogger?.AddMessage($"Minimum y = {ndmCollection.Min(x => x.CenterY)}", TraceLogStatuses.Debug); + TraceLogger?.AddMessage($"Maximum y = {ndmCollection.Max(x => x.CenterY)}", TraceLogStatuses.Debug); var tuple = InputData.Tuple; var accuracy = InputData.Accuracy; - + TraceLogger?.AddMessage($"Input force combination"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple)); var mx = tuple.Mx; var my = tuple.My; var nz = tuple.Nz; - + TraceLogger?.AddMessage($"Required accuracy rate {accuracy.IterationAccuracy}"); + TraceLogger?.AddMessage($"Maximum iteration count {accuracy.MaxIterationCount}"); try { var loaderData = new LoaderOptions @@ -53,23 +63,45 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces NdmCollection = ndmCollection }; var calculator = new Calculator(); + TraceLogger?.AddMessage($"Calculation is started", TraceLogStatuses.Debug); calculator.Run(loaderData, new CancellationToken()); + TraceLogger?.AddMessage($"Calculation result is obtained", TraceLogStatuses.Debug); var calcResult = calculator.Result; if (calcResult.AccuracyRate <= accuracy.IterationAccuracy) { - return new ForcesTupleResult() { IsValid = true, Description = "Analysis is done succsefully", LoaderResults = calcResult }; + TraceLogger?.AddMessage($"Analisis is done succsesfully"); + TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate}, {calcResult.IterationCounter} iteration has done", TraceLogStatuses.Debug); + return new ForcesTupleResult() + { + IsValid = true, + Description = "Analysis is done succsefully", + LoaderResults = calcResult + }; } else { + TraceLogger?.AddMessage($"Required accuracy rate has not achived", TraceLogStatuses.Error); + TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate}, {calcResult.IterationCounter} iteration has done", TraceLogStatuses.Warning); return new ForcesTupleResult() { IsValid = false, Description = "Required accuracy rate has not achived", LoaderResults = calcResult }; } } catch (Exception ex) { - var result = new ForcesTupleResult() { IsValid = false }; - if (ex.Message == "Calculation result is not valid: stiffness matrix is equal to zero") { result.Description = "Stiffness matrix is equal to zero \nProbably section was collapsed"; } - else { result.Description = $"Error is appeared due to analysis. Error: {ex}"; } + TraceLogger?.AddMessage($"Critical error ocured during calculation\n{ex}", TraceLogStatuses.Error); + var result = new ForcesTupleResult() + { + IsValid = false + }; + if (ex.Message == "Calculation result is not valid: stiffness matrix is equal to zero") + { + TraceLogger?.AddMessage($"Stiffness matrix is equal to zero\nProbably section was collapsed", TraceLogStatuses.Error); + result.Description = "Stiffness matrix is equal to zero\nProbably section was collapsed"; + } + else + { + result.Description = $"Error is appeared due to analysis. Error: {ex}"; + } return result; } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/SofteningFactorLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/SofteningFactorLogic.cs index 03fa77b..0b9477f 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/SofteningFactorLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/SofteningFactorLogic.cs @@ -1,6 +1,9 @@ using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; using LoaderCalculator.Logics.Geometry; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Infrastructures.Settings; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Services.Forces; using System; @@ -11,19 +14,30 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics { - internal class SofteningFactorLogic + internal class SofteningFactorLogic : ILogic { public static IStressLogic stressLogic = new StressLogic(); public IEnumerable NdmCollection { get; set; } public StrainTuple StrainTuple { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } + public StrainTuple GetSofteningFactors() { - var strainTuple = new StrainTuple(); + TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); + TraceLogger?.AddMessage($"Logic of analisys based on calculating sum of secant stifness of elementary parts EA,i = A,i * Esec,i"); + TraceLogger?.AddMessage($"Calculating geometry properies for strains"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(StrainTuple)); var loaderStainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(StrainTuple); var (MxFactor, MyFactor, NzFactor) = GeometryOperations.GetSofteningsFactors(NdmCollection, loaderStainMatrix); - strainTuple.Mx = MxFactor; - strainTuple.My = MyFactor; - strainTuple.Nz = NzFactor; + TraceLogger?.AddMessage($"Reducing of stiffness in {ProgramSetting.GeometryNames.SndAxisName}-plane: EIx_cracked / EIx_uncracked = {MxFactor}"); + TraceLogger?.AddMessage($"Reducing of stiffness in {ProgramSetting.GeometryNames.FstAxisName}-plane: EIy_cracked / EIy_uncracked = {MyFactor}"); + TraceLogger?.AddMessage($"Reducing of along {ProgramSetting.GeometryNames.TrdAxisName}-axis: EA_cracked / EA_uncracked = {NzFactor}"); + var strainTuple = new StrainTuple + { + Mx = MxFactor, + My = MyFactor, + Nz = NzFactor + }; return strainTuple; } } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs index 462a56d..f015b52 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs @@ -1,5 +1,6 @@ using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; @@ -13,11 +14,12 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public class CrackForceCalculator : ICalculator { static readonly CrackedLogic crackedLogic = new(); - static readonly ExpSofteningLogic softeningLogic = new(); + ExpSofteningLogic softeningLogic = new(); static readonly CrackStrainLogic crackStrainLogic = new(); static readonly SofteningFactorLogic softeningFactorLogic = new(); IForceTupleCalculator forceTupleCalculator; private CrackForceResult result; + private FindParameterCalculator parameterCalculator; public string Name { get; set; } public IForceTuple StartTuple { get; set; } @@ -26,7 +28,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public Accuracy Accuracy {get;set; } public IResult Result => result; - public IShiftTraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public IShiftTraceLogger? TraceLogger { get; set; } public CrackForceCalculator(IForceTupleCalculator forceTupleCalculator) { @@ -40,7 +42,23 @@ namespace StructureHelperLogics.NdmCalculations.Cracking } public void Run() { + parameterCalculator = new FindParameterCalculator() + { + Accuracy = Accuracy, + Predicate = crackedLogic.IsSectionCracked + }; + if (TraceLogger is not null) + { + forceTupleCalculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(100); + parameterCalculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); + crackedLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(150); + } + TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); result = new CrackForceResult(); + TraceLogger?.AddMessage($"Start force combination"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(StartTuple)); + TraceLogger?.AddMessage($"Actual (end) force combination"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(EndTuple)); crackedLogic.StartTuple = StartTuple; crackedLogic.EndTuple = EndTuple; crackedLogic.NdmCollection = NdmCollection; @@ -56,19 +74,17 @@ namespace StructureHelperLogics.NdmCalculations.Cracking } if (crackedLogic.IsSectionCracked(0d) == true) { + TraceLogger?.AddMessage($"Crack is appeared in start corce combination", TraceLogStatuses.Warning); SectionCrackedAtStart(); return; } if (crackedLogic.IsSectionCracked(1d) == false) { + TraceLogger?.AddMessage($"Crack is not appeared from actual (end) force combination", TraceLogStatuses.Warning); SectionIsNotCracked(); return; } - var parameterCalculator = new FindParameterCalculator() - { - Accuracy = Accuracy, - Predicate = crackedLogic.IsSectionCracked - }; + parameterCalculator.Run(); var paramResult = parameterCalculator.Result as FindParameterResult; if (paramResult.IsValid == true) @@ -79,24 +95,42 @@ namespace StructureHelperLogics.NdmCalculations.Cracking { result.IsValid = false; result.Description += paramResult.Description; + TraceLogger?.AddMessage($"Result of calculation is not valid\n{result.Description}", TraceLogStatuses.Error); } } private void SectionIsCrackedBetween(FindParameterResult? paramResult) { var factorOfCrackAppearance = paramResult.Parameter; + softeningLogic = new ExpSofteningLogic(); + if (TraceLogger is not null) + { + softeningLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); + softeningFactorLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); + } softeningLogic.ForceRatio = factorOfCrackAppearance; var psiS = softeningLogic.GetSofteningFactor(); + var tupleOfCrackApeearence = ForceTupleService.InterpolateTuples(EndTuple, StartTuple, factorOfCrackAppearance); + TraceLogger?.AddMessage($"Crack is appeared in force combination"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tupleOfCrackApeearence)); + var reducedStrainTuple = GetReducedStrainTuple(factorOfCrackAppearance, psiS); + var crackedStrainTuple = GetStrainTuple(EndTuple); + TraceLogger?.AddMessage($"Strains in cracked section from actual (end) force"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(crackedStrainTuple)); + TraceLogger?.AddMessage($"Average curvatures of cracked part of element"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(reducedStrainTuple)); + TraceLogger?.AddMessage($"Calculating factors of reducing of stifness"); + result.FactorOfCrackAppearance = factorOfCrackAppearance; result.IsValid = true; result.IsSectionCracked = true; result.Description += paramResult.Description; - result.FactorOfCrackAppearance = factorOfCrackAppearance; - result.TupleOfCrackAppearance = ForceTupleService.InterpolateTuples(EndTuple, StartTuple, factorOfCrackAppearance); - var reducedStrainTuple = GetReducedStrainTuple(factorOfCrackAppearance, psiS); - result.CrackedStrainTuple = GetStrainTuple(EndTuple); + var softeningFactors = GetSofteningFactors(reducedStrainTuple); + result.TupleOfCrackAppearance = tupleOfCrackApeearence; + result.CrackedStrainTuple = crackedStrainTuple; result.ReducedStrainTuple = reducedStrainTuple; - result.SofteningFactors=GetSofteningFactors(reducedStrainTuple); + result.SofteningFactors= softeningFactors; result.PsiS = psiS; + TraceLogger?.AddMessage($"Valid result was obtained", TraceLogStatuses.Debug); } private StrainTuple GetSofteningFactors(StrainTuple reducedStrainTuple) @@ -108,8 +142,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking private StrainTuple GetReducedStrainTuple(double factorOfCrackAppearance, double softeningFactor) { - const double notCrackedFactor = 0.99d; - var notCrackedForceTuple = ForceTupleService.InterpolateTuples(EndTuple, StartTuple, factorOfCrackAppearance * notCrackedFactor) as ForceTuple; + const double notCrackedForceFactor = 0.99d; + var notCrackedForceTuple = ForceTupleService.InterpolateTuples(EndTuple, StartTuple, factorOfCrackAppearance * notCrackedForceFactor) as ForceTuple; var crackAppearanceStrainTuple = GetStrainTuple(notCrackedForceTuple); var actualStrainTuple = GetStrainTuple(EndTuple); crackStrainLogic.BeforeCrackingTuple = crackAppearanceStrainTuple; diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs index cea21c5..8ca8d87 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs @@ -1,4 +1,6 @@ -using LoaderCalculator.Data.Ndms; +using LoaderCalculator; +using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Services.Forces; using System; @@ -15,6 +17,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public IForceTuple StartTuple { get; set; } public IForceTuple EndTuple { get; set; } public IEnumerable NdmCollection { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } + public CrackedLogic(ISectionCrackedLogic sectionLogic) { sectionCrackedLogic = sectionLogic; @@ -25,6 +29,10 @@ namespace StructureHelperLogics.NdmCalculations.Cracking } public bool IsSectionCracked(double factor) { + if (TraceLogger is not null) + { + sectionCrackedLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); + } var actualTuple = ForceTupleService.InterpolateTuples(EndTuple, StartTuple, factor); sectionCrackedLogic.Tuple = actualTuple; sectionCrackedLogic.NdmCollection = NdmCollection; diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ExpSofteningLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/ExpSofteningLogic.cs index b572d66..48773f7 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/ExpSofteningLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/ExpSofteningLogic.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; using System; using System.Collections.Generic; using System.Linq; @@ -41,19 +42,30 @@ namespace StructureHelperLogics.NdmCalculations.Cracking forceRatio = value; } } - public double FiMin {get;set;} + public double PsiSMin {get;set;} + public IShiftTraceLogger? TraceLogger { get; set; } + public ExpSofteningLogic() { - FiMin = 0.2d; + PsiSMin = 0.2d; PowerFactor = 2d; BettaFactor = 0.8d; } public double GetSofteningFactor() { - double fi; - fi = 1 - BettaFactor * Math.Pow(ForceRatio, PowerFactor); - fi = Math.Max(fi, FiMin); - return fi; + TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); + TraceLogger?.AddMessage($"Logic of calculation of psi_s factor based on exponential softening model"); + TraceLogger?.AddMessage($"psi_s = 1 - BettaFactor * ForceRatio ^ PowerFactor"); + TraceLogger?.AddMessage($"But not less than psi_s_min = {PsiSMin}"); + TraceLogger?.AddMessage($"BettaFactor = {BettaFactor}"); + TraceLogger?.AddMessage($"ForceRatio = {ForceRatio}"); + TraceLogger?.AddMessage($"PowerFactor = {BettaFactor}"); + double psi; + psi = 1 - BettaFactor * Math.Pow(ForceRatio, PowerFactor); + TraceLogger?.AddMessage($"psi_s = 1 - BettaFactor * ForceRatio ^ PowerFactor = 1 - {BettaFactor} * {ForceRatio} ^ {PowerFactor} = {psi}"); + double psi_c = Math.Max(psi, PsiSMin); + TraceLogger?.AddMessage($"Since psi_s = {psi} and psi_s_min = {PsiSMin},\npsi_s = {psi_c}"); + return psi_c; } } } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/HoleSectionCrackedLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/HoleSectionCrackedLogic.cs index 23e82a3..f20e04a 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/HoleSectionCrackedLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/HoleSectionCrackedLogic.cs @@ -1,6 +1,7 @@ using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; @@ -18,15 +19,25 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public IForceTuple Tuple { get; set; } public IEnumerable NdmCollection { get; set; } public Accuracy Accuracy { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } + public HoleSectionCrackedLogic() { if (Accuracy is null) { - Accuracy = new Accuracy() { IterationAccuracy = 0.001d, MaxIterationCount = 10000 }; + Accuracy = new Accuracy() + { + IterationAccuracy = 0.001d, + MaxIterationCount = 10000 + }; } } public bool IsSectionCracked() { + TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); + TraceLogger?.AddMessage($"It is assumed, that cracks appearence if: cross-section has elementary parts of concrete and strain of concrete greater than limit value"); + TraceLogger?.AddMessage($"Force combination for cracking check"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(Tuple)); var inputData = new ForceTupleInputData() { Accuracy = Accuracy, @@ -34,14 +45,28 @@ namespace StructureHelperLogics.NdmCalculations.Cracking NdmCollection = NdmCollection }; var calculator = new ForceTupleCalculator(inputData); + if (TraceLogger is not null) + { + calculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); + } calculator.Run(); var calcResult = calculator.Result as ForcesTupleResult; if (calcResult.IsValid == false) { + TraceLogger?.AddMessage($"Result of calculation is not valid {calcResult.Description}", TraceLogStatuses.Error); throw new StructureHelperException(ErrorStrings.ResultIsNotValid + ": Result of Section Calculation is not valid"); } var strainMatrix = calcResult.LoaderResults.ForceStrainPair.StrainMatrix; - return stressLogic.IsSectionCracked(strainMatrix, NdmCollection); + var isSectionCracked = stressLogic.IsSectionCracked(strainMatrix, NdmCollection); + if (isSectionCracked == true) + { + TraceLogger?.AddMessage($"Cracks are appeared in cross-section for current force combination"); + } + else + { + TraceLogger?.AddMessage($"Cracks are not appeared in cross-section for current force combination"); + } + return isSectionCracked; } } } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ICrackSofteningLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/ICrackSofteningLogic.cs index b14b3a4..2f0feaa 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/ICrackSofteningLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/ICrackSofteningLogic.cs @@ -1,4 +1,5 @@ -using System; +using StructureHelperCommon.Infrastructures.Interfaces; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Cracking { - public interface ICrackSofteningLogic + public interface ICrackSofteningLogic : ILogic { double GetSofteningFactor(); } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ICrackedLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/ICrackedLogic.cs index 0561c57..b7d1190 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/ICrackedLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/ICrackedLogic.cs @@ -1,4 +1,5 @@ using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Forces; using System; using System.Collections.Generic; @@ -8,7 +9,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Cracking { - internal interface ICrackedLogic + internal interface ICrackedLogic : ILogic { IForceTuple StartTuple { get; set; } IForceTuple EndTuple { get; set; } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ISectionCrackedLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/ISectionCrackedLogic.cs index a73498a..3fbbc1f 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/ISectionCrackedLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/ISectionCrackedLogic.cs @@ -1,4 +1,5 @@ using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Forces; using System; using System.Collections.Generic; @@ -8,7 +9,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Cracking { - internal interface ISectionCrackedLogic + internal interface ISectionCrackedLogic : ILogic { IForceTuple Tuple { get; set; } IEnumerable NdmCollection { get; set; } From b1fc0c763f1b465dbbb04a8a61689c5da4e35d8f Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Fri, 2 Feb 2024 12:48:39 +0500 Subject: [PATCH 03/14] Copy To window was added --- StructureHelper/App.xaml.cs | 4 +- .../UI/DataContexts/PrimitiveBase.cs | 2 +- .../PublishProfiles/FolderProfile.pubxml.user | 2 +- .../{MainModel.cs => CrossSectionModel.cs} | 4 +- ...nViewModel.cs => CrossSectionViewModel.cs} | 6 +- .../Windows/MainWindow/MainView.xaml | 5 ++ .../Windows/MainWindow/MainView.xaml.cs | 4 +- .../Windows/Services/CopyByParameterView.xaml | 14 ++-- .../Services/CopyByParameterView.xaml.cs | 6 +- .../Services/CopyByParameterViewModel.cs | 81 ++++++++++++++++++- .../PrimitiveViewModelLogic.cs | 37 ++++++++- .../Loggers/Factories/TraceTablesFactory.cs | 4 +- .../Analyses/ByForces/ForceCalculator.cs | 6 +- .../Analyses/ByForces/ForceTupleCalculator.cs | 17 +++- .../Cracking/CrackForceCalculator.cs | 4 +- .../Cracking/HoleSectionCrackedLogic.cs | 5 -- 16 files changed, 166 insertions(+), 35 deletions(-) rename StructureHelper/Windows/MainWindow/{MainModel.cs => CrossSectionModel.cs} (93%) rename StructureHelper/Windows/MainWindow/{MainViewModel.cs => CrossSectionViewModel.cs} (98%) diff --git a/StructureHelper/App.xaml.cs b/StructureHelper/App.xaml.cs index 0f7f3b1..f18a2b1 100644 --- a/StructureHelper/App.xaml.cs +++ b/StructureHelper/App.xaml.cs @@ -22,8 +22,8 @@ namespace StructureHelper builder.RegisterType().As().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); - builder.RegisterType().AsSelf().SingleInstance(); - builder.RegisterType().AsSelf().SingleInstance(); + builder.RegisterType().AsSelf().SingleInstance(); + builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf(); diff --git a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs index 39f4dbd..c0f3d50 100644 --- a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs +++ b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs @@ -242,7 +242,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts DeltaY = dy; } - public MainViewModel OwnerVM { get; private set; } + public CrossSectionViewModel OwnerVM { get; private set; } public double DeltaX { get; private set; } public double DeltaY { get; private set; } diff --git a/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user b/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user index 6310abc..7cc792e 100644 --- a/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2023-02-25T08:37:39.2738786Z;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00; + True|2024-02-02T07:22:50.1454015Z;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00; \ No newline at end of file diff --git a/StructureHelper/Windows/MainWindow/MainModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionModel.cs similarity index 93% rename from StructureHelper/Windows/MainWindow/MainModel.cs rename to StructureHelper/Windows/MainWindow/CrossSectionModel.cs index baf209c..95488a7 100644 --- a/StructureHelper/Windows/MainWindow/MainModel.cs +++ b/StructureHelper/Windows/MainWindow/CrossSectionModel.cs @@ -24,7 +24,7 @@ using System.Threading; namespace StructureHelper.Windows.MainWindow { - public class MainModel + public class CrossSectionModel { public ICrossSection Section { get; private set; } private IPrimitiveRepository primitiveRepository; @@ -37,7 +37,7 @@ namespace StructureHelper.Windows.MainWindow public ICalculationProperty CalculationProperty { get; private set; } - public MainModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService) + public CrossSectionModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService) { this.primitiveRepository = primitiveRepository; this.calculationService = calculationService; diff --git a/StructureHelper/Windows/MainWindow/MainViewModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs similarity index 98% rename from StructureHelper/Windows/MainWindow/MainViewModel.cs rename to StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs index df67429..0d35b42 100644 --- a/StructureHelper/Windows/MainWindow/MainViewModel.cs +++ b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs @@ -25,7 +25,7 @@ using System.Windows.Input; namespace StructureHelper.Windows.MainWindow { - public class MainViewModel : ViewModelBase + public class CrossSectionViewModel : ViewModelBase { ICrossSection section; ICrossSectionRepository repository => section.SectionRepository; @@ -44,7 +44,7 @@ namespace StructureHelper.Windows.MainWindow public PrimitiveViewModelLogic PrimitiveLogic => primitiveLogic; public HelpLogic HelpLogic => new HelpLogic(); - private MainModel Model { get; } + private CrossSectionModel Model { get; } private double panelX, panelY, scrollPanelX, scrollPanelY; @@ -220,7 +220,7 @@ namespace StructureHelper.Windows.MainWindow private RelayCommand selectPrimitive; private MaterialsViewModel materialsLogic; - public MainViewModel(MainModel model) + public CrossSectionViewModel(CrossSectionModel model) { visualProperty = new CrossSectionViewVisualProperty(); Model = model; diff --git a/StructureHelper/Windows/MainWindow/MainView.xaml b/StructureHelper/Windows/MainWindow/MainView.xaml index ad467a9..05a8e8e 100644 --- a/StructureHelper/Windows/MainWindow/MainView.xaml +++ b/StructureHelper/Windows/MainWindow/MainView.xaml @@ -54,6 +54,11 @@ + + + + + diff --git a/StructureHelper/Windows/MainWindow/MainView.xaml.cs b/StructureHelper/Windows/MainWindow/MainView.xaml.cs index 5c4d817..462baf1 100644 --- a/StructureHelper/Windows/MainWindow/MainView.xaml.cs +++ b/StructureHelper/Windows/MainWindow/MainView.xaml.cs @@ -8,10 +8,10 @@ namespace StructureHelper.Windows.MainWindow { public partial class MainView : Window { - private MainViewModel viewModel; + private CrossSectionViewModel viewModel; public IPrimitiveRepository PrimitiveRepository { get; } - public MainView(IPrimitiveRepository primitiveRepository, MainViewModel viewModel) + public MainView(IPrimitiveRepository primitiveRepository, CrossSectionViewModel viewModel) { PrimitiveRepository = primitiveRepository; this.viewModel = viewModel; diff --git a/StructureHelper/Windows/Services/CopyByParameterView.xaml b/StructureHelper/Windows/Services/CopyByParameterView.xaml index 8b3b642..95bc9f7 100644 --- a/StructureHelper/Windows/Services/CopyByParameterView.xaml +++ b/StructureHelper/Windows/Services/CopyByParameterView.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:StructureHelper.Windows.Services" d:DataContext ="{d:DesignInstance local:CopyByParameterViewModel}" mc:Ignorable="d" - Title="Copy To" Height="260" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterOwner"> + Title="Copy To" Height="300" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs index 9b681d9..b514987 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs @@ -61,21 +61,27 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews public void ShowCracks() { - var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN"); - var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm"); - var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m"); - - List labels = GetCrackLabels(unitForce, unitMoment, unitCurvature); - arrayParameter = new ArrayParameter(ValidTupleList.Count(), labels.Count(), labels); - CalculateWithCrack(ValidTupleList, NdmPrimitives, unitForce, unitMoment, unitCurvature); + List labels = GetCrackLabels(); + arrayParameter = new ArrayParameter(ValidTupleList.Count(), labels); + CalculateWithCrack(ValidTupleList, + NdmPrimitives, + CommonOperation.GetUnit(UnitTypes.Force), + CommonOperation.GetUnit(UnitTypes.Moment), + CommonOperation.GetUnit(UnitTypes.Curvature)); } public void ShowWindow() { SafetyProcessor.RunSafeProcess(() => { - var series = new Series(arrayParameter) { Name = "Forces and curvatures" }; - var vm = new GraphViewModel(new List() { series }); + var series = new Series(arrayParameter) + { + Name = "Forces and curvatures" + }; + var vm = new GraphViewModel(new List() + { + series + }); var wnd = new GraphView(vm); wnd.ShowDialog(); }, @@ -132,11 +138,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews } } - private static List GetCrackLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature) + private static List GetCrackLabels() { const string crc = "Crc"; const string crcFactor = "CrcSofteningFactor"; - var labels = LabelsFactory.GetLabels(); + var labels = LabelsFactory.GetCommonLabels(); + IUnit unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature); var crclabels = new List { $"{crc}{GeometryNames.CurvFstName}, {unitCurvature.Name}", diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs index 2e4827b..db6552e 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs @@ -11,11 +11,11 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews { public static class LabelsFactory { - private static IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN"); - private static IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm"); - private static IUnit unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m"); + private static IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force); + private static IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment); + private static IUnit unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature); private static GeometryNames GeometryNames => ProgramSetting.GeometryNames; - public static List GetLabels() + public static List GetCommonLabels() { var labels = new List { diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs index 8a8dc12..8e42820 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs @@ -1,6 +1,7 @@ using StructureHelper.Windows.Graphs; using StructureHelper.Windows.ViewModels.Errors; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Models; @@ -17,12 +18,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { internal class ShowDiagramLogic : ILongProcessLogic { - ArrayParameter arrayParameter; - private IEnumerable TupleList; - private IEnumerable NdmPrimitives; - private List ValidTupleList; + private ArrayParameter arrayParameter; + private IEnumerable tupleList; + private IEnumerable ndmPrimitives; + private List validTupleList; - public int StepCount => ValidTupleList.Count(); + public int StepCount => validTupleList.Count(); public Action SetProgress { get; set; } public bool Result { get; set; } @@ -48,37 +49,33 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu SafetyProcessor.RunSafeProcess(() => { var series = new Series(arrayParameter) { Name = "Forces and curvatures" }; - var vm = new GraphViewModel(new List() { series}); + var vm = new GraphViewModel(new List() { series }); var wnd = new GraphView(vm); wnd.ShowDialog(); - }, - "Errors appeared during showing a graph, see detailed information"); + }, ErrorStrings.ErrorDuring("building chart")); } private void Show() { - ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList(); - var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN"); - var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm"); - var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m"); + validTupleList = tupleList.Where(x => x.IsValid == true).ToList(); - var labels = LabelsFactory.GetLabels(); - arrayParameter = new ArrayParameter(ValidTupleList.Count(), labels.Count(), labels); - CalculateWithoutCrack(ValidTupleList, unitForce, unitMoment, unitCurvature); + var labels = LabelsFactory.GetCommonLabels(); + arrayParameter = new ArrayParameter(validTupleList.Count(), labels); + Calculate(); } public ShowDiagramLogic(IEnumerable tupleList, IEnumerable ndmPrimitives) { - TupleList = tupleList; - NdmPrimitives = ndmPrimitives; - ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList(); + this.tupleList = tupleList; + this.ndmPrimitives = ndmPrimitives; + validTupleList = tupleList.Where(x => x.IsValid == true).ToList(); } - private void CalculateWithoutCrack(List resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature) + private void Calculate() { var data = arrayParameter.Data; - for (int i = 0; i < resultList.Count(); i++) + for (int i = 0; i < validTupleList.Count(); i++) { - var valueList = ProcessResultWithouCrack(resultList, unitForce, unitMoment, unitCurvature, i); + var valueList = ProcessResult(i); for (int j = 0; j < valueList.Count; j++) { data[i, j] = valueList[j]; @@ -88,16 +85,20 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu } - private static List ProcessResultWithouCrack(List resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature, int i) + private List ProcessResult(int i) { + var unitForce = CommonOperation.GetUnit(UnitTypes.Force); + var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment); + var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature); + return new List { - resultList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer, - resultList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer, - resultList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer, - resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer, - resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer, - resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ + validTupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer, + validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer, + validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer, + validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer, + validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer, + validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ }; } } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs index 8332973..f527fcc 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs @@ -1,21 +1,102 @@ -using StructureHelper.Windows.Forces; +using StructureHelper.Infrastructure.UI.DataContexts; +using StructureHelper.Services.ResultViewers; +using StructureHelper.Windows.Forces; +using StructureHelper.Windows.Graphs; +using StructureHelper.Windows.ViewModels.Errors; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Parameters; +using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews { - public class ShowValuePointDiagramLogic + public class ShowValuePointDiagramLogic : ILongProcessLogic { + private ArrayParameter arrayParameter; + private IEnumerable tupleList; + private IEnumerable ndmPrimitives; + private List validTupleList; + private List<(PrimitiveBase PrimitiveBase, List>)> valuePoints; + private List resultFuncList; + public ForceCalculator Calculator { get; set; } public PointPrimitiveLogic PrimitiveLogic { get; set; } public ValueDelegatesLogic ValueDelegatesLogic { get; set; } - public void ShowGraph() + + public int StepCount => throw new NotImplementedException(); + + public Action SetProgress { get; set; } + public bool Result { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } + public ShowValuePointDiagramLogic(IEnumerable tupleList, IEnumerable ndmPrimitives) + { + this.tupleList = tupleList; + this.ndmPrimitives = ndmPrimitives; + validTupleList = this.tupleList.Where(x => x.IsValid == true).ToList(); + valuePoints = new List<(PrimitiveBase PrimitiveBase, List>)>(); + foreach (var item in PrimitiveLogic.Collection.CollectionItems) + { + var pointsCount = item.Item.ValuePoints.SelectedCount; + if (pointsCount > 0) + { + var points = item.Item.ValuePoints.SelectedItems.ToList(); + var primitive = item.Item.PrimitiveBase; + valuePoints.Add((primitive, points)); + } + } + } + public void ShowWindow() + { + SafetyProcessor.RunSafeProcess(() => + { + var series = new Series(arrayParameter) + { + Name = "Forces and curvatures" + }; + var vm = new GraphViewModel(new List() + { + series + }); + var wnd = new GraphView(vm); + wnd.ShowDialog(); + }, ErrorStrings.ErrorDuring("building chart")); + } + + public void WorkerDoWork(object sender, DoWorkEventArgs e) + { + Show(); + Result = true; + } + + public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e) + { + //Nothing to do + } + + public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e) + { + //Nothing to do + } + + private void Show() { } + + private List GetColumnNames() + { + var columnNames = LabelsFactory.GetCommonLabels(); + + return columnNames; + } } } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml index 2d6bd83..4b48b33 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml @@ -10,20 +10,20 @@ - - - - - diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index 6008109..cac1378 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -176,8 +176,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu }; showProgressLogic.Show(); } - }, o => SelectedResult != null && SelectedResult.IsValid - ); + }, o => SelectedResult != null); } public ICommand ShowCrackGraphsCommand { @@ -282,11 +281,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu private void InterpolateValuePoints() { + if (SelectedResult is null) + { + throw new StructureHelperException(ErrorStrings.NullReference + ": Nothing is selected"); + } + var tuple = SelectedResult.DesignForceTuple ?? throw new StructureHelperException(ErrorStrings.NullReference + ": Design force combination"); var inputData = new ValuePointsInterpolationInputData() { - FinishDesignForce = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple, - LimitState = SelectedResult.DesignForceTuple.LimitState, - CalcTerm = SelectedResult.DesignForceTuple.CalcTerm, + FinishDesignForce = tuple.Clone() as IDesignForceTuple, + LimitState = tuple.LimitState, + CalcTerm = tuple.CalcTerm, }; inputData.PrimitiveBases.AddRange(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(ndmPrimitives)); var viewModel = new ValuePointsInterpolateViewModel(inputData); @@ -294,7 +298,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu wnd.ShowDialog(); if (wnd.DialogResult != true) { return; } var interpolationLogic = new InterpolationProgressLogic(forceCalculator, viewModel.ForceInterpolationViewModel.Result); - ShowValuePointDiagramLogic pointGraphLogic = new() + ShowValuePointDiagramLogic pointGraphLogic = new(ForcesResults.ForcesResultList, ndmPrimitives) { Calculator = interpolationLogic.InterpolateCalculator, PrimitiveLogic = viewModel.PrimitiveLogic, @@ -303,7 +307,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu progressLogic = interpolationLogic; showProgressLogic = new(interpolationLogic) { - ShowResult = pointGraphLogic.ShowGraph + ShowResult = pointGraphLogic.ShowWindow }; showProgressLogic.Show(); } diff --git a/StructureHelper/Windows/UserControls/MultiplyDouble.xaml b/StructureHelper/Windows/UserControls/MultiplyDouble.xaml index d505bde..032e96e 100644 --- a/StructureHelper/Windows/UserControls/MultiplyDouble.xaml +++ b/StructureHelper/Windows/UserControls/MultiplyDouble.xaml @@ -6,7 +6,27 @@ xmlns:local="clr-namespace:StructureHelper.Windows.UserControls" mc:Ignorable="d" d:DesignHeight="25" d:DesignWidth="120"> - + + + + + + + + + + + + + + + + + diff --git a/StructureHelperCommon/Infrastructures/Exceptions/ErrorString.cs b/StructureHelperCommon/Infrastructures/Exceptions/ErrorString.cs index ed940fd..a0491f4 100644 --- a/StructureHelperCommon/Infrastructures/Exceptions/ErrorString.cs +++ b/StructureHelperCommon/Infrastructures/Exceptions/ErrorString.cs @@ -25,5 +25,7 @@ public static string ExpectedWas(System.Type expected, object obj) => ExpectedWas(expected, obj.GetType()); public static string NullReference => "#0018: Null reference"; public static string ObjectNotFound => "#0018: Object not found"; + public static string ErrorDuring(string operation) => string.Format("Errors appeared during {0}, see detailed information", operation); + public static string CalculationError => "#0019: Error of calculation"; } } diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs index e255ccf..75819c6 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/ILongProcessLogic.cs @@ -10,14 +10,12 @@ using System.Windows.Forms; namespace StructureHelperCommon.Infrastructures.Interfaces { - public interface ILongProcessLogic + public interface ILongProcessLogic : ILogic { int StepCount { get; } Action SetProgress { get; set; } bool Result { get; set; } - IShiftTraceLogger? TraceLogger { get; set; } - void WorkerDoWork(object sender, DoWorkEventArgs e); void WorkerProgressChanged(object sender, ProgressChangedEventArgs e); void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e); diff --git a/StructureHelperCommon/Models/Loggers/LoggerStrings.cs b/StructureHelperCommon/Models/Loggers/LoggerStrings.cs index 3aef8ea..60f5776 100644 --- a/StructureHelperCommon/Models/Loggers/LoggerStrings.cs +++ b/StructureHelperCommon/Models/Loggers/LoggerStrings.cs @@ -11,6 +11,9 @@ namespace StructureHelperCommon.Models.Loggers public static string DimensionLess => "(dimensionless)"; public static string MethodBasedOn => "Method of calculation based on "; public static string CalculationHasDone => "Calculation has done succesfully"; + public static string Summary => "Summary"; + public static string Maximum => "Maximum"; + public static string Minimum => "Minimum"; public static string CalculatorType(object obj) => string.Format("Calculator type: {0}", obj.GetType()); } } diff --git a/StructureHelperCommon/Models/Parameters/ArrayParameter.cs b/StructureHelperCommon/Models/Parameters/ArrayParameter.cs index 0195c18..0b3df4f 100644 --- a/StructureHelperCommon/Models/Parameters/ArrayParameter.cs +++ b/StructureHelperCommon/Models/Parameters/ArrayParameter.cs @@ -42,5 +42,6 @@ namespace StructureHelperCommon.Models.Parameters ColumnLabels = columnLabels; } } + public ArrayParameter(int rowCount, List columnLabels) : this(rowCount, columnLabels.Count, columnLabels) { } } } diff --git a/StructureHelperCommon/Models/Sections/Logics/AccidentalEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/AccidentalEccentricityLogic.cs index 3ae93dc..f90df30 100644 --- a/StructureHelperCommon/Models/Sections/Logics/AccidentalEccentricityLogic.cs +++ b/StructureHelperCommon/Models/Sections/Logics/AccidentalEccentricityLogic.cs @@ -5,6 +5,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia +//All rights reserved. + namespace StructureHelperCommon.Models.Sections { public class AccidentalEccentricityLogic : IAccidentalEccentricityLogic @@ -64,10 +67,10 @@ namespace StructureHelperCommon.Models.Sections minEccentricity, yEccentricity, yFullEccentricity); TraceLogger?.AddMessage(mesEy); - var xSign = InitialForceTuple.Mx == 0 ? 1 : Math.Sign(InitialForceTuple.Mx); - var ySign = InitialForceTuple.My == 0 ? 1 : Math.Sign(InitialForceTuple.My); - var mx = InitialForceTuple.Nz * yFullEccentricity * xSign; - var my = InitialForceTuple.Nz * xFullEccentricity * ySign; + var xSign = InitialForceTuple.Mx == 0d ? -1d : Math.Sign(InitialForceTuple.Mx); + var ySign = InitialForceTuple.My == 0d ? -1d : Math.Sign(InitialForceTuple.My); + var mx = (-1d) * InitialForceTuple.Nz * yFullEccentricity * xSign; + var my = (-1d) * InitialForceTuple.Nz * xFullEccentricity * ySign; TraceLogger?.AddMessage(string.Format("Bending moment arbitrary X-axis Mx = {0} * {1} = {2}", InitialForceTuple.Nz, yFullEccentricity, mx), TraceLogStatuses.Debug); TraceLogger?.AddMessage(string.Format("Bending moment arbitrary Y-axis My = {0} * {1} = {2}", InitialForceTuple.Nz, xFullEccentricity, my), TraceLogStatuses.Debug); diff --git a/StructureHelperCommon/Services/Units/CommonOperation.cs b/StructureHelperCommon/Services/Units/CommonOperation.cs index 1a88a7e..3e91fde 100644 --- a/StructureHelperCommon/Services/Units/CommonOperation.cs +++ b/StructureHelperCommon/Services/Units/CommonOperation.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text.RegularExpressions; +using System.Windows.Documents; namespace StructureHelperCommon.Services.Units { @@ -47,11 +48,30 @@ namespace StructureHelperCommon.Services.Units throw new StructureHelperException(ErrorStrings.DataIsInCorrect); } - public static IUnit GetUnit(UnitTypes unitType, string unitName) + public static IUnit GetUnit(UnitTypes unitType, string unitName = null) { + if (unitName is null) + { + var boolResult = DefaultUnitNames.TryGetValue(unitType, out unitName); + if (boolResult == false) + { + throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": unit type{unitType} is unknown"); + } + } return units.Where(u => u.UnitType == unitType & u.Name == unitName).Single(); } + public static Dictionary DefaultUnitNames => new() + { + { UnitTypes.Length, "m"}, + { UnitTypes.Area, "m2"}, + { UnitTypes.Force, "kN" }, + { UnitTypes.Moment, "kNm"}, + { UnitTypes.Stress, "MPa"}, + { UnitTypes.Curvature, "1/m"}, + }; + + public static string Convert(IUnit unit, string unitName, object value) { double val; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs index 5c18af6..93e7fc2 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs @@ -1,5 +1,6 @@ using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; @@ -17,6 +18,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { static readonly ForceCalculatorUpdateStrategy updateStrategy = new(); private readonly IForceTupleCalculator forceTupleCalculator; + private ForcesResults result; + public string Name { get; set; } public List LimitStatesList { get; private set; } public List CalcTermsList { get; private set; } @@ -50,7 +53,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces private void CalculateResult() { - var ndmResult = new ForcesResults() { IsValid = true }; + result = new ForcesResults() + { + IsValid = true + }; foreach (var combination in ForceCombinationLists) { foreach (var tuple in combination.DesignForces) @@ -59,15 +65,34 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces var calcTerm = tuple.CalcTerm; if (LimitStatesList.Contains(limitState) & CalcTermsList.Contains(calcTerm)) { - ProcessNdmResult(ndmResult, combination, tuple, limitState, calcTerm); + + IForcesTupleResult tupleResult; + try + { + tupleResult = ProcessNdmResult(combination, tuple); + } + catch(Exception ex) + { + tupleResult = new ForcesTupleResult() + { + IsValid = false, + Description = string.Empty + ex, + DesignForceTuple = tuple + }; + } + result.ForcesResultList.Add(tupleResult); + ActionToOutputResults?.Invoke(result); } } } - Result = ndmResult; + Result = result; } - private void ProcessNdmResult(ForcesResults ndmResult, IForceCombinationList combination, IDesignForceTuple tuple, LimitStates limitState, CalcTerms calcTerm) + private IForcesTupleResult ProcessNdmResult(IForceCombinationList combination, IDesignForceTuple tuple) { + IForcesTupleResult tupleResult; + LimitStates limitState = tuple.LimitState; + CalcTerms calcTerm = tuple.CalcTerm; var ndms = NdmPrimitivesService.GetNdms(Primitives, limitState, calcTerm); IPoint2D point2D; if (combination.SetInGravityCenter == true) @@ -89,9 +114,22 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { TraceLogger?.AddMessage("Get eccentricity for full load"); newTuple = ProcessAccEccentricity(ndms, newTuple); - newTuple = GetForceTupleByBuckling(ndmResult, combination, limitState, calcTerm, ndms, newTuple); + var buckResult = GetForceTupleByBuckling(combination, limitState, calcTerm, ndms, newTuple); + if (buckResult.isValid == true) + { + newTuple = buckResult.tuple; + } + else + { + return new ForcesTupleResult() + { + IsValid = false, + DesignForceTuple = tuple, + Description = buckResult.description, + }; + } } - GetForceResult(ndmResult, limitState, calcTerm, ndms, newTuple); + tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); } else { @@ -100,12 +138,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces string message = string.Format("Second order effect is not considered, despite force Nz={0}", newTuple.Nz); TraceLogger?.AddMessage(message, TraceLogStatuses.Warning); } - GetForceResult(ndmResult, limitState, calcTerm, ndms, newTuple); + tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); } + return tupleResult; } - private IForceTuple GetForceTupleByBuckling(ForcesResults ndmResult, IForceCombinationList combination, LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple) + private (bool isValid, IForceTuple tuple, string description) GetForceTupleByBuckling(IForceCombinationList combination, LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple) { + var tuple = newTuple.Clone() as IForceTuple; var inputData = new BucklingInputData() { Combination = combination, @@ -119,41 +159,31 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces if (bucklingResult.IsValid != true) { TraceLogger?.AddMessage(bucklingResult.Description, TraceLogStatuses.Error); - var result = new ForcesTupleResult - { - IsValid = false, - Description = $"Buckling result:\n{bucklingResult.Description}\n", - DesignForceTuple = new DesignForceTuple() - { - ForceTuple = newTuple, - LimitState = limitState, - CalcTerm = calcTerm - } - }; - ndmResult.ForcesResultList.Add(result); + return (false, tuple, $"Buckling result:\n{bucklingResult.Description}"); } else { - newTuple = CalculateBuckling(newTuple, bucklingResult); - TraceLogger?.AddMessage($"Force combination with considering of second order effects"); - TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple)); + tuple = CalculateBuckling(tuple, bucklingResult); + TraceLogger?.AddMessage(string.Intern("Force combination with considering of second order effects")); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple)); } - return newTuple; + return (true, tuple, string.Empty); } - private void GetForceResult(ForcesResults ndmResult, LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple) + private IForcesTupleResult GetForceResult(LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple) { - var result = GetPrimitiveStrainMatrix(ndms, newTuple, Accuracy); - result.DesignForceTuple.LimitState = limitState; - result.DesignForceTuple.CalcTerm = calcTerm; - result.DesignForceTuple.ForceTuple = newTuple; - ndmResult.ForcesResultList.Add(result); - ActionToOutputResults?.Invoke(ndmResult); + var tupleResult = GetPrimitiveStrainMatrix(ndms, newTuple, Accuracy); + tupleResult.DesignForceTuple.LimitState = limitState; + tupleResult.DesignForceTuple.CalcTerm = calcTerm; + tupleResult.DesignForceTuple.ForceTuple = newTuple; + return tupleResult; + } - private IForceTuple ProcessAccEccentricity(List ndms, IForceTuple newTuple) + private IForceTuple ProcessAccEccentricity(List ndms, IForceTuple tuple) { + var newTuple = tuple.Clone() as IForceTuple; var accLogic = new AccidentalEccentricityLogic() { Length = CompressedMember.GeometryLength, @@ -161,7 +191,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces SizeY = ndms.Max(x => x.CenterY) - ndms.Min(x => x.CenterY), InitialForceTuple = newTuple, }; - if (TraceLogger is not null) { accLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); } + if (TraceLogger is not null) + { + accLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); + } newTuple = accLogic.GetForceTuple(); return newTuple; } @@ -196,7 +229,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces IForceTuple longTuple; try { - longTuple = designForces.Where(x => x.LimitState == limitState & x.CalcTerm == CalcTerms.LongTerm).First().ForceTuple; + longTuple = designForces + .Where(x => x.LimitState == limitState & x.CalcTerm == CalcTerms.LongTerm) + .Single() + .ForceTuple; } catch (Exception) { diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs index cb60f1f..db90dcc 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceTupleCalculator.cs @@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.Services; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { @@ -33,18 +34,16 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces private IForcesTupleResult CalculateResult() { - TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service); - TraceLogger?.AddMessage($"Calculator logic based on calculating strain in plain section by elementary parts of finished size"); + TraceLogger?.AddMessage(string.Intern($"Calculator type: {GetType()}"), TraceLogStatuses.Service); + TraceLogger?.AddMessage(string.Intern("Calculator logic based on calculating strain in plain section by elementary parts of finished size")); var ndmCollection = InputData.NdmCollection; - TraceLogger?.AddMessage($"Collection of elementary parts contains {ndmCollection.Count()} parts"); - TraceLogger?.AddMessage($"Summary area of elementary part collection = {ndmCollection.Sum(x => x.Area * x.StressScale)}", TraceLogStatuses.Service); - TraceLogger?.AddMessage($"Minimum x = {ndmCollection.Min(x => x.CenterX)}", TraceLogStatuses.Debug); - TraceLogger?.AddMessage($"Maximum x = {ndmCollection.Max(x => x.CenterX)}", TraceLogStatuses.Debug); - TraceLogger?.AddMessage($"Minimum y = {ndmCollection.Min(x => x.CenterY)}", TraceLogStatuses.Debug); - TraceLogger?.AddMessage($"Maximum y = {ndmCollection.Max(x => x.CenterY)}", TraceLogStatuses.Debug); + if (TraceLogger is not null) + { + TraceService.TraceNdmCollection(TraceLogger, ndmCollection); + } var tuple = InputData.Tuple; var accuracy = InputData.Accuracy; - TraceLogger?.AddMessage($"Input force combination"); + TraceLogger?.AddMessage(string.Intern("Input force combination")); TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple)); var mx = tuple.Mx; var my = tuple.My; @@ -65,9 +64,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces NdmCollection = ndmCollection }; var calculator = new Calculator(); - TraceLogger?.AddMessage($"Calculation is started", TraceLogStatuses.Debug); + TraceLogger?.AddMessage(string.Intern("Calculation is started"), TraceLogStatuses.Debug); calculator.Run(loaderData, new CancellationToken()); - TraceLogger?.AddMessage($"Calculation result is obtained", TraceLogStatuses.Debug); + TraceLogger?.AddMessage(string.Intern("Calculation result is obtained"), TraceLogStatuses.Debug); var calcResult = calculator.Result; if (calcResult.AccuracyRate <= accuracy.IterationAccuracy) { @@ -77,18 +76,18 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces Description = LoggerStrings.CalculationHasDone, LoaderResults = calcResult }; - forceTupleTraceResultLogic = new ForceTupleTraceResultLogic(ndmCollection) { TraceLogger = TraceLogger}; + forceTupleTraceResultLogic = new ForceTupleTraceResultLogic(ndmCollection) { TraceLogger = TraceLogger }; forceTupleTraceResultLogic.TraceResult(result); return result; } else { - TraceLogger?.AddMessage($"Required accuracy rate has not achieved", TraceLogStatuses.Error); + TraceLogger?.AddMessage(string.Intern("Required accuracy rate has not achieved"), TraceLogStatuses.Error); TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate}, {calcResult.IterationCounter} iteration has done", TraceLogStatuses.Warning); return new ForcesTupleResult() { IsValid = false, - Description = "Required accuracy rate has not achieved", + Description = string.Intern("Required accuracy rate has not achieved"), LoaderResults = calcResult }; } @@ -103,8 +102,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces }; if (ex.Message == "Calculation result is not valid: stiffness matrix is equal to zero") { - TraceLogger?.AddMessage($"Stiffness matrix is equal to zero\nProbably section was collapsed", TraceLogStatuses.Error); - result.Description = "Stiffness matrix is equal to zero\nProbably section was collapsed"; + TraceLogger?.AddMessage(string.Intern("Stiffness matrix is equal to zero\nProbably section was collapsed"), TraceLogStatuses.Error); + result.Description = string.Intern("Stiffness matrix is equal to zero\nProbably section was collapsed"); } else { diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs index 79cb4f3..a0b557a 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs @@ -1,4 +1,5 @@ -using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Data.Materials; +using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; using LoaderCalculator.Logics.Geometry; using StructureHelperCommon.Models; @@ -9,6 +10,7 @@ using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.Materials; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Primitives; +using StructureHelperLogics.Services; using StructureHelperLogics.Services.NdmPrimitives; namespace StructureHelperLogics.NdmCalculations.Buckling @@ -28,7 +30,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling public IResult Result { get; private set; } public IAccuracy Accuracy { get; set; } - public Action ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public Action ActionToOutputResults { get; set; } public IShiftTraceLogger? TraceLogger { get; set; } private (double EtaAlongX, double EtaAlongY) GetBucklingCoefficients() @@ -50,11 +52,9 @@ namespace StructureHelperLogics.NdmCalculations.Buckling Accuracy = accuracy; var allPrimitives = options.Primitives; - var concretePrimitives = GetConcretePrimitives(); - var otherPrimitives = allPrimitives.Except(concretePrimitives); ndmCollection = NdmPrimitivesService.GetNdms(allPrimitives, options.LimitState, options.CalcTerm); - concreteNdms = NdmPrimitivesService.GetNdms(concretePrimitives, options.LimitState, options.CalcTerm); - otherNdms = NdmPrimitivesService.GetNdms(otherPrimitives, options.LimitState, options.CalcTerm); + concreteNdms = ndmCollection.Where(x => x.Material is ICrackMaterial).ToList(); + otherNdms = ndmCollection.Except(concreteNdms).ToList(); } private (IConcreteDeltaELogic DeltaLogicX, IConcreteDeltaELogic DeltaLogicY) GetDeltaLogics() @@ -78,35 +78,38 @@ namespace StructureHelperLogics.NdmCalculations.Buckling return (DeltaElogicAboutX, DeltaElogicAboutY); } - private IEnumerable GetConcretePrimitives() - { - var primitives = options.Primitives.Where(x => x.HeadMaterial.HelperMaterial is IConcreteLibMaterial); - return primitives; - } - private (double DX, double DY) GetStiffness() { + const string sumStif = "Summary stiffness"; var gravityCenter = GeometryOperations.GetGravityCenter(ndmCollection); string message = string.Format("Gravity center, x = {0}, y = {1}", gravityCenter.Cx, gravityCenter.Cy); TraceLogger?.AddMessage(message); + if (TraceLogger is not null) + { + TraceLogger.AddMessage(string.Intern("Concrete elementary parts")); + TraceService.TraceNdmCollection(TraceLogger, concreteNdms); + TraceLogger.AddMessage(string.Intern("Nonconcrete elementary parts")); + TraceService.TraceNdmCollection(TraceLogger, otherNdms); + } + var (EIx, EIy) = GeometryOperations.GetReducedMomentsOfInertia(concreteNdms, gravityCenter); - TraceLogger.AddMessage(string.Format("Summary stiffness of concrete parts EIx,c = {0}", EIx)); - TraceLogger.AddMessage(string.Format("Summary stiffness of concrete parts EIy,c = {0}", EIy)); + TraceLogger?.AddMessage(string.Format("{0} of concrete parts EIx,c = {1}", sumStif, EIx)); + TraceLogger?.AddMessage(string.Format("{0} of concrete parts EIy,c = {1}", sumStif, EIy)); var otherInertia = GeometryOperations.GetReducedMomentsOfInertia(otherNdms, gravityCenter); - TraceLogger.AddMessage(string.Format("Summary stiffness of nonconcrete parts EIx,s = {0}", otherInertia.EIy)); - TraceLogger.AddMessage(string.Format("Summary stiffness of nonconcrete parts EIy,s = {0}", otherInertia.EIy)); + TraceLogger?.AddMessage(string.Format("{0} of nonconcrete parts EIx,s = {1}", sumStif, otherInertia.EIx)); + TraceLogger?.AddMessage(string.Format("{0} of nonconcrete parts EIy,s = {1}", sumStif, otherInertia.EIy)); var (Kc, Ks) = stiffnessLogicX.GetStiffnessCoeffitients(); var dX = Kc * EIx + Ks * otherInertia.EIx; - string mesDx = string.Format("Summary stiffness Dx = Kc * EIx,c + Ks * EIx,s = {0} * {1} + {2} * {3} = {4}", - Kc, EIx, Ks, otherInertia.EIx, dX); - TraceLogger.AddMessage(mesDx); + string mesDx = string.Format("{0} Dx = Kc * EIx,c + Ks * EIx,s = {1} * {2} + {3} * {4} = {5}", + sumStif, Kc, EIx, Ks, otherInertia.EIx, dX); + TraceLogger?.AddMessage(mesDx); var stiffnessY = stiffnessLogicY.GetStiffnessCoeffitients(); var dY = stiffnessY.Kc * EIy + stiffnessY.Ks * otherInertia.EIy; - string mesDy = string.Format("Summary stiffness Dy = Kc * EIy,c + Ks * EIy,s = {0} * {1} + {2} * {3} = {4}", - stiffnessY.Kc, EIy, stiffnessY.Ks, otherInertia.EIy, dY); - TraceLogger.AddMessage(mesDy); + string mesDy = string.Format("{0} Dy = Kc * EIy,c + Ks * EIy,s = {1} * {2} + {3} * {4} = {5}", + sumStif, stiffnessY.Kc, EIy, stiffnessY.Ks, otherInertia.EIy, dY); + TraceLogger?.AddMessage(mesDy); return (dX, dY); } @@ -132,8 +135,8 @@ namespace StructureHelperLogics.NdmCalculations.Buckling point = new Point2D() { X = item.CenterX, Y = item.CenterY }; } } - TraceLogger.AddMessage(string.Format("Most tensioned (minimum compressed) point: x = {0}, y = {1}", point.X, point.Y)); - TraceLogger.AddMessage(string.Format("Strain: epsilon = {0}", maxStrain), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(string.Format("Most tensioned (minimum compressed) point: x = {0}, y = {1}", point.X, point.Y)); + TraceLogger?.AddMessage(string.Format("Strain: epsilon = {0}", maxStrain), TraceLogStatuses.Debug); return point; } diff --git a/StructureHelperLogics/Services/TraceService.cs b/StructureHelperLogics/Services/TraceService.cs new file mode 100644 index 0000000..b782d71 --- /dev/null +++ b/StructureHelperLogics/Services/TraceService.cs @@ -0,0 +1,44 @@ +using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Services +{ + internal static class TraceService + { + public static void TraceNdmCollection(ITraceLogger traceLogger, IEnumerable ndmCollection) + { + if (traceLogger is null) + { + throw new StructureHelperException(ErrorStrings.NullReference + ": trace logger"); + } + if (ndmCollection is null) + { + traceLogger.AddMessage(string.Intern("Collection of elementary parts is null"), TraceLogStatuses.Error); + throw new StructureHelperException(ErrorStrings.NullReference + ": collection of elementary parts"); + } + if (!ndmCollection.Any()) + { + traceLogger.AddMessage("Collection of elementary parts is empty", TraceLogStatuses.Warning); + } + traceLogger.AddMessage(string.Format("Collection of elementary parts contains {0} parts", ndmCollection.Count())); + var mes = "area of elementary part collection "; + traceLogger.AddMessage(string.Format("{0} {1} A = {2}, {0} reduced {1} Ared = {3}", + LoggerStrings.Summary, + mes, + ndmCollection.Sum(x => x.Area), + ndmCollection.Sum(x => x.Area * x.StressScale)), + TraceLogStatuses.Service); + traceLogger.AddMessage($"Minimum x = {ndmCollection.Min(x => x.CenterX)}", TraceLogStatuses.Debug); + traceLogger.AddMessage($"Maximum x = {ndmCollection.Max(x => x.CenterX)}", TraceLogStatuses.Debug); + traceLogger.AddMessage($"Minimum y = {ndmCollection.Min(x => x.CenterY)}", TraceLogStatuses.Debug); + traceLogger.AddMessage($"Maximum y = {ndmCollection.Max(x => x.CenterY)}", TraceLogStatuses.Debug); + } + } +}