105 lines
3.0 KiB
C#
105 lines
3.0 KiB
C#
|
|
using CaeCuttingForce;
|
|||
|
|
using CaeGlobals;
|
|||
|
|
using CaeKnowledge;
|
|||
|
|
using CaeKnowledge.View;
|
|||
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace CPSO.Forms._92_Knowledge
|
|||
|
|
{
|
|||
|
|
public partial class FrmCuttingForceCalc : Form
|
|||
|
|
{
|
|||
|
|
private Controller Self { get; }
|
|||
|
|
|
|||
|
|
public FrmCuttingForceCalc(Controller self)
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
Self = self;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void PrepareForm()
|
|||
|
|
{
|
|||
|
|
btnCheck.Visible = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FrmCuttingForceCalc_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
groupBox1.Text = @"数据";
|
|||
|
|
Text = @"切削力计算";
|
|||
|
|
|
|||
|
|
propertyGrid1.SelectedObject = new ViewCuttingForceCalc();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private async void btnCalc_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (!(propertyGrid1.SelectedObject is ViewCuttingForceCalc cuttingForce)) return;
|
|||
|
|
|
|||
|
|
if (Self?.ToolPositions == null) return;
|
|||
|
|
|
|||
|
|
var tools = new CuttingForceTools();
|
|||
|
|
|
|||
|
|
// 刀位文件
|
|||
|
|
var inputFile = cuttingForce.FilePath;
|
|||
|
|
|
|||
|
|
var totalPointsPerLayer = cuttingForce.TotalPointsPerLayer;
|
|||
|
|
var radialDepth = cuttingForce.RadialDepth;
|
|||
|
|
var zOrigin = cuttingForce.ZOrigin;
|
|||
|
|
|
|||
|
|
// 1. 对刀位文件进行预处理
|
|||
|
|
// 底层代码由西工大李许杰维护
|
|||
|
|
var toolPositions = tools.ToolPositionProcessor(inputFile, totalPointsPerLayer, radialDepth, zOrigin);
|
|||
|
|
|
|||
|
|
// 2.1 刀具参数
|
|||
|
|
var cid = cuttingForce.Cutter;
|
|||
|
|
var cutter = KnowledgeTools.FindCutter(cid);
|
|||
|
|
|
|||
|
|
// 2.2 铣削加工参数
|
|||
|
|
var pid = cuttingForce.CuttingParameter;
|
|||
|
|
var para = KnowledgeTools.FindCuttingParameter(pid);
|
|||
|
|
|
|||
|
|
btnCalc.Enabled = false;
|
|||
|
|
btnCalc.Text = @"正在计算中...";
|
|||
|
|
|
|||
|
|
if (btnCheck.Visible)
|
|||
|
|
{
|
|||
|
|
btnCheck.Visible = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
await Task.Run(() =>
|
|||
|
|
{
|
|||
|
|
Self.ToolPositions.Clear();
|
|||
|
|
|
|||
|
|
// 3. 进行刀位文件计算
|
|||
|
|
// 底层代码由西工大曲林雅维护
|
|||
|
|
tools.Calculate(cutter, para, toolPositions);
|
|||
|
|
|
|||
|
|
Self.ToolPositions.AddRange(toolPositions.Select(tp => new ViewToolPosition(tp)));
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
btnCalc.Enabled = true;
|
|||
|
|
btnCalc.Text = @"切削力计算";
|
|||
|
|
|
|||
|
|
if (Self.ToolPositions.Count > 0)
|
|||
|
|
{
|
|||
|
|
btnCheck.Visible = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
ExceptionTools.Show(ex); // TODO 处理异常
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnCheck_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (Self.ToolPositions.Count > 0)
|
|||
|
|
Self.DrawCuttingForceSymbols(Self);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|