更新
This commit is contained in:
@@ -151,10 +151,12 @@ namespace TabletTester2025.ViewModels
|
||||
[ObservableProperty] private double _friabilityCurrentRpm;
|
||||
[ObservableProperty] private double _friabilityRealtimeRounds;
|
||||
[ObservableProperty] private int _friabilityRemainingRounds = 100;
|
||||
[ObservableProperty] private bool _canSaveFriabilityResult;
|
||||
public IAsyncRelayCommand StopHardnessCommand { get; }
|
||||
public IAsyncRelayCommand StopFriabilityCommand { get; }
|
||||
public IAsyncRelayCommand ResetFriabilityCommand { get; }
|
||||
public IAsyncRelayCommand PrintFriabilityCommand { get; }
|
||||
public IAsyncRelayCommand SaveFriabilityResultCommand { get; }
|
||||
|
||||
// 溶出度新增
|
||||
[ObservableProperty] private double _dissolutionUpDownFreq = 32;
|
||||
@@ -222,6 +224,7 @@ namespace TabletTester2025.ViewModels
|
||||
|
||||
StartHardnessCommand = new AsyncRelayCommand(RunHardnessAsync);
|
||||
StartFriabilityCommand = new AsyncRelayCommand(RunFriabilityAsync);
|
||||
SaveFriabilityResultCommand = new AsyncRelayCommand(SaveFriabilityResultAsync);
|
||||
StartDisintegrationCommand = new AsyncRelayCommand(RunDisintegrationAsync);
|
||||
ClearHardnessRecordsCommand = new AsyncRelayCommand(ClearHardnessRecordsAsync);
|
||||
|
||||
@@ -310,11 +313,13 @@ namespace TabletTester2025.ViewModels
|
||||
if (_plcConfig.FriabilityStartCoilStop != 0)
|
||||
await PulseCoilAsync(_plcConfig.FriabilityStartCoilStop);
|
||||
_isFriabilityRunning = false;
|
||||
CanSaveFriabilityResult = false;
|
||||
RefreshOverallPhase();
|
||||
});
|
||||
ResetFriabilityCommand = new AsyncRelayCommand(() =>
|
||||
{
|
||||
FriabilityRemainingRounds = FriabilityTargetRounds;
|
||||
CanSaveFriabilityResult = false;
|
||||
LossPercent = 0; // 失重率清零
|
||||
SetFriabilityWeightFromPlc(0, 0); // 清空界面结果,不向PLC写零
|
||||
return Task.CompletedTask;
|
||||
@@ -1797,7 +1802,6 @@ namespace TabletTester2025.ViewModels
|
||||
HardnessAvg = stats.Average;
|
||||
HardnessAverageDeviation = stats.AverageDeviation;
|
||||
HardnessRSD = stats.RsdPercent;
|
||||
HardnessMax = stats.Maximum;
|
||||
HardnessMin = stats.Minimum;
|
||||
HardnessCurrentCount = stats.Count;
|
||||
HardnessPass = stats.IsPass;
|
||||
@@ -1848,6 +1852,7 @@ namespace TabletTester2025.ViewModels
|
||||
// 2. 标记当前正在运行的是脆碎度测试
|
||||
CurrentTest = TestType.Friability;
|
||||
_isFriabilityRunning = true;
|
||||
CanSaveFriabilityResult = false;
|
||||
RefreshOverallPhase();
|
||||
FriabilityPass = false;
|
||||
bool resultReady = false;
|
||||
@@ -1935,10 +1940,43 @@ namespace TabletTester2025.ViewModels
|
||||
|
||||
_isFriabilityRunning = false;
|
||||
RefreshOverallPhase();
|
||||
FriabilityRemainingRounds = FriabilityTargetRounds;
|
||||
if (resultReady)
|
||||
await SaveBatchResult(TestType.Friability);
|
||||
{
|
||||
CanSaveFriabilityResult = true;
|
||||
FriabilityRemainingRounds = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CanSaveFriabilityResult = false;
|
||||
FriabilityRemainingRounds = FriabilityTargetRounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveFriabilityResultAsync()
|
||||
{
|
||||
if (!CanSaveFriabilityResult)
|
||||
return;
|
||||
|
||||
if (!TryCalculateFriabilityLossFromWeights(out double localLossPercent))
|
||||
{
|
||||
bool plcLossReady = await TryRefreshFriabilityLossPercentFromPlcAsync();
|
||||
if (!plcLossReady)
|
||||
{
|
||||
await App.Current.Dispatcher.InvokeAsync(() =>
|
||||
MessageBox.Show("脆碎度实际数据异常,请确认前重、后重和失重率。", "保存失败", MessageBoxButton.OK, MessageBoxImage.Warning));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LossPercent = localLossPercent;
|
||||
FriabilityPass = LossPercent <= FriabilityMaxLossPercent;
|
||||
}
|
||||
|
||||
bool saved = await SaveBatchResult(TestType.Friability);
|
||||
if (saved)
|
||||
CanSaveFriabilityResult = false;
|
||||
}
|
||||
|
||||
private async Task<double> ReadFriabilityWeightAsync(ushort registerAddress, string label)
|
||||
@@ -2333,6 +2371,12 @@ namespace TabletTester2025.ViewModels
|
||||
string effectiveDissolutionChannel = testType == TestType.Dissolution
|
||||
? dissolutionChannel
|
||||
: "";
|
||||
double batchHardnessMax = testType == TestType.Hardness
|
||||
? _hardnessResults
|
||||
.Where(value => double.IsFinite(value) && value > 0)
|
||||
.DefaultIfEmpty(HardnessMax)
|
||||
.Max()
|
||||
: HardnessMax;
|
||||
|
||||
var batch = new TestBatch
|
||||
{
|
||||
@@ -2344,7 +2388,7 @@ namespace TabletTester2025.ViewModels
|
||||
HardnessAvg = HardnessAvg,
|
||||
HardnessAverageDeviation = HardnessAverageDeviation,
|
||||
HardnessRSD = HardnessRSD,
|
||||
HardnessMax = HardnessMax,
|
||||
HardnessMax = batchHardnessMax,
|
||||
HardnessMin = HardnessMin,
|
||||
HardnessTestCount = HardnessTestCount,
|
||||
HardnessInternalMin = HardnessInternalMin,
|
||||
|
||||
@@ -531,6 +531,7 @@
|
||||
<WrapPanel Grid.Row="2" Style="{StaticResource CommandBar}">
|
||||
<Button Command="{Binding StartFriabilityCommand}" Content="开始" Style="{StaticResource StartButton}"/>
|
||||
<Button Command="{Binding StopFriabilityCommand}" Content="停止" Style="{StaticResource StopButton}"/>
|
||||
<Button Command="{Binding SaveFriabilityResultCommand}" Content="保存记录" Style="{StaticResource SecondaryButton}" IsEnabled="{Binding CanSaveFriabilityResult}"/>
|
||||
<!--<Button Command="{Binding ResetFriabilityCommand}" Content="复位" Style="{StaticResource ResetButton}"/>-->
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user