Files
ACP/PowerAdaptabilityModule/Views/PowerAdaptabilityView.xaml
T
2026-09-24 15:20:29 +08:00

449 lines
32 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<UserControl x:Class="PowerAdaptabilityModule.Views.PowerAdaptabilityView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
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">
<UserControl.Resources>
<converters:BooleanToVisibilityConverter x:Key="BoolToVis" />
</UserControl.Resources>
<Border Background="#F5F7FA">
<Grid Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="440" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- ============ 左侧:Chroma 命令面板 ============ -->
<ScrollViewer Grid.Column="0"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
Margin="0,0,8,0">
<StackPanel>
<!-- 设备状态卡片 -->
<materialDesign:Card Margin="0,0,0,8" Padding="12,8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="Flash"
Width="22" Height="22"
Foreground="#1565C0"
Margin="0,0,8,0"
VerticalAlignment="Center" />
<TextBlock Text="电源适应性测试 · Chroma61800"
FontSize="15" FontWeight="Bold"
VerticalAlignment="Center" />
<TextBlock Text="{Binding DeviceName, StringFormat=' [{0}]'}"
FontSize="13" Foreground="#757575"
VerticalAlignment="Center" Margin="4,0,0,0" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center">
<Border Width="10" Height="10" CornerRadius="5" Margin="0,0,6,0">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="#F44336" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsConnected}" Value="True">
<Setter Property="Background" Value="#4CAF50" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
<TextBlock VerticalAlignment="Center" FontSize="12">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="未连接" />
<Setter Property="Foreground" Value="#F44336" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsConnected}" Value="True">
<Setter Property="Text" Value="已连接" />
<Setter Property="Foreground" Value="#4CAF50" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<ProgressBar IsIndeterminate="True" Width="60" Height="4"
Margin="12,0,0,0"
Visibility="{Binding IsBusy, Converter={StaticResource BoolToVis}}" />
</StackPanel>
</Grid>
</materialDesign:Card>
<!-- 三相输出控制 -->
<GroupBox Header="三相输出控制" Margin="0,0,0,8"
materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<StackPanel Margin="4">
<StackPanel Orientation="Horizontal" Margin="0,4">
<Button Content="开启输出" Command="{Binding OutputOnCommand}"
Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White" />
<Button Content="关闭输出" Command="{Binding OutputOffCommand}"
Style="{StaticResource WarnBtn}" />
<Button Content="复位" Command="{Binding ResetCommand}"
Style="{StaticResource CmdBtn}" />
<Button Content="查询 IDN" Command="{Binding QueryIdnCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="相模式" Style="{StaticResource ParamLabel}" />
<Button Content="三相" Command="{Binding SetThreePhaseModeCommand}"
Style="{StaticResource CmdBtn}" />
<Button Content="单相" Command="{Binding SetSinglePhaseModeCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="耦合模式" Style="{StaticResource ParamLabel}" />
<ComboBox Width="110" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding CouplingOptions}"
SelectedItem="{Binding CouplingMode}" />
<Button Content="应用" Command="{Binding ApplyCouplingCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="三相关系" Style="{StaticResource ParamLabel}" />
<ComboBox Width="110" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding RelationOptions}"
SelectedItem="{Binding ThreePhaseRelation}" />
<Button Content="应用" Command="{Binding ApplyRelationCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="输出继电器" Style="{StaticResource ParamLabel}" />
<Button Content="开启" Command="{Binding RelayOnCommand}"
Style="{StaticResource CmdBtn}" />
<Button Content="关闭" Command="{Binding RelayOffCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
</StackPanel>
</GroupBox>
<!-- 输出参数设置 -->
<GroupBox Header="输出参数设置" Margin="0,0,0,8"
materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<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">
<TextBlock Text="电压 (V)" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}"
Text="{Binding Voltage, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="设置" Command="{Binding SetVoltageCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="频率 (Hz)" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}"
Text="{Binding Frequency, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="设置" Command="{Binding SetFrequencyCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="波形" Style="{StaticResource ParamLabel}" />
<ComboBox Width="130" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding WaveformOptions}"
SelectedItem="{Binding Waveform}" />
<Button Content="设置" Command="{Binding SetWaveformCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
</StackPanel>
</GroupBox>
<!-- LIST 模式(三相独立) -->
<GroupBox Header="LIST 模式(三相独立)" Margin="0,0,0,8"
materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<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">
<TextBlock Text="操作模态" Style="{StaticResource ParamLabel}" />
<Button Content="FIXED 固定" Command="{Binding SetFixedModeCommand}"
Style="{StaticResource CmdBtn}" />
<Button Content="进入 LIST" Command="{Binding EnterListModeCommand}"
Style="{StaticResource CmdBtn}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="执行次数" Style="{StaticResource ParamLabel}" />
<TextBox Style="{StaticResource NumInput}" Width="60"
ToolTip="0 = 无限循环"
Text="{Binding ListCount, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="触发" Style="{StaticResource ParamLabel}" />
<ComboBox Width="88" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding ListTriggerOptions}"
SelectedItem="{Binding ListTrigger}" />
<TextBlock Text="时基" Style="{StaticResource ParamLabel}" />
<ComboBox Width="80" Height="32" FontSize="12" Margin="4,0"
ItemsSource="{Binding ListTimeBaseOptions}"
SelectedItem="{Binding ListTimeBase}" />
</StackPanel>
<Separator Margin="0,6" />
<StackPanel Orientation="Horizontal" Margin="0,4">
<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.ColumnDefinitions>
<ColumnDefinition Width="92" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<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>
<TextBlock Grid.Row="0" Grid.Column="0" Text="相位角度"
Style="{StaticResource ParamLabel}" />
<TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource NumInput}"
Width="240" ToolTip="LIST:DEGR,单位 °,如 0,90,0;三相基准 0/120/240"
Text="{Binding ListDegrText, 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="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}" />
<TextBox Grid.Row="6" Grid.Column="1" Style="{StaticResource NumInput}"
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}" />
</Grid>
<Separator Margin="0,6" />
<StackPanel Orientation="Horizontal" Margin="0,4">
<Button Content="下发三相并启动 LIST" Command="{Binding DownloadThreePhaseListCommand}"
Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White" />
<Button Content="停止 LIST" Command="{Binding ListStopCommand}"
Style="{StaticResource WarnBtn}" />
</StackPanel>
</StackPanel>
</GroupBox>
<!-- 数据采集 -->
<GroupBox Header="数据采集" 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}"
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" />
</StackPanel>
</StackPanel>
</GroupBox>
<!-- 日志 -->
<GroupBox Header="日志" materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<ScrollViewer Height="150" VerticalScrollBarVisibility="Auto">
<TextBox Text="{Binding ResponseLog, Mode=OneWay}"
IsReadOnly="True" TextWrapping="Wrap"
FontSize="11" FontFamily="Consolas"
Background="#FAFAFA" BorderThickness="0"
VerticalAlignment="Top" />
</ScrollViewer>
</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>