(1) SUEZ cycle: InitOrReadQ2Correction, (Conditional)UpdateQ2Corrections, (2) Flow dir. detection fixed, (3) etc., ver. 2.18.1182

This commit is contained in:
Milan Hanajik
2019-04-03 16:19:46 +02:00
parent e356934ede
commit b235f9ae20
15 changed files with 752 additions and 487 deletions
@@ -39,9 +39,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
public ushort FactorLimitLo { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitLo; } }
public ushort FactorLimitHi { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitHi; } }
public Counting InitFlowDir { get { return (iperlHeadCfg != null && iperlHeadCfg.ProcParams != null) ? iperlHeadCfg.ProcParams.Counting : Counting.Arbitrary; } }
#if ORACLE_DB
public int WMType_ID { get { return iperlHeadCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB
#endif
public int WMType_ID { get { return iperlHeadCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB
public int InitQ2CorrLR { get { return iperlHeadCfg.ProcParams.InitQ2CorrLR; } } /// Used by InitOrReadQ2Corrections activity
public int InitQ2CorrRL { get { return iperlHeadCfg.ProcParams.InitQ2CorrRL; } } /// Required by Oracle DB
/// Properties set by the Begin and the End form
public string SerialNr
@@ -231,35 +232,15 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
/// <summary>
/// Q2 correction factor calculated from the last test (Q2).
/// This factors should be used only for R800 meters.
/// This factor should be used only for R800 meters.
/// </summary>
/// <param name="q2TestResult">Test result from which to calculate the factor</param>
/// <param name="q2CorrectionFactor">The calculated Q2 correction factor</param>
/// <returns>true = OK, false = failed</returns>
public bool CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt q2adjResult, Results.Entities.TestData q2adjTestData, out double q2CorrectionFactor)
/// <param name="q2TestResult">A test result from which to calculate the factor</param>
/// <param name="nominalFlow">Nominal flow in m3/h</param>
/// <param name="currentFactor">0 or the current Q2 correction factor when updating the factor</param>
/// <returns>Calculated Q2 correction factor</returns>
public double CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt q2adjResult, double nominalFlow, int currentFactor = 0)
{
q2CorrectionFactor = 0;
if (q2adjResult == null) return false; /// Q2 test result is missing ==> water meter failed
double errLimitLo = q2adjTestData.ErrLimLo + q2adjTestData.Uncertainty;
double errLimitHi = q2adjTestData.ErrLimHi - q2adjTestData.Uncertainty;
if ((q2adjResult.Error < errLimitLo) || (q2adjResult.Error > errLimitHi))
{
log.WarnFormat("Q2 correction: Pos={0}, PCB#={1}, ***Q2adjError={2}%***, CalTarget={3}%, ***corrFactor={4}***, [Lo={5}%, Hi={6}%]",
Name,
SerialNr,
q2adjResult.Error.ToString("F2"),
CalibTarget.ToString("F1"),
q2CorrectionFactor.ToString("F1"),
errLimitLo.ToString("F1"),
errLimitHi.ToString("F1"));
return false; /// Q2 error too large ==> water meter failed
}
//double nominalTestFlowLph = 500.0 * (q2adjTestData.Qfrom + q2adjTestData.Qto); /// in lph => 500.0 * ...
double nominalTestFlowLph = 1000.0 * q2adjTestData.Qfrom; /// in lph => 1000.0 * ...
double nominalTestFlowLph = Config.Units.ConvertTo(Config.Unit.lph, nominalFlow);
double volumeRefShiftedToTarget = q2adjResult.VolumeRef * (1.0f + CalibTarget / 100.0f);
double q2adjErrorShiftedToTarget = Config.Formulas.ErrorFromVolumes(q2adjResult.VolumeMeter, volumeRefShiftedToTarget);
@@ -270,17 +251,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
double F = D / (nominalTestFlowLph * 10.0); /// Error corrected with 8 Raw Units per minute [%]
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
q2CorrectionFactor = (-1) * (q2adjErrorShiftedToTarget / G) * (volumeRefShiftedToTarget / q2adjResult.VolumeMeter);
double q2CorrectionFactor = (double)currentFactor - (q2adjErrorShiftedToTarget / G) * (volumeRefShiftedToTarget / q2adjResult.VolumeMeter);
log.WarnFormat("Q2 correction: Pos={0}, PCB#={1}, Q2adjError={2}%, CalTarget={3}%, corrFactor={4}, [Lo={5}%, Hi={6}%]",
Name,
SerialNr,
q2adjResult.Error.ToString("F2"),
CalibTarget.ToString("F1"),
q2CorrectionFactor.ToString("F1"),
errLimitLo.ToString("F1"),
errLimitHi.ToString("F1"));
return true;
log.WarnFormat("CalculateQ2CorrectionFactor() : Pos={0}, PCB#={1}, Error={2}%, CalTarget={3}%, Q2CorrFactor={4}",
Name,
SerialNr,
q2adjResult.Error.ToString("F2"),
CalibTarget.ToString("F1"),
q2CorrectionFactor.ToString("F1"));
return q2CorrectionFactor;
}
@@ -461,7 +441,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
///
public OptoHeadState CheckFlowDirection()
{
return (flowDirectionDetection != null) ? flowDirectionDetection.CheckFlowDirection(currentFlowDir) : OptoHeadState.DirNok;
return (flowDirectionDetection != null) ? flowDirectionDetection.CheckFlowDirection(currentFlowDir, Name) : OptoHeadState.DirNok;
}
///
public void ChangeFlowDirection()