更新20260622

This commit is contained in:
GukSang.Jin
2026-06-22 10:16:43 +08:00
parent 7158942669
commit a4f4fdd007
3 changed files with 143 additions and 43 deletions

View File

@@ -50,6 +50,12 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
private double verticalLoadN;
private double horizontalFrictionN;
private double displacementMm;
// 轻量滑动平均:滤掉力信号的高频抖动,但窗口很短(默认 3 点≈30ms@100Hz以保留静摩擦首峰
// 满足 GB/T 3903.6 数据采集频率≥30Hz、0.3~0.6s 内≥10 点)的前提下让曲线更接近标准。
private const int ForceFilterWindow = 3;
private readonly Queue<double> pressureFilterSamples = new();
private readonly Queue<double> frictionFilterSamples = new();
private int pressureRawValue;
private int frictionRawValue1;
private int frictionRawValue2;
@@ -315,8 +321,8 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
hasAdcRawValues = true;
if (conversion.IsValid)
{
verticalLoadN = conversion.Pressure;
horizontalFrictionN = conversion.Friction;
verticalLoadN = MovingAverage(pressureFilterSamples, conversion.Pressure);
horizontalFrictionN = MovingAverage(frictionFilterSamples, conversion.Friction);
adcLastError = string.Empty;
isAdcConnected = true;
}
@@ -324,6 +330,8 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
{
verticalLoadN = 0;
horizontalFrictionN = 0;
pressureFilterSamples.Clear();
frictionFilterSamples.Clear();
adcLastError = conversion.Error;
isAdcConnected = false;
}
@@ -633,6 +641,23 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services
private static double ConvertAdc(int rawValue, double zero, double coefficient) =>
(rawValue - zero) / coefficient;
private static double MovingAverage(Queue<double> window, double sample)
{
window.Enqueue(sample);
while (window.Count > ForceFilterWindow)
{
window.Dequeue();
}
var sum = 0.0;
foreach (var value in window)
{
sum += value;
}
return sum / window.Count;
}
private static void TryParseSetting(string value, string label, bool requireNonZero, List<string> invalid, out double numericValue)
{
if (!TryParseDouble(value, out numericValue))