feat: 硬件虚拟化与CNC联动集成 - 运动控制/射线源模拟实现,CNC执行联动增强

This commit is contained in:
zhengxuan.zhang
2026-05-21 15:59:38 +08:00
parent 05c41a9a21
commit 43d0e7fa89
15 changed files with 1292 additions and 9 deletions
@@ -1,5 +1,7 @@
using Prism.Ioc;
using Prism.Modularity;
using System;
using System.Configuration;
using System.Resources;
using XP.Common.Localization;
using XP.Common.Localization.Interfaces;
@@ -31,8 +33,18 @@ namespace XP.Hardware.MotionControl.Module
// 注册几何计算器(单例)| Register geometry calculator (singleton)
containerRegistry.RegisterSingleton<GeometryCalculator>();
// 注册运动系统(单例)| Register motion system (singleton)
containerRegistry.RegisterSingleton<IMotionSystem, PlcMotionSystem>();
// 根据配置选择运动系统实现 | Select motion system implementation based on config
var motionType = ConfigurationManager.AppSettings["MotionControl:Type"] ?? "PLC";
if (motionType.Equals("Simulated", StringComparison.OrdinalIgnoreCase))
{
containerRegistry.RegisterSingleton<IMotionSystem, SimulatedMotionSystem>();
System.Console.WriteLine("[MotionControlModule] [Simulated] 使用虚拟运动系统 | Using simulated motion system");
}
else
{
containerRegistry.RegisterSingleton<IMotionSystem, PlcMotionSystem>();
System.Console.WriteLine("[MotionControlModule] 使用PLC运动系统 | Using PLC motion system");
}
// 注册运动控制业务服务(单例)| Register motion control service (singleton)
containerRegistry.RegisterSingleton<IMotionControlService, MotionControlService>();
@@ -57,9 +69,18 @@ namespace XP.Hardware.MotionControl.Module
// Initialize LocalizationHelper to use ILocalizationService for string lookup (supports Fallback Chain)
LocalizationHelper.Initialize(localizationService);
// 启动 PLC 状态轮询 | Start PLC status polling
var motionService = containerProvider.Resolve<IMotionControlService>();
motionService.StartPolling();
// 仅在非虚拟模式下启动 PLC 状态轮询 | Only start PLC polling when not in simulated mode
var motionSystem = containerProvider.Resolve<IMotionSystem>();
if (motionSystem is not SimulatedMotionSystem)
{
var motionService = containerProvider.Resolve<IMotionControlService>();
motionService.StartPolling();
System.Console.WriteLine("[MotionControlModule] PLC 轮询已启动 | PLC polling started");
}
else
{
System.Console.WriteLine("[MotionControlModule] [Simulated] 跳过 PLC 轮询 | Skipping PLC polling (simulated mode)");
}
System.Console.WriteLine("[MotionControlModule] 模块已初始化 | Module initialized");
}