更新2026

This commit is contained in:
GukSang.Jin
2026-05-20 15:21:03 +08:00
parent 0cba5198f2
commit b79c34bba7
4 changed files with 21 additions and 22 deletions

View File

@@ -19,6 +19,7 @@ namespace TabletTester2025.Services
{
72 => 40 + (float)_rand.NextDouble() * 20, // 硬度最大采集力
100 => 40 + (float)_rand.NextDouble() * 20, // 硬度 40~60N
82 => _rand.Next(0, 101), // 脆碎实时圈数
410 => 100f, // 脆碎圈数
412 => 5.0f + (float)_rand.NextDouble() * 2, // 脆碎度前重
414 => 4.9f + (float)_rand.NextDouble() * 2, // 后重
@@ -41,7 +42,6 @@ namespace TabletTester2025.Services
{
int value = startAddress switch
{
82 => _rand.Next(0, 101), // 脆碎实时圈数
410 => 100, // 脆碎圈数
430 => 30, // 溶出1时间(min)
440 => 30, // 溶出2时间(min)

View File

@@ -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)
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();
double completedRounds = Math.Max(0, FriabilityRealtimeRounds);
FriabilityRemainingRounds = (int)Math.Ceiling(Math.Max(0, totalRounds - completedRounds));
if (completedRounds >= totalRounds)
{
targetRoundsReached = true;
FriabilityRemainingRounds = 0;
break;
}
// 等待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

View File

@@ -494,7 +494,7 @@
<Border Style="{StaticResource MetricCard}">
<StackPanel>
<TextBlock Text="实时圈数" Style="{StaticResource MetricLabel}"/>
<TextBlock Text="{Binding FriabilityRealtimeRounds}" Foreground="#1565C0" Style="{StaticResource MetricValue}"/>
<TextBlock Text="{Binding FriabilityRealtimeRounds, StringFormat=F1}" Foreground="#1565C0" Style="{StaticResource MetricValue}"/>
</StackPanel>
</Border>
<Border Style="{StaticResource MetricCard}">

View File

@@ -29,7 +29,7 @@
"FriabilityRpm": 320, // 脆碎度转速 r/min
"FriabilityRounds": 410, // 脆碎圈数
"FriabilityRoundsBox": 410, // 兼容旧字段:脆碎圈数
"FriabilityRealtimeRounds": 82, // 脆碎实时圈数
"FriabilityRealtimeRounds": 82, // 脆碎实时圈数32位浮点
"DisintegrationSeconds": 420, //崩解时间