From c1c2b93cf87b1b24d410f0f631bd72171fefd523 Mon Sep 17 00:00:00 2001 From: QI Mingxuan Date: Mon, 11 May 2026 11:20:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=90=E5=8A=A8=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E7=9B=B8=E5=85=B3=E7=9A=84Readme=E3=80=81Guidence?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=AD=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...d => AxisControlView_PLC_Communication.md} | 0 .../Documents/GUIDENCE.md | 65 ++++++++++++++----- XP.Hardware.MotionControl/Documents/README.md | 17 +++-- 3 files changed, 61 insertions(+), 21 deletions(-) rename XP.Hardware.MotionControl/Documents/{AxisControlView_PLC_Communication.md.md => AxisControlView_PLC_Communication.md} (100%) diff --git a/XP.Hardware.MotionControl/Documents/AxisControlView_PLC_Communication.md.md b/XP.Hardware.MotionControl/Documents/AxisControlView_PLC_Communication.md similarity index 100% rename from XP.Hardware.MotionControl/Documents/AxisControlView_PLC_Communication.md.md rename to XP.Hardware.MotionControl/Documents/AxisControlView_PLC_Communication.md diff --git a/XP.Hardware.MotionControl/Documents/GUIDENCE.md b/XP.Hardware.MotionControl/Documents/GUIDENCE.md index a4ddf6d..34d1bc3 100644 --- a/XP.Hardware.MotionControl/Documents/GUIDENCE.md +++ b/XP.Hardware.MotionControl/Documents/GUIDENCE.md @@ -60,7 +60,7 @@ protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) | `DetectorSwingAngle` | double | 探测器摆动角度(度),范围 -45~45 | | `StageRotationAngle` | double | 载物台旋转角度(度),范围 -360~360 | | `FixtureRotationAngle` | double | 夹具旋转角度(度),范围 -90~90 | -| `IsJoystickEnabled` | bool | 摇杆使能开关(默认 false) | +| `IsJoystickEnabled` | bool | 摇杆使能开关(默认 true) | | `SwapMouseButtons` | bool | 摇杆左右键功能切换(默认 false) | | `SZDZLock` | bool | 射线源/探测器Z轴锁定移动(默认 false) | | `HasSavedPositions` | bool | 是否有已保存的位置快照 | @@ -71,26 +71,27 @@ protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) - 直接编辑 RadNumericUpDown 控件 - Enter 键确认并移动轴 - Escape 键取消修改,恢复原值 + - 上下箭头键步进移动(±0.1) 2. **单轴摇杆(SourceZ/DetectorZ)** - - 左键拖拽:正向 Jog - - 右键拖拽:反向 Jog + - 左键拖拽:Y轴方向控制 SourceZ Jog(正/反向由拖拽方向决定) + - 右键拖拽:Y轴方向控制 DetectorZ Jog(正/反向由拖拽方向决定) + - 当 SZDZLock=true 时,左键同时控制 SourceZ + DetectorZ,右键同理 - 松开鼠标:停止 Jog -3. **双轴摇杆(StageX/Y + Rotation)** +3. **双轴摇杆(StageX/Y + Rotation/Swing)** - 默认模式(SwapMouseButtons=false): - - 左键拖拽:控制 StageX/Y(X轴=左右,Y轴=上下) - - 右键拖拽:控制 StageRotation(X轴=旋转) - - 切换模式(SwapMouseButtons=true): - - 左键拖拽:控制 StageRotation(X轴=旋转) - - 右键拖拽:控制 DetectorSwing(X轴=摆动,Y轴=摆动) + - 左键拖拽:X轴→StageX Jog,Y轴→StageY Jog + - 右键拖拽:X轴→DetectorSwing Jog,Y轴→StageRotation/FixtureRotation Jog + - 切换模式(SwapMouseButtons=true):左右键功能互换 + - 松开鼠标:停止所有关联轴 Jog 4. **快捷按钮** - - **使能开关**:启用/禁用摇杆控制(图标切换) - - **摇杆模式**:切换左右键功能(图标切换) - - **SZDZ锁定**:锁定 SourceZ/DetectorZ 同步移动(图标切换) - - **保存位置**:保存当前所有轴位置到快照 - - **恢复位置**:恢复到上次保存的位置快照 + - **使能开关**:启用/禁用虚拟摇杆控制(同步写入 PLC 信号) + - **摇杆模式**:切换左右键功能映射 + - **SZDZ锁定**:锁定 SourceZ/DetectorZ 同步移动(同步写入 PLC 联动使能信号) + - **保存位置**:保存当前所有轴位置到快照(需 PLC 已连接) + - **恢复位置**:恢复到上次保存的位置快照并发送移动命令 --- @@ -149,7 +150,7 @@ public class YourService --- -## 3. 下发运动控制命令 | Sending Motion Commands +## 4. 下发运动控制命令 | Sending Motion Commands 通过 DI 注入 `IMotionControlService`: @@ -161,10 +162,12 @@ using XP.Hardware.MotionControl.Services; public class YourController { private readonly IMotionControlService _mc; + private readonly IMotionSystem _motionSystem; - public YourController(IMotionControlService motionControlService) + public YourController(IMotionControlService motionControlService, IMotionSystem motionSystem) { _mc = motionControlService; + _motionSystem = motionSystem; } // 单轴移动 | Single axis move @@ -222,6 +225,15 @@ public class YourController _mc.CloseDoor(); _mc.StopDoor(); } + + // 轴复位 | Axis reset + public void AxisReset() + { + // 通过 IMotionSystem 获取轴复位实例 | Get axis reset instance via IMotionSystem + IAxisReset axisReset = _motionSystem.AxisReset; + MotionResult result = axisReset.Reset(); // 发送复位命令 + bool done = axisReset.IsResetDone; // 读取复位完成状态 + } } ``` @@ -327,6 +339,21 @@ public class YourMonitor { Console.WriteLine($"运动错误: 轴 {data.AxisId} - {data.ErrorMessage}"); }, ThreadOption.UIThread); + + // 实体摇杆激活状态变化 | Physical joystick active status changed + eventAggregator.GetEvent() + .Subscribe(isActive => + { + Console.WriteLine($"实体摇杆: {(isActive ? "激活" : "未激活")}"); + }, ThreadOption.UIThread); + + // 几何反算结果填入请求(DebugWindow → MotionControlViewModel) + // Geometry apply request (DebugWindow → MotionControlViewModel) + eventAggregator.GetEvent() + .Subscribe(data => + { + Console.WriteLine($"几何反算请求: SourceZ={data.SourceZTarget}, DetectorZ={data.DetectorZTarget}"); + }, ThreadOption.UIThread); } } ``` @@ -387,6 +414,7 @@ public class YourMonitor | `MC_Door_Close` | byte | 95 | 安全门关门 | | `MC_Door_Stop` | byte | 96 | 安全门停止 | | `MC_SourceDetZ_Linkage_Enable` | bool | 101 | 射线源与探测器Z轴联动使能 | +| `MC_Axis_Reset` | byte | 102 | 轴复位命令 | | `MC_VirtualJoystick_Enable` | bool | 111 | 虚拟摇杆使能 | ### 7.2 读取信号(ReadCommon,DB31) @@ -403,6 +431,7 @@ public class YourMonitor | `MC_Door_Status` | byte | 128 | 安全门状态(0:未知,1:开门中,2:已开,3:关门中,4:已关,5:已锁定,6:故障) | | `MC_Door_Interlock` | byte | 130 | 安全门联锁信号(0:无联锁,10:联锁有效) | | `MC_Joystick_Active` | bool | 110 | 实体摇杆输入激活 | +| `MC_Axis_ResetDone` | bool | 112 | 轴复位完成 | ### 7.3 信号类型说明 | Signal Type Notes @@ -424,6 +453,8 @@ public class YourMonitor | 多轴原子性检查 | MoveAllToTarget 任意轴越界则全部拒绝 | | 轮询异常不中断 | 轮询中 PLC 异常被捕获,不影响下一轮 | | UI 异常保护 | ViewModel 命令通过 SafeRun 包裹,PLC 异常弹窗而非崩溃 | +| PLC 断连安全 | PLC 断开时自动停止所有 Jog 并禁用摇杆,重连后需用户手动恢复 | +| 使能/联动回滚 | 使能切换或联动设置写入 PLC 失败时自动回滚 UI 状态 | --- @@ -443,4 +474,4 @@ public class YourMonitor --- -**最后更新 | Last Updated**: 2026-05-08 +**最后更新 | Last Updated**: 2026-05-11 diff --git a/XP.Hardware.MotionControl/Documents/README.md b/XP.Hardware.MotionControl/Documents/README.md index 323b65d..ec54fb6 100644 --- a/XP.Hardware.MotionControl/Documents/README.md +++ b/XP.Hardware.MotionControl/Documents/README.md @@ -81,6 +81,8 @@ XP.Hardware.MotionControl/ │ ├── ILinearAxis.cs # 直线轴策略接口 │ ├── IRotaryAxis.cs # 旋转轴策略接口 │ ├── ISafetyDoor.cs # 安全门策略接口 +│ ├── IJoystick.cs # 实体摇杆接口 +│ ├── IAxisReset.cs # 轴复位接口 │ ├── IMotionSystem.cs # 顶层系统管理接口 │ ├── LinearAxisBase.cs # 直线轴抽象基类(含边界检查) │ ├── RotaryAxisBase.cs # 旋转轴抽象基类 @@ -96,19 +98,24 @@ XP.Hardware.MotionControl/ │ ├── DoorStatusChangedEvent.cs │ ├── DoorInterlockChangedEvent.cs │ ├── GeometryUpdatedEvent.cs +│ ├── GeometryApplyRequestEvent.cs +│ ├── JoystickActiveEvent.cs │ └── MotionErrorEvent.cs ├── Implementations/ # PLC 实现层 │ ├── PlcLinearAxis.cs # 基于 PLC 的直线轴实现 │ ├── PlcRotaryAxis.cs # 基于 PLC 的旋转轴实现 │ ├── PlcSafetyDoor.cs # 基于 PLC 的安全门实现 +│ ├── PlcJoystick.cs # 基于 PLC 的实体摇杆实现 +│ ├── PlcAxisReset.cs # 基于 PLC 的轴复位实现 │ └── PlcMotionSystem.cs # 运动系统管理器 ├── Services/ # 业务服务层 │ ├── IMotionControlService.cs # 业务服务接口 │ ├── MotionControlService.cs # 服务实现(轮询、事件、日志) │ └── GeometryCalculator.cs # 几何计算器 ├── ViewModels/ # 视图模型 -│ ├── AxisControlViewModel.cs # AxisControlView ViewModel -│ └── MotionControlViewModel.cs # MotionControlView ViewModel +│ ├── AxisControlViewModel.cs # AxisControlView ViewModel +│ ├── MotionControlViewModel.cs # MotionControlView ViewModel +│ └── MotionDebugWindowViewModel.cs # MotionDebugWindow ViewModel ├── Config/ # 配置层 │ ├── MotionControlConfig.cs # 配置实体 │ ├── ConfigLoader.cs # 配置加载器 @@ -136,7 +143,7 @@ XP.Hardware.MotionControl/ | 接口 | 用途 | 注册方式 | |------|------|----------| | `IMotionControlService` | 业务控制(移动、停止、回零、Jog、开关门、几何计算) | 单例 | -| `IMotionSystem` | 底层状态读取(轴位置、状态、门状态) | 单例 | +| `IMotionSystem` | 底层状态读取(轴位置、状态、门状态、摇杆状态、轴复位) | 单例 | | `MotionControlConfig` | 配置参数(轴范围、几何原点、轮询周期) | 实例 | | `GeometryCalculator` | 几何正算/反算工具 | 单例 | @@ -148,6 +155,8 @@ XP.Hardware.MotionControl/ | `DoorStatusChangedEvent` | `DoorStatus` | 门状态变化 | | `DoorInterlockChangedEvent` | `bool` | 门联锁状态变化(true=已联锁, false=未联锁) | | `GeometryUpdatedEvent` | `GeometryData(FOD, FDD, Magnification)` | 几何参数更新(每轮询周期) | +| `GeometryApplyRequestEvent` | `GeometryApplyRequestData(SourceZTarget, DetectorZTarget, ...)` | 几何反算结果填入请求(DebugWindow → MotionControlViewModel) | +| `JoystickActiveEvent` | `bool` | 实体摇杆激活状态变化(true=激活, false=未激活) | | `MotionErrorEvent` | `MotionErrorData(AxisId, ErrorMessage)` | 轴进入 Error/Alarm 状态 | --- @@ -192,4 +201,4 @@ PLC 信号名称硬编码在 `MotionSignalNames.cs` 中,信号定义在 `PlcAd --- -**最后更新 | Last Updated**: 2026-05-08 +**最后更新 | Last Updated**: 2026-05-11