更新提示框20260604
This commit is contained in:
@@ -715,7 +715,7 @@
|
||||
<ColumnDefinition Width="1.1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Style="{StaticResource PanelBorder}" Margin="0,0,0,0">
|
||||
<Border Style="{StaticResource PanelBorder}" Margin="0,0,10,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -33,10 +33,13 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
private const ushort AxialStartCoil = 70;
|
||||
private const ushort AxialStopCoil = 73;
|
||||
private const ushort SpeedTorqueStartCoil = 80;
|
||||
private const ushort SpeedTorqueDoneCoil = 82;
|
||||
private const ushort SpeedTorqueStopCoil = 83;
|
||||
private const ushort SpeedTorqueResetCoil = 90;
|
||||
private const ushort SpeedTorqueResetEnabledCoil = 91;
|
||||
private const ushort SpeedTorqueResetDoneCoil = 92;
|
||||
private const ushort SpeedTorqueWearPlateWarningCoil = 14;
|
||||
private const ushort SpeedTorqueLimitWarningCoil = 200;
|
||||
private const ushort AxialResetCoil = 95;
|
||||
private const ushort AxialResetEnabledCoil = 96;
|
||||
private const ushort AxialResetDoneCoil = 97;
|
||||
@@ -113,6 +116,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
|
||||
private static readonly ushort[] RealtimeCoilAddresses =
|
||||
[
|
||||
SpeedTorqueDoneCoil,
|
||||
SpeedTorqueResetEnabledCoil,
|
||||
SpeedTorqueResetDoneCoil,
|
||||
AxialResetEnabledCoil,
|
||||
@@ -160,6 +164,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
private bool _isApplyingParameterConfigToInputs;
|
||||
private bool _isDisplacementResetting;
|
||||
private bool _isSpeedTorqueResetting;
|
||||
private bool _hasShownSpeedTorqueEndWarnings;
|
||||
private bool _isAxialResetEnabled;
|
||||
private bool _isAxialResetDone;
|
||||
private bool _isSpeedTorqueResetEnabled;
|
||||
@@ -581,6 +586,11 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
_maxDisplacement = Math.Max(_maxDisplacement, Math.Abs(_relativeDisplacement));
|
||||
}
|
||||
|
||||
if (_isSpeedTorqueRunning && ReadCoilValue(coilValues, SpeedTorqueDoneCoil))
|
||||
{
|
||||
await StopSpeedTorqueTestAsync("状态:已完成");
|
||||
}
|
||||
|
||||
UpdateDisplacementDisplay(ResolveDisplacementStatus(DisplacementStatusText));
|
||||
UpdateSpeedTorqueDisplay(ResolveSpeedTorqueStatus(SpeedTorqueStatusText));
|
||||
await AutoStopIfSetpointReachedAsync();
|
||||
@@ -1635,6 +1645,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
}
|
||||
|
||||
_isSpeedTorqueRunning = true;
|
||||
_hasShownSpeedTorqueEndWarnings = false;
|
||||
_finalSpeed = null;
|
||||
_finalTorque = null;
|
||||
_finalSpeedTorqueDisplacement = null;
|
||||
@@ -1653,7 +1664,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
return;
|
||||
}
|
||||
|
||||
StopSpeedTorqueTest("状态:已停止");
|
||||
await StopSpeedTorqueTestAsync("状态:已停止");
|
||||
}
|
||||
|
||||
private async Task ResetSpeedTorqueAsync()
|
||||
@@ -1689,6 +1700,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
_finalSpeed = null;
|
||||
_finalTorque = null;
|
||||
_speedTorqueStartedAt = null;
|
||||
_hasShownSpeedTorqueEndWarnings = false;
|
||||
ClearTorqueSamples();
|
||||
UpdateSpeedTorqueDisplay("状态:已复位");
|
||||
}
|
||||
@@ -2052,7 +2064,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
{
|
||||
if (await PulsePlcAsync(SpeedTorqueStopCoil, "转速/扭矩保护停止"))
|
||||
{
|
||||
StopSpeedTorqueTest(status);
|
||||
await StopSpeedTorqueTestAsync(status);
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -2061,7 +2073,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
private void StopSpeedTorqueTest(string status)
|
||||
private async Task StopSpeedTorqueTestAsync(string status)
|
||||
{
|
||||
if (!TryGetRealtimeSpeed(out double speed) || !TryGetRealtimeTorque(out double torque))
|
||||
{
|
||||
@@ -2076,6 +2088,52 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
_finalTorque = GetScaledTorque();
|
||||
_finalSpeedTorqueDisplacement = _speedTorqueDisplacement;
|
||||
UpdateSpeedTorqueDisplay(status);
|
||||
await ShowSpeedTorqueEndWarningsAsync();
|
||||
}
|
||||
|
||||
private async Task ShowSpeedTorqueEndWarningsAsync()
|
||||
{
|
||||
if (_hasShownSpeedTorqueEndWarnings)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IReadOnlyDictionary<ushort, bool> values = await _plcCoilService.ReadCoilValuesAsync(
|
||||
_parameterConfig.ToPlcConnectionConfig(),
|
||||
[SpeedTorqueLimitWarningCoil, SpeedTorqueWearPlateWarningCoil]);
|
||||
|
||||
bool limitReached = ReadCoilValue(values, SpeedTorqueLimitWarningCoil);
|
||||
bool wearPlateWorn = ReadCoilValue(values, SpeedTorqueWearPlateWarningCoil);
|
||||
if (!limitReached && !wearPlateWorn)
|
||||
{
|
||||
_hasShownSpeedTorqueEndWarnings = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var messages = new List<string>();
|
||||
if (limitReached)
|
||||
{
|
||||
messages.Add("位置已到达极限,如扭矩较大,请更换弹簧");
|
||||
}
|
||||
|
||||
if (wearPlateWorn)
|
||||
{
|
||||
messages.Add("磨耗片过渡磨损,请更换");
|
||||
}
|
||||
|
||||
_hasShownSpeedTorqueEndWarnings = true;
|
||||
MessageBox.Show(
|
||||
string.Join(Environment.NewLine, messages),
|
||||
"转速/扭矩测试提示",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusText = $"转速/扭矩结束提示读取失败:M{SpeedTorqueLimitWarningCoil}/M{SpeedTorqueWearPlateWarningCoil},{ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private double GetScaledTorque()
|
||||
|
||||
Reference in New Issue
Block a user