diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index 4f1389830..dc6de14ea 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -946,5 +946,218 @@ namespace TBF.BenchControl.Sequences return sb.ToString(); } + + + /// + /// Create a simulated test result (single meter). + /// + /// Test to be simulated + /// Test result + protected Entities.TestResult MakeSimulated(Entities.Test test, int repetitionNr, float errorPct) + { + Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single); + + tstRslt.TimeStart = DateTime.Now; + tstRslt.TimeEnd = DateTime.Now; + + tstRslt.AmbientTempAve = 20.0f; + tstRslt.AmbientPressAve = 1000.0f; + tstRslt.AmbientHumiAve = 50.0f; + + tstRslt.PressInStart = 1000.0f; + tstRslt.PressOutStart = 1000.0f; + tstRslt.TempInStart = 20.0f; + tstRslt.TempOutStart = 20.0f; + tstRslt.TempDivStart = 20.0f; + + tstRslt.PressInEnd = 1000.0f; + tstRslt.PressOutEnd = 1000.0f; + tstRslt.TempInEnd = 20.0f; + tstRslt.TempOutEnd = 20.0f; + tstRslt.TempDivEnd = 20.0f; + + tstRslt.PressInAvrg = 1000.0f; + tstRslt.PressOutAvrg = 1000.0f; + tstRslt.TempInAvrg = 20.0f; + tstRslt.TempOutAvrg = 20.0f; + tstRslt.TempDivAvrg = 20.0f; + + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStartRaw = 0; + tstRslt.MassStart = 0; + tstRslt.MassEndRaw = test.Volume * Program.LocalSettings.RealDensity / 1000.0f; + tstRslt.MassEnd = tstRslt.MassEndRaw; + tstRslt.MassDiff = tstRslt.MassEnd; + tstRslt.DensityIn = Program.LocalSettings.RealDensity; + tstRslt.DensityOut = Program.LocalSettings.RealDensity; + tstRslt.DensityDiv = Program.LocalSettings.RealDensity; + tstRslt.Time = test.TstTime; + tstRslt.FlowMass = tstRslt.MassDiff / test.TstTime; + tstRslt.FlowVolume = test.Volume / test.TstTime; + tstRslt.VolumeCTV = test.Volume; + tstRslt.VolumeMaster = test.Volume; + tstRslt.PulsesMaster = (ltrPerRefPulse > 1E-6) ? (test.Volume / ltrPerRefPulse) : 1; + tstRslt.ConstMaster = ltrPerRefPulse; + tstRslt.ErrorMaster = 0; + + for (int i = 0; i < Program.WMsCount; i++) + { + /// Reference to iPerl water meter or null: + WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length)) + ? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter) + : null; + + if ((sensPath.RegisterReaders[i] != null) && (WaterMeters.Count > i) && !WaterMeters[i].Disabled) + { + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; + tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr; + tstRslt.Meters[i].VolumeRef = test.Volume; + tstRslt.Meters[i].Time = test.TstTime; + tstRslt.Meters[i].TimeStart = 0; + tstRslt.Meters[i].TimeEnd = test.TstTime; + tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster; + tstRslt.Meters[i].VolumeStart = 0; + tstRslt.Meters[i].VolumeErrorPct = errorPct; + tstRslt.Meters[i].Passed = (test.ErrLimLo <= errorPct) && (errorPct <= test.ErrLimHi); + tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); + tstRslt.Meters[i].PulsesMeter = sensPath.RegisterReaders[i].PulsesPerLtr * tstRslt.Meters[i].VolumeMeter; + tstRslt.Meters[i].Disabled = false; + + if (iPerl == null) + { + tstRslt.Meters[i].VolumeEnd = 0; /// Normal meter + } + else + { + /// iPerl + tstRslt.Meters[i].VolumeEnd = tstRslt.Meters[i].VolumeStart + tstRslt.Meters[i].VolumeMeter; + } + } + } + + return tstRslt; + } + + + /// + /// Create a simulated test result (compound meter). + /// + /// Test to be simulated + /// Test result + protected Entities.TestResult MakeSimulatedCompound(Entities.Test test, CompoundTestType testType, int repetitionNr, float errorPct) + { + Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Combined); + + tstRslt.TimeStart = DateTime.Now; + tstRslt.TimeEnd = DateTime.Now; + + tstRslt.AmbientTempAve = 20.0f; + tstRslt.AmbientPressAve = 1000.0f; + tstRslt.AmbientHumiAve = 50.0f; + + tstRslt.PressInStart = 1000.0f; + tstRslt.PressOutStart = 1000.0f; + tstRslt.TempInStart = 20.0f; + tstRslt.TempOutStart = 20.0f; + tstRslt.TempDivStart = 20.0f; + + tstRslt.PressInEnd = 1000.0f; + tstRslt.PressOutEnd = 1000.0f; + tstRslt.TempInEnd = 20.0f; + tstRslt.TempOutEnd = 20.0f; + tstRslt.TempDivEnd = 20.0f; + + tstRslt.PressInAvrg = 1000.0f; + tstRslt.PressOutAvrg = 1000.0f; + tstRslt.TempInAvrg = 20.0f; + tstRslt.TempOutAvrg = 20.0f; + tstRslt.TempDivAvrg = 20.0f; + + tstRslt.BatchNr = Program.LocalSettings.BatchNr; + tstRslt.MassStartRaw = 0; + tstRslt.MassStart = 0; + tstRslt.MassEndRaw = test.Volume * Program.LocalSettings.RealDensity / 1000.0f; + tstRslt.MassEnd = tstRslt.MassEndRaw; + tstRslt.MassDiff = tstRslt.MassEnd; + tstRslt.DensityIn = Program.LocalSettings.RealDensity; + tstRslt.DensityOut = Program.LocalSettings.RealDensity; + tstRslt.DensityDiv = Program.LocalSettings.RealDensity; + tstRslt.Time = test.TstTime; + tstRslt.FlowMass = tstRslt.MassDiff / test.TstTime; + tstRslt.FlowVolume = test.Volume / test.TstTime; + tstRslt.VolumeCTV = test.Volume; + tstRslt.VolumeMaster = test.Volume; + tstRslt.PulsesMaster = (ltrPerRefPulse > 1E-6) ? (test.Volume / ltrPerRefPulse) : 1; + tstRslt.ConstMaster = ltrPerRefPulse; + tstRslt.ErrorMaster = 0; + + for (int iCmbnd = 0; iCmbnd < Program.CompoundWMsCount; iCmbnd++) + { + tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error + + for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++) + { + if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) + { + tstRslt.Meters[i].PulsesPerLiter = 1.0f; + tstRslt.Meters[i].VolumeMeter = 0; + } + else + { + tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr; + tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr; + } + + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; + tstRslt.Meters[i].VolumeStart = 0; + tstRslt.Meters[i].VolumeEnd = 0; /// Normal meter + + tstRslt.Meters[i].VolumeRef = test.Volume; + if (testType == CompoundTestType.Regular && IsMainMtr(i)) + { + tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); + } + else if (testType == CompoundTestType.DetectionRise && !IsMainMtr(i)) + { + tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); + } + else if (testType == CompoundTestType.DetectionFall && IsMainMtr(i)) + { + tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); + } + else + { + tstRslt.Meters[i].VolumeMeter = 0; + } + + tstRslt.Meters[i].Time = test.TstTime; + tstRslt.Meters[i].TimeStart = 0; + tstRslt.Meters[i].TimeEnd = test.TstTime; + tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster; + tstRslt.Meters[i].VolumeErrorPct = errorPct; + tstRslt.Meters[i].Passed = (test.ErrLimLo <= errorPct) && (errorPct <= test.ErrLimHi); + tstRslt.Meters[i].PulsesMeter = sensPath.RegisterReaders[i].PulsesPerLtr * tstRslt.Meters[i].VolumeMeter; + } + + tstRslt.CombinedMeters[iCmbnd].VolumeMeter = tstRslt.Meters[2 * iCmbnd].VolumeMeter + tstRslt.Meters[2 * iCmbnd + 1].VolumeMeter; + + tstRslt.CombinedMeters[iCmbnd].PulsesMaster = tstRslt.PulsesMaster; + tstRslt.CombinedMeters[iCmbnd].Time = test.TstTime; + tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.CombinedMeters[iCmbnd].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef); + tstRslt.CombinedMeters[iCmbnd].Passed = (tstRslt.ErrLimLo <= tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct) && (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct <= tstRslt.ErrLimHi); + } + + return tstRslt; + } + + /// + /// Returns information whether a meter is a main meter or an aux. meter (compound meters). + /// + /// Index to TestResult.Meters[] array + /// true = main meter, false = aux. meter + bool IsMainMtr(int i) + { + return (i % 2) == 0; + } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index c325c993b..65e9b78dd 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -18,19 +18,19 @@ namespace TBF.BenchControl.TestMethods.Adjustment System.Windows.Forms.Form modelessDlg; /// - delegate void ErrorsFormDlgt(AdjustmentSeq myRef); + delegate void ErrorsFormDlgt(AdjustmentSeq myRef, IList waterMeters); /// - void OpenWMErrorsForm(AdjustmentSeq myRef) + void OpenWMErrorsForm(AdjustmentSeq myRef, IList waterMeters) { #pragma warning disable 162 /// Disables 'Unreachable code detected' warning if (Program.WMsCount > 6) { - myRef.modelessDlg = new WMErrorsForm24(Program.WMsCount); + myRef.modelessDlg = new WMErrorsForm24(waterMeters); } else { - myRef.modelessDlg = new WMErrorsForm(Program.WMsCount); + myRef.modelessDlg = new WMErrorsForm(waterMeters); } #pragma warning restore 162 /// Disables 'Unreachable code detected' warning @@ -48,8 +48,9 @@ namespace TBF.BenchControl.TestMethods.Adjustment /// Event.OpArgumentError . Target flow is out of range /// Event.Error . . . . . . Unspecified error /// - public IList Execute(Entities.Test test) + public IList Execute(Entities.Test test, Entities.DebugMode mode) { + float simulatedError = 4.5f; /// % Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; @@ -80,9 +81,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment /// Start the test, initialize test results Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses)); - Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single); - tstRslt.DoNotEvaluate = true; - tstRslt.DoNotPublish = true; + Entities.TestResult tstRslt; int flowSetTime0 = StateMachine.Time; float estFlowSetTime = 10.0f; @@ -102,7 +101,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment int flowSetTime = StateMachine.Time - flowSetTime0; float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); - Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress)); + //Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress)); if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } } @@ -119,7 +118,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment int flowSetTime = StateMachine.Time - flowSetTime0; float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); - Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress)); + //Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress)); if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } } @@ -136,7 +135,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment int flowSetTime = StateMachine.Time - flowSetTime0; float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime); - Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress)); + //Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, false, cBrd, flowSetTime, progress)); if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } @@ -150,12 +149,10 @@ namespace TBF.BenchControl.TestMethods.Adjustment } while (!e.Contains(Event.FlowReached)); - /// - /// Show the modeless dialog with error indication - /// - Program.MainWnd.Invoke(new ErrorsFormDlgt(OpenWMErrorsForm), this); - flow_set: + /// Show the modeless dialog with error indication + Program.MainWnd.Invoke(new ErrorsFormDlgt(OpenWMErrorsForm), new object[] { this, WaterMeters }); + loop: int time = StateMachine.Time; float currentFlow = refFlow.Val; @@ -168,161 +165,185 @@ namespace TBF.BenchControl.TestMethods.Adjustment if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp()); } - tstRslt.TimeStart = DateTime.Now; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_in_progress); - //------------------------------------------------ - State.Create("Adjustment : Starting the test") - .AddOperation(checkUiOp) - .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, - test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed)) - .EnterState(); - do + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_in_progress); + //------------------------------------------------ + if (mode == Entities.DebugMode.Simulate) { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.MeasurementStarted)); + tstRslt = MakeSimulated(test, 1, simulatedError); + simulatedError *= 0.6f; - /// Measurement loop - preparation - readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses); - queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); - - bool firstTime = true; /// To reset sums for averaging - ResetAveragedData(); - - /// Measurement loop - begin - while (true) - { - //-------------------------------- - switch (ReadRegistersTempPressAmbient(measureOperations, true)) + State.Create("Adjustment : Simulating the test") + .AddOperation(checkUiOp) + .AddOperation(new Operations.TimerOp(5)) + .EnterState(); + do { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - case Event.MeasurementCompleted: goto one_test_completed; + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } } + while (!e.Contains(Event.TimerExpired)); + } + else + { + tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single); + tstRslt.DoNotEvaluate = true; + tstRslt.DoNotPublish = true; - if (firstTime) - { - firstTime = false; /// Do the following only once - tstRslt.TempInStart = tempIn.Val; - tstRslt.TempOutStart = tempOut.Val; - tstRslt.TempDivStart = tempDiv.Val; - tstRslt.PressInStart = pressIn.Val; - tstRslt.PressOutStart = pressOut.Val; - } + tstRslt.TimeStart = DateTime.Now; - tstRslt.TempInEnd = tempIn.Val; - tstRslt.TempOutEnd = tempOut.Val; - tstRslt.TempDivEnd = tempDiv.Val; - tstRslt.PressInEnd = pressIn.Val; - tstRslt.PressOutEnd = pressOut.Val; - tstRslt.MassEndRaw = mass.Val; + State.Create("Adjustment : Starting the test") + .AddOperation(checkUiOp) + .AddOperations(measureOperations) + .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, + test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.MeasurementStarted)); - AccumulateAveragedData(); + /// Measurement loop - preparation + readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses); + queryEnd1 = cBrd.QueryMeasurementEndOp(); + queryEnd2 = cBrd.QueryMeasurementEndOp(); - refFreq.Val = cBrd.ReferenceFreq; - refFlow.Val = cBrd.ReferenceFlow; - tstRslt.AmbientTempAve = airTemperature.Val; - tstRslt.AmbientPressAve = airPressure.Val; - tstRslt.AmbientHumiAve = airHumidity.Val; + bool firstTime = true; /// To reset sums for averaging + ResetAveragedData(); + + /// Measurement loop - begin + while (true) + { + //-------------------------------- + switch (ReadRegistersTempPressAmbient(measureOperations, true)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + case Event.MeasurementCompleted: goto one_test_completed; + } + + if (firstTime) + { + firstTime = false; /// Do the following only once + tstRslt.TempInStart = tempIn.Val; + tstRslt.TempOutStart = tempOut.Val; + tstRslt.TempDivStart = tempDiv.Val; + tstRslt.PressInStart = pressIn.Val; + tstRslt.PressOutStart = pressOut.Val; + } + + tstRslt.TempInEnd = tempIn.Val; + tstRslt.TempOutEnd = tempOut.Val; + tstRslt.TempDivEnd = tempDiv.Val; + tstRslt.PressInEnd = pressIn.Val; + tstRslt.PressOutEnd = pressOut.Val; + tstRslt.MassEndRaw = mass.Val; + + AccumulateAveragedData(); + + refFreq.Val = cBrd.ReferenceFreq; + refFlow.Val = cBrd.ReferenceFlow; + tstRslt.AmbientTempAve = airTemperature.Val; + tstRslt.AmbientPressAve = airPressure.Val; + tstRslt.AmbientHumiAve = airHumidity.Val; + + string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq, + cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow); + for (int i = 0; i < Program.WMsCount; i++) + { + logstr += string.Format(" M{0}=({1},{2})", i + 1, WMRefPulses[i], WMPulses[i]); + } + log.Debug(logstr); + + + float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime); + Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress)); + } + /// Measurement loop - end + + one_test_completed: + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Adjustment_in_progress); + //------------------------------------------------ + + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; + + /// + /// Populate TestResult data entity with data + /// + UpdateTestRsltWithAveragedData(tstRslt); + + 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; - string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq, - cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow); for (int i = 0; i < Program.WMsCount; i++) { - logstr += string.Format(" M{0}=({1},{2})", i + 1, WMRefPulses[i], WMPulses[i]); - } - log.Debug(logstr); - - - float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime); - Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, true, cBrd, cBrd.TTime, progress)); - } - /// Measurement loop - end - - one_test_completed: - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Adjustment_in_progress); - //------------------------------------------------ - - /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results - if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; - - /// - /// Populate TestResult data entity with data - /// - UpdateTestRsltWithAveragedData(tstRslt); - - 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; - - for (int i = 0; i < Program.WMsCount; i++) - { - if ((sensPath.RegisterReaders[i] != null) && (WaterMeters.Count > i) && !WaterMeters[i].Disabled) - { - tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; - tstRslt.Meters[i].VolumeStart = 0; /// liter - tstRslt.Meters[i].VolumeEnd = 0; /// liter - tstRslt.Meters[i].PulsesPerLiter = (sensPath.RegisterReaders[i] == null ? 1.0f : sensPath.RegisterReaders[i].PulsesPerLtr); - if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0; - else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr; - tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter - tstRslt.Meters[i].PulsesMeter = WMPulses[i]; - tstRslt.Meters[i].PulsesMaster = WMRefPulses[i]; - tstRslt.Meters[i].Time = cBrd.TTime; - if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0) + if ((sensPath.RegisterReaders[i] != null) && (WaterMeters.Count > i) && !WaterMeters[i].Disabled) { - tstRslt.Meters[i].VolumeErrorPct = - 100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef; - /// % + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; + tstRslt.Meters[i].VolumeStart = 0; /// liter + tstRslt.Meters[i].VolumeEnd = 0; /// liter + tstRslt.Meters[i].PulsesPerLiter = (sensPath.RegisterReaders[i] == null ? 1.0f : sensPath.RegisterReaders[i].PulsesPerLtr); + if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0; + else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr; + tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter + tstRslt.Meters[i].PulsesMeter = WMPulses[i]; + tstRslt.Meters[i].PulsesMaster = WMRefPulses[i]; + tstRslt.Meters[i].Time = cBrd.TTime; + if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0) + { + tstRslt.Meters[i].VolumeErrorPct = + 100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef; + /// % + } + else + { + tstRslt.Meters[i].VolumeErrorPct = -100; + } + tstRslt.Meters[i].Passed = (tstRslt.ErrLimLo <= tstRslt.Meters[i].VolumeErrorPct) && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi); + + tstRslt.Meters[i].Disabled = false; } else { - tstRslt.Meters[i].VolumeErrorPct = -100; + tstRslt.Meters[i].Disabled = true; } - tstRslt.Meters[i].Passed = (tstRslt.ErrLimLo <= tstRslt.Meters[i].VolumeErrorPct) && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi); - - tstRslt.Meters[i].Disabled = false; - } - else - { - tstRslt.Meters[i].Disabled = true; } + /// Add data - end } - /// Add data - end /// Update modeless dialog error information Bridge.OnAdjustmentInProgress(this, new AdjustmentInProgressEventArgs(tstRslt)); diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/TestMethod.cs index 603eb56b6..7e89de230 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/TestMethod.cs @@ -29,7 +29,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment public IList Execute(Entities.Test test) { - return (new AdjustmentSeq()).Execute(test); + return (new AdjustmentSeq()).Execute(test, DebugLevel); } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm.cs index 3d79bdc93..6a112778a 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm.cs @@ -2,6 +2,7 @@ /// Copyright (c) 2013-2015 Sensus Metering Systems /// using System; +using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using log4net; @@ -14,7 +15,9 @@ namespace TBF.BenchControl.TestMethods.Adjustment private static readonly ILog log = LogManager.GetLogger(typeof(WMErrorsForm)); /// Number of text boxes for serial numbers - public readonly int WaterMetersCount; + public readonly int waterMetersCount; + + readonly bool[] disabled; Entities.TestResult tr; @@ -29,21 +32,26 @@ namespace TBF.BenchControl.TestMethods.Adjustment /// Constructor /// /// Number of text boxes for serial numbers - public WMErrorsForm(int waterMetersCount) + public WMErrorsForm(IList waterMeters) + : this() { - this.WaterMetersCount = waterMetersCount; - InitializeComponent(); - completed = false; + waterMetersCount = waterMeters.Count; + + rects = new Rectangle[waterMetersCount]; + for (int i = 0; i < waterMetersCount; i++) rects[i] = new Rectangle(385, 30 + 90 * i, 324, 57); + + disabled = new bool[waterMetersCount]; + for (int i = 0; i < waterMetersCount; i++) disabled[i] = waterMeters[i].Disabled; + } + + /// Parameterless constructor for 3 watermeters + public WMErrorsForm() + { + InitializeComponent(); + + completed = false; tr = null; - - rects = new Rectangle[WaterMetersCount]; - for (int i = 0; i < WaterMetersCount; i++) - { - rects[i] = new Rectangle(385, 30 + 90 * i, 324, 57); - } - - /// Attach to 'AdjustmentInProgress' handler UiBridge.Bridge.AdjustmentInProgressHandler += delegate(object sender, UiBridge.AdjustmentInProgressEventArgs args) { @@ -55,12 +63,6 @@ namespace TBF.BenchControl.TestMethods.Adjustment }; } - /// Parameterless constructor for 3 watermeters - public WMErrorsForm() - : this(Program.WMsCount) - { - } - void Localize() { Text = Strings.Water_Meter_States; @@ -83,14 +85,14 @@ namespace TBF.BenchControl.TestMethods.Adjustment { Localize(); - Height = 50 + 90 * WaterMetersCount; + Height = 50 + 90 * waterMetersCount; - if (WaterMetersCount < 1) groupBox1.Visible = false; - if (WaterMetersCount < 2) groupBox2.Visible = false; - if (WaterMetersCount < 3) groupBox3.Visible = false; - if (WaterMetersCount < 4) groupBox4.Visible = false; - if (WaterMetersCount < 5) groupBox5.Visible = false; - if (WaterMetersCount < 6) groupBox6.Visible = false; + if (waterMetersCount < 1 || disabled[0]) groupBox1.Visible = false; + if (waterMetersCount < 2 || disabled[1]) groupBox2.Visible = false; + if (waterMetersCount < 3 || disabled[2]) groupBox3.Visible = false; + if (waterMetersCount < 4 || disabled[3]) groupBox4.Visible = false; + if (waterMetersCount < 5 || disabled[4]) groupBox5.Visible = false; + if (waterMetersCount < 6 || disabled[5]) groupBox6.Visible = false; wmErrorTextBox1.Text = "---"; wmErrorTextBox2.Text = "---"; @@ -116,14 +118,14 @@ namespace TBF.BenchControl.TestMethods.Adjustment { if (tr != null) { - if (WaterMetersCount >= 1) wmErrorTextBox1.Text = tr.Meters[0].VolumeErrorPct.ToString("F1"); - if (WaterMetersCount >= 2) wmErrorTextBox2.Text = tr.Meters[1].VolumeErrorPct.ToString("F1"); - if (WaterMetersCount >= 3) wmErrorTextBox3.Text = tr.Meters[2].VolumeErrorPct.ToString("F1"); - if (WaterMetersCount >= 4) wmErrorTextBox4.Text = tr.Meters[3].VolumeErrorPct.ToString("F1"); - if (WaterMetersCount >= 5) wmErrorTextBox5.Text = tr.Meters[4].VolumeErrorPct.ToString("F1"); - if (WaterMetersCount >= 6) wmErrorTextBox6.Text = tr.Meters[5].VolumeErrorPct.ToString("F1"); + if (waterMetersCount >= 1 && !disabled[0]) wmErrorTextBox1.Text = tr.Meters[0].VolumeErrorPct.ToString("F1"); + if (waterMetersCount >= 2 && !disabled[1]) wmErrorTextBox2.Text = tr.Meters[1].VolumeErrorPct.ToString("F1"); + if (waterMetersCount >= 3 && !disabled[2]) wmErrorTextBox3.Text = tr.Meters[2].VolumeErrorPct.ToString("F1"); + if (waterMetersCount >= 4 && !disabled[3]) wmErrorTextBox4.Text = tr.Meters[3].VolumeErrorPct.ToString("F1"); + if (waterMetersCount >= 5 && !disabled[4]) wmErrorTextBox5.Text = tr.Meters[4].VolumeErrorPct.ToString("F1"); + if (waterMetersCount >= 6 && !disabled[5]) wmErrorTextBox6.Text = tr.Meters[5].VolumeErrorPct.ToString("F1"); - for (int i = 0; i < WaterMetersCount; i++) Invalidate(rects[i]); + for (int i = 0; i < waterMetersCount; i++) Invalidate(rects[i]); } } @@ -133,9 +135,12 @@ namespace TBF.BenchControl.TestMethods.Adjustment { System.Drawing.Graphics graphics = this.CreateGraphics(); - for (int i = 0; i < WaterMetersCount; i++) + for (int i = 0; i < waterMetersCount; i++) { - PaintOne(graphics, rects[i], tr.Meters[i].VolumeErrorPct, tr.ErrLimLo, tr.ErrLimHi); + if (!disabled[i]) + { + PaintOne(graphics, rects[i], tr.Meters[i].VolumeErrorPct, tr.ErrLimLo, tr.ErrLimHi); + } } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm24.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm24.cs index e9bbd049f..baf3f7b06 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm24.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/WMErrorsForm24.cs @@ -2,6 +2,7 @@ /// Copyright (c) 2013-2015 Sensus Metering Systems /// using System; +using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using log4net; @@ -18,7 +19,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment bool completed; /// Number of text boxes for serial numbers - public readonly int WaterMetersCount; + readonly int waterMetersCount; readonly bool[] disabled; @@ -81,14 +82,15 @@ namespace TBF.BenchControl.TestMethods.Adjustment /// Constructor /// /// Number of text boxes for serial numbers - public WMErrorsForm24(int waterMetersCount) + public WMErrorsForm24(IList waterMeters) : this() { - this.WaterMetersCount = waterMetersCount; + waterMetersCount = waterMeters.Count; ShuffleTextBoxes(waterMetersCount, Program.LineSize); disabled = new bool[waterMetersCount]; + for (int i = 0; i < waterMetersCount; i++) disabled[i] = waterMeters[i].Disabled; } @@ -139,11 +141,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment for (int i = 0; i < textBoxesCount; i++) { - if (disabled != null && i < disabled.Length && disabled[i]) - { - labels[i].Visible = errors[i].Visible = true; - errors[i].Text = "---"; - } + labels[i].Visible = errors[i].Visible = (disabled == null || i >= disabled.Length || !disabled[i]); + errors[i].Text = "---"; } } @@ -177,9 +176,12 @@ namespace TBF.BenchControl.TestMethods.Adjustment { System.Drawing.Graphics graphics = this.CreateGraphics(); - for (int i = 0; i < WaterMetersCount; i++) + for (int i = 0; i < waterMetersCount; i++) { - PaintOne(graphics, rects[i], tr.Meters[i].VolumeErrorPct, tr.ErrLimLo, tr.ErrLimHi); + if (!disabled[i]) + { + PaintOne(graphics, rects[i], tr.Meters[i].VolumeErrorPct, tr.ErrLimLo, tr.ErrLimHi); + } } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs index 9793cadb3..22388a1bf 100644 --- a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs @@ -399,10 +399,5 @@ namespace TBF.BenchControl.TestMethods.LeakTest retList.Add(retVal); return retList; } - - bool IsMainMtr(int i) - { - return (i % 2) == 0; - } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs index 65198475a..e4aac1640 100644 --- a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -311,10 +311,5 @@ namespace TBF.BenchControl.TestMethods.PMaxTest retList.Add(retVal); return retList; } - - bool IsMainMtr(int i) - { - return (i % 2) == 0; - } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs index 62bfaa252..67f3bfe18 100644 --- a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs @@ -240,213 +240,5 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication return tstRslt; } - - - /// - /// Create a simulated test result (single meter). - /// - /// Test to be simulated - /// Test result - Entities.TestResult MakeSimulated(Entities.Test test, int repetitionNr, float errorPct) - { - Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single); - - tstRslt.TimeStart = DateTime.Now; - tstRslt.TimeEnd = DateTime.Now; - - tstRslt.AmbientTempAve = 20.0f; - tstRslt.AmbientPressAve = 1000.0f; - tstRslt.AmbientHumiAve = 50.0f; - - tstRslt.PressInStart = 1000.0f; - tstRslt.PressOutStart = 1000.0f; - tstRslt.TempInStart = 20.0f; - tstRslt.TempOutStart = 20.0f; - tstRslt.TempDivStart = 20.0f; - - tstRslt.PressInEnd = 1000.0f; - tstRslt.PressOutEnd = 1000.0f; - tstRslt.TempInEnd = 20.0f; - tstRslt.TempOutEnd = 20.0f; - tstRslt.TempDivEnd = 20.0f; - - tstRslt.PressInAvrg = 1000.0f; - tstRslt.PressOutAvrg = 1000.0f; - tstRslt.TempInAvrg = 20.0f; - tstRslt.TempOutAvrg = 20.0f; - tstRslt.TempDivAvrg = 20.0f; - - tstRslt.BatchNr = Program.LocalSettings.BatchNr; - tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; - tstRslt.MassEndRaw = test.Volume * Program.LocalSettings.RealDensity / 1000.0f; - tstRslt.MassEnd = tstRslt.MassEndRaw; - tstRslt.MassDiff = tstRslt.MassEnd; - tstRslt.DensityIn = Program.LocalSettings.RealDensity; - tstRslt.DensityOut = Program.LocalSettings.RealDensity; - tstRslt.DensityDiv = Program.LocalSettings.RealDensity; - tstRslt.Time = test.TstTime; - tstRslt.FlowMass = tstRslt.MassDiff / test.TstTime; - tstRslt.FlowVolume = test.Volume / test.TstTime; - tstRslt.VolumeCTV = test.Volume; - tstRslt.VolumeMaster = test.Volume; - tstRslt.PulsesMaster = (ltrPerRefPulse > 1E-6) ? (test.Volume / ltrPerRefPulse) : 1; - tstRslt.ConstMaster = ltrPerRefPulse; - tstRslt.ErrorMaster = 0; - - for (int i = 0; i < Program.WMsCount; i++) - { - /// Reference to iPerl water meter or null: - WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length)) - ? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter) - : null; - - if ((sensPath.RegisterReaders[i] != null) && (WaterMeters.Count > i) && !WaterMeters[i].Disabled) - { - tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; - tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr; - tstRslt.Meters[i].VolumeRef = test.Volume; - tstRslt.Meters[i].Time = test.TstTime; - tstRslt.Meters[i].TimeStart = 0; - tstRslt.Meters[i].TimeEnd = test.TstTime; - tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster; - tstRslt.Meters[i].VolumeStart = 0; - tstRslt.Meters[i].VolumeErrorPct = errorPct; - tstRslt.Meters[i].Passed = (test.ErrLimLo <= errorPct) && (errorPct <= test.ErrLimHi); - tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); - tstRslt.Meters[i].PulsesMeter = sensPath.RegisterReaders[i].PulsesPerLtr * tstRslt.Meters[i].VolumeMeter; - tstRslt.Meters[i].Disabled = false; - - if (iPerl == null) - { - tstRslt.Meters[i].VolumeEnd = 0; /// Normal meter - } - else - { - /// iPerl - tstRslt.Meters[i].VolumeEnd = tstRslt.Meters[i].VolumeStart + tstRslt.Meters[i].VolumeMeter; - } - } - } - - return tstRslt; - } - - - /// - /// Create a simulated test result (compound meter). - /// - /// Test to be simulated - /// Test result - Entities.TestResult MakeSimulatedCompound(Entities.Test test, CompoundTestType testType, int repetitionNr, float errorPct) - { - Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Combined); - - tstRslt.TimeStart = DateTime.Now; - tstRslt.TimeEnd = DateTime.Now; - - tstRslt.AmbientTempAve = 20.0f; - tstRslt.AmbientPressAve = 1000.0f; - tstRslt.AmbientHumiAve = 50.0f; - - tstRslt.PressInStart = 1000.0f; - tstRslt.PressOutStart = 1000.0f; - tstRslt.TempInStart = 20.0f; - tstRslt.TempOutStart = 20.0f; - tstRslt.TempDivStart = 20.0f; - - tstRslt.PressInEnd = 1000.0f; - tstRslt.PressOutEnd = 1000.0f; - tstRslt.TempInEnd = 20.0f; - tstRslt.TempOutEnd = 20.0f; - tstRslt.TempDivEnd = 20.0f; - - tstRslt.PressInAvrg = 1000.0f; - tstRslt.PressOutAvrg = 1000.0f; - tstRslt.TempInAvrg = 20.0f; - tstRslt.TempOutAvrg = 20.0f; - tstRslt.TempDivAvrg = 20.0f; - - tstRslt.BatchNr = Program.LocalSettings.BatchNr; - tstRslt.MassStartRaw = 0; - tstRslt.MassStart = 0; - tstRslt.MassEndRaw = test.Volume * Program.LocalSettings.RealDensity / 1000.0f; - tstRslt.MassEnd = tstRslt.MassEndRaw; - tstRslt.MassDiff = tstRslt.MassEnd; - tstRslt.DensityIn = Program.LocalSettings.RealDensity; - tstRslt.DensityOut = Program.LocalSettings.RealDensity; - tstRslt.DensityDiv = Program.LocalSettings.RealDensity; - tstRslt.Time = test.TstTime; - tstRslt.FlowMass = tstRslt.MassDiff / test.TstTime; - tstRslt.FlowVolume = test.Volume / test.TstTime; - tstRslt.VolumeCTV = test.Volume; - tstRslt.VolumeMaster = test.Volume; - tstRslt.PulsesMaster = (ltrPerRefPulse > 1E-6) ? (test.Volume / ltrPerRefPulse) : 1; - tstRslt.ConstMaster = ltrPerRefPulse; - tstRslt.ErrorMaster = 0; - - for (int iCmbnd = 0; iCmbnd < Program.CompoundWMsCount; iCmbnd++) - { - tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error - - for (int i = 2 * iCmbnd; i < 2 * iCmbnd + 2; i++) - { - if (sensPath.RegisterReaders[i] == null || sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) - { - tstRslt.Meters[i].PulsesPerLiter = 1.0f; - tstRslt.Meters[i].VolumeMeter = 0; - } - else - { - tstRslt.Meters[i].PulsesPerLiter = sensPath.RegisterReaders[i].PulsesPerLtr; - tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr; - } - - tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; - tstRslt.Meters[i].VolumeStart = 0; - tstRslt.Meters[i].VolumeEnd = 0; /// Normal meter - - tstRslt.Meters[i].VolumeRef = test.Volume; - if (testType == CompoundTestType.Regular && IsMainMtr(i)) - { - tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); - } - else if (testType == CompoundTestType.DetectionRise && !IsMainMtr(i)) - { - tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); - } - else if (testType == CompoundTestType.DetectionFall && IsMainMtr(i)) - { - tstRslt.Meters[i].VolumeMeter = test.Volume * (1.0f + 0.01f * errorPct); - } - else - { - tstRslt.Meters[i].VolumeMeter = 0; - } - - tstRslt.Meters[i].Time = test.TstTime; - tstRslt.Meters[i].TimeStart = 0; - tstRslt.Meters[i].TimeEnd = test.TstTime; - tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster; - tstRslt.Meters[i].VolumeErrorPct = errorPct; - tstRslt.Meters[i].Passed = (test.ErrLimLo <= errorPct) && (errorPct <= test.ErrLimHi); - tstRslt.Meters[i].PulsesMeter = sensPath.RegisterReaders[i].PulsesPerLtr * tstRslt.Meters[i].VolumeMeter; - } - - tstRslt.CombinedMeters[iCmbnd].VolumeMeter = tstRslt.Meters[2 * iCmbnd].VolumeMeter + tstRslt.Meters[2 * iCmbnd + 1].VolumeMeter; - - tstRslt.CombinedMeters[iCmbnd].PulsesMaster = tstRslt.PulsesMaster; - tstRslt.CombinedMeters[iCmbnd].Time = test.TstTime; - tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct = Formulas.ErrorFromVolumes(tstRslt.CombinedMeters[iCmbnd].VolumeMeter, tstRslt.CombinedMeters[iCmbnd].VolumeRef); - tstRslt.CombinedMeters[iCmbnd].Passed = (tstRslt.ErrLimLo <= tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct) && (tstRslt.CombinedMeters[iCmbnd].VolumeErrorPct <= tstRslt.ErrLimHi); - } - - return tstRslt; - } - - bool IsMainMtr(int i) - { - return (i % 2) == 0; - } } } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index c321e279a..c1ee52fb4 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.5.125.1")] -[assembly: AssemblyFileVersion("1.5.125.1")] +[assembly: AssemblyVersion("1.5.127.1")] +[assembly: AssemblyFileVersion("1.5.127.1")]