Trace view model was changed
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelper.Models.Calculators
|
namespace StructureHelper.Models.Calculators
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
using LoaderCalculator;
|
using StructureHelper.Windows.Graphs;
|
||||||
using StructureHelper.Windows.Graphs;
|
|
||||||
using StructureHelper.Windows.ViewModels.Errors;
|
using StructureHelper.Windows.ViewModels.Errors;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Parameters;
|
using StructureHelperCommon.Models.Parameters;
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
@@ -15,8 +14,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||||
|
|||||||
@@ -4,15 +4,11 @@ using StructureHelperCommon.Infrastructures.Enums;
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Models.Parameters;
|
using StructureHelperCommon.Models.Parameters;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
|
||||||
using StructureHelperLogics.Services.NdmPrimitives;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
||||||
public LimitStates LimitState { get; set; }
|
public LimitStates LimitState { get; set; }
|
||||||
public CalcTerms CalcTerm { get; set; }
|
public CalcTerms CalcTerm { get; set; }
|
||||||
public ForceTuple ForceTuple { get; set; }
|
public IForceTuple ForceTuple { get; set; }
|
||||||
public IEnumerable<INdmPrimitive> ndmPrimitives { get; set; }
|
public IEnumerable<INdmPrimitive> ndmPrimitives { get; set; }
|
||||||
public void Show(IDesignForceTuple finishDesignTuple)
|
public void Show(IDesignForceTuple finishDesignTuple)
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
FindCrackFactor(endDesignTuple, startDesignTuple);
|
FindCrackFactor(endDesignTuple, startDesignTuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FindCrackFactor(ForceTuple finishDesignTuple, ForceTuple startDesignTuple)
|
private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple)
|
||||||
{
|
{
|
||||||
var calculator = new CrackForceCalculator();
|
var calculator = new CrackForceCalculator();
|
||||||
calculator.StartTuple = startDesignTuple;
|
calculator.StartTuple = startDesignTuple;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
public List<INdmPrimitive> ndmPrimitives { get; set; }
|
public List<INdmPrimitive> ndmPrimitives { get; set; }
|
||||||
public LimitStates LimitState { get; set; }
|
public LimitStates LimitState { get; set; }
|
||||||
public CalcTerms CalcTerm { get; set; }
|
public CalcTerms CalcTerm { get; set; }
|
||||||
public ForceTuple ForceTuple { get; set; }
|
public IForceTuple ForceTuple { get; set; }
|
||||||
|
|
||||||
internal void Show()
|
internal void Show()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using StructureHelper.Windows.ViewModels.Errors;
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Parameters;
|
using StructureHelperCommon.Models.Parameters;
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
using StructureHelper.Infrastructure;
|
using StructureHelper.Infrastructure;
|
||||||
using StructureHelper.Windows.AddMaterialWindow;
|
|
||||||
using StructureHelper.Windows.ViewModels.Errors;
|
using StructureHelper.Windows.ViewModels.Errors;
|
||||||
using StructureHelper.Windows.ViewModels.Materials;
|
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Tables;
|
using StructureHelperCommon.Models.Tables;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.ConstrainedExecution;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
@@ -21,9 +16,10 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
|||||||
{
|
{
|
||||||
public class TraceDocumentVM : ViewModelBase
|
public class TraceDocumentVM : ViewModelBase
|
||||||
{
|
{
|
||||||
IEnumerable<ITraceLoggerEntry> loggerEntries;
|
const int tabFactor = 500;
|
||||||
IEnumerable<ITraceLoggerEntry> selectedLoggerEntries;
|
private readonly IEnumerable<ITraceLoggerEntry> loggerEntries;
|
||||||
FlowDocument document;
|
private IEnumerable<ITraceLoggerEntry> selectedLoggerEntries;
|
||||||
|
private FlowDocument document;
|
||||||
private ICommand rebuildCommand;
|
private ICommand rebuildCommand;
|
||||||
private ICommand printDocumentCommand;
|
private ICommand printDocumentCommand;
|
||||||
private int maxPriority;
|
private int maxPriority;
|
||||||
@@ -66,7 +62,7 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
|||||||
{
|
{
|
||||||
this.loggerEntries = loggerEntries;
|
this.loggerEntries = loggerEntries;
|
||||||
maxPriority = 350;
|
maxPriority = 350;
|
||||||
tabGap = 50;
|
tabGap = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand RebuildCommand =>
|
public ICommand RebuildCommand =>
|
||||||
@@ -81,40 +77,82 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
|||||||
SafetyProcessor.RunSafeProcess(DocumentReader.Print, "Error of printing document");
|
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()
|
public void Show()
|
||||||
{
|
{
|
||||||
Prepare();
|
Prepare();
|
||||||
ShowPrepared();
|
ShowPrepared();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Prepare()
|
private Block GetBlockByEntry(ITraceLoggerEntry traceEntry)
|
||||||
{
|
{
|
||||||
document = new();
|
Block block;
|
||||||
selectedLoggerEntries = loggerEntries.Where(x => x.Priority <= MaxPriority);
|
if (traceEntry is StringLogEntry stringEntry)
|
||||||
foreach (var item in selectedLoggerEntries)
|
|
||||||
{
|
{
|
||||||
ProcessLoggerEntries(item);
|
block = GetBlockByStringEntry(stringEntry);
|
||||||
}
|
}
|
||||||
}
|
else if (traceEntry is TableLogEntry tableEntry)
|
||||||
|
|
||||||
private void ProcessLoggerEntries(ITraceLoggerEntry item)
|
|
||||||
{
|
|
||||||
if (item is StringLoggerEntry stringEntry)
|
|
||||||
{
|
{
|
||||||
ProcessStringEntry(stringEntry);
|
block = GetBlockByTableEntry(tableEntry);
|
||||||
}
|
|
||||||
else if (item is TableLoggerEntry tableEntry)
|
|
||||||
{
|
|
||||||
ProcessTableEntry(tableEntry);
|
|
||||||
}
|
}
|
||||||
else
|
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();
|
var rows = tableEntry.Table.GetAllRows();
|
||||||
int rowCount = rows.Count();
|
int rowCount = rows.Count();
|
||||||
int columnCount = tableEntry.Table.RowSize;
|
int columnCount = tableEntry.Table.RowSize;
|
||||||
@@ -122,96 +160,53 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
|||||||
for (int x = 0; x < columnCount; x++)
|
for (int x = 0; x < columnCount; x++)
|
||||||
{
|
{
|
||||||
var tableColumn = new TableColumn();
|
var tableColumn = new TableColumn();
|
||||||
tableColumn.Width = new GridLength(150);
|
tableColumn.Width = new GridLength(columnWidth);
|
||||||
table.Columns.Add(tableColumn);
|
table.Columns.Add(tableColumn);
|
||||||
}
|
}
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
{
|
{
|
||||||
var newRow = new TableRow();
|
TableRow newRow = GetTableRow(row);
|
||||||
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);
|
|
||||||
}
|
|
||||||
table.RowGroups.Add(new TableRowGroup());
|
table.RowGroups.Add(new TableRowGroup());
|
||||||
table.RowGroups[0].Rows.Add(newRow);
|
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);
|
var newRow = new TableRow();
|
||||||
document.Blocks.Add(paragraph);
|
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));
|
tableCell.ColumnSpan = cell.ColumnSpan;
|
||||||
paragraph.Margin = new Thickness(stringEntry.Priority / tabGap);
|
if (cell.Role == CellRole.Regular)
|
||||||
if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Fatal))
|
|
||||||
{
|
{
|
||||||
paragraph.FontSize = 14;
|
tableCell.TextAlignment = TextAlignment.Left;
|
||||||
paragraph.Background = Brushes.Red;
|
tableCell.Background = Brushes.LightYellow;
|
||||||
paragraph.Foreground = Brushes.Black;
|
|
||||||
paragraph.FontStyle = FontStyles.Italic;
|
|
||||||
}
|
}
|
||||||
else if (stringEntry.Priority <= LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Error))
|
else if (cell.Role == CellRole.Header)
|
||||||
{
|
{
|
||||||
paragraph.FontSize = 14;
|
tableCell.TextAlignment = TextAlignment.Center;
|
||||||
paragraph.Background = Brushes.Pink;
|
tableCell.Background = Brushes.AliceBlue;
|
||||||
paragraph.Foreground = Brushes.Black;
|
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
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
|
namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
using StructureHelper.Infrastructure;
|
using StructureHelper.Infrastructure;
|
||||||
using StructureHelper.Infrastructure.Enums;
|
using StructureHelper.Infrastructure.Enums;
|
||||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
|
|
||||||
using StructureHelper.Windows.CalculationWindows.ProgressViews;
|
using StructureHelper.Windows.CalculationWindows.ProgressViews;
|
||||||
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
|
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
|
||||||
using StructureHelper.Windows.ViewModels.Errors;
|
using StructureHelper.Windows.ViewModels.Errors;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
|
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
|
||||||
using System;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using MessageBox = System.Windows.Forms.MessageBox;
|
using MessageBox = System.Windows.Forms.MessageBox;
|
||||||
|
|||||||
15
StructureHelperCommon/Infrastructures/Interfaces/ILogic.cs
Normal file
15
StructureHelperCommon/Infrastructures/Interfaces/ILogic.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -51,7 +52,7 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
TraceLogger?.AddMessage($"Calculating parameter by iterations is started,\nrequired precision {Accuracy.IterationAccuracy}");
|
TraceLogger?.AddMessage($"Calculating parameter by iterations is started,\nrequired precision {Accuracy.IterationAccuracy}");
|
||||||
if (predicate(end) == false)
|
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");
|
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": predicate for end value must be true");
|
||||||
}
|
}
|
||||||
double precision = Accuracy.IterationAccuracy;
|
double precision = Accuracy.IterationAccuracy;
|
||||||
@@ -61,21 +62,21 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
int iterationNum = 0;
|
int iterationNum = 0;
|
||||||
while (step > precision)
|
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)
|
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;
|
end = current;
|
||||||
}
|
}
|
||||||
else
|
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;
|
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;
|
current = (start + end) / 2d;
|
||||||
step = (end - start) / 2d;
|
step = (end - start) / 2d;
|
||||||
TraceLogger?.AddMessage($"New step S={current}", TraceLoggerStatuses.Debug, 50);
|
TraceLogger?.AddMessage($"New step S={current}", TraceLogStatuses.Debug, 50);
|
||||||
iterationNum++;
|
iterationNum++;
|
||||||
|
|
||||||
result.IsValid = false;
|
result.IsValid = false;
|
||||||
@@ -85,7 +86,7 @@ namespace StructureHelperCommon.Models.Calculators
|
|||||||
|
|
||||||
if (iterationNum > maxIterationCount)
|
if (iterationNum > maxIterationCount)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage($"Recuired precision was not achieved, current step {step}, required precision {precision}", TraceLoggerStatuses.Error);
|
TraceLogger?.AddMessage($"Recuired precision was not achieved, current step {step}, required precision {precision}", TraceLogStatuses.Error);
|
||||||
result.Description = "Parameter was not found succefully: \n";
|
result.Description = "Parameter was not found succefully: \n";
|
||||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": violation of iteration count");
|
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": violation of iteration count");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
using LoaderCalculator.Data.ResultData;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using System;
|
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
|
namespace StructureHelperCommon.Models.Calculators
|
||||||
{
|
{
|
||||||
public interface ICalculator : ICloneable
|
public interface ICalculator : ILogic, ICloneable
|
||||||
{
|
{
|
||||||
IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Method for calculating
|
/// Method for calculating
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
{
|
{
|
||||||
public LimitStates LimitState { get; set; }
|
public LimitStates LimitState { get; set; }
|
||||||
public CalcTerms CalcTerm { get; set; }
|
public CalcTerms CalcTerm { get; set; }
|
||||||
public ForceTuple ForceTuple { get; set; }
|
public IForceTuple ForceTuple { get; set; }
|
||||||
|
|
||||||
public DesignForceTuple(LimitStates limitState, CalcTerms calcTerm) : this()
|
public DesignForceTuple(LimitStates limitState, CalcTerms calcTerm) : this()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
{
|
{
|
||||||
LimitStates LimitState { get; set; }
|
LimitStates LimitState { get; set; }
|
||||||
CalcTerms CalcTerm { get; set; }
|
CalcTerms CalcTerm { get; set; }
|
||||||
ForceTuple ForceTuple { get; set; }
|
IForceTuple ForceTuple { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperCommon.Models.Tables;
|
using StructureHelperCommon.Models.Tables;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -6,60 +7,195 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Factory for creating trace table entries
|
||||||
|
/// </summary>
|
||||||
public class TraceTablesFactory
|
public class TraceTablesFactory
|
||||||
{
|
{
|
||||||
public int Priority { get; set; }
|
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;
|
var table = new TableLogEntry(2);
|
||||||
}
|
|
||||||
public TableLoggerEntry GetTableByPoint2D(IPoint2D point2D)
|
|
||||||
{
|
|
||||||
var table = new TableLoggerEntry(2);
|
|
||||||
table.Priority = Priority;
|
table.Priority = Priority;
|
||||||
table.Table.AddRow(GetHeaderRow());
|
table.Table.AddRow(GetPointHeaderRow());
|
||||||
table.Table.AddRow(GetPointRow(point2D));
|
table.Table.AddRow(GetPointRow(point2D));
|
||||||
return table;
|
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.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)
|
foreach (var item in points)
|
||||||
{
|
{
|
||||||
table.Table.AddRow(GetPointRow(item));
|
table.Table.AddRow(GetPointRow(item));
|
||||||
}
|
}
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
private ShTableRow<ITraceLoggerEntry> GetHeaderRow()
|
/// 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);
|
var headerRow = new ShTableRow<ITraceLoggerEntry>(2);
|
||||||
IShTableCell<ITraceLoggerEntry> tableCell;
|
IShTableCell<ITraceLoggerEntry> tableCell;
|
||||||
ITraceLoggerEntry loggerEntry;
|
ITraceLoggerEntry loggerEntry;
|
||||||
loggerEntry = new StringLoggerEntry()
|
loggerEntry = new StringLogEntry()
|
||||||
{
|
{
|
||||||
Message = "X",
|
Message = "X",
|
||||||
Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info)
|
Priority = Priority
|
||||||
};
|
};
|
||||||
tableCell = new ShTableCell<ITraceLoggerEntry>()
|
tableCell = new ShTableCell<ITraceLoggerEntry>()
|
||||||
{
|
{
|
||||||
Value = loggerEntry,
|
Value = loggerEntry,
|
||||||
Role = CellRole.Header,
|
Role = cellRole,
|
||||||
};
|
};
|
||||||
headerRow.Elements[0] = tableCell;
|
headerRow.Elements[0] = tableCell;
|
||||||
loggerEntry = new StringLoggerEntry()
|
loggerEntry = new StringLogEntry()
|
||||||
{
|
{
|
||||||
Message = "Y",
|
Message = "Y",
|
||||||
Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info)
|
Priority = Priority
|
||||||
};
|
};
|
||||||
tableCell = new ShTableCell<ITraceLoggerEntry>()
|
tableCell = new ShTableCell<ITraceLoggerEntry>()
|
||||||
{
|
{
|
||||||
Value = loggerEntry,
|
Value = loggerEntry,
|
||||||
Role = CellRole.Header,
|
Role = cellRole,
|
||||||
};
|
};
|
||||||
headerRow.Elements[1] = tableCell;
|
headerRow.Elements[1] = tableCell;
|
||||||
return headerRow;
|
return headerRow;
|
||||||
@@ -67,15 +203,15 @@ namespace StructureHelperCommon.Models.Loggers
|
|||||||
private ShTableRow<ITraceLoggerEntry> GetPointRow(IPoint2D point2D)
|
private ShTableRow<ITraceLoggerEntry> GetPointRow(IPoint2D point2D)
|
||||||
{
|
{
|
||||||
var pointRow = new ShTableRow<ITraceLoggerEntry>(2);
|
var pointRow = new ShTableRow<ITraceLoggerEntry>(2);
|
||||||
pointRow.Elements[0].Value = new StringLoggerEntry()
|
pointRow.Elements[0].Value = new StringLogEntry()
|
||||||
{
|
{
|
||||||
Message = Convert.ToString(point2D.X),
|
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),
|
Message = Convert.ToString(point2D.Y),
|
||||||
Priority = LoggerService.GetPriorityByStatus(TraceLoggerStatuses.Info)
|
Priority = LoggerService.GetPriorityByStatus(TraceLogStatuses.Info)
|
||||||
};
|
};
|
||||||
return pointRow;
|
return pointRow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public interface ILogger
|
public interface ILogger
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public interface IShiftTraceLogger : ITraceLogger
|
public interface IShiftTraceLogger : ITraceLogger
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public interface ITraceLogger
|
public interface ITraceLogger
|
||||||
{
|
{
|
||||||
List<ITraceLoggerEntry> TraceLoggerEntries { get; }
|
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);
|
void AddMessage(string message, int priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public interface ITraceLoggerEntry
|
public interface ITraceLoggerEntry
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public static class LoggerService
|
public static class LoggerService
|
||||||
{
|
{
|
||||||
@@ -16,14 +16,14 @@ namespace StructureHelperCommon.Models.Loggers
|
|||||||
const int info = 300;
|
const int info = 300;
|
||||||
const int service = 400;
|
const int service = 400;
|
||||||
const int debug = 500;
|
const int debug = 500;
|
||||||
public static int GetPriorityByStatus(TraceLoggerStatuses status)
|
public static int GetPriorityByStatus(TraceLogStatuses status)
|
||||||
{
|
{
|
||||||
if (status == TraceLoggerStatuses.Fatal) { return fatal; }
|
if (status == TraceLogStatuses.Fatal) { return fatal; }
|
||||||
else if (status == TraceLoggerStatuses.Error) { return error; }
|
else if (status == TraceLogStatuses.Error) { return error; }
|
||||||
else if (status == TraceLoggerStatuses.Warning) { return warning; }
|
else if (status == TraceLogStatuses.Warning) { return warning; }
|
||||||
else if (status == TraceLoggerStatuses.Info) { return info; }
|
else if (status == TraceLogStatuses.Info) { return info; }
|
||||||
else if (status == TraceLoggerStatuses.Service) { return service; }
|
else if (status == TraceLogStatuses.Service) { return service; }
|
||||||
else if (status == TraceLoggerStatuses.Debug) { return debug; }
|
else if (status == TraceLogStatuses.Debug) { return debug; }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(status));
|
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(status));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public class ShiftTraceLogger : IShiftTraceLogger
|
public class ShiftTraceLogger : IShiftTraceLogger
|
||||||
{
|
{
|
||||||
@@ -17,10 +17,10 @@ namespace StructureHelperCommon.Models.Loggers
|
|||||||
Logger = logger;
|
Logger = logger;
|
||||||
}
|
}
|
||||||
public ShiftTraceLogger() : this(new TraceLogger()) { }
|
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 in (fatal, error, warning) they must be kept as they are
|
||||||
if (status <= TraceLoggerStatuses.Warning)
|
if (status <= TraceLogStatuses.Warning)
|
||||||
{
|
{
|
||||||
Logger.AddMessage(message, status);
|
Logger.AddMessage(message, status);
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,10 @@ namespace StructureHelperCommon.Models.Loggers
|
|||||||
|
|
||||||
public void AddEntry(ITraceLoggerEntry loggerEntry)
|
public void AddEntry(ITraceLoggerEntry loggerEntry)
|
||||||
{
|
{
|
||||||
loggerEntry.Priority += ShiftPriority;
|
if (loggerEntry.Priority >= LoggerService.GetPriorityByStatus(TraceLogStatuses.Warning))
|
||||||
|
{
|
||||||
|
loggerEntry.Priority += ShiftPriority;
|
||||||
|
}
|
||||||
Logger.TraceLoggerEntries.Add(loggerEntry);
|
Logger.TraceLoggerEntries.Add(loggerEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public class StringLoggerEntry : ITraceLoggerEntry
|
public class StringLogEntry : ITraceLoggerEntry
|
||||||
{
|
{
|
||||||
public DateTime TimeStamp { get;}
|
public DateTime TimeStamp { get;}
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
|
|
||||||
public StringLoggerEntry()
|
public StringLogEntry()
|
||||||
{
|
{
|
||||||
TimeStamp = DateTime.Now;
|
TimeStamp = DateTime.Now;
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,16 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public class TableLoggerEntry : ITraceLoggerEntry
|
public class TableLogEntry : ITraceLoggerEntry
|
||||||
{
|
{
|
||||||
private ShTable<ITraceLoggerEntry> table;
|
private ShTable<ITraceLoggerEntry> table;
|
||||||
public ShTable<ITraceLoggerEntry> Table {get => table;}
|
public ShTable<ITraceLoggerEntry> Table {get => table;}
|
||||||
public DateTime TimeStamp { get; }
|
public DateTime TimeStamp { get; }
|
||||||
|
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
public TableLoggerEntry(int rowSize)
|
public TableLogEntry(int rowSize)
|
||||||
{
|
{
|
||||||
if (rowSize <= 0)
|
if (rowSize <= 0)
|
||||||
{
|
{
|
||||||
@@ -4,9 +4,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public enum TraceLoggerStatuses
|
public enum TraceLogStatuses
|
||||||
{
|
{
|
||||||
Fatal,
|
Fatal,
|
||||||
Error,
|
Error,
|
||||||
@@ -6,7 +6,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Loggers
|
namespace StructureHelperCommon.Models
|
||||||
{
|
{
|
||||||
public class TraceLogger : ITraceLogger
|
public class TraceLogger : ITraceLogger
|
||||||
{
|
{
|
||||||
@@ -17,12 +17,12 @@ namespace StructureHelperCommon.Models.Loggers
|
|||||||
TraceLoggerEntries = new();
|
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 == TraceLogStatuses.Fatal) { message = $"Fatal error! {message}"; }
|
||||||
if (status == TraceLoggerStatuses.Error) { message = $"Error! {message}"; }
|
if (status == TraceLogStatuses.Error) { message = $"Error! {message}"; }
|
||||||
if (status == TraceLoggerStatuses.Warning) { message = $"Warning! {message}"; }
|
if (status == TraceLogStatuses.Warning) { message = $"Warning! {message}"; }
|
||||||
TraceLoggerEntries.Add(new StringLoggerEntry()
|
TraceLoggerEntries.Add(new StringLogEntry()
|
||||||
{
|
{
|
||||||
Message = message,
|
Message = message,
|
||||||
Priority = LoggerService.GetPriorityByStatus(status)
|
Priority = LoggerService.GetPriorityByStatus(status)
|
||||||
@@ -30,7 +30,7 @@ namespace StructureHelperCommon.Models.Loggers
|
|||||||
}
|
}
|
||||||
public void AddMessage(string message, int priority)
|
public void AddMessage(string message, int priority)
|
||||||
{
|
{
|
||||||
TraceLoggerEntries.Add(new StringLoggerEntry()
|
TraceLoggerEntries.Add(new StringLogEntry()
|
||||||
{
|
{
|
||||||
Message = message,
|
Message = message,
|
||||||
Priority = priority
|
Priority = priority
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -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>
|
/// <summary>
|
||||||
/// Set a value at the specified column and row index
|
/// Set a value at the specified column and row index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Models.Sections;
|
using StructureHelperCommon.Models.Sections;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
using LoaderCalculator.Data.Matrix;
|
using LoaderCalculator.Data.Matrix;
|
||||||
using LoaderCalculator.Data.ResultData;
|
using LoaderCalculator.Data.ResultData;
|
||||||
using LoaderCalculator.Data.SourceData;
|
using LoaderCalculator.Data.SourceData;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Models.Shapes;
|
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
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
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
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
@@ -15,7 +11,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logic for build collection of points by surround points
|
/// Logic for build collection of points by surround points
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ILimitCurveLogic : IHasActionByResult
|
public interface ILimitCurveLogic : ILogic, IHasActionByResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns list of points by source collection
|
/// Returns list of points by source collection
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Models.Shapes;
|
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
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
@@ -48,7 +42,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
if (TraceLogger is not null) { limitCurveLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); }
|
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}");
|
TraceLogger?.AddMessage($"Start solution in calculator {Name}");
|
||||||
result = new LimitCurveResult();
|
result = new LimitCurveResult();
|
||||||
result.IsValid = true;
|
result.IsValid = true;
|
||||||
@@ -58,24 +52,18 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
TraceLogger?.AddMessage($"Point count {PointCount}");
|
TraceLogger?.AddMessage($"Point count {PointCount}");
|
||||||
surroundList = SurroundProcLogic.GetPoints();
|
surroundList = SurroundProcLogic.GetPoints();
|
||||||
TraceLogger?.AddMessage($"There are {surroundList.Count()} point prepared for calculation");
|
TraceLogger?.AddMessage($"There are {surroundList.Count()} point prepared for calculation");
|
||||||
TraceLogger?.AddEntry(
|
TraceLogger?.AddEntry(new TraceTablesFactory().GetByPoint2D(surroundList));
|
||||||
new TraceTablesFactory(
|
|
||||||
TraceLoggerStatuses.Info, TraceLogger.ShiftPriority)
|
|
||||||
.GetTableByPoint2D(surroundList));
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
limitCurveLogic.ActionToOutputResults = GetCurrentStepNumber;
|
limitCurveLogic.ActionToOutputResults = GetCurrentStepNumber;
|
||||||
factoredList = limitCurveLogic.GetPoints(surroundList);
|
factoredList = limitCurveLogic.GetPoints(surroundList);
|
||||||
TraceLogger?.AddMessage($"Solution was successfully obtained for {factoredList.Count()} point");
|
TraceLogger?.AddMessage($"Solution was successfully obtained for {factoredList.Count()} point");
|
||||||
TraceLogger?.AddEntry(
|
TraceLogger?.AddEntry(new TraceTablesFactory().GetByPoint2D(factoredList));
|
||||||
new TraceTablesFactory(
|
|
||||||
TraceLoggerStatuses.Info, TraceLogger.ShiftPriority)
|
|
||||||
.GetTableByPoint2D(factoredList));
|
|
||||||
result.Points = factoredList;
|
result.Points = factoredList;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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.IsValid = false;
|
||||||
result.Description += ex.Message;
|
result.Description += ex.Message;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
||||||
using System.Windows.Media.Media3D;
|
using System.Windows.Media.Media3D;
|
||||||
@@ -42,12 +42,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
var zeroPoint = new Point2D();
|
var zeroPoint = new Point2D();
|
||||||
if (limitPredicate(zeroPoint) == true)
|
if (limitPredicate(zeroPoint) == true)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage($"Predicate is true for point. All point will be skiped", TraceLoggerStatuses.Warning);
|
TraceLogger?.AddMessage($"Predicate is true for point. All point will be skiped", TraceLogStatuses.Warning);
|
||||||
TraceLogger?.AddEntry(
|
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Warning).GetByPoint2D(zeroPoint));
|
||||||
new TraceTablesFactory(
|
TraceLogger?.AddMessage($"All point will be skiped", TraceLogStatuses.Warning);
|
||||||
TraceLoggerStatuses.Warning, 0)
|
|
||||||
.GetTableByPoint2D(zeroPoint));
|
|
||||||
TraceLogger?.AddMessage($"All point will be skiped", TraceLoggerStatuses.Warning);
|
|
||||||
var range = points.Select(point => new Point2D { X = 0d, Y = 0d }).ToList();
|
var range = points.Select(point => new Point2D { X = 0d, Y = 0d }).ToList();
|
||||||
resultList.AddRange(range);
|
resultList.AddRange(range);
|
||||||
return resultList;
|
return resultList;
|
||||||
@@ -121,17 +118,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
lock (lockObject)
|
lock (lockObject)
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage($"Source point");
|
TraceLogger?.AddMessage($"Source point");
|
||||||
TraceLogger?.AddEntry(
|
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(localCurrentPoint));
|
||||||
new TraceTablesFactory(
|
|
||||||
TraceLoggerStatuses.Info, TraceLogger.ShiftPriority)
|
|
||||||
.GetTableByPoint2D(localCurrentPoint));
|
|
||||||
TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries);
|
TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries);
|
||||||
TraceLogger?.AddMessage($"Parameter value {parameter} was obtained");
|
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?.AddMessage($"Calculated point\n(X={localCurrentPoint.X} * {parameter} = {resultPoint.X},\nY={localCurrentPoint.Y} * {parameter} = {resultPoint.Y})");
|
||||||
TraceLogger?.AddEntry(
|
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(resultPoint));
|
||||||
new TraceTablesFactory(
|
|
||||||
TraceLoggerStatuses.Info, TraceLogger.ShiftPriority)
|
|
||||||
.GetTableByPoint2D(resultPoint));
|
|
||||||
}
|
}
|
||||||
return resultPoint;
|
return resultPoint;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Models.Shapes;
|
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
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
@@ -45,7 +40,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
if (parameter < limitparamValue)
|
if (parameter < limitparamValue)
|
||||||
{
|
{
|
||||||
var newAccuracy = limitparamValue / 10d;
|
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.Accuracy.IterationAccuracy = 0.0001d;
|
||||||
parameterCalculator.Run();
|
parameterCalculator.Run();
|
||||||
result = parameterCalculator.Result as FindParameterResult;
|
result = parameterCalculator.Result as FindParameterResult;
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
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.LimitCurve.Factories;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
|
||||||
using StructureHelperLogics.Services.NdmPrimitives;
|
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
|
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
@@ -39,7 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
}
|
}
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLoggerStatuses.Service);
|
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
|
||||||
TraceLogger?.AddMessage($"Start solution in calculator {Name}");
|
TraceLogger?.AddMessage($"Start solution in calculator {Name}");
|
||||||
GetNewResult();
|
GetNewResult();
|
||||||
try
|
try
|
||||||
@@ -62,7 +55,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
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.IsValid = false;
|
||||||
result.Description += ex;
|
result.Description += ex;
|
||||||
}
|
}
|
||||||
@@ -87,7 +80,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
{
|
{
|
||||||
var ndms = NdmPrimitivesService.GetNdms(primitiveSeries.Collection, limitState, calcTerm);
|
var ndms = NdmPrimitivesService.GetNdms(primitiveSeries.Collection, limitState, calcTerm);
|
||||||
TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded succesfully");
|
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)
|
foreach (var predicateEntry in InputData.PredicateEntries)
|
||||||
{
|
{
|
||||||
string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}";
|
string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}";
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
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
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperLogics.Services.NdmCalculations;
|
using StructureHelperLogics.Services.NdmCalculations;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
|
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
using LoaderCalculator.Data.Matrix;
|
using LoaderCalculator.Data.Matrix;
|
||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperLogics.Services.NdmPrimitives;
|
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
|
namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using LoaderCalculator.Logics;
|
using LoaderCalculator.Logics;
|
||||||
using LoaderCalculator.Logics.Geometry;
|
using LoaderCalculator.Logics.Geometry;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperLogics.Models.Materials;
|
using StructureHelperLogics.Models.Materials;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
using StructureHelperLogics.Services.NdmPrimitives;
|
using StructureHelperLogics.Services.NdmPrimitives;
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Services;
|
using StructureHelperCommon.Services;
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
|
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
|
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||||
{
|
{
|
||||||
@@ -25,8 +20,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
|||||||
private CrackForceResult result;
|
private CrackForceResult result;
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public ForceTuple StartTuple { get; set; }
|
public IForceTuple StartTuple { get; set; }
|
||||||
public ForceTuple EndTuple { get; set; }
|
public IForceTuple EndTuple { get; set; }
|
||||||
public IEnumerable<INdm> NdmCollection { get; set; }
|
public IEnumerable<INdm> NdmCollection { get; set; }
|
||||||
public Accuracy Accuracy {get;set; }
|
public Accuracy Accuracy {get;set; }
|
||||||
public IResult Result => result;
|
public IResult Result => result;
|
||||||
@@ -146,7 +141,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
|||||||
result.SofteningFactors = GetSofteningFactors(result.ReducedStrainTuple);
|
result.SofteningFactors = GetSofteningFactors(result.ReducedStrainTuple);
|
||||||
result.Description = "Section is not cracked";
|
result.Description = "Section is not cracked";
|
||||||
}
|
}
|
||||||
private StrainTuple GetStrainTuple(ForceTuple forceTuple)
|
private StrainTuple GetStrainTuple(IForceTuple forceTuple)
|
||||||
{
|
{
|
||||||
ForceTupleInputData inputData = new();
|
ForceTupleInputData inputData = new();
|
||||||
inputData.NdmCollection = NdmCollection;
|
inputData.NdmCollection = NdmCollection;
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
using LoaderCalculator.Data.Ndms;
|
using LoaderCalculator.Data.Ndms;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
|
||||||
using StructureHelperLogics.Services.NdmPrimitives;
|
using StructureHelperLogics.Services.NdmPrimitives;
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
|||||||
{
|
{
|
||||||
public LimitStates LimitState { get; set; }
|
public LimitStates LimitState { get; set; }
|
||||||
public CalcTerms CalcTerm { get; set; }
|
public CalcTerms CalcTerm { get; set; }
|
||||||
public ForceTuple ForceTuple { get; set; }
|
public IForceTuple ForceTuple { get; set; }
|
||||||
public List<INdmPrimitive> NdmPrimitives {get;set;}
|
public List<INdmPrimitive> NdmPrimitives {get;set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user