diff --git a/ADP.sln b/ADP.sln index 8114617..7cad4b3 100644 --- a/ADP.sln +++ b/ADP.sln @@ -39,6 +39,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceEditModule", "DeviceE EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZLGUSBCANFD", "ZLGUSBCANFD\ZLGUSBCANFD.csproj", "{542FE380-2344-4343-9AC6-F0C587C13B88}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchMovementModule", "BenchMovementModule\BenchMovementModule.csproj", "{31F84D0E-3634-4C70-A830-21AF412E3BBF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -113,6 +115,10 @@ Global {542FE380-2344-4343-9AC6-F0C587C13B88}.Debug|Any CPU.Build.0 = Debug|Any CPU {542FE380-2344-4343-9AC6-F0C587C13B88}.Release|Any CPU.ActiveCfg = Release|Any CPU {542FE380-2344-4343-9AC6-F0C587C13B88}.Release|Any CPU.Build.0 = Release|Any CPU + {31F84D0E-3634-4C70-A830-21AF412E3BBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31F84D0E-3634-4C70-A830-21AF412E3BBF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31F84D0E-3634-4C70-A830-21AF412E3BBF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31F84D0E-3634-4C70-A830-21AF412E3BBF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -125,5 +131,6 @@ Global {3456C3AC-E7FF-45F8-A68F-BEED9969812C} = {1E92D601-68FC-45F6-8251-BD0F39226E5B} {850A5BE8-0BC1-4D6A-8351-DD812C9C4427} = {1E92D601-68FC-45F6-8251-BD0F39226E5B} {170AD4C1-189D-4FBE-B10D-2A4304527834} = {1E92D601-68FC-45F6-8251-BD0F39226E5B} + {31F84D0E-3634-4C70-A830-21AF412E3BBF} = {1E92D601-68FC-45F6-8251-BD0F39226E5B} EndGlobalSection EndGlobal diff --git a/ADP/ADP.csproj b/ADP/ADP.csproj index 40276bc..f525234 100644 --- a/ADP/ADP.csproj +++ b/ADP/ADP.csproj @@ -19,6 +19,7 @@ + diff --git a/ADP/ViewModels/ShellViewModel.cs b/ADP/ViewModels/ShellViewModel.cs index a09cd54..7e86473 100644 --- a/ADP/ViewModels/ShellViewModel.cs +++ b/ADP/ViewModels/ShellViewModel.cs @@ -762,8 +762,9 @@ namespace ADP.ViewModels _regionManager.RequestNavigate(settingRegion, "SettingView", settingParameters); IsLeftDrawerOpen = false; break; - case "更新界面": - _regionManager.RequestNavigate("ShellViewManager", "UpdateInfoView"); + case "台架移动界面": + if (_globalInfo.CurrentScope != "default") return; + _regionManager.RequestNavigate("ShellViewManager", "BenchMovementView"); break; } } diff --git a/ADP/Views/ShellView.xaml b/ADP/Views/ShellView.xaml index eb17dcd..5b8bfd2 100644 --- a/ADP/Views/ShellView.xaml +++ b/ADP/Views/ShellView.xaml @@ -61,11 +61,11 @@ Style="{StaticResource MaterialDesignFlatButton}" Margin="8" /> - + Margin="8" /> diff --git a/BenchMovementModule/BenchMovementModule.cs b/BenchMovementModule/BenchMovementModule.cs new file mode 100644 index 0000000..6041442 --- /dev/null +++ b/BenchMovementModule/BenchMovementModule.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using BenchMovementModule.Views; + +namespace BenchMovementModule +{ + public class BenchMovementModule : IModule + { + public void OnInitialized(IContainerProvider containerProvider) + { + IRegionManager regionManager = containerProvider.Resolve(); + regionManager.RegisterViewWithRegion("ShellViewManager", typeof(BenchMovementView)); + } + + public void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation("BenchMovementView"); + } + } +} diff --git a/BenchMovementModule/BenchMovementModule.csproj b/BenchMovementModule/BenchMovementModule.csproj new file mode 100644 index 0000000..3df7504 --- /dev/null +++ b/BenchMovementModule/BenchMovementModule.csproj @@ -0,0 +1,14 @@ + + + + net8.0-windows + enable + true + enable + + + + + + + diff --git a/BenchMovementModule/ViewModels/BenchMovementViewModel.cs b/BenchMovementModule/ViewModels/BenchMovementViewModel.cs new file mode 100644 index 0000000..3772e97 --- /dev/null +++ b/BenchMovementModule/ViewModels/BenchMovementViewModel.cs @@ -0,0 +1,413 @@ +using System; +using System.Windows.Input; +using UIShare.ViewModelBase; + +namespace BenchMovementModule.ViewModels +{ + public class BenchMovementViewModel : NavigateViewModelBase, IRegionMemberLifetime, IDisposable + { + #region 属性与通知字段 + + public bool KeepAlive => true; + + // --- 1. 台架位置区 --- + private double _posX; + public double PosX + { + get => _posX; + set => SetProperty(ref _posX, value); + } + + private double _posY; + public double PosY + { + get => _posY; + set => SetProperty(ref _posY, value); + } + + private double _posZ; + public double PosZ + { + get => _posZ; + set => SetProperty(ref _posZ, value); + } + + // --- 2. 信号回读区 --- + private double _pos1X; + public double Pos1X + { + get => _pos1X; + set => SetProperty(ref _pos1X, value); + } + + private int _pos1Quality; + public int Pos1Quality + { + get => _pos1Quality; + set => SetProperty(ref _pos1Quality, value); + } + + private double _pos2X; + public double Pos2X + { + get => _pos2X; + set => SetProperty(ref _pos2X, value); + } + + private int _pos2Quality; + public int Pos2Quality + { + get => _pos2Quality; + set => SetProperty(ref _pos2Quality, value); + } + + private double _pos1Y; + public double Pos1Y + { + get => _pos1Y; + set => SetProperty(ref _pos1Y, value); + } + + private double _pos2Y; + public double Pos2Y + { + get => _pos2Y; + set => SetProperty(ref _pos2Y, value); + } + + // --- 3. 扫描参数区 --- + private double _scanStepX = 10; + public double ScanStepX + { + get => _scanStepX; + set => SetProperty(ref _scanStepX, value); + } + + private double _scanStartX = -120; + public double ScanStartX + { + get => _scanStartX; + set => SetProperty(ref _scanStartX, value); + } + + private double _scanEndX = 120; + public double ScanEndX + { + get => _scanEndX; + set => SetProperty(ref _scanEndX, value); + } + + private double _scanStepY = 10; + public double ScanStepY + { + get => _scanStepY; + set => SetProperty(ref _scanStepY, value); + } + + private double _scanStartY = -120; + public double ScanStartY + { + get => _scanStartY; + set => SetProperty(ref _scanStartY, value); + } + + private double _scanEndY = 120; + public double ScanEndY + { + get => _scanEndY; + set => SetProperty(ref _scanEndY, value); + } + + private double _scanStepZ = 1; + public double ScanStepZ + { + get => _scanStepZ; + set => SetProperty(ref _scanStepZ, value); + } + + private double _scanStartZ = 0; + public double ScanStartZ + { + get => _scanStartZ; + set => SetProperty(ref _scanStartZ, value); + } + + private double _scanEndZ = 0; + public double ScanEndZ + { + get => _scanEndZ; + set => SetProperty(ref _scanEndZ, value); + } + + // --- 4. 寸动参数区 --- + private double _jogX; + public double JogX + { + get => _jogX; + set => SetProperty(ref _jogX, value); + } + + private double _jogY; + public double JogY + { + get => _jogY; + set => SetProperty(ref _jogY, value); + } + + private double _jogZ; + public double JogZ + { + get => _jogZ; + set => SetProperty(ref _jogZ, value); + } + + // --- 5. 设置页:网络及PLC参数 --- + private string _plcIp = "192.168.0.30"; + public string PlcIp + { + get => _plcIp; + set => SetProperty(ref _plcIp, value); + } + + private int _plcPort = 502; + public int PlcPort + { + get => _plcPort; + set => SetProperty(ref _plcPort, value); + } + + // --- 6. 设置页:速度与零点设定 --- + private double _speedX; + public double SpeedX + { + get => _speedX; + set => SetProperty(ref _speedX, value); + } + + private double _speedY; + public double SpeedY + { + get => _speedY; + set => SetProperty(ref _speedY, value); + } + + private double _speedZ; + public double SpeedZ + { + get => _speedZ; + set => SetProperty(ref _speedZ, value); + } + + private double _zeroX; + public double ZeroX + { + get => _zeroX; + set => SetProperty(ref _zeroX, value); + } + + private double _zeroY; + public double ZeroY + { + get => _zeroY; + set => SetProperty(ref _zeroY, value); + } + + private double _zeroZ; + public double ZeroZ + { + get => _zeroZ; + set => SetProperty(ref _zeroZ, value); + } + + // --- 7. 设置页:CAN设定信号映射 --- + private int _canChannel = 0; + public int CanChannel + { + get => _canChannel; + set => SetProperty(ref _canChannel, value); + } + + private string _canMsgId = "0X0"; + public string CanMsgId + { + get => _canMsgId; + set => SetProperty(ref _canMsgId, value); + } + + private string _canMsgName = string.Empty; + public string CanMsgName + { + get => _canMsgName; + set => SetProperty(ref _canMsgName, value); + } + + private string _sigPos1X = string.Empty; + public string SigPos1X + { + get => _sigPos1X; + set => SetProperty(ref _sigPos1X, value); + } + + private string _sigPos2X = string.Empty; + public string SigPos2X + { + get => _sigPos2X; + set => SetProperty(ref _sigPos2X, value); + } + + private string _sigPos1Y = string.Empty; + public string SigPos1Y + { + get => _sigPos1Y; + set => SetProperty(ref _sigPos1Y, value); + } + + private string _sigPos2Y = string.Empty; + public string SigPos2Y + { + get => _sigPos2Y; + set => SetProperty(ref _sigPos2Y, value); + } + + private string _sigPos1Quality = string.Empty; + public string SigPos1Quality + { + get => _sigPos1Quality; + set => SetProperty(ref _sigPos1Quality, value); + } + + private string _sigPos2Quality = string.Empty; + public string SigPos2Quality + { + get => _sigPos2Quality; + set => SetProperty(ref _sigPos2Quality, value); + } + + #endregion + + #region 命令 + // 扫描控制面板命令 + public ICommand StartScanCommand { get; } + public ICommand StopScanCommand { get; } + public ICommand GoHomeCommand { get; } + + // 寸动执行单轴移动 + public ICommand MoveXCommand { get; } + public ICommand MoveYCommand { get; } + public ICommand MoveZCommand { get; } + + // 全局控制 + public ICommand EmergencyStopCommand { get; } + + // 参数设置应用命令 + public ICommand ApplyNetworkCommand { get; } + public ICommand SetSpeedCommand { get; } + public ICommand SetZeroCommand { get; } + #endregion + + #region 私有字段 + private readonly IContainerProvider _containerProvider; + private bool _isInitiated = false; + private string _testStatus = string.Empty; + #endregion + + public BenchMovementViewModel(IContainerProvider containerProvider) : base(containerProvider) + { + _containerProvider = containerProvider; + + // 初始化扫描控制命令绑定 + StartScanCommand = new DelegateCommand(OnStartScan); + StopScanCommand = new DelegateCommand(OnStopScan); + GoHomeCommand = new DelegateCommand(OnGoHome); + + // 初始化寸动命令绑定 + MoveXCommand = new DelegateCommand(OnMoveX); + MoveYCommand = new DelegateCommand(OnMoveY); + MoveZCommand = new DelegateCommand(OnMoveZ); + + // 急停与设置保存 + EmergencyStopCommand = new DelegateCommand(OnEmergencyStop); + ApplyNetworkCommand = new DelegateCommand(OnApplyNetwork); + SetSpeedCommand = new DelegateCommand(OnSetSpeed); + SetZeroCommand = new DelegateCommand(OnSetZero); + } + + #region 命令处理方法 + + private void OnStartScan() + { + // TODO: 等协议到了处理开始扫描 + } + + private void OnStopScan() + { + // TODO: 等协议到了处理停止扫描 + } + + private void OnGoHome() + { + // TODO: 等协议到了处理台架回原点逻辑 + } + + private void OnMoveX() + { + // TODO: 执行单轴X向绝对位置寸动 + } + + private void OnMoveY() + { + // TODO: 执行单轴Y向绝对位置寸动 + } + + private void OnMoveZ() + { + // TODO: 执行单轴Z向绝对位置寸动 + } + + private void OnEmergencyStop() + { + // TODO: 全局急停高优先级报文/IO发送 + } + + private void OnApplyNetwork() + { + // TODO: 应用PLC的IP和端口网络连接配置 + } + + private void OnSetSpeed() + { + // TODO: 发送三轴移动速度设定参数 + } + + private void OnSetZero() + { + // TODO: 发送台架绝对位置零点校准设定 + } + + #endregion + + #region 重写方法与生命周期导航 + + public override void OnNavigatedTo(NavigationContext navigationContext) + { + base.OnNavigatedTo(navigationContext); + + if (!_isInitiated && navigationContext.Parameters.ContainsKey("Name")) + { + _testStatus = navigationContext.Parameters.GetValue("Name"); + + // TODO: 若后续需要从全局环境 Scope 字典中加载参数配置,可以在此处对齐获取: + // var scope = _globalInfo.ScopeDic[_testStatus]; + + _isInitiated = true; + } + } + + public void Dispose() + { + // 用于界面关闭或Region注销时的资源释放(例如解除事件订阅、断开临时Socket通道、清空通信缓冲) + } + + #endregion + } +} \ No newline at end of file diff --git a/BenchMovementModule/Views/BenchMovementView.xaml b/BenchMovementModule/Views/BenchMovementView.xaml new file mode 100644 index 0000000..89f6c7b --- /dev/null +++ b/BenchMovementModule/Views/BenchMovementView.xaml @@ -0,0 +1,533 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +