更新121
This commit is contained in:
@@ -871,7 +871,7 @@
|
||||
LostTouchCapture="ManualMotionButton_LostTouchCapture"
|
||||
Margin="8,0,8,0" />
|
||||
<Button Grid.Column="2"
|
||||
Content="通气阀"
|
||||
Content="{Binding VentValveButtonText}"
|
||||
Command="{Binding VentValveCommand}"
|
||||
Margin="8,0,8,0" />
|
||||
<Button Grid.Column="3"
|
||||
|
||||
@@ -41,6 +41,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
private const ushort VentValveCoil = 6;
|
||||
private const ushort AxialForceModeCoil = 30;
|
||||
private const ushort AxialStartCoil = 70;
|
||||
private const ushort AxialDoneCoil = 72;
|
||||
private const ushort AxialStopCoil = 73;
|
||||
private const ushort SpeedTorqueStartCoil = 80;
|
||||
private const ushort SpeedTorqueDoneCoil = 82;
|
||||
@@ -136,6 +137,8 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
|
||||
private static readonly ushort[] RealtimeCoilAddresses =
|
||||
[
|
||||
VentValveCoil,
|
||||
AxialDoneCoil,
|
||||
SpeedTorqueDoneCoil,
|
||||
SpeedTorqueResetEnabledCoil,
|
||||
SpeedTorqueResetDoneCoil,
|
||||
@@ -203,6 +206,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
private bool _isApplyingParameterConfigToInputs;
|
||||
private bool _isDisplacementResetting;
|
||||
private bool _isSpeedTorqueResetting;
|
||||
private bool _isVentValveOpen;
|
||||
private bool _hasShownSpeedTorqueEndWarnings;
|
||||
private DateTime _lastParameterReadFailureLogAt = DateTime.MinValue;
|
||||
private string _relativeDisplacementText = "0.000 mm";
|
||||
@@ -238,6 +242,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
private string _axialForceSetpointModeButtonText = "轴向跳动力设置";
|
||||
private string _displacementResetButtonText = "复位";
|
||||
private string _speedTorqueResetButtonText = "复位";
|
||||
private string _ventValveButtonText = "开启通气阀";
|
||||
|
||||
public MainWindowViewModel(IPlcCoilService plcCoilService, IPlcRegisterService plcRegisterService, IFileDialogService fileDialogService)
|
||||
{
|
||||
@@ -261,7 +266,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
SelectAxialJumpForceSetpointModeCommand = new AsyncRelayCommand(SelectAxialJumpForceSetpointModeAsync);
|
||||
ForwardSpeedTorqueCommand = new AsyncRelayCommand(ForwardSpeedTorqueAsync);
|
||||
BackwardSpeedTorqueCommand = new AsyncRelayCommand(BackwardSpeedTorqueAsync);
|
||||
VentValveCommand = new AsyncRelayCommand(TriggerVentValveAsync);
|
||||
VentValveCommand = new AsyncRelayCommand(ToggleVentValveAsync);
|
||||
StartSpeedTorqueCommand = new AsyncRelayCommand(StartSpeedTorqueAsync);
|
||||
StopSpeedTorqueCommand = new AsyncRelayCommand(StopSpeedTorqueAsync);
|
||||
ResetSpeedTorqueCommand = new AsyncRelayCommand(ResetSpeedTorqueAsync);
|
||||
@@ -662,6 +667,12 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
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)
|
||||
{
|
||||
if (_isReadingRealtime)
|
||||
@@ -697,6 +708,7 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
_realtimeSpeed = realtimeSpeed;
|
||||
AppendTorqueSample(GetScaledTorque(), DateTime.Now);
|
||||
ApplyResetCoilValues(coilValues);
|
||||
UpdateVentValveState(ReadCoilValue(coilValues, VentValveCoil));
|
||||
CaptureRealtimeSample(dialIndicator, coilValues);
|
||||
FinalizeNoLoadSpeedRunIfDue();
|
||||
QueueSnapshotIfDue();
|
||||
@@ -706,6 +718,11 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
_maxDisplacement = Math.Max(_maxDisplacement, Math.Abs(_relativeDisplacement));
|
||||
}
|
||||
|
||||
if (_isDisplacementRunning && ReadCoilValue(coilValues, AxialDoneCoil))
|
||||
{
|
||||
StopDisplacementTest("状态:已完成");
|
||||
}
|
||||
|
||||
if (_isSpeedTorqueRunning && ReadCoilValue(coilValues, SpeedTorqueDoneCoil))
|
||||
{
|
||||
await StopSpeedTorqueTestAsync("状态:已完成");
|
||||
@@ -2040,11 +2057,28 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
await MoveSpeedTorqueDisplacementAsync();
|
||||
}
|
||||
|
||||
private async Task TriggerVentValveAsync()
|
||||
private async Task ToggleVentValveAsync()
|
||||
{
|
||||
if (await PulsePlcAsync(VentValveCoil, "通气阀"))
|
||||
try
|
||||
{
|
||||
StatusText = "通气阀已触发。";
|
||||
IReadOnlyDictionary<ushort, bool> values = await _plcCoilService.ReadCoilValuesAsync(
|
||||
_parameterConfig.ToPlcConnectionConfig(),
|
||||
[VentValveCoil]);
|
||||
bool targetState = !ReadCoilValue(values, VentValveCoil);
|
||||
|
||||
await _plcCoilService.WriteCoilAsync(
|
||||
_parameterConfig.ToPlcConnectionConfig(),
|
||||
VentValveCoil,
|
||||
targetState);
|
||||
|
||||
UpdateVentValveState(targetState);
|
||||
StatusText = targetState ? "通气阀已开启。" : "通气阀已关闭。";
|
||||
Log.Information("PLC常开触点开关成功:通气阀,M{CoilAddress}={Value}", VentValveCoil, targetState ? 1 : 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusText = $"PLC 通气阀开关失败:{OperatorMessageFormatter.FromException(ex)}";
|
||||
Log.Error(ex, "PLC常开触点开关失败:通气阀,M{CoilAddress}", VentValveCoil);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2838,6 +2872,12 @@ public sealed class MainWindowViewModel : ObservableObject
|
||||
SpeedTorqueResetButtonText = _isSpeedTorqueResetting || enabled ? "复位中" : "复位";
|
||||
}
|
||||
|
||||
private void UpdateVentValveState(bool isOpen)
|
||||
{
|
||||
_isVentValveOpen = isOpen;
|
||||
VentValveButtonText = _isVentValveOpen ? "关闭通气阀" : "开启通气阀";
|
||||
}
|
||||
|
||||
private static bool ReadCoilValue(IReadOnlyDictionary<ushort, bool> coilValues, ushort address)
|
||||
{
|
||||
return coilValues.TryGetValue(address, out bool value) && value;
|
||||
|
||||
Reference in New Issue
Block a user