更新20260616
This commit is contained in:
@@ -693,8 +693,8 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Text="实时转速" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
|
<TextBlock Text="实时转速" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
|
||||||
<Button Grid.Column="1"
|
<Button Grid.Column="1"
|
||||||
Content="一键归零"
|
Content="转速归零"
|
||||||
Command="{Binding ZeroSpeedTorquePressureCommand}"
|
Command="{Binding ZeroSpeedCommand}"
|
||||||
FontSize="13"
|
FontSize="13"
|
||||||
Padding="12,3"
|
Padding="12,3"
|
||||||
MinHeight="28"
|
MinHeight="28"
|
||||||
@@ -719,6 +719,14 @@
|
|||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Text="实时扭矩" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
|
<TextBlock Text="实时扭矩" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
Content="扭矩归零"
|
||||||
|
Command="{Binding ZeroTorqueCommand}"
|
||||||
|
FontSize="13"
|
||||||
|
Padding="12,3"
|
||||||
|
MinHeight="28"
|
||||||
|
Background="#64748B"
|
||||||
|
BorderBrush="#475569" />
|
||||||
<TextBlock Grid.Row="1"
|
<TextBlock Grid.Row="1"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
x:Name="RealtimeTorqueText"
|
x:Name="RealtimeTorqueText"
|
||||||
@@ -740,6 +748,14 @@
|
|||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Foreground="#52616F" />
|
Foreground="#52616F" />
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
Content="压力归零"
|
||||||
|
Command="{Binding ZeroPressureCommand}"
|
||||||
|
FontSize="13"
|
||||||
|
Padding="12,3"
|
||||||
|
MinHeight="28"
|
||||||
|
Background="#64748B"
|
||||||
|
BorderBrush="#475569" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -297,9 +297,9 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
ResetSpeedTorqueCommand = new AsyncRelayCommand(ResetSpeedTorqueAsync);
|
ResetSpeedTorqueCommand = new AsyncRelayCommand(ResetSpeedTorqueAsync);
|
||||||
ToggleVentValveCommand = new AsyncRelayCommand(ToggleVentValveAsync);
|
ToggleVentValveCommand = new AsyncRelayCommand(ToggleVentValveAsync);
|
||||||
ZeroAxialForceCommand = new AsyncRelayCommand(ZeroAxialForceAsync);
|
ZeroAxialForceCommand = new AsyncRelayCommand(ZeroAxialForceAsync);
|
||||||
ZeroSpeedTorquePressureCommand = new AsyncRelayCommand(
|
ZeroSpeedCommand = new AsyncRelayCommand(ZeroSpeedAsync, CanExecuteSpeedTorqueZeroing);
|
||||||
ZeroSpeedTorquePressureAsync,
|
ZeroTorqueCommand = new AsyncRelayCommand(ZeroTorqueAsync, CanExecuteSpeedTorqueZeroing);
|
||||||
CanZeroSpeedTorquePressure);
|
ZeroPressureCommand = new AsyncRelayCommand(ZeroPressureAsync, CanExecuteSpeedTorqueZeroing);
|
||||||
SaveNoLoadSpeedSettingCommand = new AsyncRelayCommand(SaveNoLoadSpeedSettingAsync);
|
SaveNoLoadSpeedSettingCommand = new AsyncRelayCommand(SaveNoLoadSpeedSettingAsync);
|
||||||
RecordNoLoadSpeedCommand = new AsyncRelayCommand(RecordNoLoadSpeedAsync);
|
RecordNoLoadSpeedCommand = new AsyncRelayCommand(RecordNoLoadSpeedAsync);
|
||||||
|
|
||||||
@@ -365,7 +365,11 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
|
|
||||||
public IAsyncRelayCommand ZeroAxialForceCommand { get; }
|
public IAsyncRelayCommand ZeroAxialForceCommand { get; }
|
||||||
|
|
||||||
public IAsyncRelayCommand ZeroSpeedTorquePressureCommand { get; }
|
public IAsyncRelayCommand ZeroSpeedCommand { get; }
|
||||||
|
|
||||||
|
public IAsyncRelayCommand ZeroTorqueCommand { get; }
|
||||||
|
|
||||||
|
public IAsyncRelayCommand ZeroPressureCommand { get; }
|
||||||
|
|
||||||
public IAsyncRelayCommand SaveNoLoadSpeedSettingCommand { get; }
|
public IAsyncRelayCommand SaveNoLoadSpeedSettingCommand { get; }
|
||||||
|
|
||||||
@@ -714,7 +718,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
if (SetProperty(ref _speedTorqueTestButtonText, value))
|
if (SetProperty(ref _speedTorqueTestButtonText, value))
|
||||||
{
|
{
|
||||||
ZeroSpeedTorquePressureCommand?.NotifyCanExecuteChanged();
|
NotifySpeedTorqueZeroCommandsCanExecuteChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2516,7 +2520,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
if (_isSpeedTorqueZeroing)
|
if (_isSpeedTorqueZeroing)
|
||||||
{
|
{
|
||||||
StatusText = "一键归零正在执行,已阻止启动测试。";
|
StatusText = "归零正在执行,已阻止启动测试。";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2660,12 +2664,12 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
if (_isSpeedTorqueZeroing)
|
if (_isSpeedTorqueZeroing)
|
||||||
{
|
{
|
||||||
StatusText = "一键归零正在执行,已阻止复位。";
|
StatusText = "归零正在执行,已阻止复位。";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isSpeedTorqueResetting = true;
|
_isSpeedTorqueResetting = true;
|
||||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
NotifySpeedTorqueZeroCommandsCanExecuteChanged();
|
||||||
SpeedTorqueResetButtonText = "复位中";
|
SpeedTorqueResetButtonText = "复位中";
|
||||||
UpdateSpeedTorqueDisplay();
|
UpdateSpeedTorqueDisplay();
|
||||||
|
|
||||||
@@ -2709,7 +2713,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_isSpeedTorqueResetting = false;
|
_isSpeedTorqueResetting = false;
|
||||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
NotifySpeedTorqueZeroCommandsCanExecuteChanged();
|
||||||
SpeedTorqueResetButtonText = "复位";
|
SpeedTorqueResetButtonText = "复位";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2964,7 +2968,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
StatusText = "轴向力归零完成。";
|
StatusText = "轴向力归零完成。";
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanZeroSpeedTorquePressure()
|
private bool CanExecuteSpeedTorqueZeroing()
|
||||||
{
|
{
|
||||||
return !_isSpeedTorqueRunning
|
return !_isSpeedTorqueRunning
|
||||||
&& !_isSpeedTorqueResetting
|
&& !_isSpeedTorqueResetting
|
||||||
@@ -2972,61 +2976,83 @@ public sealed class MainWindowViewModel : ObservableObject
|
|||||||
&& SpeedTorqueTestButtonText == "测试";
|
&& SpeedTorqueTestButtonText == "测试";
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ZeroSpeedTorquePressureAsync()
|
private Task ZeroSpeedAsync()
|
||||||
{
|
{
|
||||||
if (!CanZeroSpeedTorquePressure())
|
return ExecuteSpeedTorqueZeroingAsync(
|
||||||
|
"转速归零",
|
||||||
|
(SpeedZeroCoil, "转速归零"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task ZeroTorqueAsync()
|
||||||
|
{
|
||||||
|
return ExecuteSpeedTorqueZeroingAsync(
|
||||||
|
"扭矩归零",
|
||||||
|
(TorqueZeroCoil, "扭矩归零第一路"),
|
||||||
|
(SecondaryTorqueZeroCoil, "扭矩归零第二路"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task ZeroPressureAsync()
|
||||||
|
{
|
||||||
|
return ExecuteSpeedTorqueZeroingAsync(
|
||||||
|
"压力归零",
|
||||||
|
(PressureZeroCoil, "压力归零"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteSpeedTorqueZeroingAsync(
|
||||||
|
string zeroingName,
|
||||||
|
params (ushort CoilAddress, string ActionName)[] actions)
|
||||||
|
{
|
||||||
|
if (!CanExecuteSpeedTorqueZeroing())
|
||||||
{
|
{
|
||||||
StatusText = "转速/扭矩测试启动、运行或复位期间禁止一键归零。";
|
StatusText = $"转速/扭矩测试启动、运行或复位期间禁止{zeroingName}。";
|
||||||
Log.Warning(
|
Log.Warning(
|
||||||
"一键归零已阻止:测试按钮状态 {ButtonState},运行中 {IsRunning},复位中 {IsResetting}",
|
"{ZeroingName}已阻止:测试按钮状态 {ButtonState},运行中 {IsRunning},复位中 {IsResetting},其他归零执行中 {IsZeroing}",
|
||||||
|
zeroingName,
|
||||||
SpeedTorqueTestButtonText,
|
SpeedTorqueTestButtonText,
|
||||||
_isSpeedTorqueRunning,
|
_isSpeedTorqueRunning,
|
||||||
_isSpeedTorqueResetting);
|
_isSpeedTorqueResetting,
|
||||||
|
_isSpeedTorqueZeroing);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isSpeedTorqueZeroing = true;
|
_isSpeedTorqueZeroing = true;
|
||||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
NotifySpeedTorqueZeroCommandsCanExecuteChanged();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
(ushort CoilAddress, string ActionName)[] actions =
|
|
||||||
[
|
|
||||||
(TorqueZeroCoil, "扭矩归零 M1101"),
|
|
||||||
(SpeedZeroCoil, "转速归零 M1300"),
|
|
||||||
(PressureZeroCoil, "压力归零 M1301"),
|
|
||||||
(SecondaryTorqueZeroCoil, "第二路扭矩归零 M1302")
|
|
||||||
];
|
|
||||||
var completedActions = new List<string>();
|
|
||||||
foreach ((ushort coilAddress, string actionName) in actions)
|
foreach ((ushort coilAddress, string actionName) in actions)
|
||||||
{
|
{
|
||||||
if (!await PulsePlcAsync(coilAddress, actionName))
|
if (!await PulsePlcAsync(coilAddress, actionName))
|
||||||
{
|
{
|
||||||
StatusText = completedActions.Count == 0
|
StatusText = $"{zeroingName}失败,请检查设备状态。";
|
||||||
? $"一键归零失败:{actionName}未完成。"
|
|
||||||
: $"一键归零部分完成:已完成{string.Join("、", completedActions)};{actionName}失败,后续动作已停止。";
|
|
||||||
Log.Error(
|
Log.Error(
|
||||||
"一键归零失败并停止后续动作:已完成 {CompletedActions},失败点位 M{CoilAddress},动作 {ActionName}",
|
"{ZeroingName}失败并停止后续动作,失败点位 M{CoilAddress},动作 {ActionName}",
|
||||||
completedActions.Count == 0 ? "无" : string.Join(", ", completedActions),
|
zeroingName,
|
||||||
coilAddress,
|
coilAddress,
|
||||||
actionName);
|
actionName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
completedActions.Add(actionName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusText = "转速、扭矩、压力归零完成。";
|
StatusText = $"{zeroingName}完成。";
|
||||||
Log.Information(
|
Log.Information(
|
||||||
"一键归零完成,执行顺序 {ZeroingActions}",
|
"{ZeroingName}完成,执行顺序 {ZeroingActions}",
|
||||||
|
zeroingName,
|
||||||
string.Join(", ", actions.Select(static action => $"M{action.CoilAddress}")));
|
string.Join(", ", actions.Select(static action => $"M{action.CoilAddress}")));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_isSpeedTorqueZeroing = false;
|
_isSpeedTorqueZeroing = false;
|
||||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
NotifySpeedTorqueZeroCommandsCanExecuteChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NotifySpeedTorqueZeroCommandsCanExecuteChanged()
|
||||||
|
{
|
||||||
|
ZeroSpeedCommand?.NotifyCanExecuteChanged();
|
||||||
|
ZeroTorqueCommand?.NotifyCanExecuteChanged();
|
||||||
|
ZeroPressureCommand?.NotifyCanExecuteChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<bool> BeginAxialManualMotionAsync(ushort coilAddress, string actionName)
|
private async Task<bool> BeginAxialManualMotionAsync(ushort coilAddress, string actionName)
|
||||||
{
|
{
|
||||||
if (!await WriteManualMotionCoilAsync(coilAddress, true, $"{actionName}按下"))
|
if (!await WriteManualMotionCoilAsync(coilAddress, true, $"{actionName}按下"))
|
||||||
|
|||||||
Reference in New Issue
Block a user