Bug fix in CombinedWithDetectionSeq related to test.Part, ver. 2.26.1509

This commit is contained in:
Milan Hanajik 2020-07-31 08:08:08 +02:00
parent eaf0e2cf22
commit 68d01aab14
3 changed files with 114 additions and 112 deletions

View File

@ -1588,123 +1588,125 @@ namespace TBF.BenchControl.Sequences
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(fullTestName, part);
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
tstRslt.StartTime = DateTime.Now;
tstRslt.EndTime = DateTime.Now + new TimeSpan(0, 0, 1);
tstRslt.FlowSetTime = 10;
tstRslt.TestTime = tstRslt.TargetTime();
/// TODO: Verify whether 'ltrPerRefPulse' is up to date
tstRslt.PulsesMaster = (LtrPerRefPulse > 1E-6) ? (tstRslt.TargetVolume() / LtrPerRefPulse) : 1;
tstRslt.ConstMasterRaw = LtrPerRefPulse;
tstRslt.ConstMaster = LtrPerRefPulse;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Config.Formulas.RealDensity() / 1000.0f;
tstRslt.MassEnd = tstRslt.MassEndRaw;
tstRslt.DensityIn = Config.Formulas.RealDensity();
tstRslt.DensityLine = Config.Formulas.RealDensity();
tstRslt.DensityDiv = Config.Formulas.RealDensity();
tstRslt.Buoyancy = Formulas.Buoyancy();
tstRslt.FlowMass = tstRslt.MassEnd / tstRslt.TargetTime();
tstRslt.FlowVolume = tstRslt.TargetVolume() / tstRslt.TargetTime();
tstRslt.VolumeCTV = tstRslt.TargetVolume();
tstRslt.VolumeMaster = tstRslt.TargetVolume();
tstRslt.ErrorMaster = 0;
if (tstRslt != null)
{
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
tstRslt.StartTime = DateTime.Now;
tstRslt.EndTime = DateTime.Now + new TimeSpan(0, 0, 1);
tstRslt.FlowSetTime = 10;
tstRslt.TestTime = tstRslt.TargetTime();
/// TODO: Verify whether 'ltrPerRefPulse' is up to date
tstRslt.PulsesMaster = (LtrPerRefPulse > 1E-6) ? (tstRslt.TargetVolume() / LtrPerRefPulse) : 1;
tstRslt.ConstMasterRaw = LtrPerRefPulse;
tstRslt.ConstMaster = LtrPerRefPulse;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Config.Formulas.RealDensity() / 1000.0f;
tstRslt.MassEnd = tstRslt.MassEndRaw;
tstRslt.DensityIn = Config.Formulas.RealDensity();
tstRslt.DensityLine = Config.Formulas.RealDensity();
tstRslt.DensityDiv = Config.Formulas.RealDensity();
tstRslt.Buoyancy = Formulas.Buoyancy();
tstRslt.FlowMass = tstRslt.MassEnd / tstRslt.TargetTime();
tstRslt.FlowVolume = tstRslt.TargetVolume() / tstRslt.TargetTime();
tstRslt.VolumeCTV = tstRslt.TargetVolume();
tstRslt.VolumeMaster = tstRslt.TargetVolume();
tstRslt.ErrorMaster = 0;
tstRslt.AmbTempMean = 20.0f;
tstRslt.AmbPressMean = 1.0f;
tstRslt.AmbHumiMean = 50.0f;
tstRslt.AmbTempMean = 20.0f;
tstRslt.AmbPressMean = 1.0f;
tstRslt.AmbHumiMean = 50.0f;
tstRslt.PressUpStart = 1.0f;
tstRslt.PressDownStart = 1.0f;
tstRslt.TempUpStart = 20.0f;
tstRslt.TempDownStart = 20.0f;
tstRslt.TempDivStart = 20.0f;
tstRslt.PressUpEnd = 1.0f;
tstRslt.PressDownEnd = 1.0f;
tstRslt.TempUpEnd = 20.0f;
tstRslt.TempDownEnd = 20.0f;
tstRslt.TempDivEnd = 20.0f;
tstRslt.PressUpMean = 1.0f;
tstRslt.PressDownMean = 1.0f;
tstRslt.TempUpMean = 20.0f;
tstRslt.TempDownMean = 20.0f;
tstRslt.TempDivMean = 20.0f;
tstRslt.PressUpMin = 1.0f;
tstRslt.PressDownMin = 1.0f;
tstRslt.TempUpMin = 20.0f;
tstRslt.TempDownMin = 20.0f;
tstRslt.TempDivMin = 20.0f;
tstRslt.PressUpMax = 1.0f;
tstRslt.PressDownMax = 1.0f;
tstRslt.TempUpMax = 20.0f;
tstRslt.TempDownMax = 20.0f;
tstRslt.TempDivMax = 20.0f;
tstRslt.ConductMin = Conductivity.Val;
tstRslt.ConductMax = Conductivity.Val;
tstRslt.PressUpStart = 1.0f;
tstRslt.PressDownStart = 1.0f;
tstRslt.TempUpStart = 20.0f;
tstRslt.TempDownStart = 20.0f;
tstRslt.TempDivStart = 20.0f;
tstRslt.PressUpEnd = 1.0f;
tstRslt.PressDownEnd = 1.0f;
tstRslt.TempUpEnd = 20.0f;
tstRslt.TempDownEnd = 20.0f;
tstRslt.TempDivEnd = 20.0f;
tstRslt.PressUpMean = 1.0f;
tstRslt.PressDownMean = 1.0f;
tstRslt.TempUpMean = 20.0f;
tstRslt.TempDownMean = 20.0f;
tstRslt.TempDivMean = 20.0f;
tstRslt.PressUpMin = 1.0f;
tstRslt.PressDownMin = 1.0f;
tstRslt.TempUpMin = 20.0f;
tstRslt.TempDownMin = 20.0f;
tstRslt.TempDivMin = 20.0f;
tstRslt.PressUpMax = 1.0f;
tstRslt.PressDownMax = 1.0f;
tstRslt.TempUpMax = 20.0f;
tstRslt.TempDownMax = 20.0f;
tstRslt.TempDivMax = 20.0f;
tstRslt.ConductMin = Conductivity.Val;
tstRslt.ConductMax = Conductivity.Val;
tstRslt.FlowMean = (float)RefFlowStat.Average;
tstRslt.FlowStart = (float)RefFlowStat.First;
tstRslt.FlowEnd = (float)RefFlowStat.Last;
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
tstRslt.FlowMean = (float)RefFlowStat.Average;
tstRslt.FlowStart = (float)RefFlowStat.First;
tstRslt.FlowEnd = (float)RefFlowStat.Last;
tstRslt.FlowMin = (float)RefFlowStat.Min;
tstRslt.FlowMax = (float)RefFlowStat.Max;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt compoundRslt = ProcessData.BatchRslts.GetMeterTestRslt(fullTestName, i, CompoundMeterId.Compound);
Results.Entities.MeterTestRslt mainRslt = ProcessData.BatchRslts.GetMeterTestRslt(fullTestName, i, CompoundMeterId.CompoundMain);
Results.Entities.MeterTestRslt auxRslt = ProcessData.BatchRslts.GetMeterTestRslt(fullTestName, i, CompoundMeterId.CompoundAux);
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt compoundRslt = ProcessData.BatchRslts.GetMeterTestRslt(fullTestName, i, CompoundMeterId.Compound);
Results.Entities.MeterTestRslt mainRslt = ProcessData.BatchRslts.GetMeterTestRslt(fullTestName, i, CompoundMeterId.CompoundMain);
Results.Entities.MeterTestRslt auxRslt = ProcessData.BatchRslts.GetMeterTestRslt(fullTestName, i, CompoundMeterId.CompoundAux);
double compoundVolume = tstRslt.TargetVolume() * (1.0 + 0.01 * errorPct);
double mainVolume = compoundVolume * mainPart;
double auxVolume = compoundVolume * (1.0 - mainPart);
double compoundVolume = tstRslt.TargetVolume() * (1.0 + 0.01 * errorPct);
double mainVolume = compoundVolume * mainPart;
double auxVolume = compoundVolume * (1.0 - mainPart);
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
{
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux];
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainRslt : auxRslt;
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
{
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux];
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainRslt : auxRslt;
if (meterRslt != null && regReader != null)
{
meterRslt.VolumeMeter = (isAux == 0) ? mainVolume : auxVolume;
if (meterRslt != null && regReader != null)
{
meterRslt.VolumeMeter = (isAux == 0) ? mainVolume : auxVolume;
meterRslt.PulsesMeter = regReader.PulsesPerLtr * meterRslt.VolumeMeter;
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = meterRslt.VolumeMeter;
meterRslt.VolumeRef = tstRslt.TargetVolume();
meterRslt.TimestampStart = 0;
meterRslt.TimestampEnd = tstRslt.TargetTime();
meterRslt.TestTime = tstRslt.TargetTime();
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV);
meterRslt.Passed = (errorPct >= tstRslt.ErrLimLo() + tstRslt.ErrLimMargin())
&& (errorPct <= tstRslt.ErrLimHi() - tstRslt.ErrLimMargin());
meterRslt.TestDone = true;
}
}
meterRslt.PulsesMeter = regReader.PulsesPerLtr * meterRslt.VolumeMeter;
meterRslt.PulsesMaster = tstRslt.PulsesMaster;
meterRslt.PulsesPerLiter = regReader.PulsesPerLtr;
meterRslt.VolumeStart = 0;
meterRslt.VolumeEnd = meterRslt.VolumeMeter;
meterRslt.VolumeRef = tstRslt.TargetVolume();
meterRslt.TimestampStart = 0;
meterRslt.TimestampEnd = tstRslt.TargetTime();
meterRslt.TestTime = tstRslt.TargetTime();
meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV);
meterRslt.Passed = (errorPct >= tstRslt.ErrLimLo() + tstRslt.ErrLimMargin())
&& (errorPct <= tstRslt.ErrLimHi() - tstRslt.ErrLimMargin());
meterRslt.TestDone = true;
}
}
compoundRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error
compoundRslt.VolumeMeter = mainRslt.VolumeMeter + auxRslt.VolumeMeter;
compoundRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error
compoundRslt.VolumeMeter = mainRslt.VolumeMeter + auxRslt.VolumeMeter;
compoundRslt.PulsesMaster = tstRslt.PulsesMaster;
compoundRslt.TestTime = tstRslt.TargetTime();
compoundRslt.Error = Formulas.ErrorFromVolumes(compoundRslt.VolumeMeter, tstRslt.VolumeCTV);
compoundRslt.Passed = (compoundRslt.Error >= tstRslt.ErrLimLo() + tstRslt.ErrLimMargin())
&& (compoundRslt.Error <= tstRslt.ErrLimHi() - tstRslt.ErrLimMargin());
compoundRslt.TestDone = true;
tstRslt.TestDone = true;
compoundRslt.PulsesMaster = tstRslt.PulsesMaster;
compoundRslt.TestTime = tstRslt.TargetTime();
compoundRslt.Error = Formulas.ErrorFromVolumes(compoundRslt.VolumeMeter, tstRslt.VolumeCTV);
compoundRslt.Passed = (compoundRslt.Error >= tstRslt.ErrLimLo() + tstRslt.ErrLimMargin())
&& (compoundRslt.Error <= tstRslt.ErrLimHi() - tstRslt.ErrLimMargin());
compoundRslt.TestDone = true;
tstRslt.TestDone = true;
}
tstRslt.Components = Results.Entities.Components.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
}
tstRslt.Components = Results.Entities.Components
.UpdateList(BatchRslts.ComponentsList,
new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1,
(BenchInfo != null) ? BenchInfo.TestBenchName : "testbench",
inPath.Pump != null ? inPath.Pump.Name : string.Empty,
outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty,
outPath.Scale != null ? outPath.Scale.Name : string.Empty,
outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@ -56,9 +56,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
return new List<Event> { Event.ConfigurationError };
}
if (test.Part < 1 || test.Part > Config.Data.CompoundWMsCount)
if (test.Part < 0 || test.Part > Config.Data.CompoundWMsCount)
{
UiBridge.Bridge.OnError(this, string.Format("Test 'Part' should be 1 .. {0}", Config.Data.CompoundWMsCount));
UiBridge.Bridge.OnError(this, string.Format("Test 'Part' should be '-' or 1 .. {0}", Config.Data.CompoundWMsCount));
return new List<Event> { Event.ConfigurationError };
}
@ -333,7 +333,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
}
flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0;
double diff = RegisterReaders[(test.Part - 1) * 2 + 1].WMPulses - lastWMPulses[(test.Part - 1) * 2 + 1];
double diff = RegisterReaders[Math.Max(0, test.Part - 1) * 2 + 1].WMPulses - lastWMPulses[Math.Max(0, test.Part - 1) * 2 + 1];
pulseFreqsForDetection[0] = diff / (double)(StateMachine.Time - lastTime);
lastTime = StateMachine.Time;
}

View File

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