更新
This commit is contained in:
@@ -1624,7 +1624,7 @@ namespace TabletTester2025.ViewModels
|
||||
AddHardnessSample(value);
|
||||
await ReadHardnessMaxCaptureAsync();
|
||||
ApplyHardnessStatistics(count);
|
||||
await WaitForCoilStateAsync(completeCoil, false, TimeSpan.FromSeconds(10), "硬度完成信号未回落");
|
||||
await TryWaitForCoilStateAsync(completeCoil, false, TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
||||
if (_hardnessResults.Count < count)
|
||||
@@ -1786,6 +1786,20 @@ namespace TabletTester2025.ViewModels
|
||||
throw new TimeoutException(timeoutMessage);
|
||||
}
|
||||
|
||||
private async Task<bool> TryWaitForCoilStateAsync(ushort coilAddress, bool expectedState, TimeSpan timeout)
|
||||
{
|
||||
DateTime deadline = DateTime.Now.Add(timeout);
|
||||
while (_isHardnessRunning && DateTime.Now <= deadline)
|
||||
{
|
||||
if (await _plc.ReadCoilAsync(coilAddress) == expectedState)
|
||||
return true;
|
||||
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ApplyHardnessStatistics(int requiredCount)
|
||||
{
|
||||
var stats = TestCalculationService.CalculateHardness(
|
||||
|
||||
Reference in New Issue
Block a user