This commit is contained in:
Milan Hanajik 2022-10-21 15:45:53 +02:00
parent 4b85db202e
commit 0f738be73e

View File

@ -1565,125 +1565,124 @@ namespace TBF.Rig.Sequences
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(fullTestName, part);
if (tstRslt != null)
if (tstRslt == null) return; /// Prevent program crash in certain cases
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.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse;
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulse;
tstRslt.PulsesMaster = (tstRslt.ConstMasterRaw > 1E-6) ? (tstRslt.TargetVolume() / tstRslt.ConstMasterRaw) : 1;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Formulas.RealDensity() / 1000.0f;
tstRslt.MassEnd = tstRslt.MassEndRaw;
tstRslt.DensityIn = Formulas.RealDensity();
tstRslt.DensityLine = Formulas.RealDensity();
tstRslt.DensityDiv = Formulas.RealDensity();
tstRslt.MassOfEvapWater = 0;
tstRslt.Flow = 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.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;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
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.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse;
tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulse;
tstRslt.PulsesMaster = (tstRslt.ConstMasterRaw > 1E-6) ? (tstRslt.TargetVolume() / tstRslt.ConstMasterRaw) : 1;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Formulas.RealDensity() / 1000.0f;
tstRslt.MassEnd = tstRslt.MassEndRaw;
tstRslt.DensityIn = Formulas.RealDensity();
tstRslt.DensityLine = Formulas.RealDensity();
tstRslt.DensityDiv = Formulas.RealDensity();
tstRslt.MassOfEvapWater = 0;
tstRslt.Flow = tstRslt.TargetVolume() / tstRslt.TargetTime();
tstRslt.VolumeCTV = tstRslt.TargetVolume();
tstRslt.VolumeMaster = tstRslt.TargetVolume();
tstRslt.ErrorMaster = 0;
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);
tstRslt.AmbTempMean = 20.0f;
tstRslt.AmbPressMean = 1.0f;
tstRslt.AmbHumiMean = 50.0f;
double compoundVolume = tstRslt.TargetVolume() * (1.0 + 0.01 * errorPct);
double mainVolume = compoundVolume * mainPart;
double auxVolume = compoundVolume * (1.0 - mainPart);
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;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux
{
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);
GenericDevices.IRegReader regReader = sensPath.RegisterReaders[2 * i + isAux];
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainRslt : auxRslt;
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
if (meterRslt != null && regReader != null)
{
GenericDevices.IRegReader regReader = sensPath.RegisterReaders[2 * i + isAux];
Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainRslt : auxRslt;
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.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.RegValve != null ? outPath.RegValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
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;
}
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.RegValve != null ? outPath.RegValve.Name : string.Empty,
outPath.Diverter != null ? outPath.Diverter.Name : string.Empty));
}
@ -1698,6 +1697,8 @@ namespace TBF.Rig.Sequences
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(fullTestName, part);
if (tstRslt == null) return; /// Prevent program crash in certain cases
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
tstRslt.StartTime = DateTime.Now;
tstRslt.EndTime = DateTime.Now + new TimeSpan(0, 0, 1);