Output.DB.SaveFlowmeterCorrections works well with tests when Repeats count > 1.

This commit is contained in:
Milan Hanajik
2018-03-15 05:59:22 +01:00
parent e8af9418bf
commit 6a40a351a7
@@ -78,13 +78,37 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
foreach (var tr in batch.TestRslts)
{
float testTempLimLo = tr.TempLimLo();
float testTempLimHi = tr.TempLimHi();
if (tr.TestDone && tr.Components != null && tr.Components.Flowmeter == flowmeterName && tr.Evaluate() && testTempLimLo >= tempRngLo
&& testTempLimHi <= tempRngHi)
if (tr.TestDone && tr.Components != null && tr.Components.Flowmeter == flowmeterName &&
tr.RepetitionNr == 1 && tr.Evaluate() && tr.TempLimLo() >= tempRngLo && tr.TempLimHi() <= tempRngHi)
{
double correction = BenchControl.Formulas.CorrectionFromError(tr.FlowMean, tr.ErrorMaster);
rslt.Add(new MeasurementCorrection { RangeIx = rngIx, Measurement = tr.FlowMean, Correction = (float)correction });
double flow = 0;
double errorMaster = 0;
if (tr.Repeats() == 1)
{
flow = tr.FlowMean;
errorMaster = tr.ErrorMaster;
}
else
{
int count = 0;
foreach (var tr2 in batch.TestRslts)
{
if (tr2.TestDone && (tr2.TestData.Id == tr.TestData.Id))
{
flow += tr2.FlowMean;
errorMaster += tr2.ErrorMaster;
count++;
}
}
flow /= count;
errorMaster /= count;
}
double correction = BenchControl.Formulas.CorrectionFromError(flow, errorMaster);
rslt.Add(new MeasurementCorrection { RangeIx = rngIx, Measurement = (float)flow, Correction = (float)correction });
}
}