diff --git a/DeviceCommand/Devices/N36600.cs b/DeviceCommand/Devices/N36600.cs index a5a430f..18dea0c 100644 --- a/DeviceCommand/Devices/N36600.cs +++ b/DeviceCommand/Devices/N36600.cs @@ -229,26 +229,9 @@ namespace DeviceCommand.Device return await WriteReadAsync($"MEAS:VAP?{SCPIDelimiter}", SCPIDelimiter, ct); } + /// - /// 3.5.5 查询通道输出端子上测得的电池容量 - /// - public virtual async Task 查询测得电池容量(CancellationToken ct = default) - { - // 修正:去除前缀冒号 - return await WriteReadAsync($"MEAS:CAP?{SCPIDelimiter}", SCPIDelimiter, ct); - } - - /// - /// 3.5.6 查询通道输出端子上测得的恒流输出时间长度 (单位: ms) - /// - public virtual async Task 查询恒流输出时间长度(CancellationToken ct = default) - { - // 修正:去除前缀冒号 - return await WriteReadAsync($"MEAS:TIM:CC?{SCPIDelimiter}", SCPIDelimiter, ct); - } - - /// - /// 3.5.7 查询通道输出端子上测得的输出时间长度 + /// 3.5.5 查询通道输出端子上测得的输出时间长度 /// public virtual async Task 查询总输出时间长度(CancellationToken ct = default) { @@ -286,7 +269,7 @@ namespace DeviceCommand.Device { // 修正:去除前缀冒号 string 状态 = 开启 ? "ON" : "OFF"; - await SendAsync($"OUTP:TIM {状态}{SCPIDelimiter}", ct); + await SendAsync($"OUTP:TIME {状态}{SCPIDelimiter}", ct); } /// @@ -295,7 +278,7 @@ namespace DeviceCommand.Device public virtual async Task 设置定时器时间(double 秒数, CancellationToken ct = default) { // 修正:去除前缀冒号 - string cmd = string.Format(CultureInfo.InvariantCulture, "OUTP:TIM:DATA {0:F1}{1}", 秒数, SCPIDelimiter); + string cmd = string.Format(CultureInfo.InvariantCulture, "OUTP:TIME:DATA {0:F1}{1}", 秒数, SCPIDelimiter); await SendAsync(cmd, ct); } @@ -400,7 +383,14 @@ namespace DeviceCommand.Device string cmd = string.Format(CultureInfo.InvariantCulture, "VOLT:LIM {0:F3}{1}", 电压, SCPIDelimiter); await SendAsync(cmd, ct); } - + /// + /// 3.7.2.9 清除电压上限限制(恢复为设备物理允许的最大电压值) + /// + public virtual async Task 清除电压上限限制(CancellationToken ct = default) + { + // 发送 MAXimum 设为最大值以达到“清除限制”的效果 + await SendAsync($"VOLT:LIMIT MAX{SCPIDelimiter}", ct); // 对应手册 3.7.2.8 + } /// /// 3.7.3.1 设置输出功率值 (W) /// diff --git a/DeviceEditModule/DeviceEditModule.cs b/DeviceEditModule/DeviceEditModule.cs index bb7a9dd..eead725 100644 --- a/DeviceEditModule/DeviceEditModule.cs +++ b/DeviceEditModule/DeviceEditModule.cs @@ -21,6 +21,12 @@ namespace DeviceEditModule containerRegistry.RegisterForNavigation("N69200View"); containerRegistry.RegisterForNavigation("SDS2000X_HDView"); containerRegistry.RegisterForNavigation("SPAW7000View"); + containerRegistry.Register(); + containerRegistry.Register(); + containerRegistry.Register(); + containerRegistry.Register(); + containerRegistry.Register(); + containerRegistry.Register(); } } } diff --git a/DeviceEditModule/Views/DialogMangerView.xaml b/DeviceEditModule/Views/DialogMangerView.xaml index 82a7beb..034c770 100644 --- a/DeviceEditModule/Views/DialogMangerView.xaml +++ b/DeviceEditModule/Views/DialogMangerView.xaml @@ -9,7 +9,7 @@ xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare" mc:Ignorable="d" prism:ViewModelLocator.AutoWireViewModel="True" - Height="850" Width="900"> + Height="900" Width="900"> @@ -124,7 +124,7 @@ - + diff --git a/DeviceEditModule/Views/N36600View.xaml b/DeviceEditModule/Views/N36600View.xaml index 573607b..39720eb 100644 --- a/DeviceEditModule/Views/N36600View.xaml +++ b/DeviceEditModule/Views/N36600View.xaml @@ -7,7 +7,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare" mc:Ignorable="d" - prism:ViewModelLocator.AutoWireViewModel="True" + prism:ViewModelLocator.AutoWireViewModel="False" d:DesignHeight="760" d:DesignWidth="860"> diff --git a/TestingModule/ViewModels/ParametersManagerViewModel.cs b/TestingModule/ViewModels/ParametersManagerViewModel.cs index 486105a..167af42 100644 --- a/TestingModule/ViewModels/ParametersManagerViewModel.cs +++ b/TestingModule/ViewModels/ParametersManagerViewModel.cs @@ -127,26 +127,37 @@ namespace TestingModule.ViewModels if (SelectedDevice == null) return; var type = SelectedDevice.DeviceType.Split('.').Last(); var viewName = type + "View"; + var vmName = type + "ViewModel"; // 按照命名规范拼接出对应的 VM 类型名 try { - // 1. 先确保弹窗管理器窗口已打开(首次 Show,后续只追加 Tab) + // 1. 先确保弹窗管理器窗口已打开 if (_dialogWindow == null || !_dialogWindow.IsVisible) { _dialogService.Show("DialogMangerView"); - - // 找到刚刚被 DialogService 打开的窗口(按 DataContext 类型名匹配) _dialogWindow = System.Windows.Application.Current.Windows .OfType() .FirstOrDefault(w => w.DataContext?.GetType().Name == "DialogMangerViewModel"); } - // 2. 从容器按注册名解析设备编辑 View + // 2. 从当前专属容器解析设备编辑 View 实例 var view = _containerProvider.Resolve(viewName) as System.Windows.FrameworkElement; if (view == null) return; - // 3. 通过反射调用 ViewModel 上的 Initialize(deviceName) 方法, - // 避免 TestingModule 直接引用 DeviceEditModule 的类型 + // 3. 关键:从同一个台架的专属容器中解析出该设备对应的 ViewModel 实例 + // 从而实现:不同的台架(不同的专属 _containerProvider)解析出各自独立的 VM 实例 + var vmType = Assembly.Load("DeviceEditModule").GetType($"DeviceEditModule.ViewModels.{vmName}"); + if (vmType != null) + { + var scopedViewModel = _containerProvider.Resolve(vmType); + if (scopedViewModel != null) + { + // 手动绑定 DataContext,将其锁死在当前作用域内 + view.DataContext = scopedViewModel; + } + } + + // 4. 调用 ViewModel 上的 Initialize 方法 var vm = view.DataContext; if (vm != null) { @@ -154,18 +165,16 @@ namespace TestingModule.ViewModels initMethod?.Invoke(vm, new object[] { SelectedDevice.DeviceName }); } - // 4. 发布事件 → DialogMangerViewModel 接收后将此 View 添加为 Tab - // 标题格式:{当前作用域} - {设备名称} - // 去重依据:设备硬件指纹(同一物理设备不重复打开) + // 5. 发布事件,将绑定好独立 VM 的 View 实例作为 Tab 载入 var fingerprint = DeviceManager.ExtractHardwareFingerprint(SelectedDevice); _eventAggregator.GetEvent().Publish(new DialogTabInfo { - Title = $"{_globalInfo.CurrentScope} - {SelectedDevice.DeviceName}", + Title = $"{_globalInfo.CurrentScope} - {SelectedDevice.DeviceName}", Fingerprint = fingerprint, - Content = view + Content = view }); - // 5. 将窗口置顶(确保用户看到新增的 Tab) + // 6. 窗口置顶 if (_dialogWindow != null && _dialogWindow.IsVisible) { if (_dialogWindow.WindowState == System.Windows.WindowState.Minimized)