Files

140 lines
6.6 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.
# XP.Hardware.MotionControl
工业运动控制模块 | Industrial Motion Control Module
---
## 项目概述 | Project Overview
XP.Hardware.MotionControl 是 XplorePlane 平面CT工业检测系统的核心运动控制模块,负责管理4个直线轴(SourceZ、DetectorZ、StageX、StageY)、3个旋转轴(DetectorSwing、StageRotation、FixtureRotation)及1个安全防护门的全部运动控制逻辑,并提供 FOD/FDD/放大倍率的几何正算与反算能力。
### 主要特性 | Key Features
- 4个直线轴 + 3个旋转轴统一管理(策略模式)
- 安全防护门控制(联锁检查、状态机)
- FOD/FDD/放大倍率几何正算与反算
- 多轴联动移动(原子性边界检查)
- Jog 点动调试(MouseDown/MouseUp 安全控制)
- 100ms 周期 PLC 状态轮询
- 基于 Prism EventAggregator 的跨模块事件通讯
- 可配置的轴启用/禁用(FixtureRotation 等可选轴)
- Telerik Crystal 主题 UI 控件
- 中/英/繁体中文多语言支持
---
## 框架架构 | Architecture
```
XP.Hardware.MotionControl/
├── Abstractions/ # 抽象层 | Abstraction Layer
│ ├── ILinearAxis.cs # 直线轴策略接口
│ ├── IRotaryAxis.cs # 旋转轴策略接口
│ ├── ISafetyDoor.cs # 安全门策略接口
│ ├── IMotionSystem.cs # 顶层系统管理接口
│ ├── LinearAxisBase.cs # 直线轴抽象基类(含边界检查)
│ ├── RotaryAxisBase.cs # 旋转轴抽象基类
│ ├── SafetyDoorBase.cs # 安全门抽象基类
│ ├── MotionResult.cs # 统一操作结果类型
│ ├── Enums/ # 枚举定义
│ │ ├── AxisId.cs # 直线轴标识
│ │ ├── RotaryAxisId.cs # 旋转轴标识
│ │ ├── AxisStatus.cs # 轴状态
│ │ └── DoorStatus.cs # 门状态
│ └── Events/ # Prism 事件定义
│ ├── AxisStatusChangedEvent.cs
│ ├── DoorStatusChangedEvent.cs
│ ├── DoorInterlockChangedEvent.cs
│ ├── GeometryUpdatedEvent.cs
│ └── MotionErrorEvent.cs
├── Implementations/ # PLC 实现层
│ ├── PlcLinearAxis.cs # 基于 PLC 的直线轴实现
│ ├── PlcRotaryAxis.cs # 基于 PLC 的旋转轴实现
│ ├── PlcSafetyDoor.cs # 基于 PLC 的安全门实现
│ └── PlcMotionSystem.cs # 运动系统管理器
├── Services/ # 业务服务层
│ ├── IMotionControlService.cs # 业务服务接口
│ ├── MotionControlService.cs # 服务实现(轮询、事件、日志)
│ └── GeometryCalculator.cs # 几何计算器
├── 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
├── Module/
│ └── MotionControlModule.cs # Prism 模块注册
├── Resources/ # 多语言资源
│ ├── Resources.resx # 默认(英文)
│ ├── Resources.zh-CN.resx # 简体中文
│ ├── Resources.zh-TW.resx # 繁体中文
│ └── Resources.en-US.resx # 英文
└── Documents/ # 文档
├── README.md # 本文档
└── GUIDENCE.md # 外部集成指南
```
### 对外接口 | Public Interfaces
| 接口 | 用途 | 注册方式 |
|------|------|----------|
| `IMotionControlService` | 业务控制(移动、停止、回零、Jog、开关门、几何计算) | 单例 |
| `IMotionSystem` | 底层状态读取(轴位置、状态、门状态) | 单例 |
| `MotionControlConfig` | 配置参数(轴范围、几何原点、轮询周期) | 实例 |
| `GeometryCalculator` | 几何正算/反算工具 | 单例 |
### 事件 | Events
| 事件 | 载荷 | 触发时机 |
|------|------|----------|
| `AxisStatusChangedEvent` | `AxisStatusChangedData(AxisId, AxisStatus)` | 轴状态变化 |
| `DoorStatusChangedEvent` | `DoorStatus` | 门状态变化 |
| `DoorInterlockChangedEvent` | `bool` | 门联锁状态变化(true=已联锁, false=未联锁) |
| `GeometryUpdatedEvent` | `GeometryData(FOD, FDD, Magnification)` | 几何参数更新(每轮询周期) |
| `MotionErrorEvent` | `MotionErrorData(AxisId, ErrorMessage)` | 轴进入 Error/Alarm 状态 |
---
## 技术要求 | Technical Requirements
| 依赖 | 版本 | 用途 |
|------|------|------|
| .NET 8.0 | net8.0-windows7.0 | 运行时 |
| Prism.Wpf | 9.0.537 | MVVM + DI + EventAggregator |
| Telerik UI for WPF | 2024.1.408 | UI 控件(Crystal 主题) |
| XP.Common | - | 日志、多语言 |
| XP.Hardware.PLC | - | IPlcServicePLC 连接状态)、ISignalDataServicePLC 信号读写) |
---
## 配置参数 | Configuration
`App.config``<appSettings>` 中配置:
| 参数 | 默认值 | 说明 |
|------|--------|------|
| `MotionControl:SourceZ:Min/Max/Origin` | 0/500/0 | 射线源Z轴范围和原点(mm) |
| `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:Geometry:SourceZOrigin` | 0 | 射线源Z原点偏移(mm) |
| `MotionControl:Geometry:DetectorZOrigin` | 600 | 探测器Z原点偏移(mm |
| `MotionControl:Geometry:StageRotationCenterZ` | 300 | 旋转中心Z坐标(mm |
| `MotionControl:PollingInterval` | 100 | 轮询周期(ms |
| `MotionControl:DefaultVelocity` | 100 | 默认速度 |
PLC 信号名称硬编码在 `MotionSignalNames.cs` 中,信号定义在 `PlcAddrDfn.xml` 的 ReadCommon/WriteCommon 组。
---
**最后更新 | Last Updated**: 2026-04-14