IFlowMeterSingle with GetRange(.) and CorrectedFlow(.), Test method calculations clean-up, refactorization, ver. 3.1.1901

This commit is contained in:
Milan Hanajik
2022-05-04 10:23:21 +02:00
parent 9a42e199e3
commit 2c0ae68db0
51 changed files with 1001 additions and 1213 deletions
@@ -66,28 +66,13 @@ namespace TBF.Rig.TestMethods.StandingStart
DebugMode debugLevel)
{
ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard;
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;
break;
}
}
if (rangeIx == -1)
{
Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions);
return new List<Event> { Event.ConfigurationError };
}
}
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
int waterMetersCount = Math.Min(BenchInfo.WaterMetersCount, sensPath.RegisterReaders.Length);
@@ -130,13 +115,7 @@ namespace TBF.Rig.TestMethods.StandingStart
float switchTimeStart = 0.001f; /// in seconds, original vale is 1 ms
float switchTimeEnd = 0.001f; /// in seconds, original vale is 1 ms
LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h]
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
/// float timeSec = 3600.0f * timeHr;
/// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f);
int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse);
///============================================================================================
@@ -568,7 +547,7 @@ namespace TBF.Rig.TestMethods.StandingStart
StartTime = (double)StateMachine.Time;
int estimtdEndTime = StateMachine.Time + (int)test.TestTime;
int remainingTime;
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, Math.Max((int)(test.TestTime / 10), 5));
StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, Math.Max((int)(test.TestTime / 10), 5));
int initialPulsesCount = RefPulses;
@@ -595,7 +574,7 @@ namespace TBF.Rig.TestMethods.StandingStart
/// Update statistics
RefFrequency.Val = cBrd.RefFrequency;
RefFlow.Val = outPath.FlowMeter.ReadFlow();
UpdateAllStatistics(StateMachine.Time);
UpdateAllStatistics();
#region Heat meters
@@ -611,7 +590,7 @@ namespace TBF.Rig.TestMethods.StandingStart
//double deltaTime = (double)(StateMachine.Time - lastEnergyUpdateTime);
double T_in = (TempRefHi1.Val + TempRefHi2.Val) / 2; /// [°C]
double T_out = (TempRefLo1.Val + TempRefLo2.Val) / 2; /// [°C]
double deltaVolume = LtrPerRefPulse * RefPulsesDelta; /// [l]
double deltaVolume = outPath.FlowMeter.LtrPerPulse * RefPulsesDelta; /// [l]
double deltaEnergy = (0.001 * deltaVolume) * (T_in - T_out) * Formulas.HeatCoefficientWater(16, T_in, T_out, heatMetersTestParams.FlowMeasuredAtHiTempPipe); /// [J] = [m3] * [K] * [J/(m3 K)]
Energy.Update(deltaEnergy);
VolumeForEnergy.Update(deltaVolume);
@@ -659,8 +638,8 @@ namespace TBF.Rig.TestMethods.StandingStart
TestEndTime = DateTime.Now;
int endPulses = cBrd.RefPulses;
double flowVolume = 3.6 * LtrPerRefPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime;
double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowVolume, rangeIx);
double flowMID = 3.6 * outPath.FlowMeter.LtrPerPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime;
double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, Convert.ToSingle(TempDownStat.Average));
double volumeCTV = constMasterCorr * Convert.ToDouble(endPulses - startPulses);
double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l]
@@ -818,20 +797,20 @@ namespace TBF.Rig.TestMethods.StandingStart
tstRslt.MassEndRaw = 0;
tstRslt.MassEnd = 0;
tstRslt.MassOfEvapWater = 0;
tstRslt.FlowMass = 0;
tstRslt.FlowVolume = flowVolume; /// [m3/h]
tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.Flow = flowMID; /// [m3/h]
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient
tstRslt.VolumeMaster = outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
tstRslt.ConstMasterCorr = constMasterCorr; /// Corrected master pulses per liter
tstRslt.ConstMaster = constMasterCorr; /// Corrected master pulses per liter
tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.VolumeCTV = constMasterCorr * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3]
tstRslt.ErrorMaster = 0;
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;
/// 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 = switchTimeStart;
tstRslt.DiverterEnd = switchTimeEnd;