fix: 按尾号标准计算最小刀径,排除粉尘刀与去毛刺刀
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
87
ToolItem.cs
87
ToolItem.cs
@@ -30,6 +30,19 @@ namespace DrillTools
|
||||
Special // 7 - 特殊刀具
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最小刀径参数分组(按尾号使用标准)
|
||||
/// </summary>
|
||||
public enum MinDiameterParameterGroup
|
||||
{
|
||||
None,
|
||||
Drill,
|
||||
Slot,
|
||||
EA,
|
||||
Dust,
|
||||
Deburr
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刀具大类枚举
|
||||
/// </summary>
|
||||
@@ -330,5 +343,77 @@ namespace DrillTools
|
||||
_ => "未知"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 0.749mm 不参与界面最小孔径显示。
|
||||
/// </summary>
|
||||
public const double MinDiameterExcludedDiameter = 0.749;
|
||||
|
||||
/// <summary>
|
||||
/// 按尾号使用标准映射到最小刀径参数分组。
|
||||
/// 0/5/8/9→钻针,1→槽刀,2/6→EA,3→粉尘刀,4→去毛刺刀(BSH),7→不设定参数。
|
||||
/// </summary>
|
||||
public static MinDiameterParameterGroup GetMinDiameterParameterGroup(ToolSuffixType suffixType)
|
||||
{
|
||||
return suffixType switch
|
||||
{
|
||||
ToolSuffixType.Drill => MinDiameterParameterGroup.Drill,
|
||||
ToolSuffixType.NonStandard => MinDiameterParameterGroup.Drill,
|
||||
ToolSuffixType.Slot => MinDiameterParameterGroup.Slot,
|
||||
ToolSuffixType.EASlot or ToolSuffixType.EASlot2 => MinDiameterParameterGroup.EA,
|
||||
ToolSuffixType.DustSlot => MinDiameterParameterGroup.Dust,
|
||||
ToolSuffixType.DeburrSlot => MinDiameterParameterGroup.Deburr,
|
||||
ToolSuffixType.Special => MinDiameterParameterGroup.None,
|
||||
_ => MinDiameterParameterGroup.None
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按尾号规则计算最小钻针、槽刀、EA 刀直径。
|
||||
/// 粉尘刀与去毛刺刀使用独立参数表,不参与三者最小值;特殊刀与固定孔径不参与。
|
||||
/// </summary>
|
||||
/// <param name="tools">刀具集合</param>
|
||||
/// <param name="exclude749ForDisplay">为 true 时排除 0.749mm(界面显示用)</param>
|
||||
public static (double MinDrill, double MinSlot, double MinEA) CalculateMinDiameters(
|
||||
IEnumerable<ToolItem> tools,
|
||||
bool exclude749ForDisplay = false)
|
||||
{
|
||||
double minDrill = 0;
|
||||
double minSlot = 0;
|
||||
double minEA = 0;
|
||||
|
||||
foreach (var tool in tools)
|
||||
{
|
||||
if (tool.ToolType == ToolType.MachineCode)
|
||||
continue;
|
||||
|
||||
if (IsSpecialFixedDiameter(tool.Diameter))
|
||||
continue;
|
||||
|
||||
if (exclude749ForDisplay
|
||||
&& Math.Abs(tool.Diameter - MinDiameterExcludedDiameter) < 0.001)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (GetMinDiameterParameterGroup(tool.ToolSuffixType))
|
||||
{
|
||||
case MinDiameterParameterGroup.Drill:
|
||||
if (minDrill == 0 || tool.Diameter < minDrill)
|
||||
minDrill = tool.Diameter;
|
||||
break;
|
||||
case MinDiameterParameterGroup.Slot:
|
||||
if (minSlot == 0 || tool.Diameter < minSlot)
|
||||
minSlot = tool.Diameter;
|
||||
break;
|
||||
case MinDiameterParameterGroup.EA:
|
||||
if (minEA == 0 || tool.Diameter < minEA)
|
||||
minEA = tool.Diameter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (minDrill, minSlot, minEA);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user