From 79ef8c5304cb4c75ef75244bf1ddeb9edd7685fb Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Thu, 1 Feb 2024 07:36:44 +0500 Subject: [PATCH] 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(); + } + } +} + + +