更新2026
This commit is contained in:
@@ -91,6 +91,10 @@
|
||||
<TextBlock Text="加压压力:" Style="{StaticResource ParamLabel}"/>
|
||||
<TextBox x:Name="HardnessPressureBox"/>
|
||||
</StackPanel>
|
||||
<StackPanel Style="{StaticResource ParamRow}">
|
||||
<TextBlock Text="硬度破损判定(N):" Style="{StaticResource ParamLabel}"/>
|
||||
<TextBox x:Name="HardnessDamageThresholdBox" helpers:NumericInput.AllowDecimal="False"/>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
<TextBlock Text="硬度没有统一药典数值限度,此处作为企业内控范围和本机测试次数。"
|
||||
Style="{StaticResource StandardNote}"/>
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace TabletTester2025
|
||||
private async void SettingsWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await LoadHardnessPressureAsync();
|
||||
await LoadHardnessDamageThresholdAsync();
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
@@ -56,6 +57,7 @@ namespace TabletTester2025
|
||||
p.HardnessMax_N = ParseFiniteDouble(HardnessMaxBox.Text, "硬度内控上限");
|
||||
p.HardnessTestCount = int.Parse(HardnessCountBox.Text);
|
||||
double hardnessPressure = ParseFiniteDouble(HardnessPressureBox.Text, "加压压力");
|
||||
int hardnessDamageThreshold = ParsePositiveInt(HardnessDamageThresholdBox.Text, "硬度破损判定");
|
||||
p.FriabilityTargetRpm = ParseFiniteDouble(FriabilityRpmBox.Text, "脆碎度转速");
|
||||
p.FriabilityTargetTimeMin = ParseFiniteDouble(FriabilityTimeBox.Text, "脆碎度试验时间");
|
||||
p.FriabilityTargetRounds = ParsePositiveInt(FriabilityRoundsBox.Text, "脆碎圈数");
|
||||
@@ -77,6 +79,7 @@ namespace TabletTester2025
|
||||
|
||||
ValidateParameters(p);
|
||||
await WriteHardnessPressureAsync(hardnessPressure);
|
||||
await WriteHardnessDamageThresholdAsync(hardnessDamageThreshold);
|
||||
App.CurrentPharmaParams = p;
|
||||
App.SaveCurrentPharmaParameters();
|
||||
|
||||
@@ -204,6 +207,38 @@ namespace TabletTester2025
|
||||
return App.PlcConfig.HardnessPressure != 0 ? App.PlcConfig.HardnessPressure : (ushort)1480;
|
||||
}
|
||||
|
||||
private async Task LoadHardnessDamageThresholdAsync()
|
||||
{
|
||||
ushort registerAddress = ResolveHardnessDamageThresholdRegister();
|
||||
if (registerAddress == 0)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
int value = await App.PlcService.ReadIntAsync(registerAddress);
|
||||
if (value >= 0)
|
||||
HardnessDamageThresholdBox.Text = value.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
HardnessDamageThresholdBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task WriteHardnessDamageThresholdAsync(int value)
|
||||
{
|
||||
ushort registerAddress = ResolveHardnessDamageThresholdRegister();
|
||||
if (registerAddress == 0)
|
||||
throw new InvalidOperationException("硬度破损判定PLC寄存器地址未配置。");
|
||||
|
||||
await App.PlcService.WriteRegisterAsync(registerAddress, (ushort)Math.Clamp(value, 0, ushort.MaxValue));
|
||||
}
|
||||
|
||||
private static ushort ResolveHardnessDamageThresholdRegister()
|
||||
{
|
||||
return App.PlcConfig.HardnessPoSun != 0 ? App.PlcConfig.HardnessPoSun : (ushort)400;
|
||||
}
|
||||
|
||||
private static double ResolveFriabilityTargetTimeMin(PharmaParameters p)
|
||||
{
|
||||
if (p.FriabilityTargetTimeMin > 0)
|
||||
|
||||
Reference in New Issue
Block a user