Working on 2Hz correction

This commit is contained in:
Milan Hanajik
2016-02-15 15:16:44 +01:00
parent e22d58101c
commit 92bcd46549
2 changed files with 107 additions and 1 deletions
@@ -113,8 +113,9 @@ namespace TBF.BenchControl.WaterMeters.iPerl
public double Q2ErrorWOCorrection;
public bool Q2CorrectionDone;
public double CurrentQ2Correction;
public double CurrentQ2Correction;
public double Current2HzCorrection;
/// <summary> Result of the last test used to calculate Q2 correction factors, etc </summary>
public Results.Entities.MeterTestRslt LastTestResult;
@@ -219,6 +220,55 @@ namespace TBF.BenchControl.WaterMeters.iPerl
return corrFactor;
}
/// <summary>
/// 2 Hz correction factor calculated from two Q3 tests - done at 2Hz and at 8Hz.
/// This factors should be used only for DN32 and DN40 meters.
/// </summary>
/// <returns>2 Hz correction factor</returns>
public double Hz2CorrectionFactor()
{
Q2ErrorWOCorrection = LastTestResult.Error;
if (Math.Abs(LastTestResult.Error) <= 0.5)
{
Q2CorrectionDone = false;
return 0; /// No Q2 correction if error < +/-0.5 %
}
double A = 16.0 / ScalingFactor(); /// Raw units per ml: DN15=16, DN20=8, DN25=4, DN32=2, DN40=1
const double B = 8.0; /// Raw units per minute, 8
const double C = B * 60.0; /// Raw units per hour, 480
double D = C / A; /// ml correction per hour
double F = D / (NominalTestFlow * 10.0); /// Error corrected with 8 Raw Units per minute [%]
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
double errLimitLo = LastTestResult.ErrLimLo() + LastTestResult.Uncertainty();
double errLimitHi = LastTestResult.ErrLimHi() - LastTestResult.Uncertainty();
if (LastTestResult.Error < errLimitLo) return 0; /// No Q2 correction if error too large -> WM failed
if (LastTestResult.Error > errLimitHi) return 0; /// No Q2 correction if error too large -> WM failed
double volumeMeterErrLimLo = LastTestResult.VolumeRef * (100.0 + errLimitLo) / 100.0;
double volumeMeterErrLimHi = LastTestResult.VolumeRef * (100.0 + errLimitHi) / 100.0;
double corrFactorHi = (-1) * (errLimitLo / G) * (LastTestResult.VolumeRef / volumeMeterErrLimLo); /// > 0
double corrFactorLo = (-1) * (errLimitHi / G) * (LastTestResult.VolumeRef / volumeMeterErrLimHi); /// < 0
double corrFactor = (-1) * (LastTestResult.Error / G) * (LastTestResult.VolumeRef / LastTestResult.VolumeMeter);
double origCalulatedCorrFactor = corrFactor;
log.WarnFormat("Q2 correction: {0}, corrFactor={4}, error={3}% [Lo={1}%, Hi={2}%]",
Name,
errLimitLo.ToString("F1"),
errLimitHi.ToString("F1"),
LastTestResult.Error.ToString("F2"),
corrFactor.ToString("F1"));
Q2CorrectionDone = true;
return corrFactor;
}
/// <summary> Name set by the test, to be used as a part of the opto-data log file name </summary>
public string TestName;