更新
This commit is contained in:
@@ -41,6 +41,8 @@ namespace TabletTester2025.Services
|
|||||||
int value = startAddress switch
|
int value = startAddress switch
|
||||||
{
|
{
|
||||||
410 => 100, // 脆碎圈数
|
410 => 100, // 脆碎圈数
|
||||||
|
430 => 30, // 溶出1时间(min)
|
||||||
|
440 => 30, // 溶出2时间(min)
|
||||||
_ => _rand.Next(0, 1000)
|
_ => _rand.Next(0, 1000)
|
||||||
};
|
};
|
||||||
return Task.FromResult(value);
|
return Task.FromResult(value);
|
||||||
|
|||||||
@@ -1624,7 +1624,7 @@ namespace TabletTester2025.ViewModels
|
|||||||
AddHardnessSample(value);
|
AddHardnessSample(value);
|
||||||
await ReadHardnessMaxCaptureAsync();
|
await ReadHardnessMaxCaptureAsync();
|
||||||
ApplyHardnessStatistics(count);
|
ApplyHardnessStatistics(count);
|
||||||
await WaitForCoilStateAsync(completeCoil, false, TimeSpan.FromSeconds(10), "硬度完成信号未回落");
|
await TryWaitForCoilStateAsync(completeCoil, false, TimeSpan.FromSeconds(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_hardnessResults.Count < count)
|
if (_hardnessResults.Count < count)
|
||||||
@@ -1786,6 +1786,20 @@ namespace TabletTester2025.ViewModels
|
|||||||
throw new TimeoutException(timeoutMessage);
|
throw new TimeoutException(timeoutMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<bool> TryWaitForCoilStateAsync(ushort coilAddress, bool expectedState, TimeSpan timeout)
|
||||||
|
{
|
||||||
|
DateTime deadline = DateTime.Now.Add(timeout);
|
||||||
|
while (_isHardnessRunning && DateTime.Now <= deadline)
|
||||||
|
{
|
||||||
|
if (await _plc.ReadCoilAsync(coilAddress) == expectedState)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
await Task.Delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void ApplyHardnessStatistics(int requiredCount)
|
private void ApplyHardnessStatistics(int requiredCount)
|
||||||
{
|
{
|
||||||
var stats = TestCalculationService.CalculateHardness(
|
var stats = TestCalculationService.CalculateHardness(
|
||||||
|
|||||||
@@ -151,6 +151,16 @@
|
|||||||
<TextBlock Text="溶出速度2(r/min):" Style="{StaticResource ParamLabel}"/>
|
<TextBlock Text="溶出速度2(r/min):" Style="{StaticResource ParamLabel}"/>
|
||||||
<TextBox x:Name="Dissolution2SpeedBox"/>
|
<TextBox x:Name="Dissolution2SpeedBox"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel Style="{StaticResource ParamRow}">
|
||||||
|
<TextBlock Text="溶出1时间(min):" Style="{StaticResource ParamLabel}"/>
|
||||||
|
<TextBox x:Name="Dissolution1TimeBox"
|
||||||
|
helpers:NumericInput.AllowDecimal="False"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Style="{StaticResource ParamRow}">
|
||||||
|
<TextBlock Text="溶出2时间(min):" Style="{StaticResource ParamLabel}"/>
|
||||||
|
<TextBox x:Name="Dissolution2TimeBox"
|
||||||
|
helpers:NumericInput.AllowDecimal="False"/>
|
||||||
|
</StackPanel>
|
||||||
<StackPanel Style="{StaticResource ParamRow}">
|
<StackPanel Style="{StaticResource ParamRow}">
|
||||||
<TextBlock Text="溶出1取样间隔(min):" Style="{StaticResource ParamLabel}"/>
|
<TextBlock Text="溶出1取样间隔(min):" Style="{StaticResource ParamLabel}"/>
|
||||||
<TextBox x:Name="Dissolution1IntervalBox" helpers:NumericInput.AllowDecimal="True"/>
|
<TextBox x:Name="Dissolution1IntervalBox" helpers:NumericInput.AllowDecimal="True"/>
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ namespace TabletTester2025
|
|||||||
// 溶出度
|
// 溶出度
|
||||||
await LoadPlcFloatToTextBoxAsync(ResolveDissolution1SpeedRegister(), Dissolution1SpeedBox);
|
await LoadPlcFloatToTextBoxAsync(ResolveDissolution1SpeedRegister(), Dissolution1SpeedBox);
|
||||||
await LoadPlcFloatToTextBoxAsync(ResolveDissolution2SpeedRegister(), Dissolution2SpeedBox);
|
await LoadPlcFloatToTextBoxAsync(ResolveDissolution2SpeedRegister(), Dissolution2SpeedBox);
|
||||||
|
await LoadPlcIntToTextBoxAsync(ResolveDissolution1TimeRegister(), Dissolution1TimeBox);
|
||||||
|
await LoadPlcIntToTextBoxAsync(ResolveDissolution2TimeRegister(), Dissolution2TimeBox);
|
||||||
await LoadPlcFloatToTextBoxAsync(ResolveDissolution1IntervalRegister(), Dissolution1IntervalBox);
|
await LoadPlcFloatToTextBoxAsync(ResolveDissolution1IntervalRegister(), Dissolution1IntervalBox);
|
||||||
await LoadPlcFloatToTextBoxAsync(ResolveDissolution2IntervalRegister(), Dissolution2IntervalBox);
|
await LoadPlcFloatToTextBoxAsync(ResolveDissolution2IntervalRegister(), Dissolution2IntervalBox);
|
||||||
}
|
}
|
||||||
@@ -44,6 +46,8 @@ namespace TabletTester2025
|
|||||||
DisintegrationTimeMinBox.Text = ResolveDisintegrationTimeMin(p).ToString("0.###");
|
DisintegrationTimeMinBox.Text = ResolveDisintegrationTimeMin(p).ToString("0.###");
|
||||||
//DisintegrationTempBox.Text = p.DisintegrationTemperatureC.ToString();
|
//DisintegrationTempBox.Text = p.DisintegrationTemperatureC.ToString();
|
||||||
//DissolutionTempBox.Text = p.DissolutionTemperatureC.ToString();
|
//DissolutionTempBox.Text = p.DissolutionTemperatureC.ToString();
|
||||||
|
Dissolution1TimeBox.Text = p.Dissolution1TimeMin.ToString();
|
||||||
|
Dissolution2TimeBox.Text = p.Dissolution2TimeMin.ToString();
|
||||||
Dissolution1IntervalBox.Text = p.Dissolution1SampleIntervalMin.ToString();
|
Dissolution1IntervalBox.Text = p.Dissolution1SampleIntervalMin.ToString();
|
||||||
Dissolution2IntervalBox.Text = p.Dissolution2SampleIntervalMin.ToString();
|
Dissolution2IntervalBox.Text = p.Dissolution2SampleIntervalMin.ToString();
|
||||||
}
|
}
|
||||||
@@ -83,6 +87,8 @@ namespace TabletTester2025
|
|||||||
//p.DissolutionTemperatureC = ParseFiniteDouble(DissolutionTempBox.Text, "溶出介质温度");
|
//p.DissolutionTemperatureC = ParseFiniteDouble(DissolutionTempBox.Text, "溶出介质温度");
|
||||||
double dissolution1Speed = ParsePositiveDouble(Dissolution1SpeedBox.Text, "溶出速度1");
|
double dissolution1Speed = ParsePositiveDouble(Dissolution1SpeedBox.Text, "溶出速度1");
|
||||||
double dissolution2Speed = ParsePositiveDouble(Dissolution2SpeedBox.Text, "溶出速度2");
|
double dissolution2Speed = ParsePositiveDouble(Dissolution2SpeedBox.Text, "溶出速度2");
|
||||||
|
p.Dissolution1TimeMin = ParsePositiveInt(Dissolution1TimeBox.Text, "溶出1时间");
|
||||||
|
p.Dissolution2TimeMin = ParsePositiveInt(Dissolution2TimeBox.Text, "溶出2时间");
|
||||||
p.Dissolution1SampleIntervalMin = ParsePositiveDouble(Dissolution1IntervalBox.Text, "溶出1取样间隔");
|
p.Dissolution1SampleIntervalMin = ParsePositiveDouble(Dissolution1IntervalBox.Text, "溶出1取样间隔");
|
||||||
p.Dissolution2SampleIntervalMin = ParsePositiveDouble(Dissolution2IntervalBox.Text, "溶出2取样间隔");
|
p.Dissolution2SampleIntervalMin = ParsePositiveDouble(Dissolution2IntervalBox.Text, "溶出2取样间隔");
|
||||||
|
|
||||||
@@ -94,6 +100,8 @@ namespace TabletTester2025
|
|||||||
await WriteDisintegrationTimeAsync(disintegrationTimeMin);
|
await WriteDisintegrationTimeAsync(disintegrationTimeMin);
|
||||||
await WriteDissolution1SpeedAsync(dissolution1Speed);
|
await WriteDissolution1SpeedAsync(dissolution1Speed);
|
||||||
await WriteDissolution2SpeedAsync(dissolution2Speed);
|
await WriteDissolution2SpeedAsync(dissolution2Speed);
|
||||||
|
await WriteDissolution1TimeAsync(p.Dissolution1TimeMin);
|
||||||
|
await WriteDissolution2TimeAsync(p.Dissolution2TimeMin);
|
||||||
await WriteDissolution1IntervalAsync(p.Dissolution1SampleIntervalMin);
|
await WriteDissolution1IntervalAsync(p.Dissolution1SampleIntervalMin);
|
||||||
await WriteDissolution2IntervalAsync(p.Dissolution2SampleIntervalMin);
|
await WriteDissolution2IntervalAsync(p.Dissolution2SampleIntervalMin);
|
||||||
App.CurrentPharmaParams = p;
|
App.CurrentPharmaParams = p;
|
||||||
@@ -351,6 +359,24 @@ namespace TabletTester2025
|
|||||||
await App.PlcService.WriteFloatAsync(registerAddress, (float)value);
|
await App.PlcService.WriteFloatAsync(registerAddress, (float)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task WriteDissolution1TimeAsync(int value)
|
||||||
|
{
|
||||||
|
ushort registerAddress = ResolveDissolution1TimeRegister();
|
||||||
|
if (registerAddress == 0)
|
||||||
|
throw new InvalidOperationException("溶出1时间PLC寄存器地址未配置。");
|
||||||
|
|
||||||
|
await App.PlcService.WriteRegisterAsync(registerAddress, (ushort)Math.Clamp(value, 1, ushort.MaxValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task WriteDissolution2TimeAsync(int value)
|
||||||
|
{
|
||||||
|
ushort registerAddress = ResolveDissolution2TimeRegister();
|
||||||
|
if (registerAddress == 0)
|
||||||
|
throw new InvalidOperationException("溶出2时间PLC寄存器地址未配置。");
|
||||||
|
|
||||||
|
await App.PlcService.WriteRegisterAsync(registerAddress, (ushort)Math.Clamp(value, 1, ushort.MaxValue));
|
||||||
|
}
|
||||||
|
|
||||||
private static async Task WriteDissolution1IntervalAsync(double value)
|
private static async Task WriteDissolution1IntervalAsync(double value)
|
||||||
{
|
{
|
||||||
ushort registerAddress = ResolveDissolution1IntervalRegister();
|
ushort registerAddress = ResolveDissolution1IntervalRegister();
|
||||||
@@ -379,6 +405,16 @@ namespace TabletTester2025
|
|||||||
return App.PlcConfig.Dissolution2Speed != 0 ? App.PlcConfig.Dissolution2Speed : (ushort)350;
|
return App.PlcConfig.Dissolution2Speed != 0 ? App.PlcConfig.Dissolution2Speed : (ushort)350;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ushort ResolveDissolution1TimeRegister()
|
||||||
|
{
|
||||||
|
return App.PlcConfig.Dissolution1Time != 0 ? App.PlcConfig.Dissolution1Time : (ushort)430;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ushort ResolveDissolution2TimeRegister()
|
||||||
|
{
|
||||||
|
return App.PlcConfig.Dissolution2Time != 0 ? App.PlcConfig.Dissolution2Time : (ushort)440;
|
||||||
|
}
|
||||||
|
|
||||||
private static ushort ResolveDissolution1IntervalRegister()
|
private static ushort ResolveDissolution1IntervalRegister()
|
||||||
{
|
{
|
||||||
return App.PlcConfig.Dissolution1SampleInterval != 0 ? App.PlcConfig.Dissolution1SampleInterval : (ushort)432;
|
return App.PlcConfig.Dissolution1SampleInterval != 0 ? App.PlcConfig.Dissolution1SampleInterval : (ushort)432;
|
||||||
|
|||||||
Reference in New Issue
Block a user