Files
AohDrllTools/Docs/刀具尾号类型功能实现说明.md
2025-12-07 20:25:27 +08:00

223 lines
7.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 刀具尾号类型功能实现说明
## 功能概述
根据**钻孔孔径的尾号**来判断刀具类型,并在界面上显示。这个功能帮助用户更直观地了解每个刀具的具体类型和用途。
## 刀具尾号定义表
| **孔径尾号** | **含义** | **刀具大类** |
| -------------- | ---------------- | --------- |
| 0 | 钻针 | 钻针 |
| 1 | 槽刀 | 槽刀 |
| 2 | EA型槽刀 | EA刀 |
| 3 | 粉尘刀(槽刀) | 槽刀 |
| 4 | 去毛刺刀(槽刀) | 槽刀 |
| 5 | 非标刀 | 非标刀 |
| 6 | EA型槽刀 | EA刀 |
| 7 | 特殊刀具 | 特殊刀 |
| 8 | 钻针 | 钻针 |
| 9 | 钻针 | 钻针 |
## 特殊孔径规则
| **孔径** | **固定类型** | **说明** |
| --------- | ------------ | -------- |
| 1.049 | 圆孔 | 特殊孔径 |
| 3.175 | 圆孔 | 特殊孔径 |
| 0.499 | 圆孔 | 机台码孔径 |
## 技术实现
### 1. 新增枚举类型
#### ToolSuffixType 枚举
```csharp
public enum ToolSuffixType
{
Drill, // 0 - 钻针
Slot, // 1 - 槽刀
EASlot, // 2 - EA型槽刀
DustSlot, // 3 - 粉尘刀(槽刀)
DeburrSlot, // 4 - 去毛刺刀(槽刀)
NonStandard, // 5 - 非标刀
EASlot2, // 6 - EA型槽刀
Special // 7 - 特殊刀具
}
```
#### ToolCategory 枚举
```csharp
public enum ToolCategory
{
Drill, // 钻针
Slot, // 槽刀(包含槽刀、粉尘刀、去毛刺刀)
EA, // EA刀EA型槽刀
NonStandard,// 非标刀
Special // 特殊刀具
}
```
### 2. 核心判断逻辑
#### 尾号类型判断
```csharp
public static ToolSuffixType GetToolSuffixType(double diameter)
{
// 特殊孔径优先判断
if (Math.Abs(diameter - 1.049) < 0.001 ||
Math.Abs(diameter - 3.175) < 0.001 ||
Math.Abs(diameter - 0.499) < 0.001)
{
return ToolSuffixType.Drill; // 固定为圆孔
}
// 获取孔径的小数部分最后一位
string diameterStr = diameter.ToString("F3");
if (diameterStr.Length >= 4 && diameterStr.Contains('.'))
{
char lastChar = diameterStr[diameterStr.Length - 1];
int suffix = int.Parse(lastChar.ToString());
return suffix switch
{
0 => ToolSuffixType.Drill,
1 => ToolSuffixType.Slot,
2 => ToolSuffixType.EASlot,
3 => ToolSuffixType.DustSlot,
4 => ToolSuffixType.DeburrSlot,
5 => ToolSuffixType.NonStandard,
6 => ToolSuffixType.EASlot2,
7 => ToolSuffixType.Special,
8 => ToolSuffixType.Drill,
9 => ToolSuffixType.Drill,
_ => ToolSuffixType.NonStandard
};
}
return ToolSuffixType.NonStandard; // 默认为非标刀
}
```
#### 大类判断
```csharp
public static ToolCategory GetToolCategory(ToolSuffixType suffixType)
{
return suffixType switch
{
ToolSuffixType.Drill => ToolCategory.Drill,
ToolSuffixType.Slot or ToolSuffixType.DustSlot or ToolSuffixType.DeburrSlot => ToolCategory.Slot,
ToolSuffixType.EASlot or ToolSuffixType.EASlot2 => ToolCategory.EA,
ToolSuffixType.NonStandard => ToolCategory.NonStandard,
ToolSuffixType.Special => ToolCategory.Special,
_ => ToolCategory.NonStandard
};
}
```
### 3. UI界面更新
在刀具列表中新增了"尾号类型"列,显示在"类型"列后面:
| 刀具编号 | 孔径(mm) | 类型 | 尾号类型 | 孔数 |
|---------|----------|------|----------|------|
| T01 | 0.799 | 圆孔 | 槽刀 | 7 |
| T02 | 0.656 | 圆孔 | EA型槽刀 | 5 |
| T03 | 1.601 | 槽孔 | 粉尘刀 | 529 |
| T04 | 0.499 | 机台码 | 去毛刺刀 | 57 |
### 4. 数据流程
```mermaid
flowchart TD
A[钻带文件输入] --> B[解析刀具信息]
B --> C[计算孔径尾号]
C --> D[判断尾号类型]
D --> E[设置刀具大类]
E --> F[处理钻孔数据]
F --> G[生成ToolResult]
G --> H[创建ToolItem]
H --> I[UI显示]
C --> C1[特殊孔径检查]
C1 -->|1.049/3.175/0.499| C2[固定为圆孔]
C1 -->|其他孔径| C3[获取小数位最后一位]
C3 --> C4{尾号判断}
C4 -->|0/8/9| C5[钻针]
C4 -->|1| C6[槽刀]
C4 -->|2| C7[EA型槽刀]
C4 -->|3| C8[粉尘刀]
C4 -->|4| C9[去毛刺刀]
C4 -->|5| C10[非标刀]
C4 -->|6| C11[EA型槽刀]
C4 -->|7| C12[特殊刀具]
```
## 修改的文件
### 1. ToolItem.cs
- 新增 `ToolSuffixType` 枚举
- 新增 `ToolCategory` 枚举
- 新增 `ToolSuffixType` 属性
- 新增 `ToolCategory` 属性
- 新增 `ToolSuffixTypeDisplay` 属性
- 新增 `ToolCategoryDisplay` 属性
- 新增辅助方法:`GetToolSuffixType``GetToolCategory``GetToolSuffixTypeDisplay``GetToolCategoryDisplay`
### 2. DrillTapeProcessor.cs
-`ToolResult` 类中新增 `ToolSuffixType``ToolCategory` 属性
-`ProcessDrillTape` 方法中添加尾号类型计算
- 更新 `GenerateReport` 方法,添加尾号类型和大类显示
- 新增辅助方法:`GetToolSuffixType``GetToolCategory`
### 3. MainWindow.xaml
- 窗口宽度从 900 调整为 1000
- 在 ListView 中新增"尾号类型"列
- 调整各列宽度以适应新布局
### 4. MainWindowViewModel.cs
-`LoadToolsFromDrillTape` 方法中设置尾号类型属性
- 更新 `LoadSampleData` 方法,为示例数据设置尾号类型
- 新增 `TestToolSuffixTypeFunctionality` 测试方法
## 兼容性保证
1. **向后兼容**:保留现有的 `ToolType` 枚举和属性,不影响现有功能
2. **数据完整性**:新功能作为补充信息,不修改现有数据结构
3. **功能独立**:尾号类型判断逻辑独立,不影响现有的槽孔计算和机台码处理
## 测试验证
### 1. 单元测试
- 验证不同尾号的刀具类型判断
- 验证刀具大类分组逻辑
- 验证显示文本的正确性
### 2. 集成测试
- 验证钻带处理器的集成
- 验证UI显示的正确性
- 验证现有功能不受影响
### 3. 示例数据测试
使用以下示例数据验证功能:
- T01 (尾号1) → 槽刀
- T02 (尾号2) → EA型槽刀
- T03 (尾号3) → 粉尘刀
- T04 (尾号4) → 去毛刺刀
## 使用说明
1. **自动识别**:系统会根据刀具编号的尾号自动识别刀具类型
2. **界面显示**:在刀具列表的"尾号类型"列中显示具体的刀具类型
3. **报告生成**:在钻带处理报告中包含尾号类型和大类信息
4. **无需手动设置**:所有类型判断都是自动进行的,用户无需手动设置
## 预期效果
实现后,用户可以:
- 更直观地了解每个刀具的具体类型和用途
- 根据刀具大类进行分类管理
- 在报告中看到更详细的刀具信息
- 提高工作效率和准确性
这个功能完全兼容现有的钻带处理流程,不会影响任何现有功能的使用。