list更改

This commit is contained in:
“hsc”
2026-09-24 15:20:29 +08:00
parent 81c6386e62
commit c017efdb49
5 changed files with 1057 additions and 278 deletions
+167
View File
@@ -2,6 +2,7 @@
using DeviceCommand.Base; using DeviceCommand.Base;
using Model.Models; using Model.Models;
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
@@ -39,6 +40,26 @@ namespace DeviceCommand.Devices
: 0; : 0;
} }
/// <summary>
/// 从设备返回的 SCPI 响应字符串中提取全部数值并按顺序转换为 double 数组。
/// 用于解析形如 "1.2,3.4,5.6" 的多值响应(如谐波振幅数组 MEAS:HARM:ARR?)。
/// 兼容逗号/分号/空格分隔及科学计数法。
/// </summary>
/// <param name="raw">设备返回的原始字符串</param>
/// <returns>按出现顺序排列的数值数组,无有效数值时返回空数组</returns>
private static double[] ExtractDoubleArray(string raw)
{
if (string.IsNullOrWhiteSpace(raw)) return Array.Empty<double>();
var values = new List<double>();
foreach (Match m in Regex.Matches(raw, @"[+-]?(?:\d+\.?\d*|\.\d+)(?:[Ee][+-]?\d+)?"))
{
if (double.TryParse(m.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out double v))
values.Add(v);
}
return values.ToArray();
}
#region 1. 基础系统与公共指令 #region 1. 基础系统与公共指令
/// <summary> /// <summary>
@@ -65,6 +86,17 @@ namespace DeviceCommand.Devices
return await WriteReadAsync($"*IDN?{ScpiDelimiter}", ScpiDelimiter, ct); return await WriteReadAsync($"*IDN?{ScpiDelimiter}", ScpiDelimiter, ct);
} }
/// <summary>
/// 命令流延时 (*D)
/// <para>在 SCPI 命令流中插入一段延时(单位: ms),常用于 LIST 参数下发完成后、切换 OUTP:MODE 之前等待仪器就绪</para>
/// </summary>
/// <param name="milliseconds">延时时长 (ms)</param>
public virtual async Task 延时Async(double milliseconds, CancellationToken ct = default)
{
string valStr = milliseconds.ToString("0.###", CultureInfo.InvariantCulture);
await SendAsync($"*D {valStr}{ScpiDelimiter}", ct);
}
#endregion #endregion
#region 2. 基础输出与耦合控制 (OUTPut 子系统) #region 2. 基础输出与耦合控制 (OUTPut 子系统)
@@ -161,6 +193,37 @@ namespace DeviceCommand.Devices
await SendAsync($"PHASE:THREE {relation}{ScpiDelimiter}", ct); await SendAsync($"PHASE:THREE {relation}{ScpiDelimiter}", ct);
} }
/// <summary>
/// 设置相位耦合模式 (INST:COUP)
/// <para>ALL: 后续命令发送至所有相位; NONE: 仅发送至 NSEL 选定的相位</para>
/// </summary>
/// <param name="coupling">耦合模式: ALL | NONE</param>
public virtual async Task 设置相位耦合Async(string coupling, CancellationToken ct = default)
{
await SendAsync($"INST:COUP {coupling}{ScpiDelimiter}", ct);
}
/// <summary>
/// 按编号选择输出相位 (INST:NSEL)
/// <para>仅在 INST:COUP NONE 时生效,后续 SOURCE 命令将作用于选定相位</para>
/// </summary>
/// <param name="phase">相位编号: 1(A相) | 2(B相) | 3(C相)</param>
public virtual async Task 选择相位Async(int phase, CancellationToken ct = default)
{
await SendAsync($"INST:NSEL {phase}{ScpiDelimiter}", ct);
}
/// <summary>
/// 设置参数编辑方式 (INST:EDIT)
/// <para>EACH: 逐相独立编辑,配合 <see cref="选择相位Async"/> 分别为 A/B/C 三相下发各自的 LIST/参数;
/// ALL: 三相统一编辑,一次下发同时作用于三相</para>
/// </summary>
/// <param name="mode">编辑方式: EACH | ALL</param>
public virtual async Task 设置编辑方式Async(string mode, CancellationToken ct = default)
{
await SendAsync($"INST:EDIT {mode}{ScpiDelimiter}", ct);
}
/// <summary> /// <summary>
/// 设置输出开启相位角 (PHASE:ON) /// 设置输出开启相位角 (PHASE:ON)
/// </summary> /// </summary>
@@ -387,6 +450,110 @@ namespace DeviceCommand.Devices
await SendAsync($"TRIG {state}{ScpiDelimiter}", ct); await SendAsync($"TRIG {state}{ScpiDelimiter}", ct);
} }
/// <summary>
/// 查询列表触发执行状态 (TRIG:STATE?)
/// <para>返回 ON 表示 LIST 正在执行,OFF 表示已执行完毕;
/// 重新下发 LIST 参数前应先轮询本命令等待其变为 OFF,避免执行中被改写</para>
/// </summary>
/// <param name="ct">取消令牌</param>
/// <returns>true: 正在执行(ON); false: 已结束(OFF)</returns>
public virtual async Task<bool> 查询触发状态Async(CancellationToken ct = default)
{
string resp = await WriteReadAsync($"TRIG:STATE?{ScpiDelimiter}", ScpiDelimiter, ct);
return resp != null && resp.Trim().StartsWith("ON", StringComparison.OrdinalIgnoreCase);
}
#endregion
#region 7. 谐波量测 (Harmonic Sense 子系统)
/// <summary>
/// 设置谐波分析的测量来源 (CONFigure:HARMonic:SOURce)
/// </summary>
/// <param name="source">VOLT: 输出电压; CURR: 输出电流</param>
public virtual async Task 设置谐波量测源Async(string source, CancellationToken ct = default)
{
// 有效参数: VOLT, CURR
await SendAsync($"CONF:HARM:SOUR {source}{ScpiDelimiter}", ct);
}
/// <summary>
/// 设置谐波量测结果显示方式 (CONFigure:HARMonic:TIMES)
/// <para>SINGLE: 保留单次测量结果,约需 3 秒; CONTINUE: 持续更新,约需 10 秒稳定</para>
/// </summary>
/// <param name="times">显示方式: SINGLE | CONTINUE</param>
public virtual async Task 设置谐波量测方式Async(string times, CancellationToken ct = default)
{
// 有效参数: SINGLE, CONTINUE
await SendAsync($"CONF:HARM:TIM {times}{ScpiDelimiter}", ct);
}
/// <summary>
/// 设置每个谐波阶的数据格式 (CONFigure:HARMonic:PARameter)
/// </summary>
/// <param name="parameter">VALUE: 绝对值; PERCENT: 基频百分率</param>
public virtual async Task 设置谐波数据格式Async(string parameter, CancellationToken ct = default)
{
// 有效参数: VALUE, PERCENT
await SendAsync($"CONF:HARM:PAR {parameter}{ScpiDelimiter}", ct);
}
/// <summary>
/// 设置谐波分析的原始波形基频 (CONFigure:HARMonic:FREQuency)
/// </summary>
/// <param name="frequency">基频: 50 或 60 (Hz)</param>
public virtual async Task 设置谐波基频Async(int frequency, CancellationToken ct = default)
{
await SendAsync($"CONF:HARM:FREQ {frequency}{ScpiDelimiter}", ct);
}
/// <summary>
/// 开启/关闭谐波量测 (SENSe:HARMonic)
/// <para>每次新的 Fetch/Measure 前必须先 ON,约需 3 秒得到结果;
/// 若要量测其他数据,须先设回 OFF。分相量测配合 INST:COUP NONE + INST:NSEL 逐相进行</para>
/// </summary>
/// <param name="isOn">true: 开启谐波量测(ON); false: 关闭(OFF)</param>
public virtual async Task 设置谐波量测开关Async(bool isOn, CancellationToken ct = default)
{
string state = isOn ? "ON" : "OFF";
await SendAsync($"SENS:HARM {state}{ScpiDelimiter}", ct);
}
/// <summary>
/// 查询总谐波失真 (MEASure:HARMonic:THD?)
/// </summary>
/// <param name="ct">取消令牌</param>
/// <returns>总谐波失真 THD (单位: %,保留两位小数)</returns>
public virtual async Task<double> 查询谐波总失真Async(CancellationToken ct = default)
{
string resp = await WriteReadAsync($"MEAS:HARM:THD?{ScpiDelimiter}", ScpiDelimiter, ct);
return ExtractDouble(resp);
}
/// <summary>
/// 查询输出电压/电流的基频幅值 (MEASure:HARMonic:FUNDamental?)
/// </summary>
/// <param name="ct">取消令牌</param>
/// <returns>基频幅值 (单位依 CONF:HARM:PAR 为 V/A 绝对值或百分率)</returns>
public virtual async Task<double> 查询谐波基频幅值Async(CancellationToken ct = default)
{
string resp = await WriteReadAsync($"MEAS:HARM:FUND?{ScpiDelimiter}", ScpiDelimiter, ct);
return ExtractDouble(resp);
}
/// <summary>
/// 查询所有谐波阶的振幅数组 (MEASure:HARMonic:ARRay?)
/// <para>手册 5.7 谐波测量:可量测 2~50 阶谐波,来源可选输出电压(VOLT)或电流(CURR)。
/// 注意:仅返回各阶振幅,不含各阶相位角,故据此重构的波形形状为"同相叠加"近似</para>
/// </summary>
/// <param name="ct">取消令牌</param>
/// <returns>各次谐波振幅数组(按阶次升序;单位依 CONF:HARM:PAR)</returns>
public virtual async Task<double[]> 查询谐波振幅数组Async(CancellationToken ct = default)
{
string resp = await WriteReadAsync($"MEAS:HARM:ARR?{ScpiDelimiter}", ScpiDelimiter, ct);
return ExtractDoubleArray(resp);
}
#endregion #endregion
} }
@@ -2,6 +2,7 @@ using DeviceCommand.Devices;
using Prism.Commands; using Prism.Commands;
using Prism.Ioc; using Prism.Ioc;
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
@@ -30,6 +31,12 @@ namespace DeviceEditModule.ViewModels
private double _voltage; public double Voltage { get => _voltage; set => SetProperty(ref _voltage, value); } private double _voltage; public double Voltage { get => _voltage; set => SetProperty(ref _voltage, value); }
private double _frequency = 50; public double Frequency { get => _frequency; set => SetProperty(ref _frequency, value); } private double _frequency = 50; public double Frequency { get => _frequency; set => SetProperty(ref _frequency, value); }
private string _waveform = "SINE"; public string Waveform { get => _waveform; set => SetProperty(ref _waveform, value); } private string _waveform = "SINE"; public string Waveform { get => _waveform; set => SetProperty(ref _waveform, value); }
/// <summary>相位选择列表: 0=ALL(三相同时), 1=A相, 2=B相, 3=C相</summary>
public List<string> PhaseOptions { get; } = new() { "ALL (三相)", "A相 (Φ1)", "B相 (Φ2)", "C相 (Φ3)" };
private int _selectedPhaseIndex;
/// <summary>当前选中的相位索引 (0=ALL, 1=A, 2=B, 3=C)</summary>
public int SelectedPhaseIndex { get => _selectedPhaseIndex; set => SetProperty(ref _selectedPhaseIndex, value); }
#endregion #endregion
#region 测量结果 #region 测量结果
@@ -60,18 +67,34 @@ namespace DeviceEditModule.ViewModels
Reset = new DelegateCommand(async () => await Exec(async () => { await _dev!.复位Async(Ct()); Log("设备已复位"); })); Reset = new DelegateCommand(async () => await Exec(async () => { await _dev!.复位Async(Ct()); Log("设备已复位"); }));
OutOn = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置输出开关Async(true, Ct()); Log("输出已开启"); })); OutOn = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置输出开关Async(true, Ct()); Log("输出已开启"); }));
OutOff = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置输出开关Async(false, Ct()); Log("输出已关闭"); })); OutOff = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置输出开关Async(false, Ct()); Log("输出已关闭"); }));
SetV = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置交流电压Async(Voltage, Ct()); Log($"电压={Voltage}V"); })); SetV = new DelegateCommand(async () => await Exec(async () =>
SetF = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置频率Async(Frequency, Ct()); Log($"频率={Frequency}Hz"); })); {
SetWave = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置波形Async(Waveform, Ct()); Log($"波形={Waveform}"); })); await ApplyPhaseAsync();
await _dev!.设置交流电压Async(Voltage, Ct());
Log($"电压={Voltage}V → {PhaseLabel}");
}));
SetF = new DelegateCommand(async () => await Exec(async () =>
{
await ApplyPhaseAsync();
await _dev!.设置频率Async(Frequency, Ct());
Log($"频率={Frequency}Hz → {PhaseLabel}");
}));
SetWave = new DelegateCommand(async () => await Exec(async () =>
{
await ApplyPhaseAsync();
await _dev!.设置波形Async(Waveform, Ct());
Log($"波形={Waveform} → {PhaseLabel}");
}));
SetThreePhase = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置单三相模式Async(true, Ct()); Log("三相模式"); })); SetThreePhase = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置单三相模式Async(true, Ct()); Log("三相模式"); }));
SetSinglePhase = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置单三相模式Async(false, Ct()); Log("单相模式"); })); SetSinglePhase = new DelegateCommand(async () => await Exec(async () => { await _dev!.设置单三相模式Async(false, Ct()); Log("单相模式"); }));
QMeas = new DelegateCommand(async () => await Exec(async () => QMeas = new DelegateCommand(async () => await Exec(async () =>
{ {
await ApplyPhaseAsync();
MeasuredVoltage = await _dev!.读取交流电压Async(Ct()); MeasuredVoltage = await _dev!.读取交流电压Async(Ct());
MeasuredCurrent = await _dev!.读取交流电流Async(Ct()); MeasuredCurrent = await _dev!.读取交流电流Async(Ct());
MeasuredFrequency = await _dev!.读取频率Async(Ct()); MeasuredFrequency = await _dev!.读取频率Async(Ct());
MeasuredPower = await _dev!.读取真实功率Async(Ct()); MeasuredPower = await _dev!.读取真实功率Async(Ct());
Log($"测量→V:{MeasuredVoltage} I:{MeasuredCurrent} F:{MeasuredFrequency} P:{MeasuredPower}"); Log($"测量[{PhaseLabel}]→V:{MeasuredVoltage} I:{MeasuredCurrent} F:{MeasuredFrequency} P:{MeasuredPower}");
})); }));
Initialize(); Initialize();
} }
@@ -106,6 +129,32 @@ namespace DeviceEditModule.ViewModels
#region 辅助 #region 辅助
/// <summary>当前选中相位的显示标签</summary>
private string PhaseLabel => SelectedPhaseIndex switch
{
1 => "A相",
2 => "B相",
3 => "C相",
_ => "ALL"
};
/// <summary>
/// 根据 SelectedPhaseIndex 发送 INST:COUP / INST:NSEL 命令切换相位上下文。
/// <para>索引 0 → INST:COUP ALL (三相同时);索引 1~3 → INST:COUP NONE + INST:NSEL n</para>
/// </summary>
private async Task ApplyPhaseAsync()
{
if (SelectedPhaseIndex == 0)
{
await _dev!.设置相位耦合Async("ALL", Ct());
}
else
{
await _dev!.设置相位耦合Async("NONE", Ct());
await _dev!.选择相位Async(SelectedPhaseIndex, Ct());
}
}
private CancellationToken Ct() => (_cts = new CancellationTokenSource(TimeSpan.FromSeconds(10))).Token; private CancellationToken Ct() => (_cts = new CancellationTokenSource(TimeSpan.FromSeconds(10))).Token;
private async Task Exec(Func<Task> action) private async Task Exec(Func<Task> action)
@@ -94,6 +94,12 @@
</StackPanel> </StackPanel>
<GroupBox Header="参数设置" Margin="0,0,0,8" materialDesign:ColorZoneAssist.Mode="PrimaryLight"> <GroupBox Header="参数设置" Margin="0,0,0,8" materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<StackPanel Margin="4"> <StackPanel Margin="4">
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="相位选择" Style="{StaticResource ParamLabel}"/>
<ComboBox Width="130" VerticalAlignment="Center" Margin="4,0"
ItemsSource="{Binding PhaseOptions}"
SelectedIndex="{Binding SelectedPhaseIndex}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4"> <StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="电压 (V)" Style="{StaticResource ParamLabel}"/> <TextBlock Text="电压 (V)" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource NumInput}" <TextBox Style="{StaticResource NumInput}"
File diff suppressed because it is too large Load Diff
@@ -137,6 +137,12 @@
<GroupBox Header="输出参数设置" Margin="0,0,0,8" <GroupBox Header="输出参数设置" Margin="0,0,0,8"
materialDesign:ColorZoneAssist.Mode="PrimaryLight"> materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<StackPanel Margin="4"> <StackPanel Margin="4">
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="相位选择" Style="{StaticResource ParamLabel}" />
<ComboBox Width="130" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding PhaseOptions}"
SelectedIndex="{Binding SelectedPhaseIndex}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4"> <StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="电压 (V)" Style="{StaticResource ParamLabel}" /> <TextBlock Text="电压 (V)" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}" <TextBox Style="{StaticResource NumInput}"
@@ -162,10 +168,40 @@
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
<!-- LIST 模式 --> <!-- LIST 模式(三相独立) -->
<GroupBox Header="LIST 模式" Margin="0,0,0,8" <GroupBox Header="LIST 模式(三相独立)" Margin="0,0,0,8"
materialDesign:ColorZoneAssist.Mode="PrimaryLight"> materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<StackPanel Margin="4"> <StackPanel Margin="4">
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="测试项" Style="{StaticResource ParamLabel}" />
<ComboBox Width="230" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding PresetOptions}"
SelectedIndex="{Binding SelectedPresetIndex}" />
<Button Content="载入" Command="{Binding LoadPresetCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="名称" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}" Width="150"
ToolTip="保存时作为文件名(写入 D:\acp\源测试);选中已有测试项会自动填充,可改名另存"
Text="{Binding PresetName, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="保存" Command="{Binding SavePresetCommand}"
Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White" />
<Button Content="删除" Command="{Binding DeletePresetCommand}"
Style="{StaticResource WarnBtn}"
ToolTip="删除下拉框当前选中的测试项文件(带二次确认)" />
</StackPanel>
<TextBox Margin="4,0,4,2" FontSize="11" Foreground="#1565C0"
Height="46" TextWrapping="Wrap" AcceptsReturn="True"
VerticalScrollBarVisibility="Auto" VerticalContentAlignment="Top"
ToolTip="测试项说明(随文件一并保存)"
Text="{Binding PresetNote, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="{Binding PresetStorageHint}"
FontSize="11" Foreground="#757575"
Margin="4,0,4,4" TextWrapping="Wrap" />
<Separator Margin="0,4" />
<StackPanel Orientation="Horizontal" Margin="0,4"> <StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="操作模态" Style="{StaticResource ParamLabel}" /> <TextBlock Text="操作模态" Style="{StaticResource ParamLabel}" />
<Button Content="FIXED 固定" Command="{Binding SetFixedModeCommand}" <Button Content="FIXED 固定" Command="{Binding SetFixedModeCommand}"
@@ -174,32 +210,37 @@
Style="{StaticResource CmdBtn}" /> Style="{StaticResource CmdBtn}" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4"> <StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="列表耦合" Style="{StaticResource ParamLabel}" /> <TextBlock Text="执行次数" Style="{StaticResource ParamLabel}" />
<ComboBox Width="80" Height="32" FontSize="12" Margin="4,0" <TextBox Style="{StaticResource NumInput}" Width="60"
ItemsSource="{Binding ListCouplingOptions}" ToolTip="0 = 无限循环"
SelectedItem="{Binding ListCoupling}" /> Text="{Binding ListCount, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="触发" Style="{StaticResource ParamLabel}" /> <TextBlock Text="触发" Style="{StaticResource ParamLabel}" />
<ComboBox Width="100" Height="32" FontSize="12" Margin="4,0" <ComboBox Width="88" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding ListTriggerOptions}" ItemsSource="{Binding ListTriggerOptions}"
SelectedItem="{Binding ListTrigger}" /> SelectedItem="{Binding ListTrigger}" />
</StackPanel> <TextBlock Text="时基" Style="{StaticResource ParamLabel}" />
<StackPanel Orientation="Horizontal" Margin="0,4"> <ComboBox Width="80" Height="32" FontSize="12" Margin="4,0"
<TextBlock Text="执行次数" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}" Width="80"
Text="{Binding ListCount, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="时间基础" Style="{StaticResource ParamLabel}" />
<ComboBox Width="90" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding ListTimeBaseOptions}" ItemsSource="{Binding ListTimeBaseOptions}"
SelectedItem="{Binding ListTimeBase}" /> SelectedItem="{Binding ListTimeBase}" />
</StackPanel> </StackPanel>
<Button Content="应用基础配置(耦合 / 触发 / 次数 / 时基)"
Command="{Binding ApplyListBasicCommand}"
Style="{StaticResource CmdBtn}"
HorizontalAlignment="Left" Margin="0,4" />
<Separator Margin="0,6" /> <Separator Margin="0,6" />
<TextBlock Text="序列设置(英文逗号分隔,留空则不下发)" <StackPanel Orientation="Horizontal" Margin="0,4">
FontSize="12" Foreground="#616161" Margin="4,2" /> <TextBlock Text="编辑相位" Style="{StaticResource ParamLabel}" />
<ComboBox Width="100" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding ListPhaseOptions}"
SelectedIndex="{Binding ListEditPhaseIndex}" />
<TextBlock Text="该相波形" Style="{StaticResource ParamLabel}" />
<ComboBox Width="80" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding WaveformOptions}"
SelectedItem="{Binding ListWaveform}" />
</StackPanel>
<Button Content="复制当前相到三相(B/C 相位角自动 ±120°)"
Command="{Binding CopyPhaseToThreeCommand}"
Style="{StaticResource CmdBtn}"
HorizontalAlignment="Left" Margin="0,4" />
<TextBlock Text="序列设置(英文逗号分隔,留空则不下发;作用于上方选中的相位)"
FontSize="12" Foreground="#616161" Margin="4,2" TextWrapping="Wrap" />
<Grid Margin="0,2"> <Grid Margin="0,2">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="92" /> <ColumnDefinition Width="92" />
@@ -213,60 +254,71 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="AC起始电压" <TextBlock Grid.Row="0" Grid.Column="0" Text="相位角度"
Style="{StaticResource ParamLabel}" /> Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource NumInput}" <TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="单位 V,如 0,50,100,150" Width="240" ToolTip="LIST:DEGR,单位 °,如 0,90,0;三相基准 0/120/240"
Text="{Binding ListVoltAcStartText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="AC结束电压"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="单位 V,如 150,100,50,0"
Text="{Binding ListVoltAcEndText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="起始频率"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="2" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="单位 Hz,如 50,60,50"
Text="{Binding ListFreqStartText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="结束频率"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="3" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="单位 Hz,如 50,50,60"
Text="{Binding ListFreqEndText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="4" Grid.Column="0" Text="静止时间"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="4" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="单位 ms,如 500,500,500"
Text="{Binding ListDwellText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="5" Grid.Column="0" Text="相位角度"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="5" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="单位 °,如 0,120,240"
Text="{Binding ListDegrText, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding ListDegrText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="6" Grid.Column="0" Text="波形顺序" <TextBlock Grid.Row="1" Grid.Column="0" Text="AC起始电压"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:VOLT:AC:STAR,单位 V,如 230,11.5,230"
Text="{Binding ListVoltAcStartText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="AC结束电压"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="2" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:VOLT:AC:END,单位 V,如 230,11.5,230"
Text="{Binding ListVoltAcEndText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="DC起始电压"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="3" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:VOLT:DC:STAR,单位 V,如 10,10,10"
Text="{Binding ListVoltDcStartText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="4" Grid.Column="0" Text="DC结束电压"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="4" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:VOLT:DC:END,单位 V,如 10,10,10"
Text="{Binding ListVoltDcEndText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="5" Grid.Column="0" Text="起始频率"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="5" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:FREQ:STAR,单位 Hz,如 50,50,50"
Text="{Binding ListFreqStartText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="6" Grid.Column="0" Text="结束频率"
Style="{StaticResource ParamLabel}" /> Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="6" Grid.Column="1" Style="{StaticResource NumInput}" <TextBox Grid.Row="6" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="A / B 序列,如 A,B,A" Width="240" ToolTip="LIST:FREQ:END,单位 Hz,如 50,50,50"
Text="{Binding ListFreqEndText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="7" Grid.Column="0" Text="静止时间"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="7" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:DWEL,单位 ms,如 20000,280,20000"
Text="{Binding ListDwellText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="8" Grid.Column="0" Text="波形顺序"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="8" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:SHAP,A / B 序列,如 A,A,A(可留空)"
Text="{Binding ListShapeText, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding ListShapeText, UpdateSourceTrigger=PropertyChanged}" />
</Grid> </Grid>
<Button Content="应用序列" Command="{Binding ApplyListSequencesCommand}"
Style="{StaticResource CmdBtn}"
HorizontalAlignment="Left" Margin="0,4" />
<Separator Margin="0,6" /> <Separator Margin="0,6" />
<StackPanel Orientation="Horizontal" Margin="0,4"> <StackPanel Orientation="Horizontal" Margin="0,4">
<Button Content="开始执行" Command="{Binding ListStartCommand}" <Button Content="下发三相并启动 LIST" Command="{Binding DownloadThreePhaseListCommand}"
Style="{StaticResource CmdBtn}" Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White" /> Background="#388E3C" Foreground="White" />
<Button Content="停止执行" Command="{Binding ListStopCommand}" <Button Content="停止 LIST" Command="{Binding ListStopCommand}"
Style="{StaticResource WarnBtn}" /> Style="{StaticResource WarnBtn}" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
@@ -300,6 +352,9 @@
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4"> <StackPanel Orientation="Horizontal" Margin="0,4">
<CheckBox Content="采集频率" IsChecked="{Binding IsFrequencySamplingEnabled}"
VerticalAlignment="Center" Margin="4,0,10,0"
ToolTip="频率一般无需持续采集;勾选后采样循环才读取频率并绘制到右侧频率曲线" />
<TextBlock Text="频率" Style="{StaticResource ParamLabel}" /> <TextBlock Text="频率" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource MeasureBox}" <TextBox Style="{StaticResource MeasureBox}"
Text="{Binding FrequencyNow, Mode=OneWay, StringFormat={}{0:F2}}" /> Text="{Binding FrequencyNow, Mode=OneWay, StringFormat={}{0:F2}}" />
@@ -325,12 +380,11 @@
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
<!-- ============ 右侧:三相正弦波(电压 / 电流 / 功率,横轴相位角 0~360°,有正有负) ============ --> <!-- ============ 右侧:三相电压 + 输出频率(横轴为采集经过时间 s) ============ -->
<Grid Grid.Column="1"> <Grid Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 三相电压 --> <!-- 三相电压 -->
@@ -358,49 +412,33 @@
</Grid> </Grid>
</Border> </Border>
<!-- 三相电流 --> <!-- 输出频率(受左侧“采集频率”开关控制,一般不采集) -->
<Border Grid.Row="1" Background="White" BorderBrush="#DDD" BorderThickness="1" Margin="0,0,0,4"> <Border Grid.Row="1" Background="White" BorderBrush="#DDD" BorderThickness="1">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="10,6"> <StackPanel Orientation="Horizontal" Margin="10,6">
<TextBlock Text="三相电流 (A)" FontWeight="Bold" FontSize="13" <TextBlock Text="输出频率 (Hz)" FontWeight="Bold" FontSize="13"
VerticalAlignment="Center" Margin="0,0,16,0" /> VerticalAlignment="Center" Margin="0,0,16,0" />
<TextBlock Text="A" FontSize="12" Foreground="#E53935" VerticalAlignment="Center" /> <TextBlock Text="{Binding FrequencyNow, StringFormat={}{0:F2}}" FontSize="12"
<TextBlock Text="{Binding CurrentA, StringFormat={}{0:F2}}" FontSize="12" FontWeight="Bold" Foreground="#8E24AA" VerticalAlignment="Center" Margin="3,0,14,0" />
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,14,0" /> <TextBlock FontSize="11" Foreground="#4CAF50" VerticalAlignment="Center">
<TextBlock Text="B" FontSize="12" Foreground="#43A047" VerticalAlignment="Center" /> <TextBlock.Style>
<TextBlock Text="{Binding CurrentB, StringFormat={}{0:F2}}" FontSize="12" <Style TargetType="TextBlock">
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,14,0" /> <Setter Property="Text" Value="频率采集中" />
<TextBlock Text="C" FontSize="12" Foreground="#1E88E5" VerticalAlignment="Center" /> <Style.Triggers>
<TextBlock Text="{Binding CurrentC, StringFormat={}{0:F2}}" FontSize="12" <DataTrigger Binding="{Binding IsFrequencySamplingEnabled}" Value="False">
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,0,0" /> <Setter Property="Text" Value="频率采集未开启(在左侧“数据采集”勾选后才会绘制)" />
<Setter Property="Foreground" Value="#9E9E9E" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel> </StackPanel>
<oxy:PlotView Grid.Row="1" Model="{Binding CurrentPlot}" <oxy:PlotView Grid.Row="1" Model="{Binding FrequencyPlot}"
Background="Transparent" Margin="4,0,4,4" />
</Grid>
</Border>
<!-- 三相功率 -->
<Border Grid.Row="2" Background="White" BorderBrush="#DDD" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="10,6">
<TextBlock Text="三相功率 (W)" FontWeight="Bold" FontSize="13"
VerticalAlignment="Center" Margin="0,0,16,0" />
<TextBlock Text="总有功" FontSize="12" Foreground="#616161" VerticalAlignment="Center" />
<TextBlock Text="{Binding PowerNow, StringFormat={}{0:F1}}" FontSize="12"
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,14,0" />
<TextBlock Text="频率" FontSize="12" Foreground="#616161" VerticalAlignment="Center" />
<TextBlock Text="{Binding FrequencyNow, StringFormat={}{0:F2} Hz}" FontSize="12"
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,0,0" />
</StackPanel>
<oxy:PlotView Grid.Row="1" Model="{Binding PowerPlot}"
Background="Transparent" Margin="4,0,4,4" /> Background="Transparent" Margin="4,0,4,4" />
</Grid> </Grid>
</Border> </Border>