IperlHead procedure parameter CalibTargetQ2 added, ver. 2.18.1203

This commit is contained in:
Milan Hanajik 2019-04-25 13:53:08 +02:00
parent 5dad80d031
commit e32a484e81
5 changed files with 46 additions and 40 deletions

View File

@ -1956,7 +1956,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Calculate Q2 correction factor(s) from an error measured at Q2
///
double q2Correction = 0;
double q2Correction2 = 0; /// L-R direction
double q2Correction2 = 0; /// L-R direction in case of Q2CorrType.Update and Q2CorrType.ConditionalUpdate
///
if ((q2CorrType == Q2CorrType.Update) || (q2CorrType == Q2CorrType.ConditionalUpdate))
{
@ -1967,8 +1967,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
errLimitLo <= q2adjResult2.Error && q2adjResult2.Error <= errLimitHi)
{
/// Calculate updated Q2 correction factors
q2Correction = ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjTestData.Qfrom, wm.Q2CorrRL);
q2Correction2 = ihead.CalculateQ2CorrectionFactor(q2adjResult2, q2adjTestData2.Qfrom, wm.Q2CorrLR);
q2Correction = ihead.CalculateQ2CorrectionFactor(q2adjResult, ihead.CalibTargetQ2, q2adjTestData.Qfrom, wm.Q2CorrRL);
q2Correction2 = ihead.CalculateQ2CorrectionFactor(q2adjResult2, ihead.CalibTargetQ2, q2adjTestData2.Qfrom, wm.Q2CorrLR);
}
else
{
@ -1979,7 +1979,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
ihead.SerialNr,
q2adjResult.Error.ToString("F2"),
q2adjResult2.Error.ToString("F2"),
ihead.CalibTarget.ToString("F1"),
ihead.CalibTargetQ2.ToString("F1"),
errLimitLo.ToString("F1"),
errLimitHi.ToString("F1"));
@ -1997,7 +1997,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if ((errLimitLo <= q2adjResult.Error) && (q2adjResult.Error <= errLimitHi))
{
/// Calculate Q2 correction factor (assuming it was 0 when doing a test)
q2Correction = ihead.CalculateQ2CorrectionFactor(q2adjResult, q2adjTestData.Qfrom);
q2Correction = ihead.CalculateQ2CorrectionFactor(q2adjResult, ihead.CalibTargetQ2, q2adjTestData.Qfrom);
}
else
{
@ -2006,7 +2006,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
ihead.Name,
ihead.SerialNr,
q2adjResult.Error.ToString("F2"),
ihead.CalibTarget.ToString("F1"),
ihead.CalibTargetQ2.ToString("F1"),
errLimitLo.ToString("F1"),
errLimitHi.ToString("F1"));
@ -2015,8 +2015,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
}
double targetError = ihead.CalibTarget;
Byte q2CorrRL = 0;
Byte q2CorrLR = 0;
///
@ -2025,7 +2023,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// Standard process
///
if (Math.Abs(q2adjResult.Error - targetError) <= 0.5)
if (Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
@ -2039,7 +2037,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// Process for DEWA
///
if (Math.Abs(q2adjResult.Error - targetError) <= 0.5)
if (Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
@ -2056,7 +2054,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
else if (q2CorrType == Q2CorrType.RL) /// SUEZ
{
if (Math.Abs(q2adjResult.Error - targetError) <= 0.5)
if (Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
@ -2066,7 +2064,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
else if (q2CorrType == Q2CorrType.LR) /// SUEZ
{
if (Math.Abs(q2adjResult.Error - targetError) <= 0.5)
if (Math.Abs(q2adjResult.Error - ihead.CalibTargetQ2) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;

View File

@ -559,7 +559,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
double targetError = 0;
if ((sensPath != null) && (sensPath.RegisterReaders != null) && (sensPath.RegisterReaders.Length > i) && (sensPath.RegisterReaders[i] is iPerlHead.IperlHead))
{
targetError = (sensPath.RegisterReaders[i] as iPerlHead.IperlHead).CalibTarget;
targetError = (sensPath.RegisterReaders[i] as iPerlHead.IperlHead).CalibTargetQ2;
}
if ((((meterRsltQ2bc.Error - targetError) < -0.51) && (meterRsltQ2ac.Error < meterRsltQ2bc.Error)) ||

View File

@ -36,7 +36,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
public double LtrsPerPulse { get { return 1 / PulsesPerLtr; } }
public double CalibTarget { get { return iperlHeadCfg.ProcParams.CalibTarget; } }
public ushort FactorLimitLo { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitLo; } }
public double CalibTargetQ2 { get { return iperlHeadCfg.ProcParams.CalibTargetQ2; } }
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; } }
public int WMType_ID { get { return iperlHeadCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB
@ -236,10 +237,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
/// <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)
public double CalculateQ2CorrectionFactor(Results.Entities.MeterTestRslt q2adjResult, double calibTarget, double nominalFlow, int currentFactor = 0)
{
double nominalTestFlowLph = Config.Units.ConvertTo(Config.Unit.lph, nominalFlow);
double volumeRefShiftedToTarget = q2adjResult.VolumeRef * (1.0 + CalibTarget / 100.0);
double volumeRefShiftedToTarget = q2adjResult.VolumeRef * (1.0 + calibTarget / 100.0);
double q2adjErrorShiftedToTarget = Config.Formulas.ErrorFromVolumes(q2adjResult.VolumeMeter, volumeRefShiftedToTarget);
double A = 16.0 / ScalingFactor(); /// Raw units per ml: DN15=16, DN20=8, DN25=4, DN32=2, DN40=1
@ -255,7 +256,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
Name,
SerialNr,
q2adjResult.Error.ToString("F2"),
CalibTarget.ToString("F1"),
calibTarget.ToString("F1"),
q2CorrectionFactor.ToString("F1"));
return q2CorrectionFactor;

View File

@ -17,7 +17,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
public MeterType MeterType;
public float CalibTarget; /// Target error after calibration in [%]
public int FactorLimitLo; /// Lower limit for the calibration factor
public float CalibTargetQ2; /// Target error at Q2 after Q2 correction in [%]
public int FactorLimitLo; /// Lower limit for the calibration factor
public int FactorLimitHi; /// Upper limit for the calibration factor
public Counting Counting; /// Initial iPerl counting (Artbitrary, Positive or Negative)
public int WMType_ID; /// Required for Oracle DB: ID_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
@ -29,7 +30,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
MeterType = MeterType.AutoDetect;
CalibTarget = 0;
FactorLimitLo = 1000;
CalibTargetQ2 = 0;
FactorLimitLo = 1000;
FactorLimitHi = 8000;
Counting = Counting.Arbitrary;
WMType_ID = 2; /// Value for iPerl DN15
@ -41,6 +43,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
"iPerl type",
"Calib. target [%]",
"Calib. target at Q2 [%]",
"Calib. factor Lo",
"Calib. factor Hi",
"Counting",
@ -59,7 +62,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
for (MeterType mt = 0; mt < MeterType.Count; mt++) retVal.Add(mt.ToString());
return retVal;
}
else if (i == 4)
else if (i == 5)
{
IList<string> retVal = new List<string>();
for (Counting c = 0; c < Counting.Count; c++) retVal.Add(c.ToString());
@ -74,12 +77,13 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
case 0: return MeterType.ToString();
case 1: return CalibTarget.ToString();
case 2: return FactorLimitLo.ToString();
case 3: return FactorLimitHi.ToString();
case 4: return Counting.ToString();
case 5: return WMType_ID.ToString();
case 6: return InitQ2CorrLR.ToString();
case 7: return InitQ2CorrRL.ToString();
case 2: return CalibTargetQ2.ToString();
case 3: return FactorLimitLo.ToString();
case 4: return FactorLimitHi.ToString();
case 5: return Counting.ToString();
case 6: return WMType_ID.ToString();
case 7: return InitQ2CorrLR.ToString();
case 8: return InitQ2CorrRL.ToString();
default: return string.Empty;
}
}
@ -95,17 +99,18 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
}
break;
case 1: CalibTarget = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
case 2: FactorLimitLo = int.Parse(strValue); return CfgUpdateFlags.None;
case 3: FactorLimitHi = int.Parse(strValue); return CfgUpdateFlags.None;
case 4:
case 2: CalibTargetQ2 = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
case 3: FactorLimitLo = int.Parse(strValue); return CfgUpdateFlags.None;
case 4: FactorLimitHi = int.Parse(strValue); return CfgUpdateFlags.None;
case 5:
for (Counting c = 0; c < Counting.Count; c++)
{
if (c.ToString().Equals(strValue)) { Counting = c; return CfgUpdateFlags.None; }
}
break;
case 5: WMType_ID = int.Parse(strValue); return CfgUpdateFlags.None;
case 6: InitQ2CorrLR = int.Parse(strValue); return CfgUpdateFlags.None;
case 7: InitQ2CorrRL = int.Parse(strValue); return CfgUpdateFlags.None;
case 6: WMType_ID = int.Parse(strValue); return CfgUpdateFlags.None;
case 7: InitQ2CorrLR = int.Parse(strValue); return CfgUpdateFlags.None;
case 8: InitQ2CorrRL = int.Parse(strValue); return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
@ -125,20 +130,21 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
for (MeterType mt = 0; mt < MeterType.Count; mt++) if (mt.ToString().Equals(strValue)) return true;
break;
case 1:
case 2:
if (Utils.TryParseSFloat(strValue, out fDummy) && fDummy >= -10.0f && fDummy <= 10.0f) return true;
break;
case 2:
case 3:
case 4:
if (int.TryParse(strValue, out iDummy) && iDummy >= 1000 && iDummy <= 8000) return true;
break;
case 4:
case 5:
for (Counting c = 0; c < Counting.Count; c++) if (c.ToString().Equals(strValue)) return true;
break;
case 5: /// WMType_ID
case 6: /// WMType_ID
if (int.TryParse(strValue, out iDummy)) return true;
break;
case 6: /// InitQ2CorrLR
case 7: /// InitQ2CorrRL
case 7: /// InitQ2CorrLR
case 8: /// InitQ2CorrRL
if (int.TryParse(strValue, out iDummy) || (iDummy < -127) || (iDummy > 127)) return true;
break;
default:
@ -154,7 +160,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
prms.MeterType = this.MeterType;
prms.CalibTarget = this.CalibTarget;
prms.FactorLimitLo = this.FactorLimitLo;
prms.CalibTargetQ2 = this.CalibTargetQ2;
prms.FactorLimitLo = this.FactorLimitLo;
prms.FactorLimitHi = this.FactorLimitHi;
prms.Counting = this.Counting;
prms.WMType_ID = this.WMType_ID;

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.1202.0")]
[assembly: AssemblyFileVersion("2.18.1202.0")]
[assembly: AssemblyVersion("2.18.1203.0")]
[assembly: AssemblyFileVersion("2.18.1203.0")]