fix: 按尾号标准计算最小刀径,排除粉尘刀与去毛刺刀
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -47,7 +47,6 @@ namespace DrillTools
|
||||
private const int SvsiFocused = 0x10;
|
||||
private const int SelectFileFlags = SvsiSelect | SvsiDeselectOthers | SvsiEnsureVisible | SvsiFocused;
|
||||
private const double PpSourceDiameter = 3.203;
|
||||
private const double MinDiameterExcludedDiameter = 0.749;
|
||||
private const int PpSideCoordinateTolerance = 1500;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
@@ -1851,79 +1850,10 @@ M30";
|
||||
/// </summary>
|
||||
private void UpdateMinDiameterInfo()
|
||||
{
|
||||
// 初始化为最大值,以便找到最小值
|
||||
MinDrillDiameter = double.MaxValue;
|
||||
MinSlotDiameter = double.MaxValue;
|
||||
MinEADiameter = double.MaxValue;
|
||||
|
||||
// 添加调试日志
|
||||
System.Diagnostics.Debug.WriteLine("=== 开始计算最小直径信息 ===");
|
||||
|
||||
foreach (var tool in Tools)
|
||||
{
|
||||
// 添加详细的刀具信息日志
|
||||
System.Diagnostics.Debug.WriteLine($"[刀具分析] T{tool.ToolNumber:D2}: 直径={tool.Diameter:F3}, 类型={tool.ToolType}, 尾号类型={tool.ToolSuffixType}, 大类={tool.ToolCategory}");
|
||||
|
||||
// 0.749mm 不参与最小孔径显示,刀具本身仍保留在列表和后续业务流程中。
|
||||
if (Math.Abs(tool.Diameter - MinDiameterExcludedDiameter) < 0.001)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[最小孔径排除] T{tool.ToolNumber:D2}: 直径={tool.Diameter:F3} 不参与最小直径计算");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 根据刀具类型分类计算最小直径
|
||||
if (tool.ToolType == ToolType.Regular)
|
||||
{
|
||||
// 普通钻咀
|
||||
if (tool.Diameter < MinDrillDiameter)
|
||||
MinDrillDiameter = tool.Diameter;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[钻咀] 当前最小钻咀直径: {MinDrillDiameter:F3}");
|
||||
}
|
||||
else if (tool.ToolType == ToolType.Slot)
|
||||
{
|
||||
// 槽刀 - 修复:只有真正的槽刀(非EA型槽刀)才计入最小槽刀直径
|
||||
// EA型槽刀不应该计入最小槽刀直径的计算
|
||||
if (tool.ToolSuffixType != ToolSuffixType.EASlot && tool.ToolSuffixType != ToolSuffixType.EASlot2)
|
||||
{
|
||||
if (tool.Diameter < MinSlotDiameter)
|
||||
MinSlotDiameter = tool.Diameter;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[槽刀] T{tool.ToolNumber:D2}是真正的槽刀,当前最小槽刀直径: {MinSlotDiameter:F3}");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[EA刀] T{tool.ToolNumber:D2}是EA型槽刀,不计入最小槽刀直径计算");
|
||||
}
|
||||
|
||||
// 检查是否是EA型槽刀(尾号为2或6)
|
||||
if ((tool.ToolSuffixType == ToolSuffixType.EASlot || tool.ToolSuffixType == ToolSuffixType.EASlot2)
|
||||
&& tool.Diameter < MinEADiameter)
|
||||
MinEADiameter = tool.Diameter;
|
||||
|
||||
// 特别标记EA型槽刀
|
||||
if (tool.ToolSuffixType == ToolSuffixType.EASlot || tool.ToolSuffixType == ToolSuffixType.EASlot2)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[EA刀] T{tool.ToolNumber:D2}是EA型槽刀,直径={tool.Diameter:F3}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有找到对应的刀具类型,将值设为0
|
||||
if (MinDrillDiameter == double.MaxValue)
|
||||
MinDrillDiameter = 0;
|
||||
|
||||
if (MinSlotDiameter == double.MaxValue)
|
||||
MinSlotDiameter = 0;
|
||||
|
||||
if (MinEADiameter == double.MaxValue)
|
||||
MinEADiameter = 0;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"=== 最终结果 ===");
|
||||
System.Diagnostics.Debug.WriteLine($"最小钻咀: {MinDrillDiameter:F3}");
|
||||
System.Diagnostics.Debug.WriteLine($"最小槽刀: {MinSlotDiameter:F3}");
|
||||
System.Diagnostics.Debug.WriteLine($"最小EA刀: {MinEADiameter:F3}");
|
||||
System.Diagnostics.Debug.WriteLine($"=== 计算完成 ===");
|
||||
var (minDrill, minSlot, minEA) = ToolItem.CalculateMinDiameters(Tools, exclude749ForDisplay: true);
|
||||
MinDrillDiameter = minDrill;
|
||||
MinSlotDiameter = minSlot;
|
||||
MinEADiameter = minEA;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user