diff --git a/TBF/Rig/Sequences/SequenceBase.cs b/TBF/Rig/Sequences/SequenceBase.cs index d6dce25a0..fe9810fcd 100644 --- a/TBF/Rig/Sequences/SequenceBase.cs +++ b/TBF/Rig/Sequences/SequenceBase.cs @@ -1580,20 +1580,22 @@ namespace TBF.Rig.Sequences tstRslt.EndTime = DateTime.Now + new TimeSpan(0, 0, 1); tstRslt.FlowSetTime = 10; tstRslt.TestTime = tstRslt.TargetTime(); - tstRslt.PulsesMaster = (outPath.FlowMeter.LtrPerPulse > 1E-6) ? (1.0075 * tstRslt.TargetVolume() / outPath.FlowMeter.LtrPerPulse) : 1; - tstRslt.MassStartRaw = 0; - tstRslt.MassStart = Config.Entities.MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); - tstRslt.MassEndRaw = tstRslt.TargetVolume() * Config.Formulas.RealDensity() / 1000.0f; - tstRslt.MassEnd = Config.Entities.MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections); - tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; - tstRslt.FlowVolume = 3.6 * outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster / tstRslt.TestTime; - tstRslt.MassOfEvapWater = 0; - tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityLine; /// [l] commercially true volume - tstRslt.VolumeMaster = outPath.FlowMeter.LtrPerPulse * 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, 0); /// Corrected master pulses per liter - tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (outPath.FlowMeter.LtrPerPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); - + if (outPath != null) + { + tstRslt.PulsesMaster = (outPath.FlowMeter.LtrPerPulse > 1E-6) ? (1.0075 * tstRslt.TargetVolume() / outPath.FlowMeter.LtrPerPulse) : 1; + tstRslt.MassStartRaw = 0; + tstRslt.MassStart = Config.Entities.MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); + tstRslt.MassEndRaw = tstRslt.TargetVolume() * Config.Formulas.RealDensity() / 1000.0f; + tstRslt.MassEnd = Config.Entities.MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections); + tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; + tstRslt.FlowVolume = 3.6 * outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster / tstRslt.TestTime; + tstRslt.MassOfEvapWater = 0; + tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityLine; /// [l] commercially true volume + tstRslt.VolumeMaster = outPath.FlowMeter.LtrPerPulse * 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, 0); /// Corrected master pulses per liter + tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (outPath.FlowMeter.LtrPerPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); + } tstRslt.ErrorMaster = Config.Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); tstRslt.FlowMean = (float)RefFlowStat.Average; @@ -1633,11 +1635,11 @@ namespace TBF.Rig.Sequences .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)); + (inPath != null && inPath.Pump != null) ? inPath.Pump.Name : string.Empty, + (outPath != null && outPath.FlowMeter != null) ? outPath.FlowMeter.Name : string.Empty, + (outPath != null && outPath.Scale != null) ? outPath.Scale.Name : string.Empty, + (outPath != null && outPath.RegulValve != null) ? outPath.RegulValve.Name : string.Empty, + (outPath != null && outPath.Diverter != null) ? outPath.Diverter.Name : string.Empty)); } @@ -1747,13 +1749,13 @@ namespace TBF.Rig.Sequences 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)); + new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, + (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", + (inPath != null && inPath.Pump != null) ? inPath.Pump.Name : string.Empty, + (outPath != null && outPath.FlowMeter != null) ? outPath.FlowMeter.Name : string.Empty, + (outPath != null && outPath.Scale != null) ? outPath.Scale.Name : string.Empty, + (outPath != null && outPath.RegulValve != null) ? outPath.RegulValve.Name : string.Empty, + (outPath != null && outPath.Diverter != null) ? outPath.Diverter.Name : string.Empty)); } @@ -1879,13 +1881,13 @@ namespace TBF.Rig.Sequences } 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)); + new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, + (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", + (inPath != null && inPath.Pump != null) ? inPath.Pump.Name : string.Empty, + (outPath != null && outPath.FlowMeter != null) ? outPath.FlowMeter.Name : string.Empty, + (outPath != null && outPath.Scale != null) ? outPath.Scale.Name : string.Empty, + (outPath != null && outPath.RegulValve != null) ? outPath.RegulValve.Name : string.Empty, + (outPath != null && outPath.Diverter != null) ? outPath.Diverter.Name : string.Empty)); } @@ -2016,11 +2018,11 @@ namespace TBF.Rig.Sequences .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)); + (inPath != null && inPath.Pump != null) ? inPath.Pump.Name : string.Empty, + (outPath != null && outPath.FlowMeter != null) ? outPath.FlowMeter.Name : string.Empty, + (outPath != null && outPath.Scale != null) ? outPath.Scale.Name : string.Empty, + (outPath != null && outPath.RegulValve != null) ? outPath.RegulValve.Name : string.Empty, + (outPath != null && outPath.Diverter != null) ? outPath.Diverter.Name : string.Empty)); } protected bool TestAndLogUiCmdStop(IList e)