Trace view model was changed

This commit is contained in:
Evgeny Redikultsev
2024-02-01 07:36:44 +05:00
parent a680e67ab3
commit 79ef8c5304
47 changed files with 480 additions and 324 deletions

View File

@@ -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
{

View File

@@ -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

View File

@@ -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;

View File

@@ -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<INdmPrimitive> 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;

View File

@@ -15,7 +15,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public List<INdmPrimitive> 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()
{

View File

@@ -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;

View File

@@ -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<ITraceLoggerEntry> loggerEntries;
IEnumerable<ITraceLoggerEntry> selectedLoggerEntries;
FlowDocument document;
const int tabFactor = 500;
private readonly IEnumerable<ITraceLoggerEntry> loggerEntries;
private IEnumerable<ITraceLoggerEntry> 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<ITraceLoggerEntry> 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<ITraceLoggerEntry>? 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;
}
}
}

View File

@@ -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
{

View File

@@ -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;

View File

@@ -0,0 +1,15 @@
using StructureHelperCommon.Models;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Base interface for logic
/// </summary>
public interface ILogic
{
/// <summary>
/// Logger for tracing of actions
/// </summary>
IShiftTraceLogger? TraceLogger { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;

View File

@@ -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");
}

View File

@@ -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; }
/// <summary>
/// Method for calculating

View File

@@ -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()
{

View File

@@ -8,6 +8,6 @@ namespace StructureHelperCommon.Models.Forces
{
LimitStates LimitState { get; set; }
CalcTerms CalcTerm { get; set; }
ForceTuple ForceTuple { get; set; }
IForceTuple ForceTuple { get; set; }
}
}

View File

@@ -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
{
/// <summary>
/// Factory for creating trace table entries
/// </summary>
public class TraceTablesFactory
{
public int Priority { get; set; }
public TraceTablesFactory(TraceLoggerStatuses status = TraceLoggerStatuses.Info, int priorityShift = 0)
/// <summary>
/// Generates table entry for Point2D (2 columns, 2 rows)
/// </summary>
/// <param name="point2D">Point fo creating a table</param>
/// <returns>Table entry</returns>
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<IPoint2D> points)
/// <summary>
/// Generates a table representation for the provided force tuple
/// </summary>
/// <param name="forceTuple">Force tuple to create the table for</param>
/// <returns>Table entry</returns>
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;
}
/// <summary>
/// Generates table entry for Point2D (2 columns, (number of poins + 1) rows)
/// </summary>
/// <param name="points">Collection of points for creating a table</param>
/// <returns>Table entry</returns>
public TableLogEntry GetByPoint2D(IEnumerable<IPoint2D> 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<ITraceLoggerEntry> GetHeaderRow()
/// <summary>
/// Generates a table representation for the provided force tuple collection
/// </summary>
/// <param name="forceTuples">Force tuple collection to create the table for</param>
/// <returns>Table entry</returns>
public TableLogEntry GetByForceTuple(IEnumerable<IForceTuple> 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;
}
/// <summary>
/// Generates new trace table entry
/// </summary>
/// <param name="status">Default status = info</param>
public TraceTablesFactory(TraceLogStatuses status = TraceLogStatuses.Info)
{
Priority = LoggerService.GetPriorityByStatus(status);
}
private ShTableRow<ITraceLoggerEntry> GetForceTupleHeaderRow()
{
var forceTupleRow = new ShTableRow<ITraceLoggerEntry>(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<ITraceLoggerEntry> GetForceTupleRow(IForceTuple forceTuple)
{
var forceTupleRow = new ShTableRow<ITraceLoggerEntry>(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<ITraceLoggerEntry> GetPointHeaderRow()
{
const CellRole cellRole = CellRole.Header;
var headerRow = new ShTableRow<ITraceLoggerEntry>(2);
IShTableCell<ITraceLoggerEntry> tableCell;
ITraceLoggerEntry loggerEntry;
loggerEntry = new StringLoggerEntry()
loggerEntry = new StringLogEntry()
{
Message = "X",
Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info)
Priority = Priority
};
tableCell = new ShTableCell<ITraceLoggerEntry>()
{
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<ITraceLoggerEntry>()
{
Value = loggerEntry,
Role = CellRole.Header,
Role = cellRole,
};
headerRow.Elements[1] = tableCell;
return headerRow;
@@ -67,15 +203,15 @@ namespace StructureHelperCommon.Models.Loggers
private ShTableRow<ITraceLoggerEntry> GetPointRow(IPoint2D point2D)
{
var pointRow = new ShTableRow<ITraceLoggerEntry>(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;
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Loggers
namespace StructureHelperCommon.Models
{
public interface ILogger
{

View File

@@ -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
{

View File

@@ -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<ITraceLoggerEntry> 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);
}
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Loggers
namespace StructureHelperCommon.Models
{
public interface ITraceLoggerEntry
{

View File

@@ -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));

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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<ITraceLoggerEntry> table;
public ShTable<ITraceLoggerEntry> Table {get => table;}
public DateTime TimeStamp { get; }
public int Priority { get; set; }
public TableLoggerEntry(int rowSize)
public TableLogEntry(int rowSize)
{
if (rowSize <= 0)
{

View File

@@ -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,

View File

@@ -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

View File

@@ -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;

View File

@@ -54,6 +54,14 @@ namespace StructureHelperCommon.Models.Tables
}
}
public int RowCount => GetAllRows().Count();
public IShTableCell<T> GetCell(int rowIndex, int columnIndex)
{
var row = GetElementsFromRow(rowIndex);
var cell = row[columnIndex];
return cell;
}
/// <summary>
/// Set a value at the specified column and row index
/// </summary>

View File

@@ -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;

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -1,4 +1,4 @@
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories

View File

@@ -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
/// <summary>
/// Logic for build collection of points by surround points
/// </summary>
public interface ILimitCurveLogic : IHasActionByResult
public interface ILimitCurveLogic : ILogic, IHasActionByResult
{
/// <summary>
/// Returns list of points by source collection

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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}";

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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;

View File

@@ -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<INdm> 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;

View File

@@ -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

View File

@@ -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<INdmPrimitive> NdmPrimitives {get;set;}
}
}

View File

@@ -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
{

View File

@@ -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<IPoint2D>
{
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<IPoint2D>();
// 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();
}
}
}