ANEVH设备类修正

This commit is contained in:
“hsc”
2026-09-10 14:02:10 +08:00
parent d83843d2fd
commit 18995ee0e2
3 changed files with 443 additions and 31 deletions
@@ -11,7 +11,7 @@ using UIShare.ViewModelBase;
namespace DeviceEditModule.ViewModels
{
/// <summary>
/// ANEVH80 电子负载 控制面板 ViewModel
/// ANEVH 高压源载一体机 控制面板 ViewModel
/// </summary>
public class ANEVH80ViewModel : NavigateViewModelBase, IDisposable
{
@@ -26,26 +26,60 @@ namespace DeviceEditModule.ViewModels
private bool _isBusy;
public bool IsBusy { get => _isBusy; set => SetProperty(ref _isBusy, value); }
#region
#region
private double _voltage;
public double Voltage { get => _voltage; set => SetProperty(ref _voltage, value); }
private double _current;
public double Current { get => _current; set => SetProperty(ref _current, value); }
private double _power;
public double Power { get => _power; set => SetProperty(ref _power, value); }
#endregion
#region (SINK)
private double _sinkCurrent;
public double SinkCurrent { get => _sinkCurrent; set => SetProperty(ref _sinkCurrent, value); }
private double _sinkPower;
public double SinkPower { get => _sinkPower; set => SetProperty(ref _sinkPower, value); }
#endregion
#region
private double _measuredValue;
public double MeasuredValue { get => _measuredValue; set => SetProperty(ref _measuredValue, value); }
private double _measuredVoltage;
public double MeasuredVoltage { get => _measuredVoltage; set => SetProperty(ref _measuredVoltage, value); }
private double _measuredCurrent;
public double MeasuredCurrent { get => _measuredCurrent; set => SetProperty(ref _measuredCurrent, value); }
private double _measuredPower;
public double MeasuredPower { get => _measuredPower; set => SetProperty(ref _measuredPower, value); }
private string _responseLog = "";
public string ResponseLog { get => _responseLog; set => SetProperty(ref _responseLog, value); }
#endregion
#region
public ICommand QueryIdn { get; } public ICommand Measure { get; }
public ICommand QueryIdn { get; } public ICommand Reset { get; }
public ICommand OutOn { get; } public ICommand OutOff { get; }
public ICommand SetV { get; } public ICommand SetI { get; } public ICommand SetP { get; }
public ICommand SetSinkI { get; } public ICommand SetSinkP { get; }
public ICommand QMeas { get; }
#endregion
public ANEVH80ViewModel(IContainerProvider cp) : base(cp)
{
_dm = cp.Resolve<DeviceManager>();
QueryIdn = new DelegateCommand(async () => await Exec(async () => Log("IDN: 占位符设备")));
Measure = new DelegateCommand(async () => await Exec(async () => { MeasuredValue = await _dev!.(Ct()); Log($"测量值={MeasuredValue}"); }));
QueryIdn = new DelegateCommand(async () => await Exec(async () => Log("IDN:" + await _dev!.Async(Ct()))));
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("输出已开启"); }));
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"); }));
SetI = new DelegateCommand(async () => await Exec(async () => { await _dev!.Async(Current, Ct()); Log($"电流={Current}A"); }));
SetP = new DelegateCommand(async () => await Exec(async () => { await _dev!.Async(Power, Ct()); Log($"功率={Power}W"); }));
SetSinkI = new DelegateCommand(async () => await Exec(async () => { await _dev!.Async(SinkCurrent, Ct()); Log($"负载电流={SinkCurrent}A"); }));
SetSinkP = new DelegateCommand(async () => await Exec(async () => { await _dev!.Async(SinkPower, Ct()); Log($"负载功率={SinkPower}W"); }));
QMeas = new DelegateCommand(async () => await Exec(async () =>
{
MeasuredVoltage = await _dev!.Async(Ct());
MeasuredCurrent = await _dev!.Async(Ct());
MeasuredPower = await _dev!.Async(Ct());
Log($"测量→V:{MeasuredVoltage} I:{MeasuredCurrent} P:{MeasuredPower}");
}));
Initialize();
}
+75 -13
View File
@@ -25,7 +25,7 @@
<materialDesign:PackIcon Kind="LightningBolt" Width="22" Height="22"
Foreground="#1565C0" Margin="0,0,8,0"
VerticalAlignment="Center"/>
<TextBlock Text="ANEVH80 电子负载"
<TextBlock Text="ANEVH 高压源载一体机"
FontSize="15" FontWeight="Bold"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding DeviceName, StringFormat=' [{0}]'}"
@@ -71,21 +71,83 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,4,0">
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="操作" Style="{StaticResource ParamLabel}"/>
<Button Content="查询IDN" Command="{Binding QueryIdn}" Style="{StaticResource CmdBtn}"/>
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1" Margin="4,0,0,0">
<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 Orientation="Horizontal" Margin="0,4">
<TextBlock Text="测量值" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource MeasureBox}"
Text="{Binding MeasuredValue, Mode=OneWay}"/>
<TextBlock Text="" VerticalAlignment="Center" Margin="2,0,8,0"/>
<Button Content="开启" Command="{Binding OutOn}"
Style="{StaticResource MaterialDesignRaisedButton}"
Background="#388E3C" Foreground="White"
Height="32" Padding="12,0" FontSize="12" Margin="4,0"/>
<Button Content="关闭" Command="{Binding OutOff}"
Style="{StaticResource WarnBtn}"/>
</StackPanel>
<Button Content="刷新全部测量" Command="{Binding Measure}" Style="{StaticResource CmdBtn}" HorizontalAlignment="Left" Margin="0,4,0,0"/>
</StackPanel>
</GroupBox>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="系统" Style="{StaticResource ParamLabel}"/>
<Button Content="复位" Command="{Binding Reset}" Style="{StaticResource CmdBtn}"/>
</StackPanel>
<GroupBox Header="源模式参数" Margin="0,8,0,8" materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<StackPanel Margin="4">
<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 SetV}" Style="{StaticResource CmdBtn}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="电流 (A)" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource NumInput}"
Text="{Binding Current, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="设置" Command="{Binding SetI}" Style="{StaticResource CmdBtn}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="功率 (W)" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource NumInput}"
Text="{Binding Power, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="设置" Command="{Binding SetP}" Style="{StaticResource CmdBtn}"/>
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox Header="负载(SINK)参数" Margin="0,0,0,8" materialDesign:ColorZoneAssist.Mode="PrimaryLight">
<StackPanel Margin="4">
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="负载电流 (A)" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource NumInput}"
Text="{Binding SinkCurrent, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="设置" Command="{Binding SetSinkI}" Style="{StaticResource CmdBtn}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="负载功率 (W)" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource NumInput}"
Text="{Binding SinkPower, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="设置" Command="{Binding SetSinkP}" Style="{StaticResource CmdBtn}"/>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel Grid.Column="1" Margin="4,0,0,0">
<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}"/>
<TextBox Style="{StaticResource MeasureBox}"
Text="{Binding MeasuredVoltage, Mode=OneWay}"/>
<TextBlock Text="V" VerticalAlignment="Center" Margin="2,0,8,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="电流" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource MeasureBox}"
Text="{Binding MeasuredCurrent, Mode=OneWay}"/>
<TextBlock Text="A" VerticalAlignment="Center" Margin="2,0,8,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4">
<TextBlock Text="功率" Style="{StaticResource ParamLabel}"/>
<TextBox Style="{StaticResource MeasureBox}"
Text="{Binding MeasuredPower, Mode=OneWay}"/>
<TextBlock Text="W" VerticalAlignment="Center" Margin="2,0,8,0"/>
</StackPanel>
<Button Content="刷新全部测量" Command="{Binding QMeas}" Style="{StaticResource CmdBtn}" HorizontalAlignment="Left" Margin="0,4,0,0"/>
</StackPanel>
</GroupBox>
<GroupBox Header="设备信息" Margin="0,0,0,8" materialDesign:ColorZoneAssist.Mode="PrimaryLight">