Compound meter test simulations added to iPerlCommunication method.
This commit is contained in:
@@ -430,11 +430,12 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
|
||||
{
|
||||
if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon)
|
||||
{
|
||||
tstRslt.Meters[i].VolumeMeter = 0;
|
||||
tstRslt.Meters[i].PulsesPerLiter = 1.0f;
|
||||
tstRslt.Meters[i].VolumeMeter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.Meters[i].PulsesPerLiter = (sensPath.RegisterReaders[i] == null ? 1.0f : sensPath.RegisterReaders[i].PulsesPerLtr);
|
||||
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
|
||||
tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CanTest(Entities.MetersKind meters) { return meters == Entities.MetersKind.Single; }
|
||||
public bool CanTest(Entities.MetersKind meters) { return true; }
|
||||
|
||||
public TestMethod()
|
||||
{
|
||||
|
||||
+128
-6
@@ -85,9 +85,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
Entities.TestResult tstRslt;
|
||||
|
||||
if (testParams.Activity.Contains("Q3")) tstRslt = MakeSimulated(test, 1, 0.5f);
|
||||
else if (testParams.Activity.Contains("Q2")) tstRslt = MakeSimulated(test, 1, 1.7f);
|
||||
else tstRslt = MakeSimulated(test, 1, 2.2f); /// Q1
|
||||
if (testParams.Activity.ToLower().Contains("q3")) tstRslt = MakeSimulated(test, 1, 0.5f);
|
||||
else if (testParams.Activity.ToLower().Contains("q2")) tstRslt = MakeSimulated(test, 1, 1.7f);
|
||||
else if (testParams.Activity.ToLower().Contains("q1")) tstRslt = MakeSimulated(test, 1, 2.2f);
|
||||
else if (testParams.Activity.ToLower().Contains("compound ok")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.Regular, 1, 0.7f);
|
||||
else if (testParams.Activity.ToLower().Contains("compound nok")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.Regular, 1, 4.7f);
|
||||
else if (testParams.Activity.ToLower().Contains("compound rise")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.DetectionRise, 1, 0.7f);
|
||||
else if (testParams.Activity.ToLower().Contains("compound fall")) tstRslt = MakeSimulatedCompound(test, CompoundTestType.DetectionFall, 1, 0.7f);
|
||||
else tstRslt = null;
|
||||
|
||||
AddOrOverwriteResult(tstRslt);
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(tstRslt));
|
||||
@@ -238,10 +243,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Virtually apply Q2 correction to a test used for the correction calculation.
|
||||
/// Create a simulated test result (single meter).
|
||||
/// </summary>
|
||||
/// <param name="oriTestRslt">Q2Adj test result</param>
|
||||
/// <returns>Virtual Q2 test result</returns>
|
||||
/// <param name="test">Test to be simulated</param>
|
||||
/// <returns>Test result</returns>
|
||||
Entities.TestResult MakeSimulated(Entities.Test test, int repetitionNr, float errorPct)
|
||||
{
|
||||
Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single);
|
||||
@@ -326,5 +331,122 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
return tstRslt;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a simulated test result (compound meter).
|
||||
/// </summary>
|
||||
/// <param name="test">Test to be simulated</param>
|
||||
/// <returns>Test result</returns>
|
||||
Entities.TestResult MakeSimulatedCompound(Entities.Test test, CompoundTestType testType, int repetitionNr, float errorPct)
|
||||
{
|
||||
Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Combined);
|
||||
|
||||
tstRslt.TimeStart = DateTime.Now;
|
||||
tstRslt.TimeEnd = DateTime.Now;
|
||||
|
||||
tstRslt.AmbientTempAve = 20.0f;
|
||||
tstRslt.AmbientPressAve = 1000.0f;
|
||||
tstRslt.AmbientHumiAve = 50.0f;
|
||||
|
||||
tstRslt.PressInStart = 1000.0f;
|
||||
tstRslt.PressOutStart = 1000.0f;
|
||||
tstRslt.TempInStart = 20.0f;
|
||||
tstRslt.TempOutStart = 20.0f;
|
||||
tstRslt.TempDivStart = 20.0f;
|
||||
|
||||
tstRslt.PressInEnd = 1000.0f;
|
||||
tstRslt.PressOutEnd = 1000.0f;
|
||||
tstRslt.TempInEnd = 20.0f;
|
||||
tstRslt.TempOutEnd = 20.0f;
|
||||
tstRslt.TempDivEnd = 20.0f;
|
||||
|
||||
tstRslt.PressInAvrg = 1000.0f;
|
||||
tstRslt.PressOutAvrg = 1000.0f;
|
||||
tstRslt.TempInAvrg = 20.0f;
|
||||
tstRslt.TempOutAvrg = 20.0f;
|
||||
tstRslt.TempDivAvrg = 20.0f;
|
||||
|
||||
tstRslt.BatchNr = Program.LocalSettings.BatchNr;
|
||||
tstRslt.MassStartRaw = 0;
|
||||
tstRslt.MassStart = 0;
|
||||
tstRslt.MassEndRaw = test.Volume * Program.LocalSettings.RealDensity / 1000.0f;
|
||||
tstRslt.MassEnd = tstRslt.MassEndRaw;
|
||||
tstRslt.MassDiff = tstRslt.MassEnd;
|
||||
tstRslt.DensityIn = Program.LocalSettings.RealDensity;
|
||||
tstRslt.DensityOut = Program.LocalSettings.RealDensity;
|
||||
tstRslt.DensityDiv = Program.LocalSettings.RealDensity;
|
||||
tstRslt.Time = test.TstTime;
|
||||
tstRslt.FlowMass = tstRslt.MassDiff / test.TstTime;
|
||||
tstRslt.FlowVolume = test.Volume / test.TstTime;
|
||||
tstRslt.VolumeCTV = test.Volume;
|
||||
tstRslt.VolumeMaster = test.Volume;
|
||||
tstRslt.PulsesMaster = (ltrPerRefPulse > 1E-6) ? (test.Volume / ltrPerRefPulse) : 1;
|
||||
tstRslt.ConstMaster = ltrPerRefPulse;
|
||||
tstRslt.ErrorMaster = 0;
|
||||
|
||||
for (int iCmbnd = 0; iCmbnd < Program.CompoundWMsCount; iCmbnd++)
|
||||
{
|
||||
tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error
|
||||
|
||||
for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++)
|
||||
{
|
||||
if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon)
|
||||
{
|
||||
tstRslt.Meters[i].PulsesPerLiter = 1.0f;
|
||||
tstRslt.Meters[i].VolumeMeter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr;
|
||||
tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
|
||||
}
|
||||
|
||||
tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty;
|
||||
tstRslt.Meters[i].VolumeStart = 0;
|
||||
tstRslt.Meters[i].VolumeEnd = 0; /// Normal meter
|
||||
|
||||
tstRslt.Meters[i].VolumeRef = test.Volume;
|
||||
if (testType == CompoundTestType.Regular && IsMainMtr(i))
|
||||
{
|
||||
tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct);
|
||||
}
|
||||
else if (testType == CompoundTestType.DetectionRise && !IsMainMtr(i))
|
||||
{
|
||||
tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct);
|
||||
}
|
||||
else if (testType == CompoundTestType.DetectionFall && IsMainMtr(i))
|
||||
{
|
||||
tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct);
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.Meters[i].VolumeMeter = 0;
|
||||
}
|
||||
|
||||
tstRslt.Meters[i].Time = test.TstTime;
|
||||
tstRslt.Meters[i].TimeStart = 0;
|
||||
tstRslt.Meters[i].TimeEnd = test.TstTime;
|
||||
tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster;
|
||||
tstRslt.Meters[i].VolumeErrorPct = errorPct;
|
||||
tstRslt.Meters[i].Passed = (test.ErrLimLo <= errorPct) && (errorPct <= test.ErrLimHi);
|
||||
tstRslt.Meters[i].PulsesMeter = sensPath.RegisterReaders[i].PulsesPerLtr * tstRslt.Meters[i].VolumeMeter;
|
||||
}
|
||||
|
||||
tstRslt.CombinedMeters[iCmbnd].VolumeMeter = tstRslt.Meters[2 * iCmbnd].VolumeMeter + tstRslt.Meters[2 * iCmbnd + 1].VolumeMeter;
|
||||
|
||||
tstRslt.CombinedMeters[iCmbnd].PulsesMaster = tstRslt.PulsesMaster;
|
||||
tstRslt.CombinedMeters[iCmbnd].Time = test.TstTime;
|
||||
tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.CombinedMeters[iCmbnd].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef);
|
||||
tstRslt.CombinedMeters[iCmbnd].Passed = (tstRslt.ErrLimLo <= tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct) && (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct <= tstRslt.ErrLimHi);
|
||||
}
|
||||
|
||||
return tstRslt;
|
||||
}
|
||||
|
||||
bool IsMainMtr(int i)
|
||||
{
|
||||
return (i % 2) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user