Long Progress Logics were added

This commit is contained in:
Evgeny Redikultsev
2023-11-12 20:38:11 +05:00
parent 36cb0878e9
commit ba797e7aaa
16 changed files with 513 additions and 242 deletions

View File

@@ -0,0 +1,155 @@
using LoaderCalculator;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
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
{
internal class CrackDiagramLogic : ILongProcessLogic
{
static readonly CrackForceCalculator calculator = new();
private List<IForcesTupleResult> ValidTupleList { get; set; }
ArrayParameter<double> arrayParameter;
private IEnumerable<IForcesTupleResult> TupleList { get; set; }
private IEnumerable<INdmPrimitive> NdmPrimitives { get; set; }
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public Action<int> SetProgress { get; set; }
public bool Result { get; set; }
public int StepCount => ValidTupleList.Count();
public CrackDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
{
TupleList = tupleList;
NdmPrimitives = ndmPrimitives;
ValidTupleList = TupleList.Where(x => x.IsValid == true).ToList();
}
public void WorkerDoWork(object sender, DoWorkEventArgs e)
{
ShowCracks();
Result = true;
}
public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{
//nothing to do
}
public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//nothing to do
}
public void ShowCracks()
{
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
string[] labels = GetCrackLabels(unitForce, unitMoment, unitCurvature);
arrayParameter = new ArrayParameter<double>(ValidTupleList.Count(), labels.Count(), labels);
CalculateWithCrack(ValidTupleList, NdmPrimitives, unitForce, unitMoment, unitCurvature);
}
public void ShowWindow()
{
SafetyProcessor.RunSafeProcess(() =>
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
},
"Errors appeared during showing a graph, see detailed information");
}
private void CalculateWithCrack(List<IForcesTupleResult> validTupleList, IEnumerable<INdmPrimitive> ndmPrimitives, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
var data = arrayParameter.Data;
for (int i = 0; i < validTupleList.Count(); i++)
{
var valueList = new List<double>
{
validTupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer
};
calculator.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple;
var limitState = validTupleList[i].DesignForceTuple.LimitState;
var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm;
var ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
calculator.NdmCollection = ndms;
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid == false)
{
MessageBox.Show(
"Result is not valid",
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
valueList.Add(result.CrackedStrainTuple.Mx);
valueList.Add(result.CrackedStrainTuple.My);
valueList.Add(result.CrackedStrainTuple.Nz);
valueList.Add(result.ReducedStrainTuple.Mx);
valueList.Add(result.ReducedStrainTuple.My);
valueList.Add(result.ReducedStrainTuple.Nz);
valueList.Add(result.SofteningFactors.Mx);
valueList.Add(result.SofteningFactors.My);
valueList.Add(result.SofteningFactors.Nz);
valueList.Add(result.PsiS);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
SetProgress?.Invoke(i);
}
}
private static string[] GetCrackLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
const string crc = "Crc";
const string crcFactor = "CrcSofteningFactor";
return new string[]
{
$"{GeometryNames.MomFstName}, {unitMoment.Name}",
$"{GeometryNames.MomSndName}, {unitMoment.Name}",
$"{GeometryNames.LongForceName}, {unitForce.Name}",
$"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{GeometryNames.StrainTrdName}",
$"{crc}{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{crc}{GeometryNames.StrainTrdName}",
$"{crcFactor}Ix",
$"{crcFactor}Iy",
$"{crcFactor}Az",
$"PsiFactor"
};
}
}
}

View File

@@ -1,12 +1,12 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.ProgressViews.InterpolationProgressView"
<Window x:Class="StructureHelper.Windows.CalculationWindows.ProgressViews.ShowProgressView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:InterpolationProgressViewModel}"
Title="InterpolationProgressView" Height="150" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None">
d:DataContext="{d:DesignInstance local:ShowProgressViewModel}"
Title="{Binding WindowTitle}" Height="150" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
@@ -16,14 +16,16 @@
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Progress"/>
<ProgressBar Grid.Column="1" Grid.Row="0" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" Value="{Binding ProgressValue}"/>
<TextBlock Grid.Row="1" Text="Total step"/>
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding MaxValue}" IsEnabled="False"/>
<TextBlock Grid.Row="2" Text="Current step"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding ProgressValue}" IsEnabled="False"/>
<TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding WindowTitle}"/>
<TextBlock Grid.Row="1" Text="Progress"/>
<ProgressBar Grid.Column="1" Grid.Row="1" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" Value="{Binding ProgressValue}"/>
<TextBlock Grid.Row="2" Text="Total step"/>
<TextBox Grid.Column="2" Grid.Row="2" Text="{Binding MaxValue}" IsEnabled="False"/>
<TextBlock Grid.Row="3" Text="Current step"/>
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding ProgressValue}" IsEnabled="False"/>
</Grid>
</Window>

View File

@@ -18,10 +18,10 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
/// <summary>
/// Логика взаимодействия для InterpolationProgressView.xaml
/// </summary>
public partial class InterpolationProgressView : Window
public partial class ShowProgressView : Window
{
InterpolationProgressViewModel viewModel;
public InterpolationProgressView(InterpolationProgressViewModel viewModel)
ShowProgressViewModel viewModel;
public ShowProgressView(ShowProgressViewModel viewModel)
{
InitializeComponent();
this.viewModel = viewModel;

View File

@@ -7,12 +7,14 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.ProgressViews
{
public class InterpolationProgressViewModel : ViewModelBase
public class ShowProgressViewModel : ViewModelBase
{
private double progressValue;
private double maxValue;
private double minValue;
public string WindowTitle { get; set; }
public double MinValue
{
get => minValue; set