运动控制:新增射线源与探测器 Z 轴联动移动功能,支持同步位移控制,新增实体摇杆实现 PLC 摇杆状态监控和事件发布,IMotionSystem 接口新增 Joystick 属性,更新文档说明联动功能使用方法。

This commit is contained in:
QI Mingxuan
2026-05-09 11:30:05 +08:00
parent fa8ad29862
commit f4a2856b92
11 changed files with 910 additions and 39 deletions
+68 -12
View File
@@ -14,7 +14,7 @@ XP.Hardware.MotionControl 是 XplorePlane 平面CT工业检测系统的核心运
- 安全防护门控制(联锁检查、状态机)
- FOD/FDD/放大倍率几何正算与反算
- 多轴联动移动(原子性边界检查)
- Jog 点动调试(MouseDown/MouseUp 安全控制)
- Jog 点动调试(虚拟摇杆控制)
- 100ms 周期 PLC 状态轮询
- 基于 Prism EventAggregator 的跨模块事件通讯
- 可配置的轴启用/禁用(FixtureRotation 等可选轴)
@@ -23,6 +23,56 @@ XP.Hardware.MotionControl 是 XplorePlane 平面CT工业检测系统的核心运
---
## 界面组件 | UI Components
### AxisControlView(核心界面控件)
`AxisControlView.xaml` 是运动控制模块的核心用户控件,提供完整的轴控制和调试功能:
```
XP.Hardware.MotionControl/Views/
├── AxisControlView.xaml # 核心轴控制面板(350px+ UserControl
└── AxisControlView.xaml.cs
```
**功能组成 | Features**
| 区域 | 组件 | 功能说明 |
|------|------|----------|
| **标题栏** | TextBlock | 显示"运动控制"标题 |
| **左侧** | RadNumericUpDown | 7个轴位置输入框(StageX/Y/SourceZ/DetectorZ/DetectorSwing/StageRotation/FixtureRotation |
| **右侧** | VirtualJoystick | 单轴摇杆(Z轴)+ 双轴摇杆(XY+旋转) |
| **底部** | RadButton | 使能开关、摇杆模式切换、SZDZ锁定、保存/恢复位置 |
**ViewModel 绑定 | ViewModel Bindings**
| 属性 | 类型 | 说明 |
|------|------|------|
| `StageXPosition` / `StageYPosition` | double | 载物台 X/Y 轴位置(mm |
| `SourceZPosition` / `DetectorZPosition` | double | 射线源/探测器 Z 轴位置(mm) |
| `DetectorSwingAngle` | double | 探测器摆动角度(度) |
| `StageRotationAngle` | double | 载物台旋转角度(度) |
| `FixtureRotationAngle` | double | 夹具旋转角度(度) |
| `IsJoystickEnabled` | bool | 摇杆使能开关 |
| `SwapMouseButtons` | bool | 摇杆左右键功能切换 |
| `SZDZLock` | bool | 射线源/探测器Z轴锁定移动 |
| `SavedPositions` | SavedPositions | 已保存的位置快照 |
**交互方式 | Interaction Modes**
1. **手动输入**:直接编辑 RadNumericUpDownEnter 确认,Escape 取消
2. **单轴摇杆**:拖拽单轴摇杆控制 SourceZ/DetectorZ 轴 Jog
3. **双轴摇杆**
- 左键拖拽:控制 StageX/Y 轴(X轴=左右,Y轴=上下)
- 右键拖拽:控制 StageRotation/DetectorSwing 轴(X轴=旋转,Y轴=摆动)
4. **快捷按钮**
- 使能开关:启用/禁用摇杆控制
- 摇杆模式:切换左右键功能(左键XY/右键旋转 vs 左键旋转/右键摆动)
- SZDZ锁定:锁定 SourceZ/DetectorZ 同步移动
- 保存/恢复:保存当前所有轴位置或恢复到上次保存位置
---
## 框架架构 | Architecture
```
@@ -56,17 +106,18 @@ XP.Hardware.MotionControl/
│ ├── IMotionControlService.cs # 业务服务接口
│ ├── MotionControlService.cs # 服务实现(轮询、事件、日志)
│ └── GeometryCalculator.cs # 几何计算器
├── ViewModels/ # 视图模型
│ ├── AxisControlViewModel.cs # AxisControlView ViewModel
│ └── MotionControlViewModel.cs # MotionControlView ViewModel
├── Config/ # 配置层
│ ├── MotionControlConfig.cs # 配置实体
│ ├── ConfigLoader.cs # 配置加载器
│ └── MotionSignalNames.cs # PLC 信号名称常量
├── ViewModels/ # 视图模型
│ ├── MotionControlViewModel.cs # 操作面板 ViewModel
│ └── MotionDebugViewModel.cs # 调试窗口 ViewModel
├── Views/ # WPF 视图
│ ├── MotionControlView.xaml # 操作面板(350px UserControl
│ ├── MotionDebugWindow.xaml # Jog 调试窗口
── MotionControlView.xaml.cs
│ ├── AxisControlView.xaml # 核心轴控制面板(350px+
│ ├── AxisControlView.xaml.cs
── MotionControlView.xaml # 简化版操作面板
│ └── MotionDebugWindow.xaml # Jog 调试窗口
├── Module/
│ └── MotionControlModule.cs # Prism 模块注册
├── Resources/ # 多语言资源
@@ -123,17 +174,22 @@ XP.Hardware.MotionControl/
| `MotionControl:DetectorZ:Min/Max/Origin` | 0/600/0 | 探测器Z轴范围和原点(mm) |
| `MotionControl:StageX:Min/Max/Origin` | -150/150/0 | 载物台X轴范围和原点(mm) |
| `MotionControl:StageY:Min/Max/Origin` | -150/150/0 | 载物台Y轴范围和原点(mm) |
| `MotionControl:DetectorSwing:Min/Max/Enabled` | -45/45/true | 探测器摆动范围和启用 |
| `MotionControl:StageRotation:Min/Max/Enabled` | -360/360/true | 载物台旋转范围和启用 |
| `MotionControl:FixtureRotation:Min/Max/Enabled` | -90/90/false | 夹具旋转范围和启用 |
| `MotionControl:DetectorSwing:Min/Max/Origin/Enabled` | -45/45/0/true | 探测器摆动范围、原点和启用 |
| `MotionControl:StageRotation:Min/Max/Origin/Enabled` | -360/360/0/true | 载物台旋转范围、原点和启用 |
| `MotionControl:FixtureRotation:Min/Max/Origin/Enabled` | -90/90/0/false | 夹具旋转范围、原点和启用 |
| `MotionControl:Geometry:SourceZOrigin` | 0 | 射线源Z原点偏移(mm) |
| `MotionControl:Geometry:DetectorZOrigin` | 600 | 探测器Z原点偏移(mm |
| `MotionControl:Geometry:StageRotationCenterZ` | 300 | 旋转中心Z坐标(mm |
| `MotionControl:Geometry:StageRotationCenterZ` | 0 | 旋转中心Z坐标(mm,固定值 |
| `MotionControl:Geometry:SwingPivotOffset` | 0 | 探测器摆动旋转中心Z偏移(mm) |
| `MotionControl:Geometry:SwingRadius` | 0 | 探测器摆动半径(mm) |
| `MotionControl:PollingInterval` | 100 | 轮询周期(ms |
| `MotionControl:DefaultVelocity` | 100 | 默认速度 |
| `MotionControl:SourceDetectorZLinkage:Enabled` | false | 射线源与探测器Z轴联动使能 |
| `MotionControl:SourceDetectorZLinkage:TriggerThreshold` | 1.0 | 联动触发的位置变化阈值(mm) |
| `MotionControl:SourceDetectorZLinkage:SpeedPercent` | 100 | 联动移动速度百分比(0-100) |
PLC 信号名称硬编码在 `MotionSignalNames.cs` 中,信号定义在 `PlcAddrDfn.xml` 的 ReadCommon/WriteCommon 组。
---
**最后更新 | Last Updated**: 2026-04-14
**最后更新 | Last Updated**: 2026-05-08