更新2026
This commit is contained in:
@@ -19,6 +19,7 @@ namespace TabletTester2025.Services
|
|||||||
{
|
{
|
||||||
72 => 40 + (float)_rand.NextDouble() * 20, // 硬度最大采集力
|
72 => 40 + (float)_rand.NextDouble() * 20, // 硬度最大采集力
|
||||||
100 => 40 + (float)_rand.NextDouble() * 20, // 硬度 40~60N
|
100 => 40 + (float)_rand.NextDouble() * 20, // 硬度 40~60N
|
||||||
|
82 => _rand.Next(0, 101), // 脆碎实时圈数
|
||||||
410 => 100f, // 脆碎圈数
|
410 => 100f, // 脆碎圈数
|
||||||
412 => 5.0f + (float)_rand.NextDouble() * 2, // 脆碎度前重
|
412 => 5.0f + (float)_rand.NextDouble() * 2, // 脆碎度前重
|
||||||
414 => 4.9f + (float)_rand.NextDouble() * 2, // 后重
|
414 => 4.9f + (float)_rand.NextDouble() * 2, // 后重
|
||||||
@@ -41,7 +42,6 @@ namespace TabletTester2025.Services
|
|||||||
{
|
{
|
||||||
int value = startAddress switch
|
int value = startAddress switch
|
||||||
{
|
{
|
||||||
82 => _rand.Next(0, 101), // 脆碎实时圈数
|
|
||||||
410 => 100, // 脆碎圈数
|
410 => 100, // 脆碎圈数
|
||||||
430 => 30, // 溶出1时间(min)
|
430 => 30, // 溶出1时间(min)
|
||||||
440 => 30, // 溶出2时间(min)
|
440 => 30, // 溶出2时间(min)
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace TabletTester2025.ViewModels
|
|||||||
[ObservableProperty] private bool _friabilityClockwise = true;
|
[ObservableProperty] private bool _friabilityClockwise = true;
|
||||||
[ObservableProperty] private bool _friabilityCounterClockwise;
|
[ObservableProperty] private bool _friabilityCounterClockwise;
|
||||||
[ObservableProperty] private double _friabilityCurrentRpm;
|
[ObservableProperty] private double _friabilityCurrentRpm;
|
||||||
[ObservableProperty] private int _friabilityRealtimeRounds;
|
[ObservableProperty] private double _friabilityRealtimeRounds;
|
||||||
[ObservableProperty] private int _friabilityRemainingRounds = 100;
|
[ObservableProperty] private int _friabilityRemainingRounds = 100;
|
||||||
public IAsyncRelayCommand StopHardnessCommand { get; }
|
public IAsyncRelayCommand StopHardnessCommand { get; }
|
||||||
public IAsyncRelayCommand StopFriabilityCommand { get; }
|
public IAsyncRelayCommand StopFriabilityCommand { get; }
|
||||||
@@ -1885,36 +1885,35 @@ namespace TabletTester2025.ViewModels
|
|||||||
throw new InvalidOperationException("脆碎前重量必须大于0");
|
throw new InvalidOperationException("脆碎前重量必须大于0");
|
||||||
|
|
||||||
double rpm = FriabilityTargetRpm > 0 ? FriabilityTargetRpm : 25;
|
double rpm = FriabilityTargetRpm > 0 ? FriabilityTargetRpm : 25;
|
||||||
double testTimeMin = FriabilityTargetTimeMin > 0 ? FriabilityTargetTimeMin : 4;
|
|
||||||
int totalRounds = Math.Max(1, FriabilityTargetRounds);
|
int totalRounds = Math.Max(1, FriabilityTargetRounds);
|
||||||
FriabilityRemainingRounds = totalRounds;
|
FriabilityRemainingRounds = totalRounds;
|
||||||
FriabilityCurrentRpm = rpm;
|
FriabilityCurrentRpm = rpm;
|
||||||
await RefreshFriabilityRealtimeRoundsAsync();
|
await RefreshFriabilityRealtimeRoundsAsync();
|
||||||
await PulseCoilAsync(startCoil);
|
await PulseCoilAsync(startCoil);
|
||||||
int durationMs = (int)Math.Ceiling(testTimeMin * 60 * 1000); // 总运行时间(毫秒)
|
bool targetRoundsReached = false;
|
||||||
|
|
||||||
for (int i = 0; i < durationMs; i += 100)
|
while (_isFriabilityRunning)
|
||||||
{
|
{
|
||||||
// 如果用户点了停止,只结束脆碎度测试,不影响其它测试
|
await RefreshFriabilityRealtimeRoundsAsync();
|
||||||
if (!_isFriabilityRunning)
|
|
||||||
|
double completedRounds = Math.Max(0, FriabilityRealtimeRounds);
|
||||||
|
FriabilityRemainingRounds = (int)Math.Ceiling(Math.Max(0, totalRounds - completedRounds));
|
||||||
|
if (completedRounds >= totalRounds)
|
||||||
|
{
|
||||||
|
targetRoundsReached = true;
|
||||||
|
FriabilityRemainingRounds = 0;
|
||||||
break;
|
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,再更新下一次
|
// 等待100ms,再更新下一次
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
}
|
}
|
||||||
if (!_isFriabilityRunning)
|
if (!_isFriabilityRunning || !targetRoundsReached)
|
||||||
throw new InvalidOperationException("脆碎度测试已停止,未保存结果");
|
throw new InvalidOperationException("脆碎度测试已停止,未保存结果");
|
||||||
|
|
||||||
|
if (_plcConfig.FriabilityStartCoilStop != 0)
|
||||||
|
await PulseCoilAsync(_plcConfig.FriabilityStartCoilStop);
|
||||||
|
|
||||||
double weightAfter = await ReadFriabilityWeightAsync(ResolveFriabilityWeightAfterRegister(), "脆碎后重量");
|
double weightAfter = await ReadFriabilityWeightAsync(ResolveFriabilityWeightAfterRegister(), "脆碎后重量");
|
||||||
SetFriabilityWeightFromPlc(weightAfter: weightAfter);
|
SetFriabilityWeightFromPlc(weightAfter: weightAfter);
|
||||||
FriabilityCurrentRpm = rpm;
|
FriabilityCurrentRpm = rpm;
|
||||||
@@ -1982,8 +1981,8 @@ namespace TabletTester2025.ViewModels
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int value = await _plc.ReadIntAsync(registerAddress);
|
double value = await _plc.ReadFloatAsync(registerAddress);
|
||||||
if (value >= 0)
|
if (double.IsFinite(value) && value >= 0)
|
||||||
FriabilityRealtimeRounds = value;
|
FriabilityRealtimeRounds = value;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
@@ -494,7 +494,7 @@
|
|||||||
<Border Style="{StaticResource MetricCard}">
|
<Border Style="{StaticResource MetricCard}">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="实时圈数" Style="{StaticResource MetricLabel}"/>
|
<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>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Style="{StaticResource MetricCard}">
|
<Border Style="{StaticResource MetricCard}">
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
"FriabilityRpm": 320, // 脆碎度转速 r/min
|
"FriabilityRpm": 320, // 脆碎度转速 r/min
|
||||||
"FriabilityRounds": 410, // 脆碎圈数
|
"FriabilityRounds": 410, // 脆碎圈数
|
||||||
"FriabilityRoundsBox": 410, // 兼容旧字段:脆碎圈数
|
"FriabilityRoundsBox": 410, // 兼容旧字段:脆碎圈数
|
||||||
"FriabilityRealtimeRounds": 82, // 脆碎实时圈数
|
"FriabilityRealtimeRounds": 82, // 脆碎实时圈数,32位浮点
|
||||||
"DisintegrationSeconds": 420, //崩解时间
|
"DisintegrationSeconds": 420, //崩解时间
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user