From 2c0ae68db00eda477111caaecf23e0b08f3304df Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 2 May 2022 09:28:16 +0200 Subject: [PATCH] IFlowMeterSingle with GetRange(.) and CorrectedFlow(.), Test method calculations clean-up, refactorization, ver. 3.1.1901 --- Results/Entities/MeterTestRslt.cs | 3 +- Results/Entities/TestRslt.cs | 18 +-- Results/Mappings/TestRsltMap.cs | 7 +- Results/Output/WMChart.cs | 2 +- Results/WMeterRsltItemSpec.cs | 2 +- TBF/Properties/AssemblyInfo.cs | 4 +- .../DataEntry/Double24/CycleBeginningForm.cs | 3 + TBF/Rig/Dummy/FlowMeter/FlowMeter.cs | 2 +- TBF/Rig/GenericDevices/IFlowMeter.cs | 27 ++-- TBF/Rig/GenericDevices/IFlowMeterSingle.cs | 25 ++++ TBF/Rig/Operations/EnthalpyCalculationOp.cs | 7 +- .../SaveFlowmeterCorr.cs | 4 +- .../Output/FileWriters/IperlLogger/Writer.cs | 4 +- TBF/Rig/Sequences/ProcessData.cs | 79 ++++++----- TBF/Rig/Sequences/SequenceBase.cs | 45 +++---- .../TestMethods/Adjustment/AdjustmentSeq.cs | 85 ++++++------ .../CombinedWithDetectionSeq.cs | 94 ++++++------- .../DiverterTest/DiverterTestSeq.cs | 81 +++++------- TBF/Rig/TestMethods/Dummy/DummySeq.cs | 2 +- TBF/Rig/TestMethods/Endurance/EnduranceSeq.cs | 91 ++++++------- .../TestMethods/FixedStart/FixedStartSeq.cs | 48 ++----- .../FixedStartAdvancedSeq.cs | 72 ++++------ .../FixedStartDeferredEvalSeq.cs | 47 ++----- .../FixedStartMassCollAdvancedSeq.cs | 86 +++++------- .../FixedStartMassCollDeferredEvalSeq.cs | 97 ++++++-------- .../FixedStartTankCollectionSeq.cs | 77 +++++------ .../FlowAdjustment/FlowAdjustmentSeq.cs | 69 +++++----- .../TestMethods/FlyingStart/FlyingStartSeq.cs | 97 +++++++------- .../FlyingStartFirstRepetWithMassCollSeq.cs | 112 ++++++++-------- .../FlyingStartMassCollComparativeSeq.cs | 88 ++++++------- .../FlyingStartMassCollProlongedSeq.cs | 95 ++++++-------- .../FlyingStartMassCollectionSeq.cs | 112 ++++++++-------- .../FlyingStartTankCollectionSeq.cs | 75 +++++------ TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs | 13 +- .../TestMethods/ManualEntry/ManualEntrySeq.cs | 3 +- TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs | 9 +- .../TestMethods/PulsesTest/PulsesTestSeq.cs | 49 +++---- .../PulsesTestManual/PulsesTestManualSeq.cs | 77 +++++------ .../RoiDetection/RoiDetectionSeq.cs | 3 +- .../SensitivityTest/SensitivityTestSeq.cs | 34 +---- .../StandingStart/StandingStartSeq.cs | 63 +++------ .../StandingStartMassCollectionSeq.cs | 75 +++++------ .../iPerlCommunicationSeq.cs | 12 +- TBF/Rig/Uni/FlowMeter/FlowMeter.cs | 52 ++++++-- TBF/Rig/Uni/FlowMetersInParallel/FlowMeter.cs | 123 ++++++++++-------- TBF/Rig/Various/ErrorFlags/Errors.cs | 6 +- TBF/TBF.csproj | 1 + TBF/UI/Process/ProcessTabPageCtrl.cs | 3 +- TBF/UI/Process/ProcessTabPageCtrl24.cs | 9 +- TBF/UI/Process/ProcessTabPageCtrl48.cs | 11 +- TBF/UI/Process/ProcessTabPageCtrl6.cs | 11 +- 51 files changed, 1001 insertions(+), 1213 deletions(-) create mode 100644 TBF/Rig/GenericDevices/IFlowMeterSingle.cs diff --git a/Results/Entities/MeterTestRslt.cs b/Results/Entities/MeterTestRslt.cs index 8387c2ad7..079bb7aee 100644 --- a/Results/Entities/MeterTestRslt.cs +++ b/Results/Entities/MeterTestRslt.cs @@ -55,8 +55,7 @@ namespace Results.Entities public virtual DateTime StartTime() { return TestRslt.StartTime; } public virtual DateTime EndTime() { return TestRslt.EndTime; } public virtual double FlowSetTime() { return TestRslt.FlowSetTime; } /// [s] - public virtual double FlowMass() { return TestRslt.FlowMass; } /// [kg/h] - public virtual double FlowVolume() { return TestRslt.FlowVolume; } /// [m3/h] + public virtual double Flow() { return TestRslt.Flow; } /// [m3/h] public virtual double ErrorMaster() { return TestRslt.ErrorMaster; } /// [%] public virtual double DensityLine() { return TestRslt.DensityLine; } public virtual Components Components(){ return TestRslt.Components; } diff --git a/Results/Entities/TestRslt.cs b/Results/Entities/TestRslt.cs index d66dad1a2..762eeecd3 100644 --- a/Results/Entities/TestRslt.cs +++ b/Results/Entities/TestRslt.cs @@ -44,8 +44,8 @@ namespace Results.Entities public virtual double DensityLine { get; set; } /// [kg/m3] public virtual double DensityDiv { get; set; } /// [kg/m3] public virtual double MassOfEvapWater { get; set; } /// [kg] - public virtual double FlowMass { get; set; } /// [kg/h] calculated from conventional true value - public virtual double FlowVolume { get; set; } /// [m3/h] + public virtual double SpareDbl { get; set; } + public virtual double Flow { get; set; } /// [m3/h] calculated from conventional true value public virtual double VolumeCTV { get; set; } /// [l] Volume conventional true value public virtual double VolumeMaster { get; set; } /// [l] Volume from the master flow meter public virtual double ErrorMaster { get; set; } /// [%] Error of the master flow meter @@ -277,8 +277,8 @@ namespace Results.Entities DensityLine = src.DensityLine; DensityDiv = src.DensityDiv; MassOfEvapWater = src.MassOfEvapWater; - FlowMass = src.FlowMass; - FlowVolume = src.FlowVolume; + SpareDbl = src.SpareDbl; + Flow = src.Flow; VolumeCTV = src.VolumeCTV; VolumeMaster = src.VolumeMaster; ErrorMaster = src.ErrorMaster; @@ -415,7 +415,7 @@ namespace Results.Entities return string.Format("TestRslt: Part={0} RepetitionNr={1} TestDone={2} Remark={3} StartTime={4} EndTime={5} FlowSetTime={6} TestTime={7} PulsesMaster={8} ConstMaster={9} MassStartRaw={10} MassStart={11} MassEndRaw={12} MassEnd={13} DensityIn={14} DensityOut={15} DensityDiv={16} MassOfEvapWaater={17} FlowMass={18} FlowVolume={19} VolumeCTV={20} VolumeMaster={21} ErrorMaster={22} DiverterStart={85} DiverterEnd={86} ErrorFlags={23} InfoFlags={24} AmbTempMean={25} AmbTempStart={26} AmbTempEnd={27} AmbTempMin={28} AmbTempMax={29} AmbPressMean={30} AmbPressStart={31} AmbPressEnd={32} AmbPressMin={33} AmbPressMax={34} AmbHumiMean={35} AmbHumiStart={36} AmbHumiEnd={37} AmbHumiMin={38} AmbHumiMax={39} PressUpMean={40} PressUpStart={41} PressUpEnd={42} PressUpMin={43} PressUpMax={44} PressDownMean={45} PressDownStart={46} PressDownEnd={47} PressDownMin={48} PressDownMax={49} PressDeltaMean={50} PressDeltaStart={51} PressDeltaEnd={52} PressDeltaMin={53} PressDeltaMax={54} TempUpMean={55} TempUpStart={56} TempUpEnd={57} TempUpMin={58} TempUpMax={59} TempDownMean={60} TempDownStart={61} TempDownEnd={62} TempDownMin={63} TempDownMax={64} TempDivMean={65} TempDivStart={66} TempDivEnd={67} TempDivMin={68} TempDivMax={69} FlowMean={70} FlowStart={71} FlowEnd={72} FlowMin={73} FlowMax={74} Custom1={75} Custom2={76} Custom3={77} Custom4={78} Custom5={79} Custom6={80} Custom7={81} Custom8={82} Custom9={83} Custom10={84}", Part, RepetitionNr, TestDone, Remark, StartTime, EndTime, FlowSetTime, TestTime, PulsesMaster, ConstMaster, MassStartRaw, MassStart, MassEndRaw, MassEnd, - DensityIn, DensityLine, DensityDiv, MassOfEvapWater, FlowMass, FlowVolume, + DensityIn, DensityLine, DensityDiv, MassOfEvapWater, SpareDbl, Flow, VolumeCTV, VolumeMaster, ErrorMaster, ErrorFlags, InfoFlags, AmbTempMean, AmbTempStart, AmbTempEnd, AmbTempMin, AmbTempMax, AmbPressMean, AmbPressStart, AmbPressEnd, AmbPressMin, AmbPressMax, @@ -484,8 +484,8 @@ namespace Results.Entities writer.Write(DensityLine); writer.Write(DensityDiv); writer.Write(MassOfEvapWater); - writer.Write(FlowMass); - writer.Write(FlowVolume); + writer.Write(SpareDbl); + writer.Write(Flow); writer.Write(VolumeCTV); writer.Write(VolumeMaster); writer.Write(ErrorMaster); @@ -625,8 +625,8 @@ namespace Results.Entities DensityLine = reader.ReadDouble(); DensityDiv = reader.ReadDouble(); MassOfEvapWater = reader.ReadDouble(); - FlowMass = reader.ReadDouble(); - FlowVolume = reader.ReadDouble(); + SpareDbl = reader.ReadDouble(); + Flow = reader.ReadDouble(); VolumeCTV = reader.ReadDouble(); VolumeMaster = reader.ReadDouble(); ErrorMaster = reader.ReadDouble(); diff --git a/Results/Mappings/TestRsltMap.cs b/Results/Mappings/TestRsltMap.cs index d6a94ec4a..014952522 100644 --- a/Results/Mappings/TestRsltMap.cs +++ b/Results/Mappings/TestRsltMap.cs @@ -39,10 +39,9 @@ namespace Results.Mappings Map(x => x.DensityIn); Map(x => x.DensityLine); Map(x => x.DensityDiv); - Map(x => x.MassOfEvapWater) - .Column("Buoyancy"); - Map(x => x.FlowMass); - Map(x => x.FlowVolume); + Map(x => x.MassOfEvapWater).Column("Buoyancy"); + Map(x => x.SpareDbl).Column("FlowMass"); + Map(x => x.Flow).Column("FlowVolume"); Map(x => x.VolumeCTV); Map(x => x.VolumeMaster); Map(x => x.ErrorMaster); diff --git a/Results/Output/WMChart.cs b/Results/Output/WMChart.cs index 2e09db12b..c0a131dc6 100644 --- a/Results/Output/WMChart.cs +++ b/Results/Output/WMChart.cs @@ -25,7 +25,7 @@ namespace Results.Output IList unsortedPoints = new List(); foreach (var mtr in wm.RegularMeterTestRslts()) { - double flow = mtr.TestRslt.FlowVolume; + double flow = mtr.TestRslt.Flow; var td = mtr.TestRslt.TestData; if (mtr.IsPilotRslt() && flow > 0 && td.Evaluate && diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs index 48a97373a..0635eb8b8 100644 --- a/Results/WMeterRsltItemSpec.cs +++ b/Results/WMeterRsltItemSpec.cs @@ -204,7 +204,7 @@ namespace Results /// AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_from, string.Format("{0} {1}", Strings.VName_Flow, Strings.from), Quantity.Flow, ItemCategory.TestData, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).Qfrom()))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_to, string.Format("{0} {1}", Strings.VName_Flow, Strings.to), Quantity.Flow, ItemCategory.TestData, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).Qto()))); - AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow, string.Format("{0} v r", Strings.VName_Flow), Strings.Tooltip_Q_v_r, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowVolume))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.Flow, string.Format("{0} v r", Strings.VName_Flow), Strings.Tooltip_Q_v_r, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).Flow))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_mean, string.Format("{0} rim ()", Strings.VName_Flow), Strings.Tooltip_Q_rim, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowMean))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_min, string.Format("{0} ref min ()", Strings.VName_Flow), Strings.Tooltip_Q_min, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowMin))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Q_ref_max, string.Format("{0} ref max ()", Strings.VName_Flow), Strings.Tooltip_Q_max, Quantity.Flow, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) == null) ? "" : FormatDbl(u, f, p, "V3", w.GetTestRslt(t).FlowMax))); diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 3ddce6cbe..c942659f6 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.1.1899.0")] -[assembly: AssemblyFileVersion("3.1.1899.0")] +[assembly: AssemblyVersion("3.1.1901.0")] +[assembly: AssemblyFileVersion("3.1.1901.0")] diff --git a/TBF/Rig/DataEntry/Double24/CycleBeginningForm.cs b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.cs index 3806ead16..d5b322efe 100644 --- a/TBF/Rig/DataEntry/Double24/CycleBeginningForm.cs +++ b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.cs @@ -146,6 +146,9 @@ namespace TBF.Rig.DataEntry.Double24 if (Program.LocalSettings.LastSNTextsCount == textBoxesCount) { comboBoxes[i].Items.Add((Program.LocalSettings.LastSNTexts[i] == null) ? string.Empty : Program.LocalSettings.LastSNTexts[i]); + } + if (Program.LocalSettings.LastAuxSNTextsCount == textBoxesCount) + { column2ComboBoxes[i].Items.Add((Program.LocalSettings.LastAuxSNTexts[i] == null) ? string.Empty : Program.LocalSettings.LastAuxSNTexts[i]); } diff --git a/TBF/Rig/Dummy/FlowMeter/FlowMeter.cs b/TBF/Rig/Dummy/FlowMeter/FlowMeter.cs index 5dce7eb2e..f1f41bf82 100644 --- a/TBF/Rig/Dummy/FlowMeter/FlowMeter.cs +++ b/TBF/Rig/Dummy/FlowMeter/FlowMeter.cs @@ -22,7 +22,7 @@ namespace TBF.Rig.Dummy.FlowMeter public IDrawingItem DrawingItem { get { return flowMeterCfg as IDrawingItem; } } - public double LtrPerPulseCorrected(double flow, int rangeIx) + public double LtrPerPulseCorrected(double flow, float temperature) { return flow; } diff --git a/TBF/Rig/GenericDevices/IFlowMeter.cs b/TBF/Rig/GenericDevices/IFlowMeter.cs index 88e03010d..3f340ad2c 100644 --- a/TBF/Rig/GenericDevices/IFlowMeter.cs +++ b/TBF/Rig/GenericDevices/IFlowMeter.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2021 Sensus Slovensko a.s. +/// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.Generic; @@ -13,15 +13,9 @@ namespace TBF.Rig.GenericDevices public interface IFlowMeter : IComponent { /// - /// Nominal flow in m3/h at the nominal output frequency (see below). - /// In case of a flowmeter couple, the sum of two nominal flows (reached at sum of nominal freq.). + /// Reference flow meter communicated to the board: 1-based index, 0 for parallel flow meters /// - double NominalFlow { get; } - - /// - /// Nominal frequency in Hz. - /// - double NominalFreq { get; } + int Idx1 { get; } /// /// Nominal (uncorrected) volume per flowmeter pulse in [l]. @@ -32,12 +26,19 @@ namespace TBF.Rig.GenericDevices /// Corrected volume per flowmeter pulse in [l]. /// /// Water flow in [m3/h] - double LtrPerPulseCorrected(double flow, int rangeIx); + /// Water temperature in [°C] + double LtrPerPulseCorrected(double flow, float temperature); /// - /// Reference flow meter communicated to the board: 1-based index, 0 for flow meter twins + /// Nominal flow in m3/h at the nominal output frequency (see below). + /// In case of a flowmeter couple, the sum of two nominal flows (reached at sum of nominal freq.). /// - int Idx1 { get; } + double NominalFlow { get; } + + /// + /// Nominal frequency in Hz. + /// + double NominalFreq { get; } /// /// Returns current flow value in [m3/h] @@ -51,7 +52,7 @@ namespace TBF.Rig.GenericDevices /// Frequency in Hz double ReadFrequency(); - /// + /// /// Events: FlowDone, Error /// /// Reference to a variable for the measured flow in xxx diff --git a/TBF/Rig/GenericDevices/IFlowMeterSingle.cs b/TBF/Rig/GenericDevices/IFlowMeterSingle.cs new file mode 100644 index 000000000..04d4e4537 --- /dev/null +++ b/TBF/Rig/GenericDevices/IFlowMeterSingle.cs @@ -0,0 +1,25 @@ +/// +/// Copyright (c) 2022 Sensus Slovensko a.s. +/// + +namespace TBF.Rig.GenericDevices +{ + public interface IFlowMeterSingle : IFlowMeter + { + /// + /// Determine flow meter range + /// + /// Lower boundary of temperature + /// Upper boundary of temperature + /// flow meter range (0..5) or -1 if no range fits the specified temperature range + int GetRange(float tempRngLo, float tempRngHi); + + /// + /// Apply flow measurement correction + /// + /// Measured flow in [m3/h] + /// Tange 0..5 + /// Corrected flow in [m3/h] + double CorrectedFlow(double flow, int rng); + } +} diff --git a/TBF/Rig/Operations/EnthalpyCalculationOp.cs b/TBF/Rig/Operations/EnthalpyCalculationOp.cs index 03453e094..d49c5ca5d 100644 --- a/TBF/Rig/Operations/EnthalpyCalculationOp.cs +++ b/TBF/Rig/Operations/EnthalpyCalculationOp.cs @@ -3,6 +3,7 @@ /// using System; using log4net; +using TBF.Rig.Sequences; namespace TBF.Rig.Operations { @@ -73,12 +74,14 @@ namespace TBF.Rig.Operations private void AccumulateEnthalpy() { /// Calculate # of reference pulses - int newRefPulses = Rig.Sequences.ProcessData.RefPulses; + int newRefPulses = ProcessData.RefPulses; int deltaPulses = newRefPulses - lastRefPulses; lastRefPulses = newRefPulses; /// Calculate volume [l] - double deltaVolume = deltaPulses * Rig.Sequences.ProcessData.LtrPerRefPulse; + double deltaVolume = (ProcessData.Devices != null && ProcessData.Devices.FlowMeter != null) + ? deltaPulses * ProcessData.Devices.FlowMeter.LtrPerPulse + : 0; for (int i = 0; i < enthalpy.Length; i++) { diff --git a/TBF/Rig/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs b/TBF/Rig/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs index b78456afc..c900a6162 100644 --- a/TBF/Rig/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs +++ b/TBF/Rig/Output/DB/SaveFlowmeterCorrections/SaveFlowmeterCorr.cs @@ -92,7 +92,7 @@ namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections if (tr.Repeats() == 1) { - flow = tr.FlowVolume; + flow = tr.Flow; errorMaster = tr.ErrorMaster; } else @@ -103,7 +103,7 @@ namespace TBF.Rig.Output.DB.SaveFlowmeterCorrections { if (tr2.TestDone && (tr2.TestData.Name == tr.TestData.Name)) { - flow += tr2.FlowVolume; + flow += tr2.Flow; errorMaster += tr2.ErrorMaster; count++; } diff --git a/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs b/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs index a2649a4c9..f2b2123ac 100644 --- a/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs +++ b/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs @@ -381,7 +381,7 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger if (mtr != null) { logger.WriteLine(string.Format("Q{0}bestanden={1}", flID, 1)); - logger.WriteLine(string.Format("Durchfluss{0}={1}", flID, Utils.DoubleToStr(Units.ConvertTo(Unit.lph, mtr.FlowVolume()), 5, true))); + logger.WriteLine(string.Format("Durchfluss{0}={1}", flID, Utils.DoubleToStr(Units.ConvertTo(Unit.lph, mtr.Flow()), 5, true))); logger.WriteLine(string.Format("Fehler{0}={1}", flID, mtr.Error.ToString(Program.AltCulture))); logger.WriteLine(string.Format("ZeitImpulse{0}={1}", flID, mtr.TestTime.ToString(Program.AltCulture))); logger.WriteLine(string.Format("Impulse{0}={1}", flID, 0)); @@ -395,7 +395,7 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger logger.WriteLine(string.Format("Q{0}KorrBestanden={1}", flID, mtr.Passed ? 1 : 0)); logger.WriteLine(string.Format("Anfangsstand{0}={1}", flID, mtr.VolumeStart).ToString(Program.AltCulture)); logger.WriteLine(string.Format("Endstand{0}={1}", flID, mtr.VolumeEnd).ToString(Program.AltCulture)); - logger.WriteLine(string.Format("QMittelwert{0}={1}", flID, Utils.DoubleToStr(Units.ConvertTo(Unit.lph, mtr.FlowVolume()), 5, true))); + logger.WriteLine(string.Format("QMittelwert{0}={1}", flID, Utils.DoubleToStr(Units.ConvertTo(Unit.lph, mtr.Flow()), 5, true))); logger.WriteLine(string.Format("QStandardAbweichung{0}={1}", flID, 0)); logger.WriteLine(string.Format("ImpedanzMittelwert{0}={1}", flID, "0,00000")); logger.WriteLine(string.Format("AusfallGrund{0}={1}", flID, 0)); diff --git a/TBF/Rig/Sequences/ProcessData.cs b/TBF/Rig/Sequences/ProcessData.cs index 334a381bf..5cec93a60 100644 --- a/TBF/Rig/Sequences/ProcessData.cs +++ b/TBF/Rig/Sequences/ProcessData.cs @@ -246,10 +246,6 @@ namespace TBF.Rig.Sequences public static DoubleBox PressDelta = new DoubleBox() { Name = "Pressure Delta", Format = "F2" }; /// [bar] public static FloatBox Conductivity = new FloatBox(750) { Name = "Conductivity", Format = "F0" }; /// [uS/cm], default is 750 - public static double LtrPerRefPulse; /// to calculate the ref.volume - //{ - // get { return (Devices != null && Devices.FlowMeter != null) ? Devices.FlowMeter.LtrPerPulseCorrected : 0; } - //} public static int RefPulses { get { return StateMachine.ControlBoard.RefPulses; } } public static int RefPulsesDelta; public static DoubleBox RefFrequency = new DoubleBox() { Name = "RefFreq", Format = "F2" }; @@ -361,39 +357,48 @@ namespace TBF.Rig.Sequences public static Statistics DiverterStart = new Statistics(new Plotter("Div start")); public static Statistics DiverterEnd = new Statistics(new Plotter("Div end")); - public static int machineTimeStart; - public static int lastMachineTime; - - protected static void StartNewStatistics(int machineTime, int batchNr, string testName, int repetition, int skippedSamplesCount) + static int machineTimeStart; + static int lastMachineTime; + static IFlowMeter flowMeter; + /// + protected static void StartNewStatistics(IFlowMeter flowMeter, + int batchNr, Config.Entities.Test test, int repetition, int skippedSamplesCount) { - machineTimeStart = machineTime; - lastMachineTime = machineTime; + ProcessData.flowMeter = flowMeter; - AmbTempStat.Start (batchNr, testName, repetition); - AmbPressStat.Start(batchNr, testName, repetition); - AmbHumiStat.Start (batchNr, testName, repetition); + machineTimeStart = lastMachineTime = StateMachine.Time; - TempUpStat.Start (batchNr, testName, repetition, skippedSamplesCount); - TempDownStat.Start (batchNr, testName, repetition, skippedSamplesCount); - TempDiffStat.Start (batchNr, testName, repetition, skippedSamplesCount); - TempDivStat.Start (batchNr, testName, repetition, skippedSamplesCount); - PressUpStat.Start (batchNr, testName, repetition, skippedSamplesCount); - PressDownStat.Start (batchNr, testName, repetition, skippedSamplesCount); - PressDeltaStat.Start(batchNr, testName, repetition, skippedSamplesCount); - ConductStat.Start (batchNr, testName, repetition, skippedSamplesCount); - RefFlowStat.Start (batchNr, testName, repetition, skippedSamplesCount); - MassStat.Start (batchNr, testName, repetition, skippedSamplesCount); + AmbTempStat.Start (batchNr, test.Name, repetition); + AmbPressStat.Start(batchNr, test.Name, repetition); + AmbHumiStat.Start (batchNr, test.Name, repetition); + + TempUpStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + TempDownStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + TempDiffStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + TempDivStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + PressUpStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + PressDownStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + PressDeltaStat.Start(batchNr, test.Name, repetition, skippedSamplesCount); + ConductStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + RefFlowStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); + MassStat.Start (batchNr, test.Name, repetition, skippedSamplesCount); - TempRefHiStat.Start(batchNr, testName, repetition); - TempRefLoStat.Start (batchNr, testName, repetition); - Energy.Start (batchNr, testName, repetition); - VolumeForEnergy.Start(batchNr, testName, repetition); + TempRefHiStat.Start (batchNr, test.Name, repetition); + TempRefLoStat.Start (batchNr, test.Name, repetition); + Energy.Start (batchNr, test.Name, repetition); + VolumeForEnergy.Start(batchNr, test.Name, repetition); lastEnergyUpdateTime = 0; + + if (flowMeter is Uni.FlowMetersInParallel.FlowMeter) + { + (flowMeter as Uni.FlowMetersInParallel.FlowMeter).StartStatistics(test); + } } - protected static void UpdateAllStatistics(int machineTime) + protected static void UpdateAllStatistics() { - int timeDelta = machineTime - lastMachineTime; + int timeDelta = StateMachine.Time - lastMachineTime; + lastMachineTime = StateMachine.Time; AmbTempStat.Update(AmbTemp); AmbPressStat.Update(AmbPress); @@ -409,6 +414,11 @@ namespace TBF.Rig.Sequences ConductStat.Update(Conductivity); RefFlowStat.Update(RefFlow); + if (flowMeter is Uni.FlowMetersInParallel.FlowMeter) + { + (flowMeter as Uni.FlowMetersInParallel.FlowMeter).UpdateStatistics(timeDelta); + } + double massIncreasePerSec; MassStat.Update(Mass, out massIncreasePerSec); FlowFromMassIncrease = 3600 * massIncreasePerSec / Formulas.DistilledWaterDensityFromTemp(TempDiv.Val); @@ -418,8 +428,6 @@ namespace TBF.Rig.Sequences TempRefHiStat.Update((TempRefHi1.Val + TempRefHi2.Val) / 2); TempRefLoStat.Update((TempRefLo1.Val + TempRefLo2.Val) / 2); } - - lastMachineTime = machineTime; } protected static void StopRecordingStatistics() @@ -440,6 +448,11 @@ namespace TBF.Rig.Sequences MassStat.Stop(); FlowFromMassIncrease = 0; + if (flowMeter is Uni.FlowMetersInParallel.FlowMeter) + { + (flowMeter as Uni.FlowMetersInParallel.FlowMeter).StopStatistics(); + } + TempRefHiStat.Stop(); TempRefLoStat.Stop(); Energy.Stop(); @@ -479,7 +492,7 @@ namespace TBF.Rig.Sequences Utils.DoubleToStr(RefFlow.Val, 4), /// flow measured by the reference flow meter in m3/h StateMachine.ControlBoard.TestTime.ToString("F3"),/// test time in s StateMachine.ControlBoard.RefPulses, /// reference flow meter pulses count - Formulas.VolumeFromPulses(StateMachine.ControlBoard.RefPulses, 1.0f / LtrPerRefPulse).ToString("F3"), /// volume in l + outPath.FlowMeter != null ? Formulas.VolumeFromPulses(StateMachine.ControlBoard.RefPulses, 1 / outPath.FlowMeter.LtrPerPulse).ToString("F3") : "0.000", /// volume in l benchPath.TempMtrUp != null ? benchPath.TempMtrUp.ReadTemperature() : 0, /// temp. at the beginning of line in degree C benchPath.TempMtrDown != null ? benchPath.TempMtrDown.ReadTemperature() : 0, /// temp. at the end of line in degree C outPath.TempMtrDiv != null ? outPath.TempMtrDiv.ReadTemperature() : 0, /// temp. at the diverter in degree C @@ -509,7 +522,7 @@ namespace TBF.Rig.Sequences Utils.DoubleToStr(RefFlow.Val, 4), StateMachine.ControlBoard.TestTime.ToString("F3"), StateMachine.ControlBoard.RefPulses, - Formulas.VolumeFromPulses(StateMachine.ControlBoard.RefPulses, 1.0f / LtrPerRefPulse).ToString("F3"), + outPath.FlowMeter != null ? Formulas.VolumeFromPulses(StateMachine.ControlBoard.RefPulses, 1 / outPath.FlowMeter.LtrPerPulse).ToString("F3") : "0.000", benchPath.TempMtrUp != null ? benchPath.TempMtrUp.ReadTemperature() : 0, /// temp. at the beginning of line in degree C benchPath.TempMtrDown != null ? benchPath.TempMtrDown.ReadTemperature() : 0, /// temp. at the end of test in degree C outPath.TempMtrDiv != null ? outPath.TempMtrDiv.ReadTemperature() : 0, /// temp. at the diverter in degree C diff --git a/TBF/Rig/Sequences/SequenceBase.cs b/TBF/Rig/Sequences/SequenceBase.cs index 39725c413..464e208b7 100644 --- a/TBF/Rig/Sequences/SequenceBase.cs +++ b/TBF/Rig/Sequences/SequenceBase.cs @@ -1114,7 +1114,7 @@ namespace TBF.Rig.Sequences sb.Append(";"); sb.Append(tstRslt.Batch.SampleTemp); /// BE sb.Append(";"); sb.Append(tstRslt.FlowMax); /// BF pipe expansion: teraz vynechat sb.Append(";"); sb.Append(tstRslt.FlowMin); /// BG [kg/h] Qm - sb.Append(";"); sb.Append(tstRslt.FlowVolume); /// BH [l/h] Qv + sb.Append(";"); sb.Append(tstRslt.Flow); /// BH [l/h] Qv sb.Append(";"); sb.Append(tstRslt.VolumeCTV); /// BI [l] Vet .... komercne prava hodnota objemu - podla vahy sb.Append(";"); sb.Append(tstRslt.VolumeMaster); /// BJ [l] Velm ... objem podla etalonu (Prolonged: objem do vahy podla impulzov hradlovanych klapkou) sb.Append(";"); sb.Append(tstRslt.TestTimeCorrection); /// BK [s] test time correction (diverter correction) @@ -1382,13 +1382,12 @@ namespace TBF.Rig.Sequences tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); tstRslt.MassEndRaw = tstRslt.TargetVolume() * Formulas.RealDensity() / 1000.0f; tstRslt.MassEnd = 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.Flow = 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.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.Flow, tstRslt.TempDownMean); /// Corrected master pulses per liter tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (outPath.FlowMeter.LtrPerPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); @@ -1497,14 +1496,15 @@ namespace TBF.Rig.Sequences tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); tstRslt.MassEndRaw = tstRslt.TargetVolume() * Formulas.RealDensity() / 1000.0f; tstRslt.MassEnd = 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.Flow = 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.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.Flow, tstRslt.TempDownMean); + /// Corrected master pulses per liter + tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (outPath.FlowMeter.LtrPerPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); @@ -1573,9 +1573,9 @@ namespace TBF.Rig.Sequences tstRslt.FlowSetTime = 10; tstRslt.TestTime = tstRslt.TargetTime(); /// TODO: Verify whether 'ltrPerRefPulse' is up to date - tstRslt.PulsesMaster = (LtrPerRefPulse > 1E-6) ? (tstRslt.TargetVolume() / LtrPerRefPulse) : 1; - tstRslt.ConstMasterRaw = LtrPerRefPulse; - tstRslt.ConstMaster = LtrPerRefPulse; + 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; @@ -1584,8 +1584,7 @@ namespace TBF.Rig.Sequences tstRslt.DensityLine = Formulas.RealDensity(); tstRslt.DensityDiv = Formulas.RealDensity(); tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = tstRslt.MassEnd / tstRslt.TargetTime(); - tstRslt.FlowVolume = tstRslt.TargetVolume() / tstRslt.TargetTime(); + tstRslt.Flow = tstRslt.TargetVolume() / tstRslt.TargetTime(); tstRslt.VolumeCTV = tstRslt.TargetVolume(); tstRslt.VolumeMaster = tstRslt.TargetVolume(); tstRslt.ErrorMaster = 0; @@ -1705,9 +1704,9 @@ namespace TBF.Rig.Sequences tstRslt.FlowSetTime = 10; tstRslt.TestTime = tstRslt.TargetTime(); /// TODO: Verify whether 'ltrPerRefPulse' is up to date - tstRslt.PulsesMaster = (LtrPerRefPulse > 1E-6) ? (tstRslt.TargetVolume() / LtrPerRefPulse) : 1; - tstRslt.ConstMasterRaw = LtrPerRefPulse; - tstRslt.ConstMaster = LtrPerRefPulse; + 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; @@ -1716,8 +1715,7 @@ namespace TBF.Rig.Sequences tstRslt.DensityLine = Formulas.RealDensity(); tstRslt.DensityDiv = Formulas.RealDensity(); tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = tstRslt.MassEnd / tstRslt.TargetTime(); - tstRslt.FlowVolume = tstRslt.TargetVolume() / tstRslt.TargetTime(); + tstRslt.Flow = tstRslt.TargetVolume() / tstRslt.TargetTime(); tstRslt.VolumeCTV = tstRslt.TargetVolume(); tstRslt.VolumeMaster = tstRslt.TargetVolume(); tstRslt.ErrorMaster = 0; @@ -1854,7 +1852,6 @@ namespace TBF.Rig.Sequences log.FatalFormat(" Flow: {0}", RefFlow); log.FatalFormat(" Mass: {0}", (outPath.Scale is IScale) ? (outPath.Scale as IScale).Mass : 0); log.FatalFormat(" Start mass: {0}", StartMass); - log.FatalFormat(" Liter/ref.pulse: {0}", LtrPerRefPulse); log.FatalFormat(" Reference pulses: {0}", RefPulses); } diff --git a/TBF/Rig/TestMethods/Adjustment/AdjustmentSeq.cs b/TBF/Rig/TestMethods/Adjustment/AdjustmentSeq.cs index c00873a84..6f8c02a0f 100644 --- a/TBF/Rig/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TBF/Rig/TestMethods/Adjustment/AdjustmentSeq.cs @@ -97,28 +97,15 @@ namespace TBF.Rig.TestMethods.Adjustment float simulatedError = 4.5f; /// % bool stopCycle = false; - int rangeIx = 0; /// Default range, used for non-Elde flowmeters - if (outPath.FlowMeter is Uni.FlowMeter.FlowMeter) + int rangeIx = (outPath.FlowMeter is IFlowMeterSingle) + ? (outPath.FlowMeter as IFlowMeterSingle).GetRange(test.TempLimLo, test.TempLimHi) + : 0; /// Default range, used for non-Elde and parallel flowmeters + if (rangeIx == -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.ConfigurationError }; - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } - IList e; /// Events from currently running operations Event retVal = Event.Done; TBF.Rig.ControlBoard.Uni.UniCB cBrd = StateMachine.ControlBoard as TBF.Rig.ControlBoard.Uni.UniCB; @@ -154,7 +141,6 @@ namespace TBF.Rig.TestMethods.Adjustment if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] int flowSetTime = 0; /// Start the test, initialize test results @@ -370,7 +356,7 @@ namespace TBF.Rig.TestMethods.Adjustment { /// Measurement loop preparation int totalPulses = Convert.ToInt32(Math.Round(test.Volume / outPath.FlowMeter.LtrPerPulse)); - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); /// Measurement loop State.Create(string.Format("{0}({1}) : FlyingStartStopTestOp is running", test.Method, test.Name)) @@ -388,7 +374,7 @@ namespace TBF.Rig.TestMethods.Adjustment /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } @@ -414,37 +400,42 @@ namespace TBF.Rig.TestMethods.Adjustment if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + + /// Raw data UpdateTempPressDensAmb(tstRslt); - - /// Main results - tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) - tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; - tstRslt.MassEndRaw = 0; - tstRslt.MassEnd = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.MassStartRaw = 0; + tstRslt.MassStart = 0; + tstRslt.MassEndRaw = 0; + tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - 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.ConstMasterCorr; /// Corrected master pulses per liter - tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] - 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; + /// Corrected value + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); + + /// Main results + tstRslt.ConstMaster = tstRslt.ConstMasterCorr; + tstRslt.VolumeCTV = tstRslt.ConstMasterCorr * tstRslt.PulsesMaster; /// [l] + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// [m3/h] + tstRslt.ErrorMaster = 0.0f; /// Not available without mass measurement + + 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 = 0; tstRslt.DiverterEnd = 0; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TBF/Rig/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 39362bd2b..c8d364085 100644 --- a/TBF/Rig/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TBF/Rig/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -76,25 +76,11 @@ namespace TBF.Rig.TestMethods.CombinedWithDetection return Simulate(test, repetitionNr, isLastRepetition, testParams); } - 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.ConfigurationError }; - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } IScale scale = outPath.Scale as IScale; @@ -155,13 +141,7 @@ namespace TBF.Rig.TestMethods.CombinedWithDetection cBrd.StopAll(false); - 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); ///============================================================================================ @@ -548,7 +528,7 @@ namespace TBF.Rig.TestMethods.CombinedWithDetection /// queryEnd1 = cBrd.QueryMeasurementEndOp(); - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); int estimtdEndTime = StateMachine.Time + (int)test.TestTime; /// Read the diverter switch time @@ -580,7 +560,7 @@ namespace TBF.Rig.TestMethods.CombinedWithDetection Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); /// TODO: Reimplement //for (int i = 0; i < TBF.Data.CompoundWMsCount; i++) @@ -675,45 +655,51 @@ namespace TBF.Rig.TestMethods.CombinedWithDetection if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results - tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + /// Raw data + UpdateTempPressDensAmb(tstRslt); + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.MassStartRaw = StartMass.Val; + tstRslt.MassEndRaw = EndMass.Val; tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * 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 = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// 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.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.RefPulses / 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 = outPath.Diverter.TestTimeCorrection(tstRslt.FlowVolume); + tstRslt.TestTimeCorrection = 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.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// [m3/h] 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.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 = switchTimeStart; tstRslt.DiverterEnd = switchTimeEnd; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, switchTimeStart, switchTimeEnd, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/DiverterTest/DiverterTestSeq.cs b/TBF/Rig/TestMethods/DiverterTest/DiverterTestSeq.cs index b1b5519f0..f59d47bd1 100644 --- a/TBF/Rig/TestMethods/DiverterTest/DiverterTestSeq.cs +++ b/TBF/Rig/TestMethods/DiverterTest/DiverterTestSeq.cs @@ -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.ConfigurationError }; /// or Event.UiCmdStop ??? - } - } - + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList 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; diff --git a/TBF/Rig/TestMethods/Dummy/DummySeq.cs b/TBF/Rig/TestMethods/Dummy/DummySeq.cs index 7e5033f1d..9941d4d32 100644 --- a/TBF/Rig/TestMethods/Dummy/DummySeq.cs +++ b/TBF/Rig/TestMethods/Dummy/DummySeq.cs @@ -44,7 +44,7 @@ namespace TBF.Rig.TestMethods.Dummy /// Start the test, initialize test results Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(null, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); /// Read pressure and temperature once State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name)) diff --git a/TBF/Rig/TestMethods/Endurance/EnduranceSeq.cs b/TBF/Rig/TestMethods/Endurance/EnduranceSeq.cs index 77121d55f..a4e63f930 100644 --- a/TBF/Rig/TestMethods/Endurance/EnduranceSeq.cs +++ b/TBF/Rig/TestMethods/Endurance/EnduranceSeq.cs @@ -68,28 +68,13 @@ namespace TBF.Rig.TestMethods.Endurance ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; ControlBoard.Uni.UniCB eldeCB = cBrd as ControlBoard.Uni.UniCB; - 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.ConfigurationError }; - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } - IList e; /// Events from currently running operations Event retVal = Event.Done; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -141,8 +126,7 @@ namespace TBF.Rig.TestMethods.Endurance enduranceDataLoggingOp = null; } - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); ///============================================================================================ @@ -313,7 +297,7 @@ namespace TBF.Rig.TestMethods.Endurance queryEnd1 = cBrd.QueryMeasurementEndOp(); int estimtdEndTime = StateMachine.Time + (int)test.TestTime; - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); /// Measurement loop - begin State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name)) @@ -345,7 +329,7 @@ namespace TBF.Rig.TestMethods.Endurance RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } @@ -378,37 +362,42 @@ namespace TBF.Rig.TestMethods.Endurance if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + + /// Raw data UpdateTempPressDensAmb(tstRslt); + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.MassStartRaw = 0; + tstRslt.MassStart = 0; + tstRslt.MassEndRaw = 0; + tstRslt.MassEnd = 0; + tstRslt.MassOfEvapWater = 0; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] + + /// Corrected value + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); /// Main results - tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) - tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; - tstRslt.MassEndRaw = 0; - tstRslt.MassEnd = 0; - tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - 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.ConstMasterCorr; /// Corrected master pulses per liter - tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement + tstRslt.ConstMaster = tstRslt.ConstMasterCorr; + tstRslt.VolumeCTV = tstRslt.ConstMasterCorr * tstRslt.PulsesMaster; /// [l] + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// [m3/h] + tstRslt.ErrorMaster = 0.0f; /// Not available without mass measurement - 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.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 = 0; tstRslt.DiverterEnd = 0; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; @@ -524,7 +513,7 @@ namespace TBF.Rig.TestMethods.Endurance cBrd.StopAll(false); int estimtdEndTime = StateMachine.Time + (int)test.TestTime; - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); /// @@ -568,7 +557,7 @@ namespace TBF.Rig.TestMethods.Endurance RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); } while (!e.Contains(Event.CommandCompleted)); @@ -607,7 +596,7 @@ namespace TBF.Rig.TestMethods.Endurance RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } @@ -635,7 +624,7 @@ namespace TBF.Rig.TestMethods.Endurance RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } diff --git a/TBF/Rig/TestMethods/FixedStart/FixedStartSeq.cs b/TBF/Rig/TestMethods/FixedStart/FixedStartSeq.cs index 6d4c7f772..22fe7ecef 100644 --- a/TBF/Rig/TestMethods/FixedStart/FixedStartSeq.cs +++ b/TBF/Rig/TestMethods/FixedStart/FixedStartSeq.cs @@ -64,27 +64,12 @@ namespace TBF.Rig.TestMethods.FixedStart HeatMeters.TestParams heatMetersTestParams, DebugMode debugLevel) { - 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.ConfigurationError }; - } - } - + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList e; /// Events from currently running operations TBF.Rig.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; @@ -125,13 +110,7 @@ namespace TBF.Rig.TestMethods.FixedStart 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); ///============================================================================================ @@ -538,7 +517,7 @@ namespace TBF.Rig.TestMethods.FixedStart /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - 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 estimtdEndTime = StateMachine.Time + (int)test.TestTime; /// Measurement loop - begin @@ -572,7 +551,7 @@ namespace TBF.Rig.TestMethods.FixedStart RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); if (heatMetersTestParams != null) { @@ -585,7 +564,7 @@ namespace TBF.Rig.TestMethods.FixedStart //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); @@ -653,8 +632,8 @@ namespace TBF.Rig.TestMethods.FixedStart cBrd.StopAll(false); - double flowVolume = 3.6 * LtrPerRefPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime; - double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowVolume, rangeIx); + double flowVolume = 3.6 * outPath.FlowMeter.LtrPerPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime; + double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowVolume, Convert.ToSingle(TempDownStat.Average)); double volumeCTV = constMasterCorr * Convert.ToDouble(endPulses - startPulses); double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l] @@ -814,9 +793,8 @@ namespace TBF.Rig.TestMethods.FixedStart 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 = flowVolume; /// [m3/h] + 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 = constMasterCorr; /// Corrected master pulses per liter tstRslt.ConstMaster = constMasterCorr; /// Corrected master pulses per liter diff --git a/TBF/Rig/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TBF/Rig/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index 8c4603477..3fc1dc76f 100644 --- a/TBF/Rig/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TBF/Rig/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -71,27 +71,12 @@ namespace TBF.Rig.TestMethods.FixedStartAdvanced return new List { Event.ConfigurationError }; } - 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.ConfigurationError }; - } - } - + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList e; /// Events from currently running operations TBF.Rig.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; @@ -134,13 +119,7 @@ namespace TBF.Rig.TestMethods.FixedStartAdvanced 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); ///============================================================================================ @@ -394,7 +373,7 @@ namespace TBF.Rig.TestMethods.FixedStartAdvanced /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - 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 estimtdEndTime = StateMachine.Time + (int)test.TestTime; /// Measurement loop - begin @@ -427,7 +406,7 @@ namespace TBF.Rig.TestMethods.FixedStartAdvanced RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } @@ -544,29 +523,33 @@ namespace TBF.Rig.TestMethods.FixedStartAdvanced if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// Raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = massStart; /// [kg] calculated before displaying 'End state' dialog tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + + /// Corrected values + tstRslt.MassStart = massStart; /// [kg] calculated before displaying 'End state' dialog + tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog tstRslt.MassOfEvapWater = massOfEvaporatedWater; - tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; - tstRslt.VolumeCTV = volumeCTV; /// [kg] calculated before displaying 'End state' dialog - 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 + + /// Main results + tstRslt.VolumeCTV = volumeCTV; /// [kg] calculated before displaying 'End state' dialog + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.Flow, tstRslt.TempDownMean); + /// Corrected master pulses per liter + tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster); + /// Calculated master pulses per liter tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); tstRslt.FlowMean = (float)RefFlowStat.Average; @@ -577,6 +560,7 @@ namespace TBF.Rig.TestMethods.FixedStartAdvanced tstRslt.DiverterStart = switchTimeStart; tstRslt.DiverterEnd = switchTimeEnd; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, true, switchTimeStart, switchTimeEnd, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs b/TBF/Rig/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs index 6d783a7ed..6fa083d13 100644 --- a/TBF/Rig/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs +++ b/TBF/Rig/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs @@ -75,26 +75,12 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval TestPart = test.Part, }; - 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.ConfigurationError }; - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } GenericDevices.IHasWMStatesForm dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm; if (!(dataEntryCmpnt is GenericDevices.IDataEntryForCamera)) @@ -143,13 +129,7 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval 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); ///============================================================================================ @@ -576,7 +556,7 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - 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 estimtdEndTime = StateMachine.Time + (int)test.TestTime; /// Measurement loop - begin @@ -610,7 +590,7 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); if (heatMetersTestParams != null) { @@ -623,7 +603,7 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval //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); @@ -693,8 +673,8 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval cBrd.StopAll(false); - double flowVolume = 3.6 * LtrPerRefPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime; - double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowVolume, rangeIx); + double flowVolume = 3.6 * outPath.FlowMeter.LtrPerPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime; + double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowVolume, Convert.ToSingle(TempDownStat.Average)); double volumeCTV = constMasterCorr * Convert.ToDouble(endPulses - startPulses); if (debugLevel == Common.DebugMode.Simulate) volumeCTV = test.Volume; double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l] @@ -811,9 +791,8 @@ namespace TBF.Rig.TestMethods.FixedStartDeferredEval 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 = flowVolume; /// [m3/h] + tstRslt.VolumeMaster = outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient tstRslt.ConstMasterCorr = constMasterCorr; /// Corrected master pulses per liter diff --git a/TBF/Rig/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs b/TBF/Rig/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs index 8216ae084..c77f5301c 100644 --- a/TBF/Rig/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs +++ b/TBF/Rig/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs @@ -84,25 +84,12 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced 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.ConfigurationError }; - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } else if (outPath.FlowMeter is TBF.Rig.Dummy.FlowMeter.FlowMeter) { var flowm = outPath.FlowMeter as TBF.Rig.Dummy.FlowMeter.FlowMeter; @@ -150,13 +137,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced 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); ///============================================================================================ @@ -488,7 +469,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - 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 estimtdEndTime = StateMachine.Time + (int)test.TestTime; /// Measurement loop - begin @@ -522,7 +503,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); if (heatMetersTestParams != null) { @@ -535,7 +516,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced //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); @@ -790,52 +771,55 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollAdvanced if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// Raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = 0; TimeSpan duration = TestEndTime - TestStartTime; tstRslt.TestTime = duration.TotalSeconds; /// [s] measurement time, at least 1 to prevent division by zero - tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = massStart; tstRslt.MassEndRaw = EndMass.Val; + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + + /// Corrected values + tstRslt.MassStart = massStart; tstRslt.MassEnd = massEnd; tstRslt.MassOfEvapWater = massOfEvaporatedWater; - tstRslt.FlowMass = 3600.0 * (massEnd - massStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h] - double flow = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] + /// Main results + tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] if (cBrd is ControlBoard.Papouch.PapouchCB) { /// Test bench with Papouch control board without reference flow meter - tstRslt.VolumeMaster = volumeCTV; /// [l] volume from the master flow meter - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.ConstMasterRaw = 1; /// Uncorrected master flowmeter coefficient - tstRslt.ConstMasterCorr = 1; /// Corrected master pulses per liter + tstRslt.VolumeMaster = tstRslt.VolumeCTV; + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// [m3/h] + tstRslt.ConstMasterRaw = 1; /// Uncorrected master flowmeter coefficient + tstRslt.ConstMasterCorr = 1; /// Corrected master pulses per liter tstRslt.ConstMaster = 1; + tstRslt.ErrorMaster = 0; } else { /// Test bench with ELDE control board and reference flow meter - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - 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); + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// [m3/h] + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.Flow, tstRslt.TempDownMean); + tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr + : (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster); + tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); } - /// 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; + /// 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; diff --git a/TBF/Rig/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs b/TBF/Rig/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs index 3f2c78001..b956eaf03 100644 --- a/TBF/Rig/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs +++ b/TBF/Rig/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs @@ -98,26 +98,12 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollDeferredEval return new List { Event.ConfigurationError }; } - 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.ConfigurationError }; - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } GenericDevices.IHasWMStatesForm dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm; if (!(dataEntryCmpnt is GenericDevices.IDataEntryForCamera)) @@ -168,14 +154,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollDeferredEval 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); ///============================================================================================ @@ -650,7 +629,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollDeferredEval /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - 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 estimtdEndTime = StateMachine.Time + (int)test.TestTime; /// Measurement loop - begin @@ -684,7 +663,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollDeferredEval RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); if (heatMetersTestParams != null) { @@ -697,7 +676,7 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollDeferredEval //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); @@ -895,40 +874,44 @@ namespace TBF.Rig.TestMethods.FixedStartMassCollDeferredEval if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + + /// Raw data UpdateTempPressDensAmb(tstRslt); + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.MassStartRaw = StartMass.Val; + tstRslt.MassEndRaw = EndMass.Val; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] + + /// Corrected values + tstRslt.MassStart = massStart; + tstRslt.MassEnd = massEnd; + tstRslt.MassOfEvapWater = massOfEvaporatedWater; + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); /// Main results - tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero - tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) - tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = massStart; - tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = massEnd; - tstRslt.MassOfEvapWater = massOfEvaporatedWater; - tstRslt.FlowMass = 3600.0 * (massEnd - massStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h] - double flow = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient - tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flow, rangeIx); /// Corrected master pulses per liter - tstRslt.ConstMaster = (tstRslt.VolumeMaster == 0) ? tstRslt.ConstMasterCorr : (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster); - /// Calculated master pulses per liter + tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; - tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); - tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); - tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last); - tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min); - tstRslt.FlowMax = Convert.ToSingle(RefFlowStat.Max); + 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 = switchTimeStart; tstRslt.DiverterEnd = switchTimeEnd; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, true, switchTimeStart, switchTimeEnd, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs b/TBF/Rig/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs index ec929b2d2..1895383ab 100644 --- a/TBF/Rig/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs +++ b/TBF/Rig/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs @@ -87,27 +87,12 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection IVolumeMeter tank = outPath.Scale as IVolumeMeter; bool manualLevelMsrmnt = (singleTestParams != null) ? singleTestParams.ManualLevelMsrmnt : compoundTestParams.ManualLevelMsrmnt; - 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); - new List { Event.ConfigurationError }; - } - } - + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList e; /// Events from currently running operations TBF.Rig.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; @@ -148,13 +133,7 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection 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); DoubleBox volumeBox = new DoubleBox(); @@ -503,7 +482,7 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - 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 estimtdEndTime = StateMachine.Time + (int)test.TestTime; /// Measurement loop - begin @@ -537,7 +516,7 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); if (compoundTestParams != null) { @@ -728,9 +707,9 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// Raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; @@ -738,29 +717,33 @@ namespace TBF.Rig.TestMethods.FixedStartTankCollection tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; - tstRslt.MassEnd = 0; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] + + /// Corrected values + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; /// [kg/h] - double flow = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient - tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flow, rangeIx); /// Corrected master pulses per liter - tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; - /// Calculated master pulses per liter + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); + + /// Main results + tstRslt.VolumeCTV = volumeCTV; + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; + tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; - 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; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, true, switchTimeStart, switchTimeEnd, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs b/TBF/Rig/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs index 592fae169..6e7f4f17c 100644 --- a/TBF/Rig/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs +++ b/TBF/Rig/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs @@ -70,28 +70,13 @@ namespace TBF.Rig.TestMethods.FlowAdjustment 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; - } - } - - if (rangeIx == -1) - { - Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); - return new List { Event.ConfigurationError }; - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } - IList e; /// Events from currently running operations Event retVal = Event.Done; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -126,8 +111,7 @@ namespace TBF.Rig.TestMethods.FlowAdjustment if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); ///============================================================================================ @@ -290,9 +274,9 @@ namespace TBF.Rig.TestMethods.FlowAdjustment if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// Raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; @@ -301,27 +285,34 @@ namespace TBF.Rig.TestMethods.FlowAdjustment tstRslt.FlowSetTime = Convert.ToInt32(Math.Round(tstRslt.TestTime)); /// [s] test time = flow set time tstRslt.PulsesMaster = 0; tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; - tstRslt.MassEnd = 0; - tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; - tstRslt.FlowVolume = 0; - 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.ConstMasterCorr; - tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement + tstRslt.TimeBtwnMassMsrmnts = 0; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; - 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; + /// Corrected values + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; + tstRslt.MassOfEvapWater = 0; + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); + /// Corrected master pulses per liter + /// Main results + tstRslt.ConstMaster = tstRslt.ConstMasterCorr; + tstRslt.VolumeCTV = tstRslt.ConstMasterCorr * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// TODO: ??? + tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement + + /// 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 = 0; tstRslt.DiverterEnd = 0; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs b/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs index 131431318..93979f2d2 100644 --- a/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -72,28 +72,13 @@ namespace TBF.Rig.TestMethods.FlyingStart ControlBoard.Uni.UniCB cBrd = StateMachine.ControlBoard as ControlBoard.Uni.UniCB; - 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.ConfigurationError }; - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } - IList e; /// Events from currently running operations Event retVal = Event.Done; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -127,8 +112,7 @@ namespace TBF.Rig.TestMethods.FlyingStart if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); ///============================================================================================ @@ -382,7 +366,7 @@ namespace TBF.Rig.TestMethods.FlyingStart /// Measurement loop preparation int estimtdEndTime = StateMachine.Time + (int)test.TestTime; int remainingTime; - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); /// Measurement loop State.Create(string.Format("{0}({1}) : FlyingStartStopTestOp is running", test.Method, test.Name)) @@ -407,7 +391,7 @@ namespace TBF.Rig.TestMethods.FlyingStart /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); #region Heat meters @@ -423,7 +407,7 @@ namespace TBF.Rig.TestMethods.FlyingStart //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); @@ -461,40 +445,53 @@ namespace TBF.Rig.TestMethods.FlyingStart if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + + /// Raw data UpdateTempPressDensAmb(tstRslt); + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.MassStartRaw = 0; + tstRslt.MassEndRaw = 0; + tstRslt.TimeBtwnMassMsrmnts = 0; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] - /// Main results - tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) - tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; - tstRslt.MassEndRaw = 0; - tstRslt.MassEnd = 0; + /// Corrected data + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; /// [kg/h] - double flow = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - 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(flow, rangeIx); /// Corrected master pulses per liter - tstRslt.ConstMaster = tstRslt.ConstMasterCorr; - tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ErrorMaster = 0.0; /// Cannot be determined without a mass measurement + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; - tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); - tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); - tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last); - tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min); - tstRslt.FlowMax = Convert.ToSingle(RefFlowStat.Max); + /// Main result calculation + tstRslt.VolumeCTV = tstRslt.ConstMasterCorr * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; + tstRslt.ErrorMaster = 0.0; /// Not available without a mass measurement + tstRslt.ConstMaster = tstRslt.ConstMasterCorr; + + /// More corrected data + 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 = 0; + tstRslt.DivStart10 = 0; + tstRslt.DivStart50 = 0; + tstRslt.DivStart90 = 0; tstRslt.DiverterEnd = 0; + tstRslt.DivEnd90 = 0; + tstRslt.DivEnd50 = 0; + tstRslt.DivEnd10 = 0; + long infoFlags = 0; - tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0, out infoFlags, out stopCycle) : 0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) + ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; if (compoundTestParams != null) diff --git a/TBF/Rig/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs b/TBF/Rig/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs index be35c7783..4c4e9743a 100644 --- a/TBF/Rig/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs @@ -102,27 +102,12 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl new List { Event.ConfigurationError }; } - 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); - new List { Event.ConfigurationError }; - } - } - + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList e; /// Events from currently running operations Event retVal = Event.Done; @@ -165,8 +150,7 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl : heatMetersTestParams.NextTestVolume); /// 'totalPulses' calculation has to be inside test repetition loop for this method !!! - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; - int totalPulses = (int)((repetitionNr == 1 ? test.Volume : nextTestVolume) / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32((repetitionNr == 1 ? test.Volume : nextTestVolume) / outPath.FlowMeter.LtrPerPulse); ///============================================================================================ @@ -531,7 +515,7 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl /// Measurement loop preparation int estimtdEndTime = StateMachine.Time + (int)((repetitionNr == 1) ? test.TestTime : (test.TestTime * nextTestVolume / test.Volume)); int remainingTime; - 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); @@ -564,7 +548,7 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); #region Heat meters @@ -580,7 +564,7 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl //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); @@ -686,39 +670,47 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results - tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) - double flow = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] + /// Raw data + UpdateTempPressDensAmb(tstRslt); + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + double flowMID = 3.6 * tstRslt.ConstMasterRaw * tstRslt.PulsesMaster / tstRslt.TestTime; + + /// Corrected value + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); if (repetitionNr == 1) { - tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); + /// Raw data tstRslt.MassStartRaw = StartMass.Val; + tstRslt.MassEndRaw = EndMass.Val; + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + + /// Corrected values tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections); - tstRslt.MassEndRaw = EndMass.Val; tstRslt.MassEnd = MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections); - tstRslt.FlowMass = 3600 * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.TestTime; /// [kg/h] - tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.DensityLine; /// [l] commercially true volume + tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); + double mass = tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater; + + /// 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 = outPath.Diverter.TestTimeCorrection(flow); + tstRslt.TestTimeCorrection = 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(flow, rangeIx); /// Corrected master pulses per liter - tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; - /// Calculated master pulses per liter + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); + tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; + /// Calculated master pulses per liter tstRslt.DiverterStart = outPath.Diverter.SwitchTimeStart.Val; tstRslt.DivStart10 = 0; @@ -731,6 +723,7 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl log.DebugFormat("Diverter switch time [s]: Start: {0}ms ({1} {2} {3}) End: {4}ms ({5} {6} {7})", (tstRslt.DiverterStart * 1000).ToString("F0"), tstRslt.DivStart10, tstRslt.DivStart50, tstRslt.DivStart90, (tstRslt.DiverterEnd * 1000).ToString("F0"), tstRslt.DivEnd90, tstRslt.DivEnd50, tstRslt.DivEnd10); + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; @@ -739,21 +732,23 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl { Results.Entities.TestRslt tstResRepet1 = BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, test.Repeats, 1), test.Part); + /// Not used + tstRslt.MassStartRaw = 0; + tstRslt.MassEndRaw = 0; tstRslt.TimeBtwnMassMsrmnts = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; - tstRslt.MassEndRaw = 0; tstRslt.MassEnd = 0; - tstRslt.FlowMass = 0; - tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient - tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flow, rangeIx); /// Corrected master pulses per liter - tstRslt.ConstMaster = tstResRepet1.ConstMaster; /// Master constant ( pulses per liter) from the first repetition (=against the scale) + + /// Main results + tstRslt.ConstMaster = tstResRepet1.ConstMaster; /// From the first repetition (=from mass measurement) tstRslt.VolumeMaster = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] volume from the master flow meter tstRslt.VolumeCTV = tstRslt.VolumeMaster; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; tstRslt.ErrorMaster = tstResRepet1.ErrorMaster; /// Cannot be determined without a mass measurement - tstRslt.DiverterStart = 0; + /// Not used + tstRslt.DiverterStart = 0; tstRslt.DivStart10 = 0; tstRslt.DivStart50 = 0; tstRslt.DivStart90 = 0; @@ -767,13 +762,12 @@ namespace TBF.Rig.TestMethods.FlyingStartFirstRepetWithMassColl tstRslt.InfoFlags = infoFlags; } - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; - 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); if (compoundTestParams != null) { diff --git a/TBF/Rig/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs b/TBF/Rig/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs index 743f8659f..9bc3bb346 100644 --- a/TBF/Rig/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs @@ -96,26 +96,12 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative TBF.Rig.ControlBoard.Uni.UniCB cBrd = StateMachine.ControlBoard as TBF.Rig.ControlBoard.Uni.UniCB; - 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.ConfigurationError }; - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } string vlvNames = (singleTestParams != null) ? singleTestParams.ValveName : ((compoundTestParams != null) ? compoundTestParams.ValveName @@ -180,8 +166,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); ///============================================================================================ @@ -628,7 +613,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative /// Measurement loop preparation int estimtdEndTime = StateMachine.Time + (int)test.TestTime; int remainingTime; - 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); @@ -655,7 +640,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); #region Heat meters @@ -670,7 +655,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative //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); @@ -772,43 +757,47 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// Raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = StartMass.Val; tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = EndMass.Val + (refMass - (measuredRefMass.Val - StartMass.Val)); - tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.TestTime; /// [kg/h] - double flow = 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 + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] + + /// Corrected values + tstRslt.MassStart = StartMass.Val; + tstRslt.MassEnd = EndMass.Val + (refMass - (measuredRefMass.Val - StartMass.Val)); + tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); + 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 = outPath.Diverter.TestTimeCorrection(flow); + tstRslt.TestTimeCorrection = 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(flow, rangeIx); /// Corrected master pulses per liter - tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; - /// Calculated master pulses per liter - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; - tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); - tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); - tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last); - tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min); - tstRslt.FlowMax = Convert.ToSingle(RefFlowStat.Max); + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; + tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); + tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; + /// 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; @@ -821,6 +810,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollComparative log.DebugFormat("Diverter switch time [s]: Start: {0}ms ({1} {2} {3}) End: {4}ms ({5} {6} {7})", (tstRslt.DiverterStart * 1000).ToString("F0"), tstRslt.DivStart10, tstRslt.DivStart50, tstRslt.DivStart90, (tstRslt.DiverterEnd * 1000).ToString("F0"), tstRslt.DivEnd90, tstRslt.DivEnd50, tstRslt.DivEnd10); + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs b/TBF/Rig/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs index 81dad9d86..a193eea81 100644 --- a/TBF/Rig/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs @@ -86,26 +86,12 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged ControlBoard.Uni.UniCB cBrd = StateMachine.ControlBoard as ControlBoard.Uni.UniCB; IScale scale = outPath.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); - new List { Event.ConfigurationError }; - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } float volumeToTank = (singleTestParams != null) ? singleTestParams.VolumeToTank : ((compoundTestParams != null) ? compoundTestParams.VolumeToTank : heatMetersTestParams.VolumeToTank); @@ -158,9 +144,8 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged Event retVal = Event.Done; - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; - int targetTotalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); - int targetMassPulses = (int)(volumeToTank / LtrPerRefPulse + 0.5f); + int targetTotalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); + int targetMassPulses = Convert.ToInt32(volumeToTank / outPath.FlowMeter.LtrPerPulse); ///============================================================================================ @@ -530,7 +515,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged /// Measurement loop preparation int estimtdEndTime = StateMachine.Time + (int)test.TestTime; - 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); @@ -650,47 +635,50 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + + /// Raw data UpdateTempPressDensAmb(tstRslt); - - double totalPulses = Convert.ToDouble(cBrd.RefPulses); - double massPulses = Convert.ToDouble(cBrd.MassRefPulses); - - /// Main results + double totalPulses = Convert.ToDouble(cBrd.RefPulses); + double massPulses = Convert.ToDouble(cBrd.MassRefPulses); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time (TODO: or cBrd.ImpulseTime(0) ???) tstRslt.PulsesMaster = massPulses; /// Pulses of the master flow meter (test total) tstRslt.TotalPulsesMstr = totalPulses; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time (TODO: or cBrd.ImpulseTime(0) ???) - tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); 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.FlowMass = 3600 * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) * totalPulses / (tstRslt.TestTime * massPulses); /// [kg/h] - double flow = 3.6 * LtrPerRefPulse * totalPulses / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.DensityLine; /// [l] commercially true volume of collected water + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * massPulses; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.ConstMasterRaw * totalPulses / tstRslt.TestTime; /// [m3/h] + + /// Corrected data + tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections); + tstRslt.MassEnd = MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections); + tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); + double mass = tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater; + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); + + /// Main result calculation + tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * mass / tstRslt.DensityLine; /// [l] commercially true volume of collected water if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon)) { - tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(flow); + tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(flowMID); tstRslt.VolumeCTV *= tstRslt.TestTime + tstRslt.TestTimeCorrection; tstRslt.VolumeCTV /= tstRslt.TestTime; } - tstRslt.VolumeMaster = LtrPerRefPulse * massPulses; /// [l] volume from the master flow meter - tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient - tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flow, rangeIx); /// Master pulses per liter from a correction table and a flow - tstRslt.ConstMaster = (massPulses != 0) ? (tstRslt.VolumeCTV / massPulses) : tstRslt.ConstMasterCorr; - /// Master pulses per liter from the measured mass + tstRslt.Flow = 3.6 * totalPulses * tstRslt.VolumeCTV / (massPulses * tstRslt.TestTime); /// Flow from VolumeCTV, ratio of pulses and time tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowVolume = 3.6 * totalPulses * tstRslt.VolumeCTV / (massPulses * tstRslt.TestTime); - tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); - tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); - tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last); - tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min); - tstRslt.FlowMax = Convert.ToSingle(RefFlowStat.Max); + tstRslt.ConstMaster = (massPulses != 0) ? (tstRslt.VolumeCTV / massPulses) : tstRslt.ConstMasterCorr; + /// Master pulses per liter from the measured mass + /// More corrected data + 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; @@ -703,8 +691,11 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged log.DebugFormat("Diverter switch time [s]: Start: {0}ms ({1} {2} {3}) End: {4}ms ({5} {6} {7})", (tstRslt.DiverterStart * 1000).ToString("F0"), tstRslt.DivStart10, tstRslt.DivStart50, tstRslt.DivStart90, (tstRslt.DiverterEnd * 1000).ToString("F0"), tstRslt.DivEnd90, tstRslt.DivEnd50, tstRslt.DivEnd10); + long infoFlags = 0; - tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd, out infoFlags, out stopCycle) : 0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) + ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd, out infoFlags, out stopCycle) + : 0; tstRslt.InfoFlags = infoFlags; if (compoundTestParams != null) @@ -1024,7 +1015,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); UpdateEnergy(heatMetersTestParams); if (showRemainingTimeMsg) ShowRemainingTime(Math.Max(estimtdEndTime - StateMachine.Time, 0)); @@ -1049,7 +1040,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollProlonged //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); diff --git a/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index b086a293f..93e5fbc58 100644 --- a/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -99,26 +99,12 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection ControlBoard.Uni.UniCB cBrd = StateMachine.ControlBoard as 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.ConfigurationError }; /// or Event.UiCmdStop ??? - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList e; /// Events from currently running operations Event retVal = Event.Done; @@ -156,8 +142,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = cBrd.Devices.FlowMeter.LtrPerPulse; - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); ///============================================================================================ @@ -540,11 +525,11 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_in_progress); //------------------------------------------------ - + /// Measurement loop preparation int estimtdEndTime = StateMachine.Time + (int)test.TestTime; int remainingTime; - 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); @@ -572,7 +557,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); #region Heat meters @@ -588,7 +573,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection //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); @@ -693,43 +678,47 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results - tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + /// Raw data + UpdateTempPressDensAmb(tstRslt); + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.FlowSetTime = flowSetTime; + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.MassStartRaw = StartMass.Val; + tstRslt.MassEndRaw = EndMass.Val; tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// 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.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 + + /// Corrected data + tstRslt.MassStart = MeasurementCorrection.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections); + tstRslt.MassEnd = MeasurementCorrection.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections); tstRslt.MassOfEvapWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); - tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + tstRslt.MassOfEvapWater) / tstRslt.TestTime; /// [kg/h] - double flow = 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); + + /// Main result calculation + tstRslt.VolumeCTV = 1000 * tstRslt.Batch.Buoyancy * mass / tstRslt.DensityLine; if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon)) { - tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(flow); + tstRslt.TestTimeCorrection = 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(flow, rangeIx); /// Master pulses per liter from a correction table and a flow - tstRslt.ConstMaster = (tstRslt.PulsesMaster != 0) ? (tstRslt.VolumeCTV / tstRslt.PulsesMaster) : tstRslt.ConstMasterCorr; - /// Master pulses per liter from the measured mass - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; - tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); - tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); - tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last); - tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min); - tstRslt.FlowMax = Convert.ToSingle(RefFlowStat.Max); + tstRslt.Flow = 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 + /// 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; @@ -742,8 +731,11 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection log.DebugFormat("Diverter switch time [s]: Start: {0}ms ({1} {2} {3}) End: {4}ms ({5} {6} {7})", (tstRslt.DiverterStart * 1000).ToString("F0"), tstRslt.DivStart10, tstRslt.DivStart50, tstRslt.DivStart90, (tstRslt.DiverterEnd * 1000).ToString("F0"), tstRslt.DivEnd90, tstRslt.DivEnd50, tstRslt.DivEnd10); + long infoFlags = 0; - tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd, out infoFlags, out stopCycle) : 0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) + ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd, out infoFlags, out stopCycle) + : 0; tstRslt.InfoFlags = infoFlags; if (compoundTestParams != null) @@ -1146,13 +1138,13 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection /// Simulate flow - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(null, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); IntBox remainingTime = new IntBox((int)test.TestTime); State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name)) - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp((int)test.TestTime, remainingTime)) - .EnterState(); + .AddOperation(checkUiOp) + .AddOperation(new Operations.TimerOp((int)test.TestTime, remainingTime)) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -1174,7 +1166,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection PressUp.Val = 2.7f; PressDown.Val = 2.2f; - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); } while (!e.Contains(Event.TimerExpired)); diff --git a/TBF/Rig/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs b/TBF/Rig/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs index 239115eee..0a2ed2c28 100644 --- a/TBF/Rig/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs @@ -100,26 +100,12 @@ namespace TBF.Rig.TestMethods.FlyingStartTankCollection bool manualLevelMsrmnt = (singleTestParams != null) ? singleTestParams.ManualLevelMsrmnt : compoundTestParams.ManualLevelMsrmnt; - 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.ConfigurationError }; - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } if (test.Volume > outPath.Scale.Capacity * Constants.TankFullFactor) { @@ -162,8 +148,7 @@ namespace TBF.Rig.TestMethods.FlyingStartTankCollection if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); DoubleBox volumeBox = new DoubleBox(); @@ -377,7 +362,7 @@ namespace TBF.Rig.TestMethods.FlyingStartTankCollection /// Measurement loop preparation int estimtdEndTime = StateMachine.Time + (int)test.TestTime; int remainingTime; - 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); @@ -404,7 +389,7 @@ namespace TBF.Rig.TestMethods.FlyingStartTankCollection /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } @@ -489,9 +474,9 @@ namespace TBF.Rig.TestMethods.FlyingStartTankCollection if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; @@ -499,32 +484,36 @@ namespace TBF.Rig.TestMethods.FlyingStartTankCollection tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; - tstRslt.MassEnd = 0; + tstRslt.TimeBtwnMassMsrmnts = 0; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] + + /// Corrected values + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; - double flow = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeCTV = volumeBox.Val; /// [l] + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); + + /// Main results + tstRslt.VolumeCTV = volumeBox.Val; /// [l] if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon)) { - tstRslt.TestTimeCorrection = outPath.Diverter.TestTimeCorrection(flow); + tstRslt.TestTimeCorrection = 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(flow, rangeIx); /// Corrected master pulses per liter - tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; + tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); + tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; /// Calculated master pulses per liter - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowVolume = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; - tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); - tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); - tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last); - tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min); - tstRslt.FlowMax = Convert.ToSingle(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 = outPath.Diverter.SwitchTimeStart.Val; tstRslt.DivStart10 = 0; diff --git a/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs b/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs index 5a556e6b5..e1bc7ae64 100644 --- a/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TBF/Rig/TestMethods/LeakTest/LeakTestSeq.cs @@ -235,8 +235,8 @@ namespace TBF.Rig.TestMethods.LeakTest while (e.Contains(Event.TimerBusy)); - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); - UpdateAllStatistics(StateMachine.Time); + StartNewStatistics(null, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); + UpdateAllStatistics(); if (testParams.MaxMassIncrease > 0) { @@ -259,7 +259,7 @@ namespace TBF.Rig.TestMethods.LeakTest goto stopTest; } - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); } while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next)); } @@ -283,7 +283,7 @@ namespace TBF.Rig.TestMethods.LeakTest if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0); if (remainingTime > 60) @@ -318,7 +318,7 @@ namespace TBF.Rig.TestMethods.LeakTest goto stopTest; } - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); } while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next)); } @@ -392,8 +392,7 @@ namespace TBF.Rig.TestMethods.LeakTest } tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 0; /// [m3/h] + tstRslt.Flow = 0; /// [m3/h] tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3] tstRslt.ConstMasterRaw = 0; /// Convert the flow to [m3/h] diff --git a/TBF/Rig/TestMethods/ManualEntry/ManualEntrySeq.cs b/TBF/Rig/TestMethods/ManualEntry/ManualEntrySeq.cs index 68115b83f..9933b254c 100644 --- a/TBF/Rig/TestMethods/ManualEntry/ManualEntrySeq.cs +++ b/TBF/Rig/TestMethods/ManualEntry/ManualEntrySeq.cs @@ -69,8 +69,7 @@ namespace TBF.Rig.TestMethods.ManualEntry tstRslt.MassEndRaw = 0; tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; - tstRslt.FlowVolume = 0; + tstRslt.Flow = 0; tstRslt.VolumeMaster = 0; tstRslt.ConstMasterRaw = 0; tstRslt.ConstMasterCorr = 0; diff --git a/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs b/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs index c78c1ea6f..63456e48e 100644 --- a/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TBF/Rig/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -166,8 +166,8 @@ namespace TBF.Rig.TestMethods.PMaxTest /// int flowSetTime = (int)Math.Round((DateTime.Now - TestStartTime).TotalSeconds); - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); - UpdateAllStatistics(StateMachine.Time); + StartNewStatistics(null, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); + UpdateAllStatistics(); int startTime = StateMachine.Time; int endTime = startTime + testParams.DurationPMax; @@ -187,7 +187,7 @@ namespace TBF.Rig.TestMethods.PMaxTest if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); int remainingTime = Math.Max(endTime - StateMachine.Time, 0); if (remainingTime > 60) @@ -233,8 +233,7 @@ namespace TBF.Rig.TestMethods.PMaxTest tstRslt.MassEndRaw = 0; tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 0; /// [m3/h] + tstRslt.Flow = 0; /// [m3/h] tstRslt.VolumeMaster = 0; /// [l] volume from the master flow meter tstRslt.VolumeCTV = 0; /// [l] 1000.0f is because density is in [kg/m3] tstRslt.ConstMasterRaw = 0; /// Convert the flow to [m3/h] diff --git a/TBF/Rig/TestMethods/PulsesTest/PulsesTestSeq.cs b/TBF/Rig/TestMethods/PulsesTest/PulsesTestSeq.cs index 5aeff37bc..3e70f28e5 100644 --- a/TBF/Rig/TestMethods/PulsesTest/PulsesTestSeq.cs +++ b/TBF/Rig/TestMethods/PulsesTest/PulsesTestSeq.cs @@ -59,25 +59,11 @@ namespace TBF.Rig.TestMethods.PulsesTest { float simulatedError = 4.5f; /// % - 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.ConfigurationError }; - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } IList e; /// Events from currently running operations @@ -115,8 +101,7 @@ namespace TBF.Rig.TestMethods.PulsesTest if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); /// Start the test, initialize test results Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); @@ -345,7 +330,7 @@ namespace TBF.Rig.TestMethods.PulsesTest /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); /// Measurement loop - begin while (true) @@ -360,7 +345,7 @@ namespace TBF.Rig.TestMethods.PulsesTest RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } @@ -393,21 +378,21 @@ namespace TBF.Rig.TestMethods.PulsesTest tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - 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.ConstMasterCorr; /// Corrected master pulses per liter - tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.Flow = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.Flow, tstRslt.TempDownMean); + /// Corrected master pulses per liter + tstRslt.ConstMaster = tstRslt.ConstMasterCorr; /// Corrected master pulses per liter + tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.ErrorMaster = 0.0f; /// Not available without mass measurement tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); diff --git a/TBF/Rig/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs b/TBF/Rig/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs index 1f474f573..bc0664d5d 100644 --- a/TBF/Rig/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs +++ b/TBF/Rig/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs @@ -59,28 +59,13 @@ namespace TBF.Rig.TestMethods.PulsesTestManual { float simulatedError = 4.5f; /// % - 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.ConfigurationError }; - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } - IList e; /// Events from currently running operations Event retVal = Event.Done; TBF.Rig.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; @@ -116,9 +101,7 @@ namespace TBF.Rig.TestMethods.PulsesTestManual if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); - + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); /// Read pressure and temperature once before calling Bridge.OnTestSelected(...) State.Create(string.Format("{0}({1}) : Measuring process data", test.Method, test.Name)) @@ -347,7 +330,7 @@ namespace TBF.Rig.TestMethods.PulsesTestManual /// Measurement loop - preparation queryEnd1 = cBrd.QueryMeasurementEndOp(); - StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0); + StartNewStatistics(outPath.FlowMeter, BatchRslts.Batch.BatchNr, test, repetitionNr, 0); /// Measurement loop - begin while (true) @@ -362,7 +345,7 @@ namespace TBF.Rig.TestMethods.PulsesTestManual RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.Test)); } @@ -388,37 +371,43 @@ namespace TBF.Rig.TestMethods.PulsesTestManual if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// Raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; - tstRslt.MassEnd = 0; - tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.RefPulses / tstRslt.TestTime; /// [m3/h] - 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.ConstMasterCorr; /// Corrected master pulses per liter - tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + double flowMID = 3.6 * tstRslt.VolumeMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.FlowMean = Convert.ToSingle(RefFlowStat.Average); - tstRslt.FlowStart = Convert.ToSingle(RefFlowStat.First); - tstRslt.FlowEnd = Convert.ToSingle(RefFlowStat.Last); - tstRslt.FlowMin = Convert.ToSingle(RefFlowStat.Min); - tstRslt.FlowMax = Convert.ToSingle(RefFlowStat.Max); + /// Corrected values + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; + tstRslt.MassOfEvapWater = 0; + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowMID, tstRslt.TempDownMean); + + /// Main results + tstRslt.ConstMaster = tstRslt.ConstMasterCorr; /// Corrected master pulses per liter + tstRslt.VolumeCTV = tstRslt.ConstMasterCorr * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.Flow = 3.6 * tstRslt.VolumeCTV / tstRslt.TestTime; /// [m3/h] + tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement + + /// 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 = 0; tstRslt.DiverterEnd = 0; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/RoiDetection/RoiDetectionSeq.cs b/TBF/Rig/TestMethods/RoiDetection/RoiDetectionSeq.cs index 2b2008ba1..c6d0e854c 100644 --- a/TBF/Rig/TestMethods/RoiDetection/RoiDetectionSeq.cs +++ b/TBF/Rig/TestMethods/RoiDetection/RoiDetectionSeq.cs @@ -58,8 +58,7 @@ namespace TBF.Rig.TestMethods.RoiDetection /// LtrPerRefPulse and totalPulses are only to make time estimates - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + int totalPulses = Convert.ToInt32(test.Volume / outPath.FlowMeter.LtrPerPulse); //==================== // Start the test diff --git a/TBF/Rig/TestMethods/SensitivityTest/SensitivityTestSeq.cs b/TBF/Rig/TestMethods/SensitivityTest/SensitivityTestSeq.cs index 03d0e77fd..73eed3e6c 100644 --- a/TBF/Rig/TestMethods/SensitivityTest/SensitivityTestSeq.cs +++ b/TBF/Rig/TestMethods/SensitivityTest/SensitivityTestSeq.cs @@ -38,28 +38,13 @@ namespace TBF.Rig.TestMethods.SensitivityTest return new List { Event.Done }; /// TODO: Test method simulation } - 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.ConfigurationError }; /// or Event.UiCmdStop ??? - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? } - IList e; /// Events from currently running operations Event retVal = Event.Done; TBF.Rig.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; @@ -105,13 +90,7 @@ namespace TBF.Rig.TestMethods.SensitivityTest //-------------------------------- cBrd.StopAll(false); - 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); ///============================================================================================ @@ -454,8 +433,7 @@ namespace TBF.Rig.TestMethods.SensitivityTest tstRslt.MassEndRaw = 0; tstRslt.MassEnd = 0; tstRslt.MassOfEvapWater = 0; - tstRslt.FlowMass = 0; - tstRslt.FlowVolume = 0; + tstRslt.Flow = 0; tstRslt.VolumeCTV = 0; tstRslt.VolumeMaster = 0; tstRslt.ConstMasterRaw = 0; diff --git a/TBF/Rig/TestMethods/StandingStart/StandingStartSeq.cs b/TBF/Rig/TestMethods/StandingStart/StandingStartSeq.cs index 957748d6e..8ae2ba9a1 100644 --- a/TBF/Rig/TestMethods/StandingStart/StandingStartSeq.cs +++ b/TBF/Rig/TestMethods/StandingStart/StandingStartSeq.cs @@ -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.ConfigurationError }; - } - } - + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList 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; diff --git a/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs b/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs index d7012ac34..24ee69c85 100644 --- a/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs +++ b/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs @@ -84,26 +84,12 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; 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; - break; - } - } - - if (rangeIx == -1) - { - Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); - return new List { Event.ConfigurationError }; - } - } + Bridge.OnError(this, Strings.Flow_meter_temperature_range_does_not_fit_this_test_conditions); + return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? + } IList e; /// Events from currently running operations int waterMetersCount = Math.Min(BenchInfo.WaterMetersCount, sensPath.RegisterReaders.Length); @@ -148,13 +134,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection 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); ///============================================================================================ @@ -652,7 +632,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection 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; @@ -679,7 +659,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); - UpdateAllStatistics(StateMachine.Time); + UpdateAllStatistics(); #region Heat meters @@ -695,7 +675,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection //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); @@ -781,7 +761,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection double massStart = MeasurementCorrection.CorrectedValue(StartMass.Val, scale.Corrections); double massEnd = MeasurementCorrection.CorrectedValue(EndMass.Val, scale.Corrections); double densityOut = Formulas.WaterDensityFromTempPress((TempUpStat.Average + TempDownStat.Average) / 2, - (PressUpStat.Average + PressDownStat.Average) / 2); + (PressUpStat.Average + PressDownStat.Average) / 2); double buoyancy = Formulas.Buoyancy(); double massOfEvaporatedWater = (double)(tMass2 - tMass1) * outPath.Scale.EvaporationRate(TempDivStat.Average); double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart + massOfEvaporatedWater) / densityOut; @@ -925,42 +905,44 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection if (tstRslt != null) { Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); - UpdateTempPressDensAmb(tstRslt); - /// Main results + /// Raw data + UpdateTempPressDensAmb(tstRslt); tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; tstRslt.TestTime = Math.Max(1.0, DateTimeBox.DurationSec(timeStampStart, timeStampEnd)); /// Min. 1s to prevent division by zero - tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = massStart; tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = massEnd; + tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; + + /// Corrected values + tstRslt.MassStart = massStart; + tstRslt.MassEnd = massEnd; tstRslt.MassOfEvapWater = massOfEvaporatedWater; - tstRslt.FlowMass = 3600.0 * (massEnd - massStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * volumeCTV / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] + + /// Main results + tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.Flow = 3.6 * volumeCTV / tstRslt.TestTime; /// [m3/h] if (cBrd is ControlBoard.Uni.UniCB) { /// Test bench with Uni control board and q reference flow meter - 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) ? (LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; + tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; + tstRslt.ConstMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.Flow, tstRslt.TempDownMean); + tstRslt.VolumeMaster = tstRslt.ConstMasterRaw * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.ConstMaster = (tstRslt.VolumeMaster != 0) ? (tstRslt.ConstMasterRaw * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : tstRslt.ConstMasterCorr; } else { /// Test bench with Papouch control board without reference flow meter - tstRslt.VolumeMaster = volumeCTV; /// [l] volume from the master flow meter - tstRslt.ConstMasterRaw = 1; /// Uncorrected master flowmeter coefficient - tstRslt.ConstMasterCorr = 1; /// Corrected master pulses per liter + tstRslt.VolumeMaster = volumeCTV; /// [l] volume from the master flow meter + tstRslt.ConstMasterRaw = 1; /// Uncorrected master flowmeter coefficient + tstRslt.ConstMasterCorr = 1; /// Corrected master pulses per liter tstRslt.ConstMaster = 1; } - /// Calculated master pulses per lite tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); tstRslt.FlowMean = (float)RefFlowStat.Average; @@ -971,6 +953,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection tstRslt.DiverterStart = switchTimeStart; tstRslt.DiverterEnd = switchTimeEnd; + long infoFlags = 0; tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, true, switchTimeStart, switchTimeEnd, out infoFlags, out stopCycle) : 0; tstRslt.InfoFlags = infoFlags; diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs index cb066602a..06e485f52 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs @@ -551,8 +551,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication tstRslt.MassEndRaw = oriTestRslt.MassEndRaw; tstRslt.MassEnd = oriTestRslt.MassEnd; tstRslt.MassOfEvapWater = oriTestRslt.MassOfEvapWater; - tstRslt.FlowMass = oriTestRslt.FlowMass; - tstRslt.FlowVolume = oriTestRslt.FlowVolume; + tstRslt.SpareDbl = oriTestRslt.SpareDbl; + tstRslt.Flow = oriTestRslt.Flow; tstRslt.VolumeCTV = oriTestRslt.VolumeCTV; tstRslt.VolumeMaster = oriTestRslt.VolumeMaster; tstRslt.ErrorMaster = oriTestRslt.ErrorMaster; @@ -703,8 +703,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication tstRslt.MassEndRaw = oriTestRslt.MassEndRaw; tstRslt.MassEnd = oriTestRslt.MassEnd; tstRslt.MassOfEvapWater = oriTestRslt.MassOfEvapWater; - tstRslt.FlowMass = oriTestRslt.FlowMass; - tstRslt.FlowVolume = oriTestRslt.FlowVolume; + tstRslt.SpareDbl = oriTestRslt.SpareDbl; + tstRslt.Flow = oriTestRslt.Flow; tstRslt.VolumeCTV = oriTestRslt.VolumeCTV; tstRslt.VolumeMaster = oriTestRslt.VolumeMaster; tstRslt.ErrorMaster = oriTestRslt.ErrorMaster; @@ -855,8 +855,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication tstRslt.MassEndRaw = testRsltQ2ac.MassEndRaw; tstRslt.MassEnd = testRsltQ2ac.MassEnd; tstRslt.MassOfEvapWater = testRsltQ2ac.MassOfEvapWater; - tstRslt.FlowMass = testRsltQ2ac.FlowMass; - tstRslt.FlowVolume = testRsltQ2ac.FlowVolume; + tstRslt.SpareDbl = testRsltQ2ac.SpareDbl; + tstRslt.Flow = testRsltQ2ac.Flow; tstRslt.VolumeCTV = testRsltQ2ac.VolumeCTV; tstRslt.VolumeMaster = testRsltQ2ac.VolumeMaster; tstRslt.ErrorMaster = testRsltQ2ac.ErrorMaster; diff --git a/TBF/Rig/Uni/FlowMeter/FlowMeter.cs b/TBF/Rig/Uni/FlowMeter/FlowMeter.cs index d8f45d849..dfbea8cc7 100644 --- a/TBF/Rig/Uni/FlowMeter/FlowMeter.cs +++ b/TBF/Rig/Uni/FlowMeter/FlowMeter.cs @@ -13,12 +13,13 @@ using TBF.Resources; namespace TBF.Rig.Uni.FlowMeter { - public class FlowMeter : ComponentBase, GenericDevices.IFlowMeter, GenericDevices.IHasCalendarEvents, IDrawingItCmpntWithMeasuredVal + public class FlowMeter : ComponentBase, GenericDevices.IFlowMeterSingle, GenericDevices.IHasCalendarEvents, IDrawingItCmpntWithMeasuredVal { private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter)); public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); } readonly FlowMeterCfg flowMeterCfg; + public int Idx1 { get { return (flowMeterCfg != null) ? flowMeterCfg.Idx1 : 0; } } public double NominalFlow { get { return (flowMeterCfg != null) ? flowMeterCfg.NominalFlow : 0; } } public double NominalFreq { get { return (flowMeterCfg != null) ? flowMeterCfg.NominalFreq : 2000; } } @@ -28,7 +29,7 @@ namespace TBF.Rig.Uni.FlowMeter public double GetTempHi(int ix) { return flowMeterCfg.GetTempHi(ix); } public double GetPressLo(int ix) { return flowMeterCfg.GetPressLo(ix); } public double GetPressHi(int ix) { return flowMeterCfg.GetPressHi(ix); } - + public SchematicDrawing.IDrawingItem DrawingItem { get { return flowMeterCfg as SchematicDrawing.IDrawingItem; } } public string MsrdFormat { get { return flowMeterCfg.MsrdFormat; } } @@ -82,20 +83,46 @@ namespace TBF.Rig.Uni.FlowMeter } - public double LtrPerPulseCorrected(double flow, int rangeIx) + /// + /// Determine flow meter range + /// + /// Lower boundary of temperature + /// Upper boundary of temperature + /// flow meter range (0..5) or -1 if no range fits the specified temperature range + public int GetRange(float tempRngLo, float tempRngHi) + { + for (int rng = 0; rng <= 5; rng++) + { + if (RangeEnabled(rng) && GetTempLo(rng) <= tempRngLo && tempRngHi <= GetTempHi(rng)) + { + return rng; + } + } + return -1; + } + + public double LtrPerPulseCorrected(double flow, float temperature) { /// Apply correction - var rangeCorrections = new List(); - foreach (var corr in Corrections) - { - if (corr.RangeIx == rangeIx) rangeCorrections.Add(corr); - } - double correctedFlow = MeasurementCorrection.CorrectedValue(flow, rangeCorrections); + int rng = GetRange(temperature, temperature); + double correctedFlow = (measurementCorrections == null || rng < 0) ? flow : CorrectedFlow(flow, rng); return (LtrPerPulse * correctedFlow / flow); } + /// + /// Apply flow measurement correction + /// + /// Measured flow in [m3/h] + /// Tange 0..5 + /// Corrected flow in [m3/h] + public double CorrectedFlow(double flow, int rng) + { + return MeasurementCorrection.CorrectedValue(flow, measurementCorrections[rng]); + } + readonly UniCB uniCB; + IList[] measurementCorrections; public FlowMeter() { } @@ -108,6 +135,13 @@ namespace TBF.Rig.Uni.FlowMeter uniCB = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB; if (uniCB == null) throw new Exception(string.Format("Cannot find {0} (a parent of {1})", cfg.ParentName, Name)); + measurementCorrections = new IList[6]; + for (int i = 0; i < measurementCorrections.Length; i++) measurementCorrections[i] = new List(); + foreach (var corr in Corrections) + { + if (corr.RangeIx >= 0 && corr.RangeIx < measurementCorrections.Length) measurementCorrections[corr.RangeIx].Add(corr); + } + log.Warn(this.ToString()); } diff --git a/TBF/Rig/Uni/FlowMetersInParallel/FlowMeter.cs b/TBF/Rig/Uni/FlowMetersInParallel/FlowMeter.cs index 00f8bd8f9..9f2756754 100644 --- a/TBF/Rig/Uni/FlowMetersInParallel/FlowMeter.cs +++ b/TBF/Rig/Uni/FlowMetersInParallel/FlowMeter.cs @@ -19,9 +19,9 @@ namespace TBF.Rig.Uni.FlowMetersInParallel readonly FlowMeterCfg flowMeterCfg; UniCB uniCB; - IFlowMeter flowMeter1; - IFlowMeter flowMeter2; - IFlowMeter flowMeter3; + IFlowMeterSingle flowMeter1; + IFlowMeterSingle flowMeter2; + IFlowMeterSingle flowMeter3; double nominalFlow; double nominalFreq; double ltrPerPulse; @@ -42,67 +42,76 @@ namespace TBF.Rig.Uni.FlowMetersInParallel double[] refFreq; /// 0..sum, 1..I11, 2..I12, 3..I13 int[] refPulses; - public double LtrPerPulseCorrected(double flow, int rangeIx) + public double LtrPerPulseCorrected(double flow, float temperature) { - log.DebugFormat("LtrPerPulseCorrected({0}, {1}) started", flow, rangeIx); + return LtrPerPulse; - refFreq[0] = uniCB.RefFrequency; - refFreq[1] = uniCB.RefFrequency1; - refFreq[2] = uniCB.RefFrequency2; - refFreq[3] = uniCB.RefFrequency3; - log.DebugFormat("refFreq[] = ({0}, {1}, {2}, {3})", refFreq[0], refFreq[1], refFreq[2], refFreq[3]); + //log.DebugFormat("LtrPerPulseCorrected({0}, {1}) started", flow, rangeIx); - refPulses[0] = uniCB.RefPulses; - refPulses[1] = uniCB.RefPulses1; - refPulses[2] = uniCB.RefPulses2; - refPulses[3] = uniCB.RefPulses3; - log.DebugFormat("refPulses[] = ({0}, {1}, {2}, {3})", refPulses[0], refPulses[1], refPulses[2], refPulses[3]); + //refFreq[0] = uniCB.RefFrequency; + //refFreq[1] = uniCB.RefFrequency1; + //refFreq[2] = uniCB.RefFrequency2; + //refFreq[3] = uniCB.RefFrequency3; + //log.DebugFormat("refFreq[] = ({0}, {1}, {2}, {3})", refFreq[0], refFreq[1], refFreq[2], refFreq[3]); - double flow1, flow2, flow3; - double contribution1, contribution2, contribution3; - if (refPulses[0] != 0) - { - /// Division by zero prevented inside this 'if' - double ltrPerPulseCorrected = 0; - if (flowMeter1 != null) - { - double ratio = (double)refPulses[flowMeter1.Idx1] / (double)refPulses[0]; - flow1 = flow * ratio; - contribution1 = flowMeter1.LtrPerPulseCorrected(flow1, rangeIx) * ratio; - ltrPerPulseCorrected += contribution1; - log.DebugFormat("flowmeter1 = {0}, flow1 = {1}, contribution1 = {2}", flowMeter1.Name, flow1, contribution1); - } - if (flowMeter2 != null) - { - double ratio = (double)refPulses[flowMeter2.Idx1] / (double)refPulses[0]; - flow2 = flow * ratio; - contribution2 = flowMeter2.LtrPerPulseCorrected(flow2, rangeIx) * ratio; - ltrPerPulseCorrected += contribution2; - log.DebugFormat("flowmeter2 = {0}, flow2 = {1}, contribution2 = {2}", flowMeter2.Name, flow2, contribution2); - } - if (flowMeter3 != null) - { - double ratio = (double)refPulses[flowMeter3.Idx1] / (double)refPulses[0]; - flow3 = flow * ratio; - contribution3 = flowMeter3.LtrPerPulseCorrected(flow3, rangeIx) * ratio; - ltrPerPulseCorrected += contribution3; - log.DebugFormat("flowmeter3 = {0}, flow3 = {1}, contribution3 = {2}", flowMeter3.Name, flow3, contribution3); - } + //refPulses[0] = uniCB.RefPulses; + //refPulses[1] = uniCB.RefPulses1; + //refPulses[2] = uniCB.RefPulses2; + //refPulses[3] = uniCB.RefPulses3; + //log.DebugFormat("refPulses[] = ({0}, {1}, {2}, {3})", refPulses[0], refPulses[1], refPulses[2], refPulses[3]); - log.DebugFormat("LtrPerPulseCorrected() returns {0}", ltrPerPulseCorrected); - return ltrPerPulseCorrected; - } - else - { - log.DebugFormat("LtrPerPulseCorrected() returns 1"); - return 1; - } + //double flow1, flow2, flow3; + //double contribution1, contribution2, contribution3; + //if (refPulses[0] != 0) + //{ + // /// Division by zero prevented inside this 'if' + // double ltrPerPulseCorrected = 0; + // if (flowMeter1 != null) + // { + // double ratio = (double)refPulses[flowMeter1.Idx1] / (double)refPulses[0]; + // flow1 = flow * ratio; + // contribution1 = flowMeter1.LtrPerPulseCorrected(flow1, rangeIx) * ratio; + // ltrPerPulseCorrected += contribution1; + // log.DebugFormat("flowmeter1 = {0}, flow1 = {1}, contribution1 = {2}", flowMeter1.Name, flow1, contribution1); + // } + // if (flowMeter2 != null) + // { + // double ratio = (double)refPulses[flowMeter2.Idx1] / (double)refPulses[0]; + // flow2 = flow * ratio; + // contribution2 = flowMeter2.LtrPerPulseCorrected(flow2, rangeIx) * ratio; + // ltrPerPulseCorrected += contribution2; + // log.DebugFormat("flowmeter2 = {0}, flow2 = {1}, contribution2 = {2}", flowMeter2.Name, flow2, contribution2); + // } + // if (flowMeter3 != null) + // { + // double ratio = (double)refPulses[flowMeter3.Idx1] / (double)refPulses[0]; + // flow3 = flow * ratio; + // contribution3 = flowMeter3.LtrPerPulseCorrected(flow3, rangeIx) * ratio; + // ltrPerPulseCorrected += contribution3; + // log.DebugFormat("flowmeter3 = {0}, flow3 = {1}, contribution3 = {2}", flowMeter3.Name, flow3, contribution3); + // } + + // log.DebugFormat("LtrPerPulseCorrected() returns {0}", ltrPerPulseCorrected); + // return ltrPerPulseCorrected; + //} + //else + //{ + // log.DebugFormat("LtrPerPulseCorrected() returns 1"); + // return 1; + //} } public bool MsrmntAvailable { - get { return true; } + get + { + bool result = true; + if (flowMeter1 != null) result = result && flowMeter1.MsrmntAvailable; + if (flowMeter2 != null) result = result && flowMeter2.MsrmntAvailable; + if (flowMeter3 != null) result = result && flowMeter3.MsrmntAvailable; + return result; + } } public double MeasuredVal @@ -130,9 +139,9 @@ namespace TBF.Rig.Uni.FlowMetersInParallel uniCB = TbfComponents.FindComponent(flowMeterCfg.ParentName) as UniCB; if (uniCB == null) throw new Exception("Cannot find " + Name + " parent"); - if (!string.IsNullOrEmpty(flowMeterCfg.Flowmeter1)) flowMeter1 = TbfComponents.FindComponent(flowMeterCfg.Flowmeter1) as IFlowMeter; - if (!string.IsNullOrEmpty(flowMeterCfg.Flowmeter2)) flowMeter2 = TbfComponents.FindComponent(flowMeterCfg.Flowmeter2) as IFlowMeter; - if (!string.IsNullOrEmpty(flowMeterCfg.Flowmeter3)) flowMeter3 = TbfComponents.FindComponent(flowMeterCfg.Flowmeter3) as IFlowMeter; + if (!string.IsNullOrEmpty(flowMeterCfg.Flowmeter1)) flowMeter1 = TbfComponents.FindComponent(flowMeterCfg.Flowmeter1) as IFlowMeterSingle; + if (!string.IsNullOrEmpty(flowMeterCfg.Flowmeter2)) flowMeter2 = TbfComponents.FindComponent(flowMeterCfg.Flowmeter2) as IFlowMeterSingle; + if (!string.IsNullOrEmpty(flowMeterCfg.Flowmeter3)) flowMeter3 = TbfComponents.FindComponent(flowMeterCfg.Flowmeter3) as IFlowMeterSingle; nominalFlow = 0; flowMetersCount = 0; diff --git a/TBF/Rig/Various/ErrorFlags/Errors.cs b/TBF/Rig/Various/ErrorFlags/Errors.cs index 31ffe0fec..a78fc3232 100644 --- a/TBF/Rig/Various/ErrorFlags/Errors.cs +++ b/TBF/Rig/Various/ErrorFlags/Errors.cs @@ -32,7 +32,7 @@ namespace TBF.Rig.Various.ErrorFlags /// Any E# is 'true' on error, 'false' when OK /// Average flow - bool E1 = (testRslt.FlowVolume < testRslt.Qfrom()) || (testRslt.FlowVolume > testRslt.Qto()); + bool E1 = (testRslt.Flow < testRslt.Qfrom()) || (testRslt.Flow > testRslt.Qto()); /// Max. and min. up and down water temperature bool E2 = ProcessData.TempUpStat.Min < testRslt.TempLimLo() @@ -88,8 +88,8 @@ namespace TBF.Rig.Various.ErrorFlags || ProcessData.PressDownStat.Max > errorsCfg.TestParams.Pressure_max; /// Max. and min. flow - double rectifiedFlowMin = (testRslt.FlowMean == 0) ? testRslt.FlowMin : testRslt.FlowMin * testRslt.FlowVolume / testRslt.FlowMean; - double rectifiedFlowMax = (testRslt.FlowMean == 0) ? testRslt.FlowMax : testRslt.FlowMax * testRslt.FlowVolume / testRslt.FlowMean; + double rectifiedFlowMin = (testRslt.FlowMean == 0) ? testRslt.FlowMin : testRslt.FlowMin * testRslt.Flow / testRslt.FlowMean; + double rectifiedFlowMax = (testRslt.FlowMean == 0) ? testRslt.FlowMax : testRslt.FlowMax * testRslt.Flow / testRslt.FlowMean; bool E21 = rectifiedFlowMin < testRslt.Qfrom() || rectifiedFlowMax > testRslt.Qto(); /// Electrical conductivity of water diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index a172914a4..c24878275 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -608,6 +608,7 @@ + diff --git a/TBF/UI/Process/ProcessTabPageCtrl.cs b/TBF/UI/Process/ProcessTabPageCtrl.cs index ed5ee5a98..d275d3c5a 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl.cs @@ -768,7 +768,8 @@ namespace TBF.UI.Process (ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2); double volumeCtv = 1000 * Formulas.Buoyancy() * (ProcessData.Mass - ProcessData.StartMass.Val) / density; //double refVolume = cBrd.RefPulses * cBrd.Devices.FlowMeter.LtrPerPulse; - double refVolume = ProcessData.LtrPerRefPulse * ProcessData.RefPulses; + double refVolume = (ProcessData.Devices != null && ProcessData.Devices.FlowMeter != null) + ? ProcessData.Devices.FlowMeter.LtrPerPulse * ProcessData.RefPulses : 0; double refError = Formulas.ErrorFromVolumes(refVolume, volumeCtv); if (refErrorIx != 0 && testDataListView.Items.Count > refErrorIx) diff --git a/TBF/UI/Process/ProcessTabPageCtrl24.cs b/TBF/UI/Process/ProcessTabPageCtrl24.cs index 2fd7a6565..efcef18a0 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl24.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl24.cs @@ -438,7 +438,8 @@ namespace TBF.UI.Process /// Available only during a test /// refPulsesLabel.Text = ProcessData.RefPulses.ToString(); - double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses; + double refVolume = (ProcessData.Devices != null && ProcessData.Devices.FlowMeter != null) + ? ProcessData.Devices.FlowMeter.LtrPerPulse * (double)ProcessData.RefPulses : 0; refVolumeLabel.Text = refVolume.ToString("F2"); //double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val; @@ -459,7 +460,7 @@ namespace TBF.UI.Process pulses[i].Text = rr.WMPulses.ToString(); refPulses[i].Text = rr.WMRefPulses.ToString(); volume[i].Text = rr.WMVolume.ToString("F1"); - error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1"); + error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.Devices.FlowMeter.LtrPerPulse).ToString("F1"); } } } @@ -478,7 +479,7 @@ namespace TBF.UI.Process pulses[i].Text = rr.WMPulses.ToString(); refPulses[i].Text = rr.WMRefPulses.ToString(); volume[i].Text = rr.WMVolume.ToString("F1"); - error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1"); + error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.Devices.FlowMeter.LtrPerPulse).ToString("F1"); compoundVolume += rr.WMVolume; } } @@ -525,7 +526,7 @@ namespace TBF.UI.Process refPulsesLabel.Text = tRes.PulsesMaster.ToString("F0"); refFreqLabel.Text = "---"; - refFlowLabel.Text = Utils.DoubleToStr(tRes.FlowVolume, 4); + refFlowLabel.Text = Utils.DoubleToStr(tRes.Flow, 4); refVolumeLabel.Text = tRes.VolumeCTV.ToString("F2"); //regValvePosLabel.Text = tstRslt. diff --git a/TBF/UI/Process/ProcessTabPageCtrl48.cs b/TBF/UI/Process/ProcessTabPageCtrl48.cs index 84da6196c..fff8fcd0e 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl48.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl48.cs @@ -467,8 +467,9 @@ namespace TBF.UI.Process /// Available only during a test /// refPulsesLabel.Text = ProcessData.RefPulses.ToString(); - double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses; - refVolumeLabel.Text = refVolume.ToString("F2"); + double refVolume = (ProcessData.Devices != null && ProcessData.Devices.FlowMeter != null) + ? ProcessData.Devices.FlowMeter.LtrPerPulse * (double)ProcessData.RefPulses : 0; + refVolumeLabel.Text = refVolume.ToString("F2"); //double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val; //massDiffLabel.Text = massDiff.ToString("F3"); @@ -488,7 +489,7 @@ namespace TBF.UI.Process pulses[i].Text = rr.WMPulses.ToString(); refPulses[i].Text = rr.WMRefPulses.ToString(); volume[i].Text = rr.WMVolume.ToString("F1"); - error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1"); + error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.Devices.FlowMeter.LtrPerPulse).ToString("F1"); } } } @@ -507,7 +508,7 @@ namespace TBF.UI.Process pulses[i].Text = rr.WMPulses.ToString(); refPulses[i].Text = rr.WMRefPulses.ToString(); volume[i].Text = rr.WMVolume.ToString("F1"); - error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1"); + error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.Devices.FlowMeter.LtrPerPulse).ToString("F1"); compoundVolume += rr.WMVolume; } } @@ -554,7 +555,7 @@ namespace TBF.UI.Process refPulsesLabel.Text = tRes.PulsesMaster.ToString("F0"); refFreqLabel.Text = "---"; - refFlowLabel.Text = Utils.DoubleToStr(tRes.FlowVolume, 4); + refFlowLabel.Text = Utils.DoubleToStr(tRes.Flow, 4); refVolumeLabel.Text = tRes.VolumeCTV.ToString("F2"); //regValvePosLabel.Text = tstRslt. diff --git a/TBF/UI/Process/ProcessTabPageCtrl6.cs b/TBF/UI/Process/ProcessTabPageCtrl6.cs index 55c398a69..a17f6af0c 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl6.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl6.cs @@ -471,8 +471,9 @@ namespace TBF.UI.Process /// Available only during a test /// refPulsesLabel.Text = ProcessData.RefPulses.ToString(); - double refVolume = ProcessData.LtrPerRefPulse * (double)ProcessData.RefPulses; - refVolumeLabel.Text = refVolume.ToString("F2"); + double refVolume = (ProcessData.Devices != null && ProcessData.Devices.FlowMeter != null) + ? ProcessData.Devices.FlowMeter.LtrPerPulse * (double)ProcessData.RefPulses : 0; + refVolumeLabel.Text = refVolume.ToString("F2"); //double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val; //massDiffLabel.Text = massDiff.ToString("F3"); @@ -492,7 +493,7 @@ namespace TBF.UI.Process pulses[i].Text = rr.WMPulses.ToString(); refPulses[i].Text = rr.WMRefPulses.ToString(); volume[i].Text = rr.WMVolume.ToString("F1"); - error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1"); + error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.Devices.FlowMeter.LtrPerPulse).ToString("F1"); } } } @@ -511,7 +512,7 @@ namespace TBF.UI.Process pulses[i].Text = rr.WMPulses.ToString(); refPulses[i].Text = rr.WMRefPulses.ToString(); volume[i].Text = rr.WMVolume.ToString("F1"); - error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.LtrPerRefPulse).ToString("F1"); + error[i].Text = Formulas.ErrorFromVolumes(rr.WMVolume, rr.WMRefPulses * ProcessData.Devices.FlowMeter.LtrPerPulse).ToString("F1"); compoundVolume += rr.WMVolume; } } @@ -558,7 +559,7 @@ namespace TBF.UI.Process refPulsesLabel.Text = tRes.PulsesMaster.ToString("F0"); refFreqLabel.Text = "---"; - refFlowLabel.Text = Utils.DoubleToStr(tRes.FlowVolume, 4); + refFlowLabel.Text = Utils.DoubleToStr(tRes.Flow, 4); refVolumeLabel.Text = tRes.VolumeCTV.ToString("F2"); //regValvePosLabel.Text = tstRslt.