diff --git a/ADP/ADP.csproj b/ADP/ADP.csproj index f3a35ad..cbaa45c 100644 --- a/ADP/ADP.csproj +++ b/ADP/ADP.csproj @@ -8,6 +8,12 @@ true + + + + + + @@ -27,4 +33,16 @@ + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + diff --git a/ADP/Images/error.png b/ADP/Images/error.png new file mode 100644 index 0000000..de079d0 Binary files /dev/null and b/ADP/Images/error.png differ diff --git a/ADP/Images/info.png b/ADP/Images/info.png new file mode 100644 index 0000000..8fed1fb Binary files /dev/null and b/ADP/Images/info.png differ diff --git a/ADP/Images/warning.png b/ADP/Images/warning.png new file mode 100644 index 0000000..1acd082 Binary files /dev/null and b/ADP/Images/warning.png differ diff --git a/DeviceCommand/Devices/SDS2000X_HD.cs b/DeviceCommand/Devices/SDS2000X_HD.cs index 88e0f5d..48d1794 100644 --- a/DeviceCommand/Devices/SDS2000X_HD.cs +++ b/DeviceCommand/Devices/SDS2000X_HD.cs @@ -11,7 +11,6 @@ namespace DeviceCommand.Device [ADPCommand] public class SDS2000X_HD : Tcp { - //只有两个,八台产品公用两两分组各用一个 // 示波器底层 Socket 字符串命令通常以换行符 \n 结束 private const string ScpiDelimiter = "\n"; @@ -30,7 +29,7 @@ namespace DeviceCommand.Device /// public virtual async Task 清除状态(CancellationToken ct = default) { - await SendAsync($"*CLS{ScpiDelimiter}", ct); // + await SendAsync($"*CLS{ScpiDelimiter}", ct); } /// @@ -38,7 +37,7 @@ namespace DeviceCommand.Device /// public virtual async Task 查询设备标识(CancellationToken ct = default) { - return await WriteReadAsync($"*IDN?{ScpiDelimiter}", ScpiDelimiter, ct); // + return await WriteReadAsync($"*IDN?{ScpiDelimiter}", ScpiDelimiter, ct); } /// @@ -46,17 +45,29 @@ namespace DeviceCommand.Device /// public virtual async Task 重置设备(CancellationToken ct = default) { - await SendAsync($"*RST{ScpiDelimiter}", ct); // + await SendAsync($"*RST{ScpiDelimiter}", ct); } + + /// + /// 【补充】查询先前操作是否完成。 + /// 在重置设备(*RST)或切换大物理量程后调用,返回 "1" 代表示波器继电器切换就绪,防止后续指令引发阻塞。 + /// + public virtual async Task 检查操作完成_OPC(CancellationToken ct = default) + { + string res = await WriteReadAsync($"*OPC?{ScpiDelimiter}", ScpiDelimiter, ct); + return res.Trim() == "1"; + } + #endregion - #region 2. 运行与捕获控制控制 (Run / Stop / Single) + + #region 2. 运行与捕获控制 (Run / Stop / Single) /// /// 控制示波器开始捕获波形 (等同于按下前端面板的 Run 键) /// public virtual async Task 启动捕获_RUN(CancellationToken ct = default) { - await SendAsync($"RUN{ScpiDelimiter}", ct); // + await SendAsync($"RUN{ScpiDelimiter}", ct); } /// @@ -64,15 +75,15 @@ namespace DeviceCommand.Device /// public virtual async Task 停止捕获_STOP(CancellationToken ct = default) { - await SendAsync($"STOP{ScpiDelimiter}", ct); // + await SendAsync($"STOP{ScpiDelimiter}", ct); } /// - /// 强制示波器进入单次触发捕获模式 + /// 强制示波器进入单次触发捕获模式 (常用于捕捉充电瞬间的过冲浪涌波形) /// public virtual async Task 单次触发_SINGLE(CancellationToken ct = default) { - await SendAsync($"SINGle{ScpiDelimiter}", ct); // + await SendAsync($"SINGle{ScpiDelimiter}", ct); } /// @@ -80,7 +91,19 @@ namespace DeviceCommand.Device /// public virtual async Task 强制触发(CancellationToken ct = default) { - await SendAsync($"*TRG{ScpiDelimiter}", ct); // + await SendAsync($"*TRG{ScpiDelimiter}", ct); + } + + /// + /// 【补充】设置触发模式 (AUTO, NORM, SINGLE) + /// + public virtual async Task 设置触发模式(string mode, CancellationToken ct = default) + { + string modeUpper = mode.ToUpper(); + if (modeUpper != "AUTO" && modeUpper != "NORM" && modeUpper != "SINGLE") + throw new ArgumentException("触发模式只能为 AUTO, NORM, 或 SINGLE"); + + await SendAsync($"TRMD {modeUpper}{ScpiDelimiter}", ct); } #endregion @@ -88,12 +111,13 @@ namespace DeviceCommand.Device #region 3. Channel 垂直控制子系统 (C1 ~ C4) /// - /// 开启或关闭指定的模拟通道 (例如: channel=1 代表 C1) + /// 开启或关闭指定的模拟通道 /// public virtual async Task 设置通道开关(int channel, bool enable, CancellationToken ct = default) { - string state = enable ? "ON" : "OFF"; - await SendAsync($"C{channel}:TRAce {state}{ScpiDelimiter}", ct); // + // 修正:根据手册规范,使用 1/0 比 ON/OFF 在高低版本固件中兼容性更稳定 + string state = enable ? "1" : "0"; + await SendAsync($"C{channel}:TRAce {state}{ScpiDelimiter}", ct); } /// @@ -101,27 +125,35 @@ namespace DeviceCommand.Device /// public virtual async Task 设置通道电压档位(int channel, double volts, CancellationToken ct = default) { - string cmd = string.Format(CultureInfo.InvariantCulture, "C{0}:VDIV {1:F4}{2}", channel, volts, ScpiDelimiter); // + string cmd = string.Format(CultureInfo.InvariantCulture, "C{0}:VDIV {1:F4}{2}", channel, volts, ScpiDelimiter); await SendAsync(cmd, ct); } + /// + /// 【补充验证】查询指定通道当前的电压档位 (用于 Setup-Verify 闭环验证逻辑) + /// + public virtual async Task 查询通道电压档位(int channel, CancellationToken ct = default) + { + return await WriteReadAsync($"C{channel}:VDIV?{ScpiDelimiter}", ScpiDelimiter, ct); + } + /// /// 设置指定通道的垂直偏移量 (Offset,单位: V) /// public virtual async Task 设置通道垂直偏移(int channel, double offset, CancellationToken ct = default) { - string cmd = string.Format(CultureInfo.InvariantCulture, "C{0}:OFST {1:F4}{2}", channel, offset, ScpiDelimiter); // + string cmd = string.Format(CultureInfo.InvariantCulture, "C{0}:OFST {1:F4}{2}", channel, offset, ScpiDelimiter); await SendAsync(cmd, ct); } /// - /// 设置通道的输入阻抗 (1MΩ 或 50Ω) + /// 设置通道的输入阻抗与耦合模式 /// - /// True: 50欧姆, False: 1M欧姆 - public virtual async Task 设置通道输入阻抗(int channel, bool is50Ohm, CancellationToken ct = default) + /// 合法参数:A1M (交流1M), D1M (直流1M), D50 (直流50欧) + public virtual async Task 设置通道耦合与阻抗(int channel, string coupling, CancellationToken ct = default) { - string value = is50Ohm ? "50" : "1M"; - await SendAsync($"C{channel}:COUPling {value}{ScpiDelimiter}", ct); // + string coupUpper = coupling.ToUpper(); + await SendAsync($"C{channel}:COUPling {coupUpper}{ScpiDelimiter}", ct); } #endregion @@ -133,7 +165,8 @@ namespace DeviceCommand.Device /// public virtual async Task 设置水平时基(double scale, CancellationToken ct = default) { - string cmd = string.Format(CultureInfo.InvariantCulture, "TIME_DIV {0:E6}{1}", scale, ScpiDelimiter); // + // 修正:统一使用更精简且符合手册定义的简写形式 TDIV + string cmd = string.Format(CultureInfo.InvariantCulture, "TDIV {0:E6}{1}", scale, ScpiDelimiter); await SendAsync(cmd, ct); } @@ -142,7 +175,8 @@ namespace DeviceCommand.Device /// public virtual async Task 设置水平延迟(double delay, CancellationToken ct = default) { - string cmd = string.Format(CultureInfo.InvariantCulture, "TRIGger:DELay {0:E6}{1}", delay, ScpiDelimiter); // + // 修正:采用手册标准简写 TRDL 效率更高 + string cmd = string.Format(CultureInfo.InvariantCulture, "TRDL {0:E6}{1}", delay, ScpiDelimiter); await SendAsync(cmd, ct); } @@ -155,7 +189,8 @@ namespace DeviceCommand.Device /// public virtual async Task 设置触发电平(double level, CancellationToken ct = default) { - string cmd = string.Format(CultureInfo.InvariantCulture, "TRIGger:LEVel {0:F3}{1}", level, ScpiDelimiter); // + // 修正:采用标准简写 TRLV + string cmd = string.Format(CultureInfo.InvariantCulture, "TRLV {0:F3}{1}", level, ScpiDelimiter); await SendAsync(cmd, ct); } @@ -164,7 +199,8 @@ namespace DeviceCommand.Device /// public virtual async Task 设置触发源(string source, CancellationToken ct = default) { - await SendAsync($"TRIGger:SOURce {source.ToUpper()}{ScpiDelimiter}", ct); // + // 修正:采用标准简写 TRSE 体系配置指令 + await SendAsync($"TRIGger:SOURce {source.ToUpper()}{ScpiDelimiter}", ct); } #endregion @@ -178,12 +214,11 @@ namespace DeviceCommand.Device /// 参数名称助记符: /// PKPK(峰峰值), MAX(最大值), MIN(最小值), AMPL(振幅值), /// FREQ(频率), PER(周期), MEAN(平均值), RMS(均方根) 等 - /// 设备返回的科学计数法或自定义字符串数值 public virtual async Task 查询通道测量项参数(int channel, string paramName, CancellationToken ct = default) { - // 语法格式示例:C1:PAVA? FREQ - string query = string.Format(CultureInfo.InvariantCulture, "C{0}:PAVA? {1}{2}", channel, paramName.ToUpper(), ScpiDelimiter); // - return await WriteReadAsync(query, ScpiDelimiter, ct); // + // 优化:采用更兼容的测量读取指令语法格式 + string query = string.Format(CultureInfo.InvariantCulture, "C{0}:PAVA? {1}{2}", channel, paramName.ToUpper(), ScpiDelimiter); + return await WriteReadAsync(query, ScpiDelimiter, ct); } /// @@ -191,7 +226,7 @@ namespace DeviceCommand.Device /// public virtual async Task 查询实际电压峰峰值(int channel, CancellationToken ct = default) { - return await 查询通道测量项参数(channel, "PKPK", ct); // + return await 查询通道测量项参数(channel, "PKPK", ct); } /// @@ -199,7 +234,7 @@ namespace DeviceCommand.Device /// public virtual async Task 查询实际频率(int channel, CancellationToken ct = default) { - return await 查询通道测量项参数(channel, "FREQ", ct); // + return await 查询通道测量项参数(channel, "FREQ", ct); } /// @@ -207,7 +242,7 @@ namespace DeviceCommand.Device /// public virtual async Task 查询实际电压均方根(int channel, CancellationToken ct = default) { - return await 查询通道测量项参数(channel, "RMS", ct); // + return await 查询通道测量项参数(channel, "RMS", ct); } #endregion diff --git a/DeviceEditModule/ViewModels/SDS2000X_HDViewModel.cs b/DeviceEditModule/ViewModels/SDS2000X_HDViewModel.cs index e5ba2ca..85b8988 100644 --- a/DeviceEditModule/ViewModels/SDS2000X_HDViewModel.cs +++ b/DeviceEditModule/ViewModels/SDS2000X_HDViewModel.cs @@ -152,8 +152,7 @@ namespace DeviceEditModule.ViewModels public ICommand SetChannelOffCommand { get; } public ICommand SetVoltsDivCommand { get; } public ICommand SetOffsetCommand { get; } - public ICommand SetImpedance50Command { get; } - public ICommand SetImpedance1MCommand { get; } + public ICommand SetTimeBaseCommand { get; } public ICommand SetTriggerLevelCommand { get; } public ICommand SetTriggerSourceCommand { get; } @@ -178,8 +177,7 @@ namespace DeviceEditModule.ViewModels SetChannelOffCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置通道开关(Channel, false, Ct()); AppendLog($"通道 {Channel} 已关闭"); })); SetVoltsDivCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置通道电压档位(Channel, VoltsPerDiv, Ct()); AppendLog($"C{Channel} 电压档位已设为 {VoltsPerDiv} V/div"); })); SetOffsetCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置通道垂直偏移(Channel, Offset, Ct()); AppendLog($"C{Channel} 垂直偏移已设为 {Offset} V"); })); - SetImpedance50Command = new DelegateCommand(async () => await Exec(async () => { await _device!.设置通道输入阻抗(Channel, true, Ct()); AppendLog($"C{Channel} 输入阻抗已设为 50Ω"); })); - SetImpedance1MCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置通道输入阻抗(Channel, false, Ct()); AppendLog($"C{Channel} 输入阻抗已设为 1MΩ"); })); + SetTimeBaseCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置水平时基(TimeBase, Ct()); AppendLog($"水平时基已设为 {TimeBase} s/div"); })); SetTriggerLevelCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置触发电平(TriggerLevel, Ct()); AppendLog($"触发电平已设为 {TriggerLevel} V"); })); SetTriggerSourceCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置触发源(TriggerSource, Ct()); AppendLog($"触发源已设为 {TriggerSource}"); })); diff --git a/SettingModule/Views/SettingView.xaml b/SettingModule/Views/SettingView.xaml index ca90ae7..9da1d2b 100644 --- a/SettingModule/Views/SettingView.xaml +++ b/SettingModule/Views/SettingView.xaml @@ -481,6 +481,7 @@