更新2026
This commit is contained in:
@@ -149,7 +149,7 @@ namespace TabletTester2025.ViewModels
|
||||
[ObservableProperty] private bool _friabilityClockwise = true;
|
||||
[ObservableProperty] private bool _friabilityCounterClockwise;
|
||||
[ObservableProperty] private double _friabilityCurrentRpm;
|
||||
[ObservableProperty] private int _friabilityRealtimeRounds;
|
||||
[ObservableProperty] private double _friabilityRealtimeRounds;
|
||||
[ObservableProperty] private int _friabilityRemainingRounds = 100;
|
||||
public IAsyncRelayCommand StopHardnessCommand { get; }
|
||||
public IAsyncRelayCommand StopFriabilityCommand { get; }
|
||||
@@ -1885,36 +1885,35 @@ namespace TabletTester2025.ViewModels
|
||||
throw new InvalidOperationException("脆碎前重量必须大于0");
|
||||
|
||||
double rpm = FriabilityTargetRpm > 0 ? FriabilityTargetRpm : 25;
|
||||
double testTimeMin = FriabilityTargetTimeMin > 0 ? FriabilityTargetTimeMin : 4;
|
||||
int totalRounds = Math.Max(1, FriabilityTargetRounds);
|
||||
FriabilityRemainingRounds = totalRounds;
|
||||
FriabilityCurrentRpm = rpm;
|
||||
await RefreshFriabilityRealtimeRoundsAsync();
|
||||
await PulseCoilAsync(startCoil);
|
||||
int durationMs = (int)Math.Ceiling(testTimeMin * 60 * 1000); // 总运行时间(毫秒)
|
||||
bool targetRoundsReached = false;
|
||||
|
||||
for (int i = 0; i < durationMs; i += 100)
|
||||
while (_isFriabilityRunning)
|
||||
{
|
||||
// 如果用户点了停止,只结束脆碎度测试,不影响其它测试
|
||||
if (!_isFriabilityRunning)
|
||||
await RefreshFriabilityRealtimeRoundsAsync();
|
||||
|
||||
double completedRounds = Math.Max(0, FriabilityRealtimeRounds);
|
||||
FriabilityRemainingRounds = (int)Math.Ceiling(Math.Max(0, totalRounds - completedRounds));
|
||||
if (completedRounds >= totalRounds)
|
||||
{
|
||||
targetRoundsReached = true;
|
||||
FriabilityRemainingRounds = 0;
|
||||
break;
|
||||
|
||||
// 计算当前剩余圈数
|
||||
double elapsedMs = i;
|
||||
double elapsedRounds = rpm / 60 / 1000 * elapsedMs;
|
||||
int remainingRounds = (int)Math.Ceiling(totalRounds - elapsedRounds);
|
||||
|
||||
// 更新界面绑定的剩余圈数
|
||||
FriabilityRemainingRounds = remainingRounds;
|
||||
if (i % 500 == 0)
|
||||
await RefreshFriabilityRealtimeRoundsAsync();
|
||||
}
|
||||
|
||||
// 等待100ms,再更新下一次
|
||||
await Task.Delay(100);
|
||||
}
|
||||
if (!_isFriabilityRunning)
|
||||
if (!_isFriabilityRunning || !targetRoundsReached)
|
||||
throw new InvalidOperationException("脆碎度测试已停止,未保存结果");
|
||||
|
||||
if (_plcConfig.FriabilityStartCoilStop != 0)
|
||||
await PulseCoilAsync(_plcConfig.FriabilityStartCoilStop);
|
||||
|
||||
double weightAfter = await ReadFriabilityWeightAsync(ResolveFriabilityWeightAfterRegister(), "脆碎后重量");
|
||||
SetFriabilityWeightFromPlc(weightAfter: weightAfter);
|
||||
FriabilityCurrentRpm = rpm;
|
||||
@@ -1982,8 +1981,8 @@ namespace TabletTester2025.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
int value = await _plc.ReadIntAsync(registerAddress);
|
||||
if (value >= 0)
|
||||
double value = await _plc.ReadFloatAsync(registerAddress);
|
||||
if (double.IsFinite(value) && value >= 0)
|
||||
FriabilityRealtimeRounds = value;
|
||||
}
|
||||
catch
|
||||
|
||||
Reference in New Issue
Block a user