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