20260619
This commit is contained in:
@@ -894,6 +894,7 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Content="前进"
|
<Button Content="前进"
|
||||||
Tag="SpeedTorqueForward"
|
Tag="SpeedTorqueForward"
|
||||||
@@ -929,6 +930,10 @@
|
|||||||
<Button Grid.Column="4"
|
<Button Grid.Column="4"
|
||||||
Content="{Binding SpeedTorqueResetButtonText}"
|
Content="{Binding SpeedTorqueResetButtonText}"
|
||||||
Command="{Binding ResetSpeedTorqueCommand}"
|
Command="{Binding ResetSpeedTorqueCommand}"
|
||||||
|
Margin="8,0,8,0" />
|
||||||
|
<Button Grid.Column="5"
|
||||||
|
Content="{Binding VentValveButtonText}"
|
||||||
|
Command="{Binding ToggleVentValveCommand}"
|
||||||
Margin="8,0,0,0" />
|
Margin="8,0,0,0" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
private string _noLoadSpeedTestButtonText = "测试";
|
private string _noLoadSpeedTestButtonText = "测试";
|
||||||
private string _displacementResetButtonText = "复位";
|
private string _displacementResetButtonText = "复位";
|
||||||
private string _speedTorqueResetButtonText = "复位";
|
private string _speedTorqueResetButtonText = "复位";
|
||||||
|
private string _ventValveButtonText = "通气阀";
|
||||||
|
|
||||||
public MainWindowViewModel(IPlcCoilService plcCoilService, IPlcRegisterService plcRegisterService, IFileDialogService fileDialogService)
|
public MainWindowViewModel(IPlcCoilService plcCoilService, IPlcRegisterService plcRegisterService, IFileDialogService fileDialogService)
|
||||||
{
|
{
|
||||||
@@ -285,6 +286,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
StartSpeedTorqueCommand = new AsyncRelayCommand(StartSpeedTorqueAsync);
|
StartSpeedTorqueCommand = new AsyncRelayCommand(StartSpeedTorqueAsync);
|
||||||
StopSpeedTorqueCommand = new AsyncRelayCommand(StopSpeedTorqueAsync);
|
StopSpeedTorqueCommand = new AsyncRelayCommand(StopSpeedTorqueAsync);
|
||||||
ResetSpeedTorqueCommand = new AsyncRelayCommand(ResetSpeedTorqueAsync);
|
ResetSpeedTorqueCommand = new AsyncRelayCommand(ResetSpeedTorqueAsync);
|
||||||
|
ToggleVentValveCommand = new AsyncRelayCommand(ToggleVentValveAsync);
|
||||||
SaveNoLoadSpeedSettingCommand = new AsyncRelayCommand(SaveNoLoadSpeedSettingAsync);
|
SaveNoLoadSpeedSettingCommand = new AsyncRelayCommand(SaveNoLoadSpeedSettingAsync);
|
||||||
RecordNoLoadSpeedCommand = new AsyncRelayCommand(RecordNoLoadSpeedAsync);
|
RecordNoLoadSpeedCommand = new AsyncRelayCommand(RecordNoLoadSpeedAsync);
|
||||||
|
|
||||||
@@ -344,6 +346,8 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
|
|
||||||
public IAsyncRelayCommand ResetSpeedTorqueCommand { get; }
|
public IAsyncRelayCommand ResetSpeedTorqueCommand { get; }
|
||||||
|
|
||||||
|
public IAsyncRelayCommand ToggleVentValveCommand { get; }
|
||||||
|
|
||||||
public IAsyncRelayCommand SaveNoLoadSpeedSettingCommand { get; }
|
public IAsyncRelayCommand SaveNoLoadSpeedSettingCommand { get; }
|
||||||
|
|
||||||
public IAsyncRelayCommand RecordNoLoadSpeedCommand { get; }
|
public IAsyncRelayCommand RecordNoLoadSpeedCommand { get; }
|
||||||
@@ -712,6 +716,12 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
private set => SetProperty(ref _speedTorqueResetButtonText, value);
|
private set => SetProperty(ref _speedTorqueResetButtonText, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string VentValveButtonText
|
||||||
|
{
|
||||||
|
get => _ventValveButtonText;
|
||||||
|
private set => SetProperty(ref _ventValveButtonText, value);
|
||||||
|
}
|
||||||
|
|
||||||
private async void RealtimeTimer_Tick(object? sender, EventArgs e)
|
private async void RealtimeTimer_Tick(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_isReadingRealtime)
|
if (_isReadingRealtime)
|
||||||
@@ -749,6 +759,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
AppendTorqueSample(GetScaledTorque(), DateTime.Now);
|
AppendTorqueSample(GetScaledTorque(), DateTime.Now);
|
||||||
ApplyResetCoilValues(coilValues);
|
ApplyResetCoilValues(coilValues);
|
||||||
bool isVentValveOpen = ReadCoilValue(coilValues, VentValveCoil);
|
bool isVentValveOpen = ReadCoilValue(coilValues, VentValveCoil);
|
||||||
|
VentValveButtonText = isVentValveOpen ? "关闭气阀" : "通气阀";
|
||||||
if (_isSpeedTorqueRunning && !isVentValveOpen)
|
if (_isSpeedTorqueRunning && !isVentValveOpen)
|
||||||
{
|
{
|
||||||
Log.Error("转速/扭矩测试运行中检测到通气阀关闭,M{VentValveCoil}=0,立即停止测试", VentValveCoil);
|
Log.Error("转速/扭矩测试运行中检测到通气阀关闭,M{VentValveCoil}=0,立即停止测试", VentValveCoil);
|
||||||
@@ -2628,6 +2639,53 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ToggleVentValveAsync()
|
||||||
|
{
|
||||||
|
bool targetState = _ventValveButtonText == "通气阀";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PlcConnectionConfig config = _parameterConfig.ToPlcConnectionConfig();
|
||||||
|
await _plcCoilService.WriteCoilAsync(config, VentValveCoil, targetState);
|
||||||
|
await Task.Delay(100);
|
||||||
|
|
||||||
|
IReadOnlyDictionary<ushort, bool> values = await _plcCoilService.ReadCoilValuesAsync(
|
||||||
|
config,
|
||||||
|
[VentValveCoil, SpeedTorqueEnabledCoil]);
|
||||||
|
bool actualState = ReadCoilValue(values, VentValveCoil);
|
||||||
|
if (actualState != targetState)
|
||||||
|
{
|
||||||
|
string error = targetState
|
||||||
|
? "通气阀未能开启,请检查 PLC 状态。"
|
||||||
|
: "通气阀未能关闭,请检查 PLC 状态。";
|
||||||
|
StatusText = error;
|
||||||
|
Log.Warning(
|
||||||
|
"通气阀切换失败:目标 {Target},实际 {Actual},M{VentValveCoil}={ActualState},扭矩使能 M{EnabledCoil}={Enabled}",
|
||||||
|
targetState ? "开启" : "关闭",
|
||||||
|
actualState ? "开启" : "关闭",
|
||||||
|
VentValveCoil,
|
||||||
|
actualState ? 1 : 0,
|
||||||
|
SpeedTorqueEnabledCoil,
|
||||||
|
ReadCoilValue(values, SpeedTorqueEnabledCoil) ? 1 : 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VentValveButtonText = actualState ? "关闭气阀" : "通气阀";
|
||||||
|
StatusText = actualState ? "通气阀已开启。" : "通气阀已关闭。";
|
||||||
|
Log.Information(
|
||||||
|
"通气阀切换成功:目标 {Target},M{VentValveCoil}={State},扭矩使能 M{EnabledCoil}={Enabled}",
|
||||||
|
targetState ? "开启" : "关闭",
|
||||||
|
VentValveCoil,
|
||||||
|
actualState ? 1 : 0,
|
||||||
|
SpeedTorqueEnabledCoil,
|
||||||
|
ReadCoilValue(values, SpeedTorqueEnabledCoil) ? 1 : 0);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
StatusText = $"通气阀操作失败:{OperatorMessageFormatter.FromException(ex)}";
|
||||||
|
Log.Error(ex, "通气阀操作失败,目标 {Target},M{VentValveCoil}", targetState ? "开启" : "关闭", VentValveCoil);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task ForwardDisplacementAsync()
|
private async Task ForwardDisplacementAsync()
|
||||||
{
|
{
|
||||||
if (!await PulsePlcAsync(AxialForwardCoil, "轴向前进"))
|
if (!await PulsePlcAsync(AxialForwardCoil, "轴向前进"))
|
||||||
|
|||||||
Reference in New Issue
Block a user