From 9bd5fba6dc82bf4fde3a67f02db040a098c37f03 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 2 Feb 2015 18:09:05 +0100 Subject: [PATCH] (1) CycleNr renamed to BatchNr (no DB change) and added to results/logs (2) Safer result items --- .../Basic/BasicPrintDocument.cs | 2 +- .../ResultsWriters/Basic/Writer.cs | 2 +- .../BenchControl/Sequences/MainSeq.cs | 2 +- .../BenchControl/Sequences/SequenceBase.cs | 1 + .../TestMethods/Adjustment/AdjustmentSeq.cs | 6 +- .../CombinedMeters/CombinedMetersSeq.cs | 15 ++--- .../CombinedWithDetectionSeq.cs | 18 +++--- .../FixedStartMassCollectionSeq.cs | 31 +++++----- .../TestMethods/FlyingStart/FlyingStartSeq.cs | 58 ++++++++++--------- .../FlyingStartCollectionMethodSeq.cs | 31 +++++----- .../ReferenceFlowmeterCalibrationSeq.cs | 30 +++++----- TestBenchFramework/Entities/TestResult.cs | 2 +- TestBenchFramework/Forms/ResultItemSpec.cs | 50 ++++++++++++---- TestBenchFramework/Forms/ResultsConfig.cs | 2 +- TestBenchFramework/LocalSettings.cs | 4 +- TestBenchFramework/Mappings/TestResultMap.cs | 3 +- .../Screens/ResultsTabPageCtrl.cs | 17 +++--- 17 files changed, 158 insertions(+), 116 deletions(-) diff --git a/TestBenchFramework/BenchControl/ResultsPrinters/Basic/BasicPrintDocument.cs b/TestBenchFramework/BenchControl/ResultsPrinters/Basic/BasicPrintDocument.cs index 96d16b6fd..4b24e42df 100644 --- a/TestBenchFramework/BenchControl/ResultsPrinters/Basic/BasicPrintDocument.cs +++ b/TestBenchFramework/BenchControl/ResultsPrinters/Basic/BasicPrintDocument.cs @@ -136,7 +136,7 @@ namespace TBF.BenchControl.ResultsPrinters.Basic string[] rightColumn = new string[] { - unsortedResults[0].CycleNr.ToString(), + unsortedResults[0].BatchNr.ToString(), //dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(), string.Format("{0}.{1}.{2} {3}:{4}", dateTime.Year.ToString("D4"), dateTime.Month.ToString("D2"), diff --git a/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs b/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs index 6abfe1f08..604af48f2 100644 --- a/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs +++ b/TestBenchFramework/BenchControl/ResultsWriters/Basic/Writer.cs @@ -142,7 +142,7 @@ namespace TBF.BenchControl.ResultsWriters.Basic string[] rightColumn = new string[] { - unsortedResults[0].CycleNr.ToString(), + unsortedResults[0].BatchNr.ToString(), //dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(), string.Format("{0}.{1}.{2} {3}:{4}", dateTime.Year.ToString("D4"), dateTime.Month.ToString("D2"), diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 5873f0b14..57e81a403 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -408,7 +408,7 @@ namespace TBF.BenchControl.Sequences //-------------------------------- - Program.LocalSettings.CycleNr++; + Program.LocalSettings.BatchNr++; Program.LocalSettings.Save(); diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index f4c31f8bb..0c5d8c2a7 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -725,6 +725,7 @@ namespace TBF.BenchControl.Sequences System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(tstRslt.TimeStart); + sb.Append(";"); sb.Append(tstRslt.BatchNr); sb.Append(";"); sb.Append(tstRslt.TestName); sb.Append(";"); sb.Append(tstRslt.RepetitionNr); sb.Append(";"); sb.Append("1"); diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index b667f564d..d79e9638e 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -246,9 +246,10 @@ namespace TBF.BenchControl.TestMethods.Adjustment /// /// Populate TestResult data entity with data /// - tstRslt.TimeEnd = DateTime.Now; - tstRslt.CycleNr = Program.LocalSettings.CycleNr; UpdateTestRsltWithAveragedData(tstRslt); + + tstRslt.TimeEnd = DateTime.Now; + tstRslt.BatchNr = Program.LocalSettings.BatchNr; tstRslt.MassStart = 0; tstRslt.MassEnd = 0; tstRslt.MassDiff = 0; @@ -276,6 +277,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment tstRslt.TimeDivEnd3 = 0; tstRslt.TimeDivEnd4 = 0; tstRslt.TimeDivEnd5 = 0; + for (int i = 0; i < Program.WMsCount; i++) { if (sensPath.RegisterReaders[i] != null) diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs index 2f6d016fc..55d35998f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs @@ -350,23 +350,24 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters /// /// Populate TestResult data entity with data /// - tstRslt.CycleNr = Program.LocalSettings.CycleNr; UpdateTestRsltWithAveragedData(tstRslt); + + tstRslt.BatchNr = Program.LocalSettings.BatchNr; tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] tstRslt.Time = cBrd.TTime; /// [s] measurement time tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) - tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; - /// Corrected master pulses per liter - if (tstRslt.VolumeCTV <= float.Epsilon) + tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + + if (tstRslt.VolumeCTV <= float.Epsilon) { tstRslt.ErrorMaster = 0.1f; } diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index c61d1ba09..f631c2de1 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -545,23 +545,24 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection /// /// Populate TestResult data entity with data /// - tstRslt.CycleNr = Program.LocalSettings.CycleNr; UpdateTestRsltWithAveragedData(tstRslt); - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); + + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] tstRslt.Time = cBrd.TTime; /// [s] measurement time tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) - tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; - /// Corrected master pulses per liter - if (tstRslt.VolumeCTV <= float.Epsilon) + tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + + if (tstRslt.VolumeCTV <= float.Epsilon) { tstRslt.ErrorMaster = 0.1f; } @@ -569,6 +570,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection { tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV; } + tstRslt.TimeDivStart0 = 0; tstRslt.TimeDivStart1 = 0; tstRslt.TimeDivStart2 = 0; diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 0c5f71797..32fd8241c 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -464,22 +464,23 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// /// Populate TestResult data entity with data /// - tstRslt.CycleNr = Program.LocalSettings.CycleNr; UpdateTestRsltWithAveragedData(tstRslt); - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); - tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - tstRslt.Time = cBrd.TTime; /// [s] measurement time - tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] - tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] - tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter - tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) - tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; - /// Corrected master pulses per liter + + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); + tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); + tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.Time = cBrd.TTime; /// [s] measurement time + tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] + tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] + tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter + tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) + tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + if (tstRslt.VolumeCTV <= float.Epsilon) { tstRslt.ErrorMaster = 0.1f; diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index 48033fea8..9b4eebdd2 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -211,36 +211,38 @@ namespace TBF.BenchControl.TestMethods.FlyingStart /// /// Populate TestResult data entity with data /// - tstRslt.TimeEnd = DateTime.Now; - tstRslt.CycleNr = Program.LocalSettings.CycleNr; UpdateTestRsltWithAveragedData(tstRslt); - tstRslt.MassStart = 0; - tstRslt.MassEnd = 0; - tstRslt.MassDiff = 0; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - tstRslt.Time = cBrd.TTime; /// [s] measurement time - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] - tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) - tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume / 1000.0f); /// Convert the flow to [m3/h] - tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] + + tstRslt.TimeEnd = DateTime.Now; + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStart = 0; + tstRslt.MassEnd = 0; + tstRslt.MassDiff = 0; + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.Time = cBrd.TTime; /// [s] measurement time + tstRslt.FlowMass = 0; /// [kg/h] + tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] + tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) + tstRslt.VolumeMaster = ltrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.ConstMaster = outPath.FlowMeter.LtrPerPulseCorrected(tstRslt.FlowVolume / 1000.0f); /// Convert the flow to [m3/h] + tstRslt.VolumeCTV = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] 1000.0f is because density is in [kg/m3] /// Corrected master pulses per liter - tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement - tstRslt.TimeDivStart0 = 0; - tstRslt.TimeDivStart1 = 0; - tstRslt.TimeDivStart2 = 0; - tstRslt.TimeDivStart3 = 0; - tstRslt.TimeDivStart4 = 0; - tstRslt.TimeDivStart5 = 0; - tstRslt.TimeDivEnd0 = 0; - tstRslt.TimeDivEnd1 = 0; - tstRslt.TimeDivEnd2 = 0; - tstRslt.TimeDivEnd3 = 0; - tstRslt.TimeDivEnd4 = 0; - tstRslt.TimeDivEnd5 = 0; + tstRslt.ErrorMaster = 0.0f; /// Cannot be determined without the collected water mass measurement + tstRslt.TimeDivStart0 = 0; + tstRslt.TimeDivStart1 = 0; + tstRslt.TimeDivStart2 = 0; + tstRslt.TimeDivStart3 = 0; + tstRslt.TimeDivStart4 = 0; + tstRslt.TimeDivStart5 = 0; + tstRslt.TimeDivEnd0 = 0; + tstRslt.TimeDivEnd1 = 0; + tstRslt.TimeDivEnd2 = 0; + tstRslt.TimeDivEnd3 = 0; + tstRslt.TimeDivEnd4 = 0; + tstRslt.TimeDivEnd5 = 0; + for (int i = 0; i < Program.WMsCount; i++) { if (sensPath.RegisterReaders[i] != null) diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs index a3268e089..d74c0a6bc 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs @@ -349,22 +349,23 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod /// /// Populate TestResult data entity with data /// - tstRslt.CycleNr = Program.LocalSettings.CycleNr; UpdateTestRsltWithAveragedData(tstRslt); - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); - tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - tstRslt.Time = cBrd.TTime; /// [s] measurement time - tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] - tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] - tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter - tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) - tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; - /// Corrected master pulses per liter + + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); + tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); + tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.Time = cBrd.TTime; /// [s] measurement time + tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] + tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] + tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter + tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) + tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + if (tstRslt.VolumeCTV <= float.Epsilon) { tstRslt.ErrorMaster = 0.0f; diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs index e2cbef749..d7163590b 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs @@ -332,21 +332,23 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration /// /// Populate TestResult data entity with data /// - tstRslt.CycleNr = Program.LocalSettings.CycleNr; UpdateTestRsltWithAveragedData(tstRslt); - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); - tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - tstRslt.Time = cBrd.TTime; /// [s] measurement time - tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] - tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] - tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter - tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) - tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); + tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); + tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart; + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] + tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] + tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] + tstRslt.Time = cBrd.TTime; /// [s] measurement time + tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h] + tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h] + tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter + tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total) + tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + if (tstRslt.VolumeCTV <= float.Epsilon) { tstRslt.ErrorMaster = 0.1f; diff --git a/TestBenchFramework/Entities/TestResult.cs b/TestBenchFramework/Entities/TestResult.cs index d22b2a2b4..aceac36a7 100644 --- a/TestBenchFramework/Entities/TestResult.cs +++ b/TestBenchFramework/Entities/TestResult.cs @@ -7,7 +7,7 @@ namespace TBF.Entities { public virtual int Id { get; protected set; } public virtual string Name { get; set; } - public virtual int CycleNr { get; set; } + public virtual int BatchNr { get; set; } public virtual MetersKind MetersKind { get; set; } public virtual IList Meters { get; set; } public virtual IList CombinedMeters { get; set; } diff --git a/TestBenchFramework/Forms/ResultItemSpec.cs b/TestBenchFramework/Forms/ResultItemSpec.cs index 75913e2bb..60c5ce384 100644 --- a/TestBenchFramework/Forms/ResultItemSpec.cs +++ b/TestBenchFramework/Forms/ResultItemSpec.cs @@ -12,15 +12,44 @@ namespace TBF.Forms public readonly string Name; /// Name-s of all items must be unique public readonly string ClmnHeaderText; /// Text printed in the column header - /// Function to pick a MeterTestResult field and convert it into a string - public delegate string PrintDlgt(Entities.MeterTestResult meterTestResult); - public readonly PrintDlgt Print; + /// /// Function to pick a MeterTestResult field and convert it into a string + /// + public delegate string PrintDlgt(Entities.MeterTestResult meterTestResult); + + private readonly PrintDlgt printDlgt; + + public bool CanPrintSingle { get { return (printDlgt != null); } } + + /// Safe wrapper which replaces null-s by empty strings + public string Print(Entities.MeterTestResult meterTestResult) + { + string str = printDlgt(meterTestResult); + return (str == null) ? string.Empty : str; + } + + + /// + /// Function to pick a MeterTestResult field and convert it into a string + /// public delegate string PrintCombinedDlgt(Entities.MeterTestResult largeMeterTestResult, Entities.MeterTestResult smallMeterTestResult, Entities.MeterTestResult combinedMeterTestResult); - public readonly PrintCombinedDlgt PrintCombined; + private readonly PrintCombinedDlgt printCombinedDlgt; + + public bool CanPrintCombined { get { return (printCombinedDlgt != null); } } + + /// Safe wrapper which replaces null-s by empty strings + public string PrintCombined(Entities.MeterTestResult largeMeterTestResult, + Entities.MeterTestResult smallMeterTestResult, + Entities.MeterTestResult combinedMeterTestResult) + { + string str = printCombinedDlgt(largeMeterTestResult, smallMeterTestResult, combinedMeterTestResult); + return (str == null) ? string.Empty : str; + } + + /// /// Public constructor @@ -29,12 +58,11 @@ namespace TBF.Forms { Name = name; ClmnHeaderText = clmnHeaderText; - Print = printDlgt; - PrintCombined = printCombinedDlgt; + this.printDlgt = printDlgt; + this.printCombinedDlgt = printCombinedDlgt; } - /// Static list of all available items public static readonly IList AllItems; @@ -48,8 +76,8 @@ namespace TBF.Forms (x, y, z) => x.TestResult.TestName)); AllItems.Add(new ResultItemSpec("Procedure name", Strings.Procedure, x => x.TestResult.ProcedureName, (x, y, z) => x.TestResult.ProcedureName)); - AllItems.Add(new ResultItemSpec("Tets cycle number", "Cycel nr.", x => x.TestResult.CycleNr.ToString(), - (x, y, z) => x.TestResult.CycleNr.ToString())); + AllItems.Add(new ResultItemSpec("Batch number", "Batch nr.", x => x.TestResult.BatchNr.ToString(), + (x, y, z) => x.TestResult.BatchNr.ToString())); /// Target values AllItems.Add(new ResultItemSpec("Q from", Strings.Q_from_m3h, x => x.TestResult.Qfrom.ToString("F3"), @@ -102,8 +130,8 @@ namespace TBF.Forms (x, y, z) => (z.Passed ? Strings.Passed + "|Green" : Strings.Failed + "|Red"))); /// Single water meters only results - AllItems.Add(new ResultItemSpec("Serial Nr", "s/n", x => x.SerialNr, (x, y, z) => z.SerialNr)); - AllItems.Add(new ResultItemSpec("End state", "End state", x => x.EndState, (x, y, z) => z.EndState)); + AllItems.Add(new ResultItemSpec("Serial Nr", "s/n", x => x.SerialNr, null)); + AllItems.Add(new ResultItemSpec("End state", "End state", x => x.EndState, null)); AllItems.Add(new ResultItemSpec("Pulses", "Pulses", x => x.PulsesMeter.ToString(), null)); AllItems.Add(new ResultItemSpec("Reference pulses", "Ref.pulses", x => x.PulsesMaster.ToString(), null)); diff --git a/TestBenchFramework/Forms/ResultsConfig.cs b/TestBenchFramework/Forms/ResultsConfig.cs index 9d0eb3895..527c276fc 100644 --- a/TestBenchFramework/Forms/ResultsConfig.cs +++ b/TestBenchFramework/Forms/ResultsConfig.cs @@ -131,7 +131,7 @@ namespace TBF.Forms currentlyAvailableItems = new List(); foreach (var item in ResultItemSpec.AllItems) { - if (!GetSelectedItems().Contains(item) && (combined ? (item.PrintCombined != null) : (item.Print != null))) + if (!GetSelectedItems().Contains(item) && (combined ? item.CanPrintCombined : item.CanPrintSingle)) { currentlyAvailableItems.Add(item); availableResultsListBox.Items.Add(item.Name); diff --git a/TestBenchFramework/LocalSettings.cs b/TestBenchFramework/LocalSettings.cs index b686dbb20..3f1480ea7 100644 --- a/TestBenchFramework/LocalSettings.cs +++ b/TestBenchFramework/LocalSettings.cs @@ -57,7 +57,7 @@ namespace TBF [XmlElementAttribute("LastProcedure")] public string LastProcedureName; - public int CycleNr; + public int BatchNr; public int RightPaneHorizSplitterDistance; @@ -165,7 +165,7 @@ namespace TBF testBenches[i] = ls.testBenches[i]; LastBenchName = ls.LastBenchName; LastProcedureName = ls.LastProcedureName; - CycleNr = ls.CycleNr; + BatchNr = ls.BatchNr; MainWndLeft = ls.MainWndLeft; MainWndTop = ls.MainWndTop; diff --git a/TestBenchFramework/Mappings/TestResultMap.cs b/TestBenchFramework/Mappings/TestResultMap.cs index a50ff77ab..e63b80cc6 100644 --- a/TestBenchFramework/Mappings/TestResultMap.cs +++ b/TestBenchFramework/Mappings/TestResultMap.cs @@ -9,7 +9,8 @@ namespace TBF.Mappings { Id(x => x.Id); Map(x => x.Name); - Map(x => x.CycleNr); + Map(x => x.BatchNr) + .Column("CycleNr"); Map(x => x.MetersKind); HasMany(x => x.Meters) .Cascade.All(); diff --git a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs index 4c0d43b57..0dd7b5432 100644 --- a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs +++ b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs @@ -269,13 +269,14 @@ namespace TBF.Screens string str; if (combined) { - str = (item.PrintCombined == null) ? string.Empty : item.PrintCombined(testRslt.Meters[2 * mtr - 2], - testRslt.Meters[2 * mtr - 1], - testRslt.CombinedMeters[mtr - 1]); + str = item.CanPrintCombined ? item.PrintCombined(testRslt.Meters[2 * mtr - 2], + testRslt.Meters[2 * mtr - 1], + testRslt.CombinedMeters[mtr - 1]) + : string.Empty; } else { - str = (item.Print == null) ? string.Empty : item.Print(testRslt.Meters[mtr - 1]); + str = item.CanPrintSingle ? item.Print(testRslt.Meters[mtr - 1]) : string.Empty; } string[] texts = str.Split(new char[] { '|' }); @@ -346,9 +347,9 @@ namespace TBF.Screens { foreach (var tr in trs) { - string str = (item.PrintCombined == null || tr == null) ? string.Empty : item.PrintCombined(tr.Meters[2 * mtr - 2], - tr.Meters[2 * mtr - 1], - tr.CombinedMeters[mtr - 1]); + string str = (!item.CanPrintCombined || tr == null) ? string.Empty : item.PrintCombined(tr.Meters[2 * mtr - 2], + tr.Meters[2 * mtr - 1], + tr.CombinedMeters[mtr - 1]); string[] texts = str.Split(new char[] { '|' }); if (texts.Length == 1) { @@ -371,7 +372,7 @@ namespace TBF.Screens { foreach (var tr in trs) { - string str = (item.Print == null || tr == null) ? string.Empty : item.Print(tr.Meters[mtr - 1]); + string str = (!item.CanPrintSingle || tr == null) ? string.Empty : item.Print(tr.Meters[mtr - 1]); string[] texts = str.Split(new char[] { '|' }); if (texts.Length == 1)