FIX NaN - devide by zero
Add simulation logic to `StandingStartStopTestOp` and handle zero `TestTime` edge cases in `FlyingStartMassCollectionSeq`
This commit is contained in:
parent
a997c3d7be
commit
df2c56e6c4
@ -5,6 +5,7 @@ using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Common;
|
||||
using log4net;
|
||||
using TBF.Rig.GenericDevices;
|
||||
|
||||
@ -24,6 +25,9 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
readonly TBF.Rig.Uni.Diverter.Diverter diverter;
|
||||
readonly int pulsesCount; /// Number of reference pulses for a complete test
|
||||
readonly bool withDiverter; /// Test with diverter (and scale)
|
||||
|
||||
private DateTime startTimeForSimulation;
|
||||
private bool simulationTimerStarted = false;
|
||||
|
||||
///
|
||||
/// Internal state of this operation
|
||||
@ -183,6 +187,28 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
{
|
||||
log.DebugFormat("Run() opState={0}", opState);
|
||||
|
||||
//Simulation of processing time 25 seconds
|
||||
if (uniCB.DebugLevel == DebugMode.Simulate)
|
||||
{
|
||||
if (opState == OpState.StartingTest)
|
||||
{
|
||||
startTimeForSimulation = DateTime.Now;
|
||||
simulationTimerStarted = false;
|
||||
}
|
||||
if (opState == OpState.TestInProgress)
|
||||
{
|
||||
if (!simulationTimerStarted)
|
||||
{
|
||||
startTimeForSimulation = DateTime.Now;
|
||||
simulationTimerStarted = true;
|
||||
}
|
||||
else if (DateTime.Now - startTimeForSimulation > TimeSpan.FromSeconds(25))
|
||||
{
|
||||
return Event.TestCompleted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (opState)
|
||||
{
|
||||
case OpState.StartingTest:
|
||||
|
||||
@ -691,7 +691,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1;
|
||||
tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse;
|
||||
tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter
|
||||
double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] flow before correction from the master flow meter
|
||||
double flowMID = tstRslt.TestTime == 0 ? 0 : 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] flow before correction from the master flow meter
|
||||
|
||||
/// Corrected data
|
||||
tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections);
|
||||
@ -708,7 +708,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
tstRslt.VolumeCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection;
|
||||
tstRslt.VolumeCTV /= tstRslt.TestTime;
|
||||
}
|
||||
tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// Flow from VolumeCTV and time
|
||||
tstRslt.Flow = tstRslt.TestTime==0 ? 0 : 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// Flow from VolumeCTV and time
|
||||
tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV);
|
||||
tstRslt.ConstMaster = (tstRslt.PulsesMaster != 0) ? (tstRslt.VolumeCTV / tstRslt.PulsesMaster) : tstRslt.ConstMasterCorr;
|
||||
/// Master pulses per liter from the measured mass
|
||||
@ -719,9 +719,14 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
{
|
||||
tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(flowMID);
|
||||
tstRslt.MassCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection;
|
||||
tstRslt.MassCTV /= tstRslt.TestTime;
|
||||
if (tstRslt.TestTime!= 0)
|
||||
tstRslt.MassCTV /= tstRslt.TestTime;
|
||||
else
|
||||
{
|
||||
tstRslt.MassCTV = 0;
|
||||
}
|
||||
}
|
||||
tstRslt.MassFlow = 3.6 * tstRslt.MassCTV / tstRslt.TestTime; /// Flow from MassCTV and time
|
||||
tstRslt.MassFlow = tstRslt.TestTime == 0 ? 0 : 3.6 * tstRslt.MassCTV / tstRslt.TestTime; /// Flow from MassCTV and time
|
||||
tstRslt.MassErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.MassCTV);
|
||||
tstRslt.MassConstMaster = (tstRslt.PulsesMaster != 0) ? (tstRslt.MassCTV / tstRslt.PulsesMaster) : tstRslt.ConstMasterCorr;
|
||||
|
||||
@ -1016,8 +1021,8 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
|
||||
meterRslt.VolumeEnd = dstrReader.VolumeLtrEnd; /// liter
|
||||
meterRslt.VolumeMeter =
|
||||
Math.Abs(dstrReader.VolumeLtrEnd - dstrReader.VolumeLtrStart);
|
||||
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.PulsesMaster =
|
||||
meterRslt.VolumeRef = tstRslt.TestTime==0? tstRslt.VolumeCTV : tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
|
||||
meterRslt.PulsesMaster = tstRslt.TestTime == 0? tstRslt.PulsesMaster :
|
||||
tstRslt.PulsesMaster * meterRslt.TestTime / tstRslt.TestTime;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user