This commit is contained in:
xyy
2026-06-08 13:47:06 +08:00
parent d5f7d309a0
commit 08042e243f
2 changed files with 16 additions and 10 deletions

View File

@@ -91,6 +91,6 @@ public class CalibrationCoefficients
public ushort PressureProtection { get; set; }
public ushort TemperatureCoefficient { get; set; }
public ushort ResistanceCoefficient { get; set; }
public double ThermalConductivityCorrection { get; set; } = 40.5f;//蒸馏水 比热率修正
public double ThermalDiffusivityCorrection { get; set; } = 0.53;//导热率修正
public double ThermalConductivityCorrection { get; set; } = 47.305349f;//蒸馏水 比热率修正
public double ThermalDiffusivityCorrection { get; set; } = 0.312912;//导热率修正
}

View File

@@ -158,7 +158,8 @@ public partial class D7896ViewModel : ObservableObject
// }
// catch { return 0; }
//}
// 在类成员变量区域添加
private int currentSettleMs = 200; // 电流稳定等待时间(毫秒)
[RelayCommand]
private async Task StartTestAsync()
{
@@ -334,14 +335,18 @@ public partial class D7896ViewModel : ObservableObject
await _th1963Ustd.PrepareBatchAsync(samples);
await _th1953Ustd.PrepareBatchAsync(samples);
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, true);
try { await Task.Delay(5, _testCts.Token); } catch (OperationCanceledException) { break; }
// 等待电流稳定(不触发采集)
try { await Task.Delay(currentSettleMs, _testCts.Token); } catch (OperationCanceledException) { break; }
// 电流稳定后,触发采集
await Task.WhenAll(_th1963Ustd.TriggerAsync(), _th1953Ustd.TriggerAsync());
// 继续加热剩余时间(加热总时间 = 稳定等待时间 + 有效加热时间)
try { await Task.Delay((int)(heatingDuration * 1000), _testCts.Token); } catch (OperationCanceledException) { break; }
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, false);
int remainingMs = (int)((totalDuration - heatingDuration) * 1000) + 100;
try { await Task.Delay(remainingMs, _testCts.Token); } catch (OperationCanceledException) { break; }
@@ -439,7 +444,7 @@ public partial class D7896ViewModel : ObservableObject
// 测量间隔(即使舍弃也等待,让样品恢复)
if (validCount < requiredCount && !_stopRequested && attemptCount < maxAttempts)
{
try { await Task.Delay(_config.TestParameters.IntervalSeconds * 1000, _testCts.Token); } catch (OperationCanceledException) { break; }
try { await Task.Delay(_config.TestParameters.IntervalSeconds * 100, _testCts.Token); } catch (OperationCanceledException) { break; }
}
}
@@ -506,12 +511,13 @@ public partial class D7896ViewModel : ObservableObject
}
}
// 滑动平均平滑(窗口5
// 滑动平均平滑(窗口大小改为 11
int windowSize = 40; // 原为 5
double[] smoothDeltaT = new double[n];
for (int i = 0; i < n; i++)
{
int start = Math.Max(0, i - 2);
int end = Math.Min(n - 1, i + 2);
int start = Math.Max(0, i - windowSize / 2);
int end = Math.Min(n - 1, i + windowSize / 2);
double sum = 0; int cnt = 0;
for (int j = start; j <= end; j++)
if (!double.IsNaN(deltaT[j])) { sum += deltaT[j]; cnt++; }