chroma synthesis模式

This commit is contained in:
“hsc”
2026-10-09 09:23:32 +08:00
parent c017efdb49
commit 8dd08fcc7a
3 changed files with 572 additions and 364 deletions
@@ -8,7 +8,6 @@
xmlns:prism="http://prismlibrary.com/"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare"
xmlns:oxy="http://oxyplot.org/wpf"
prism:ViewModelLocator.AutoWireViewModel="True"
d:DesignHeight="1080"
d:DesignWidth="1920">
@@ -19,7 +18,6 @@
<Border Background="#F5F7FA">
<Grid Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="440" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
@@ -97,6 +95,9 @@
Style="{StaticResource WarnBtn}" />
<Button Content="复位" Command="{Binding ResetCommand}"
Style="{StaticResource CmdBtn}" />
<Button Content="退出远程" Command="{Binding ExitRemoteCommand}"
Style="{StaticResource CmdBtn}"
ToolTip="SYST:LOC:退出远程状态、恢复前面板操作(手册注明僅 RS-232 控制下有效)" />
<Button Content="查询 IDN" Command="{Binding QueryIdnCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
@@ -324,45 +325,88 @@
</StackPanel>
</GroupBox>
<!-- 数据采集 -->
<GroupBox Header="数据采集" Margin="0,0,0,8"
<!-- SYNTHESIS 自定义谐波波形输出 -->
<GroupBox Header="SYNTHESIS 波形输出(自定义谐波)" Margin="0,0,0,8"
materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<StackPanel Margin="4">
<StackPanel Orientation="Horizontal" Margin="0,4">
<Button Content="开始采集" Command="{Binding StartSamplingCommand}"
Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White" />
<Button Content="停止采集" Command="{Binding StopSamplingCommand}"
<TextBlock Text="波形文件" Style="{StaticResource ParamLabel}" />
<ComboBox Width="210" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding SynthPresetOptions}"
SelectedIndex="{Binding SelectedSynthPresetIndex}" />
<Button Content="载入" Command="{Binding LoadSynthPresetCommand}"
Style="{StaticResource CmdBtn}" />
<Button Content="清空图表" Command="{Binding ClearChartsCommand}"
Style="{StaticResource CmdBtn}" />
<TextBlock VerticalAlignment="Center" FontSize="12" Margin="8,0,0,0">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="采集中…" />
<Setter Property="Foreground" Value="#4CAF50" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsSampling}" Value="False">
<Setter Property="Text" Value="采集已停止" />
<Setter Property="Foreground" Value="#9E9E9E" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<CheckBox Content="采集频率" IsChecked="{Binding IsFrequencySamplingEnabled}"
VerticalAlignment="Center" Margin="4,0,10,0"
ToolTip="频率一般无需持续采集;勾选后采样循环才读取频率并绘制到右侧频率曲线" />
<TextBlock Text="频率" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource MeasureBox}"
Text="{Binding FrequencyNow, Mode=OneWay, StringFormat={}{0:F2}}" />
<TextBlock Text="Hz" VerticalAlignment="Center" Margin="2,0,12,0" />
<TextBlock Text="功率" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource MeasureBox}"
Text="{Binding PowerNow, Mode=OneWay, StringFormat={}{0:F2}}" />
<TextBlock Text="W" VerticalAlignment="Center" Margin="2,0,0,0" />
<TextBlock Text="名称" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}" Width="150"
ToolTip="保存时作为文件名(写入 D:\acp\源测试\合成波形);选中已有波形会自动填充,可改名另存"
Text="{Binding SynthPresetName, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="保存" Command="{Binding SaveSynthPresetCommand}"
Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White" />
<Button Content="删除" Command="{Binding DeleteSynthPresetCommand}"
Style="{StaticResource WarnBtn}"
ToolTip="删除下拉框当前选中的波形文件(带二次确认)" />
</StackPanel>
<TextBox Margin="4,0,4,2" FontSize="11" Foreground="#1565C0"
Height="40" TextWrapping="Wrap" AcceptsReturn="True"
VerticalScrollBarVisibility="Auto" VerticalContentAlignment="Top"
ToolTip="波形说明(随文件一并保存)"
Text="{Binding SynthPresetNote, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="{Binding SynthStorageHint}"
FontSize="11" Foreground="#757575"
Margin="4,0,4,4" TextWrapping="Wrap" />
<Separator Margin="0,4" />
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="数据格式" Style="{StaticResource ParamLabel}" />
<ComboBox Width="120" Height="32" FontSize="12" Margin="4,0"
ToolTip="SYNT:COMP,VALUE=绝对值 / PERCENT=基频百分率,后缀 1/2/3 为三段波形"
ItemsSource="{Binding SynthComposeOptions}"
SelectedItem="{Binding SynthCompose}" />
<TextBlock Text="基频" Style="{StaticResource ParamLabel}" />
<ComboBox Width="70" Height="32" FontSize="12" Margin="4,0"
ToolTip="SYNT:FREQ,仅支持 50 / 60 Hz"
ItemsSource="{Binding SynthFrequencyOptions}"
SelectedItem="{Binding SynthFrequency}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="基波电压" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}"
ToolTip="SYNT:FUND,基波交流电压,单位 V,0.0 ~ 300.0"
Text="{Binding SynthFundamental, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="V" VerticalAlignment="Center" Margin="2,0,10,0" />
<TextBlock Text="直流" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}"
ToolTip="SYNT:DC,叠加直流电压,单位 V,-424.2 ~ 424.2"
Text="{Binding SynthDc, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="V" VerticalAlignment="Center" Margin="2,0,0,0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="起始相位" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}"
ToolTip="SYNT:SPH,起始相位角,单位 °,0.0 ~ 359.9"
Text="{Binding SynthStartPhase, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="°" VerticalAlignment="Center" Margin="2,0,0,0" />
</StackPanel>
<TextBlock Text="谐波振幅(SYNT:AMPL,英文逗号分隔,首值=2次谐波,依次 3/4/5…最多 50 阶,留空不下发)"
FontSize="11" Foreground="#616161" Margin="4,4,4,2" TextWrapping="Wrap" />
<TextBox Style="{StaticResource NumInput}" Width="380" HorizontalAlignment="Left" Margin="4,0"
ToolTip="如 0,10,0,5 表示 2次=0、3次=10、4次=0、5次=5(VALUE 为绝对值 V,PERCENT 为基波百分率)"
Text="{Binding SynthAmplitudeText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="谐波相位(SYNT:PHAS,英文逗号分隔,与振幅逐阶对应,单位 °,0~359.9,留空不下发)"
FontSize="11" Foreground="#616161" Margin="4,4,4,2" TextWrapping="Wrap" />
<TextBox Style="{StaticResource NumInput}" Width="380" HorizontalAlignment="Left" Margin="4,0"
ToolTip="如 0,180,90 与振幅序列逐阶对应"
Text="{Binding SynthPhaseText, UpdateSourceTrigger=PropertyChanged}" />
<Separator Margin="0,6" />
<StackPanel Orientation="Horizontal" Margin="0,4">
<Button Content="下发并启动 SYNTH" Command="{Binding DownloadSynthesisCommand}"
Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White" />
<Button Content="停止 SYNTH" Command="{Binding SynthStopCommand}"
Style="{StaticResource WarnBtn}" />
</StackPanel>
</StackPanel>
</GroupBox>
@@ -379,70 +423,6 @@
</GroupBox>
</StackPanel>
</ScrollViewer>
<!-- ============ 右侧:三相电压 + 输出频率(横轴为采集经过时间 s) ============ -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- 三相电压 -->
<Border Grid.Row="0" Background="White" BorderBrush="#DDD" BorderThickness="1" Margin="0,0,0,4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="10,6">
<TextBlock Text="三相电压 (V)" FontWeight="Bold" FontSize="13"
VerticalAlignment="Center" Margin="0,0,16,0" />
<TextBlock Text="A" FontSize="12" Foreground="#E53935" VerticalAlignment="Center" />
<TextBlock Text="{Binding VoltageA, StringFormat={}{0:F1}}" FontSize="12"
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,14,0" />
<TextBlock Text="B" FontSize="12" Foreground="#43A047" VerticalAlignment="Center" />
<TextBlock Text="{Binding VoltageB, StringFormat={}{0:F1}}" FontSize="12"
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,14,0" />
<TextBlock Text="C" FontSize="12" Foreground="#1E88E5" VerticalAlignment="Center" />
<TextBlock Text="{Binding VoltageC, StringFormat={}{0:F1}}" FontSize="12"
FontWeight="Bold" VerticalAlignment="Center" Margin="3,0,0,0" />
</StackPanel>
<oxy:PlotView Grid.Row="1" Model="{Binding VoltagePlot}"
Background="Transparent" Margin="4,0,4,4" />
</Grid>
</Border>
<!-- 输出频率(受左侧“采集频率”开关控制,一般不采集) -->
<Border Grid.Row="1" Background="White" BorderBrush="#DDD" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="10,6">
<TextBlock Text="输出频率 (Hz)" FontWeight="Bold" FontSize="13"
VerticalAlignment="Center" Margin="0,0,16,0" />
<TextBlock Text="{Binding FrequencyNow, StringFormat={}{0:F2}}" FontSize="12"
FontWeight="Bold" Foreground="#8E24AA" VerticalAlignment="Center" Margin="3,0,14,0" />
<TextBlock FontSize="11" Foreground="#4CAF50" VerticalAlignment="Center">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="频率采集中" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsFrequencySamplingEnabled}" Value="False">
<Setter Property="Text" Value="频率采集未开启(在左侧“数据采集”勾选后才会绘制)" />
<Setter Property="Foreground" Value="#9E9E9E" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
<oxy:PlotView Grid.Row="1" Model="{Binding FrequencyPlot}"
Background="Transparent" Margin="4,0,4,4" />
</Grid>
</Border>
</Grid>
</Grid>
</Border>
</UserControl>