更新20260519
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
public ushort HardnessOver { get; set; }
|
public ushort HardnessOver { get; set; }
|
||||||
public ushort HardnessCompleteCoil { get; set; }
|
public ushort HardnessCompleteCoil { get; set; }
|
||||||
public ushort HardnessPoSun { get; set; }
|
public ushort HardnessPoSun { get; set; }
|
||||||
|
public ushort HardnessPressure { get; set; }
|
||||||
// 脆碎度
|
// 脆碎度
|
||||||
public ushort FriabilityStartCoil { get; set; }
|
public ushort FriabilityStartCoil { get; set; }
|
||||||
public ushort FriabilityTestTime { get; set; }
|
public ushort FriabilityTestTime { get; set; }
|
||||||
|
|||||||
@@ -87,6 +87,10 @@
|
|||||||
<TextBlock Text="测试次数:" Style="{StaticResource ParamLabel}"/>
|
<TextBlock Text="测试次数:" Style="{StaticResource ParamLabel}"/>
|
||||||
<TextBox x:Name="HardnessCountBox" helpers:NumericInput.AllowDecimal="False"/>
|
<TextBox x:Name="HardnessCountBox" helpers:NumericInput.AllowDecimal="False"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel Style="{StaticResource ParamRow}">
|
||||||
|
<TextBlock Text="加压压力:" Style="{StaticResource ParamLabel}"/>
|
||||||
|
<TextBox x:Name="HardnessPressureBox"/>
|
||||||
|
</StackPanel>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
<TextBlock Text="硬度没有统一药典数值限度,此处作为企业内控范围和本机测试次数。"
|
<TextBlock Text="硬度没有统一药典数值限度,此处作为企业内控范围和本机测试次数。"
|
||||||
Style="{StaticResource StandardNote}"/>
|
Style="{StaticResource StandardNote}"/>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using TabletTester2025.Models;
|
using TabletTester2025.Models;
|
||||||
@@ -12,6 +13,12 @@ namespace TabletTester2025
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
Loaded += SettingsWindow_Loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void SettingsWindow_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
await LoadHardnessPressureAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSettings()
|
private void LoadSettings()
|
||||||
@@ -39,7 +46,7 @@ namespace TabletTester2025
|
|||||||
SampleTimesBox.Text = string.Join(",", p.DissolutionSampleTimes ?? Array.Empty<int>());
|
SampleTimesBox.Text = string.Join(",", p.DissolutionSampleTimes ?? Array.Empty<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
private async void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -50,6 +57,7 @@ namespace TabletTester2025
|
|||||||
p.HardnessMin_N = ParseFiniteDouble(HardnessMinBox.Text, "硬度内控下限");
|
p.HardnessMin_N = ParseFiniteDouble(HardnessMinBox.Text, "硬度内控下限");
|
||||||
p.HardnessMax_N = ParseFiniteDouble(HardnessMaxBox.Text, "硬度内控上限");
|
p.HardnessMax_N = ParseFiniteDouble(HardnessMaxBox.Text, "硬度内控上限");
|
||||||
p.HardnessTestCount = int.Parse(HardnessCountBox.Text);
|
p.HardnessTestCount = int.Parse(HardnessCountBox.Text);
|
||||||
|
double hardnessPressure = ParseFiniteDouble(HardnessPressureBox.Text, "加压压力");
|
||||||
p.FriabilityTargetRpm = ParseFiniteDouble(FriabilityRpmBox.Text, "脆碎度转速");
|
p.FriabilityTargetRpm = ParseFiniteDouble(FriabilityRpmBox.Text, "脆碎度转速");
|
||||||
p.FriabilityTargetTimeMin = ParseFiniteDouble(FriabilityTimeBox.Text, "脆碎度试验时间");
|
p.FriabilityTargetTimeMin = ParseFiniteDouble(FriabilityTimeBox.Text, "脆碎度试验时间");
|
||||||
p.FriabilityTargetRounds = CalculateFriabilityRounds(p.FriabilityTargetTimeMin, p.FriabilityTargetRpm);
|
p.FriabilityTargetRounds = CalculateFriabilityRounds(p.FriabilityTargetTimeMin, p.FriabilityTargetRpm);
|
||||||
@@ -70,6 +78,7 @@ namespace TabletTester2025
|
|||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
ValidateParameters(p);
|
ValidateParameters(p);
|
||||||
|
await WriteHardnessPressureAsync(hardnessPressure);
|
||||||
App.CurrentPharmaParams = p;
|
App.CurrentPharmaParams = p;
|
||||||
App.SaveCurrentPharmaParameters();
|
App.SaveCurrentPharmaParameters();
|
||||||
|
|
||||||
@@ -169,10 +178,44 @@ namespace TabletTester2025
|
|||||||
{
|
{
|
||||||
if (!double.TryParse(text, out double value) || !double.IsFinite(value))
|
if (!double.TryParse(text, out double value) || !double.IsFinite(value))
|
||||||
throw new InvalidOperationException($"{fieldName}必须为有效数字。");
|
throw new InvalidOperationException($"{fieldName}必须为有效数字。");
|
||||||
|
if (value < 0)
|
||||||
|
throw new InvalidOperationException($"{fieldName}不能小于0。");
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task LoadHardnessPressureAsync()
|
||||||
|
{
|
||||||
|
ushort registerAddress = ResolveHardnessPressureRegister();
|
||||||
|
if (registerAddress == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
float value = await App.PlcService.ReadFloatAsync(registerAddress);
|
||||||
|
if (float.IsFinite(value))
|
||||||
|
HardnessPressureBox.Text = value.ToString("0.###");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
HardnessPressureBox.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task WriteHardnessPressureAsync(double value)
|
||||||
|
{
|
||||||
|
ushort registerAddress = ResolveHardnessPressureRegister();
|
||||||
|
if (registerAddress == 0)
|
||||||
|
throw new InvalidOperationException("加压压力PLC寄存器地址未配置。");
|
||||||
|
|
||||||
|
await App.PlcService.WriteFloatAsync(registerAddress, (float)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ushort ResolveHardnessPressureRegister()
|
||||||
|
{
|
||||||
|
return App.PlcConfig.HardnessPressure != 0 ? App.PlcConfig.HardnessPressure : (ushort)1480;
|
||||||
|
}
|
||||||
|
|
||||||
private static double ResolveFriabilityTargetTimeMin(PharmaParameters p)
|
private static double ResolveFriabilityTargetTimeMin(PharmaParameters p)
|
||||||
{
|
{
|
||||||
if (p.FriabilityTargetTimeMin > 0)
|
if (p.FriabilityTargetTimeMin > 0)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"HardnessSudu": 300, // 硬度速度输入mm/min
|
"HardnessSudu": 300, // 硬度速度输入mm/min
|
||||||
"HardnessWeiyi": 310, // 硬度位移输入mm/min
|
"HardnessWeiyi": 310, // 硬度位移输入mm/min
|
||||||
"HardnessPoSun": 400, // 硬度破损判定输入N
|
"HardnessPoSun": 400, // 硬度破损判定输入N
|
||||||
|
"HardnessPressure": 1480, // 加压压力
|
||||||
"HardnessMax": 72, //最大力采集
|
"HardnessMax": 72, //最大力采集
|
||||||
"HardnessShishilizhi": 1314, //力显示
|
"HardnessShishilizhi": 1314, //力显示
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user