IFlowMeterSingle with GetRange(.) and CorrectedFlow(.), Test method calculations clean-up, refactorization, ver. 3.1.1901
This commit is contained in:
@@ -88,27 +88,12 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
TBF.Rig.ControlBoard.Uni.UniCB cBrd = StateMachine.ControlBoard as TBF.Rig.ControlBoard.Uni.UniCB;
|
||||
IScale scale = cBrd.Devices.Scale as IScale;
|
||||
|
||||
int rangeIx = 0; /// Default range, used for non-Elde flowmeters
|
||||
if (outPath.FlowMeter is Uni.FlowMeter.FlowMeter)
|
||||
if ((outPath.FlowMeter is IFlowMeterSingle) &&
|
||||
(outPath.FlowMeter as IFlowMeterSingle).GetRange(test.TempLimLo, test.TempLimHi) == -1)
|
||||
{
|
||||
Uni.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Uni.FlowMeter.FlowMeter;
|
||||
rangeIx = -1; /// Indicates invalid range
|
||||
for (int r = 0; r <= 5; r++)
|
||||
{
|
||||
if (eldeFM.RangeEnabled(r) && eldeFM.GetTempLo(r) <= test.TempLimLo
|
||||
&& eldeFM.GetTempHi(r) >= test.TempLimHi)
|
||||
{
|
||||
rangeIx = r;
|
||||
}
|
||||
}
|
||||
|
||||
if (rangeIx == -1)
|
||||
{
|
||||
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
|
||||
return new List<Event> { Event.ConfigurationError }; /// or Event.UiCmdStop ???
|
||||
}
|
||||
}
|
||||
|
||||
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
|
||||
return new List<Event> { Event.ConfigurationError }; /// or Event.UiCmdStop ???
|
||||
}
|
||||
|
||||
IList<Event> e; /// Events from currently running operations
|
||||
Event retVal = Event.Done;
|
||||
@@ -142,8 +127,7 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown));
|
||||
if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta));
|
||||
|
||||
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse;
|
||||
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
|
||||
int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse);
|
||||
|
||||
///============================================================================================
|
||||
|
||||
@@ -450,7 +434,7 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
/// Diverter test loop
|
||||
///
|
||||
int remainingPulses = totalPulses;
|
||||
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
|
||||
StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0);
|
||||
DiverterStart.Start(BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
|
||||
DiverterEnd.Start(BatchRslts.Batch.BatchNr, test.Name, repetitionNr);
|
||||
|
||||
@@ -500,7 +484,7 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
/// Update statistics
|
||||
RefFrequency.Val = cBrd.RefFrequency;
|
||||
RefFlow.Val = outPath.FlowMeter.ReadFlow();
|
||||
UpdateAllStatistics(StateMachine.Time);
|
||||
UpdateAllStatistics();
|
||||
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test));
|
||||
}
|
||||
@@ -648,42 +632,47 @@ namespace TBF.Rig.TestMethods.DiverterTest
|
||||
if (tstRslt != null)
|
||||
{
|
||||
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
|
||||
UpdateTempPressDensAmb(tstRslt);
|
||||
|
||||
/// Main results
|
||||
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
||||
/// Raw data
|
||||
UpdateTempPressDensAmb(tstRslt);
|
||||
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
|
||||
tstRslt.StartTime = TestStartTime;
|
||||
tstRslt.EndTime = TestEndTime;
|
||||
tstRslt.FlowSetTime = flowSetTime;
|
||||
tstRslt.TestTime = cumulativeTestTime[0]; /// [s] measurement time
|
||||
tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1;
|
||||
tstRslt.PulsesMaster = Convert.ToDouble(cumulativeEtPulses[0]); /// Pulses of the master flow meter (test total)
|
||||
tstRslt.MassStartRaw = StartMass.Val;
|
||||
tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections);
|
||||
tstRslt.MassEndRaw = EndMass.Val;
|
||||
tstRslt.MassEnd = MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections);
|
||||
tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1;
|
||||
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
|
||||
tstRslt.VolumeMaster = outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
||||
double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h]
|
||||
|
||||
/// Corrected values
|
||||
tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections);
|
||||
tstRslt.MassEnd = MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections);
|
||||
tstRslt.MassOfEvapWater = (double)tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean);
|
||||
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.TestTime; /// [kg/h]
|
||||
tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h]
|
||||
tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.DensityLine; /// [l] commercially true volume
|
||||
double mass = tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater;
|
||||
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); /// Corrected master pulses per liter
|
||||
|
||||
/// Main results
|
||||
tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * mass / tstRslt.DensityLine; /// [l] commercially true volume
|
||||
if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon))
|
||||
{
|
||||
tstRslt.TestTimeCorrection = testParams.DivRepetitions * outPath.Diverter.TestTimeCorrection(tstRslt.FlowVolume);
|
||||
tstRslt.TestTimeCorrection = testParams.DivRepetitions * outPath.Diverter.TestTimeCorrection(flowMID);
|
||||
tstRslt.VolumeCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection;
|
||||
tstRslt.VolumeCTV /= tstRslt.TestTime;
|
||||
}
|
||||
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
||||
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
|
||||
tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume, rangeIx); /// Corrected master pulses per liter
|
||||
tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster);
|
||||
/// Calculated master pulses per liter
|
||||
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
|
||||
|
||||
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.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// [m3/h]
|
||||
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
|
||||
tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster);
|
||||
/// Calculated master pulses per liter
|
||||
/// Flow statistics correction
|
||||
tstRslt.FlowMean = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Average / tstRslt.ConstMasterRaw);
|
||||
tstRslt.FlowStart = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.First / tstRslt.ConstMasterRaw);
|
||||
tstRslt.FlowEnd = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Last / tstRslt.ConstMasterRaw);
|
||||
tstRslt.FlowMin = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Min / tstRslt.ConstMasterRaw);
|
||||
tstRslt.FlowMax = Convert.ToSingle(tstRslt.ConstMaster * RefFlowStat.Max / tstRslt.ConstMasterRaw);
|
||||
|
||||
tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val;
|
||||
tstRslt.DivStart10 = 0;
|
||||
|
||||
Reference in New Issue
Block a user