更新20260613
This commit is contained in:
@@ -703,10 +703,10 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="实时转速" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
|
||||
<Button Grid.Column="1"
|
||||
Content="转速归零"
|
||||
Command="{Binding ZeroSpeedCommand}"
|
||||
Content="一键归零"
|
||||
Command="{Binding ZeroSpeedTorquePressureCommand}"
|
||||
FontSize="13"
|
||||
Padding="8,3"
|
||||
Padding="12,3"
|
||||
MinHeight="28"
|
||||
Background="#64748B"
|
||||
BorderBrush="#475569" />
|
||||
@@ -729,14 +729,6 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="实时扭矩" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
|
||||
<Button Grid.Column="1"
|
||||
Content="扭矩归零"
|
||||
Command="{Binding ZeroTorqueCommand}"
|
||||
FontSize="13"
|
||||
Padding="8,3"
|
||||
MinHeight="28"
|
||||
Background="#64748B"
|
||||
BorderBrush="#475569" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
x:Name="RealtimeTorqueText"
|
||||
@@ -758,15 +750,6 @@
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="#52616F" />
|
||||
<Button Grid.Column="1"
|
||||
Content="压力归零"
|
||||
Command="{Binding ZeroPressureCommand}"
|
||||
FontSize="13"
|
||||
Padding="8,3"
|
||||
MinHeight="28"
|
||||
Background="#64748B"
|
||||
BorderBrush="#475569"
|
||||
Margin="8,0,0,0" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -228,6 +228,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
private bool _isApplyingParameterConfigToInputs;
|
||||
private bool _isDisplacementResetting;
|
||||
private bool _isSpeedTorqueResetting;
|
||||
private bool _isSpeedTorqueZeroing;
|
||||
private bool _hasShownSpeedTorqueEndWarnings;
|
||||
private DateTime _lastParameterReadFailureLogAt = DateTime.MinValue;
|
||||
private string _dialIndicatorText = "0.000 mm";
|
||||
@@ -296,9 +297,9 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
ResetSpeedTorqueCommand = new AsyncRelayCommand(ResetSpeedTorqueAsync);
|
||||
ToggleVentValveCommand = new AsyncRelayCommand(ToggleVentValveAsync);
|
||||
ZeroAxialForceCommand = new AsyncRelayCommand(ZeroAxialForceAsync);
|
||||
ZeroTorqueCommand = new AsyncRelayCommand(ZeroTorqueAsync);
|
||||
ZeroSpeedCommand = new AsyncRelayCommand(ZeroSpeedAsync);
|
||||
ZeroPressureCommand = new AsyncRelayCommand(ZeroPressureAsync);
|
||||
ZeroSpeedTorquePressureCommand = new AsyncRelayCommand(
|
||||
ZeroSpeedTorquePressureAsync,
|
||||
CanZeroSpeedTorquePressure);
|
||||
SaveNoLoadSpeedSettingCommand = new AsyncRelayCommand(SaveNoLoadSpeedSettingAsync);
|
||||
RecordNoLoadSpeedCommand = new AsyncRelayCommand(RecordNoLoadSpeedAsync);
|
||||
|
||||
@@ -364,11 +365,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
|
||||
public IAsyncRelayCommand ZeroAxialForceCommand { get; }
|
||||
|
||||
public IAsyncRelayCommand ZeroTorqueCommand { get; }
|
||||
|
||||
public IAsyncRelayCommand ZeroSpeedCommand { get; }
|
||||
|
||||
public IAsyncRelayCommand ZeroPressureCommand { get; }
|
||||
public IAsyncRelayCommand ZeroSpeedTorquePressureCommand { get; }
|
||||
|
||||
public IAsyncRelayCommand SaveNoLoadSpeedSettingCommand { get; }
|
||||
|
||||
@@ -713,7 +710,13 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
public string SpeedTorqueTestButtonText
|
||||
{
|
||||
get => _speedTorqueTestButtonText;
|
||||
private set => SetProperty(ref _speedTorqueTestButtonText, value);
|
||||
private set
|
||||
{
|
||||
if (SetProperty(ref _speedTorqueTestButtonText, value))
|
||||
{
|
||||
ZeroSpeedTorquePressureCommand?.NotifyCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string NoLoadSpeedTestButtonText
|
||||
@@ -2511,6 +2514,12 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
|
||||
private async Task StartSpeedTorqueAsync()
|
||||
{
|
||||
if (_isSpeedTorqueZeroing)
|
||||
{
|
||||
StatusText = "一键归零正在执行,已阻止启动测试。";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isSpeedTorqueRunning)
|
||||
{
|
||||
UpdateSpeedTorqueDisplay();
|
||||
@@ -2649,7 +2658,14 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
|
||||
private async Task ResetSpeedTorqueAsync()
|
||||
{
|
||||
if (_isSpeedTorqueZeroing)
|
||||
{
|
||||
StatusText = "一键归零正在执行,已阻止复位。";
|
||||
return;
|
||||
}
|
||||
|
||||
_isSpeedTorqueResetting = true;
|
||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
||||
SpeedTorqueResetButtonText = "复位中";
|
||||
UpdateSpeedTorqueDisplay();
|
||||
|
||||
@@ -2693,6 +2709,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
finally
|
||||
{
|
||||
_isSpeedTorqueResetting = false;
|
||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
||||
SpeedTorqueResetButtonText = "复位";
|
||||
}
|
||||
}
|
||||
@@ -2947,34 +2964,67 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
StatusText = "轴向力归零完成。";
|
||||
}
|
||||
|
||||
private async Task ZeroTorqueAsync()
|
||||
private bool CanZeroSpeedTorquePressure()
|
||||
{
|
||||
if (!await PulsePlcAsync(TorqueZeroCoil, "扭矩归零 M1101"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StatusText = "扭矩归零完成。";
|
||||
return !_isSpeedTorqueRunning
|
||||
&& !_isSpeedTorqueResetting
|
||||
&& !_isSpeedTorqueZeroing
|
||||
&& SpeedTorqueTestButtonText == "测试";
|
||||
}
|
||||
|
||||
private async Task ZeroSpeedAsync()
|
||||
private async Task ZeroSpeedTorquePressureAsync()
|
||||
{
|
||||
if (!await PulsePlcAsync(SpeedZeroCoil, "转速归零 M1300"))
|
||||
if (!CanZeroSpeedTorquePressure())
|
||||
{
|
||||
StatusText = "转速/扭矩测试启动、运行或复位期间禁止一键归零。";
|
||||
Log.Warning(
|
||||
"一键归零已阻止:测试按钮状态 {ButtonState},运行中 {IsRunning},复位中 {IsResetting}",
|
||||
SpeedTorqueTestButtonText,
|
||||
_isSpeedTorqueRunning,
|
||||
_isSpeedTorqueResetting);
|
||||
return;
|
||||
}
|
||||
|
||||
StatusText = "转速归零完成。";
|
||||
}
|
||||
|
||||
private async Task ZeroPressureAsync()
|
||||
{
|
||||
if (!await PulsePlcAsync(PressureZeroCoil, "压力归零 M1301"))
|
||||
_isSpeedTorqueZeroing = true;
|
||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
||||
try
|
||||
{
|
||||
return;
|
||||
}
|
||||
(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)
|
||||
{
|
||||
if (!await PulsePlcAsync(coilAddress, actionName))
|
||||
{
|
||||
StatusText = completedActions.Count == 0
|
||||
? $"一键归零失败:{actionName}未完成。"
|
||||
: $"一键归零部分完成:已完成{string.Join("、", completedActions)};{actionName}失败,后续动作已停止。";
|
||||
Log.Error(
|
||||
"一键归零失败并停止后续动作:已完成 {CompletedActions},失败点位 M{CoilAddress},动作 {ActionName}",
|
||||
completedActions.Count == 0 ? "无" : string.Join(", ", completedActions),
|
||||
coilAddress,
|
||||
actionName);
|
||||
return;
|
||||
}
|
||||
|
||||
StatusText = "压力归零完成。";
|
||||
completedActions.Add(actionName);
|
||||
}
|
||||
|
||||
StatusText = "转速、扭矩、压力归零完成。";
|
||||
Log.Information(
|
||||
"一键归零完成,执行顺序 {ZeroingActions}",
|
||||
string.Join(", ", actions.Select(static action => $"M{action.CoilAddress}")));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isSpeedTorqueZeroing = false;
|
||||
ZeroSpeedTorquePressureCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> BeginAxialManualMotionAsync(ushort coilAddress, string actionName)
|
||||
|
||||
Reference in New Issue
Block a user