diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 1765cebcd..027fc943b 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -29,8 +29,6 @@ namespace TBF.BenchControl.Sequences /// public IList Execute(Entities.Test dummyArg) { - bool beginningDlgClosed = true; - /// Operations running in more then one state checkUiOp = new CheckUIOp(true); @@ -159,6 +157,14 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------------------------------------- select_procedure: + + /// Make sure the CycleBeginForm is closed (aftrer an abnormal procedure/test end, etc.) + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stop; + } + selection = MakeSelection(MKSelContext.ProcedureNotSelected); //-------------------------------- @@ -211,8 +217,8 @@ namespace TBF.BenchControl.Sequences case Event.UiCmdStop: goto stop; } - if (OpenDataEntryBeginning()) goto stop; - beginningDlgClosed = false; + if (OpenCycleBeginForm()) goto stop; + cycleBeginFormOpened = true; assume_bench_filled: @@ -274,10 +280,10 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------- e = testMethodSequence.Execute(test); - if (!beginningDlgClosed) + if (cycleBeginFormOpened) { - beginningDlgClosed = true; - if (CloseDataEntryBeginning()) goto stop; + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stop; } if (e.Contains(Event.Error)) goto error; @@ -313,10 +319,10 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------- e = testMethodSequence.Execute(test); - if (!beginningDlgClosed) + if (cycleBeginFormOpened) { - beginningDlgClosed = true; - if (CloseDataEntryBeginning()) goto stop; + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stop; } if (e.Contains(Event.Error)) goto error; @@ -692,68 +698,6 @@ namespace TBF.BenchControl.Sequences while (true) StateMachine.WaitRunDevsRunOps(); } - /// - /// Opens a modeless dialog for entering data at the beginning of a procedure (serial numbers) - /// - /// false = OK, true = stop pressed - bool OpenDataEntryBeginning() - { - IList e; - GenericDevices.IDataEntry dataEntryCmpnt = - TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; - if (dataEntryCmpnt is IHasCycleBeginForm) - { - Bridge.OnActivity(this, "Enter the water meter data"); - State.Create("MainSeq : Enter begin data") - .AddPermanentOperation((dataEntryCmpnt as IHasCycleBeginForm).ShowCycleBeginFormOp(WaterMeters)) - .AddOperation(checkUiOp) - .EnterState(); - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) return true; - } - return false; - } - - /// - /// Waits until a modeless dialog for entering data at the beginnig of a procedure is closed. - /// This function is typically called at the end of the first test of the procedure. - /// - /// false = OK, true = stop pressed - bool CloseDataEntryBeginning() - { - IList e; - GenericDevices.IDataEntry dataEntryCmpnt = - TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; - if (dataEntryCmpnt as IHasCycleBeginForm != null) - { - if (!State.LastEvents.Contains(Event.ModelessFormClosed)) - { - /// Wait until modeless dialg is closed - State.Create("MainSeq : Check whether the entry form is closed") - .AddOperation(checkUiOp) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) return true; - } - while (!e.Contains(Event.ModelessFormClosed)); - } - - /// A state without any dataEntryCmpnt operation so that Stop() when entering - /// this state and Start() when entering the following state are executed. - State.Create("MainSeq : Nothing") - .AddOperation(checkUiOp) - .RemovePermanentOperation(dataEntryCmpnt as IOperation) - .EnterState(); - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) return true; - - dataEntryCmpnt.UpdateTestResults(WaterMeters, results); - } - return false; - } - /// /// Perform a camera test /// diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index 522a8c4ff..9033ed44d 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -102,6 +102,8 @@ namespace TBF.BenchControl.Sequences protected static float TimeEstimateBeginRpts; /// Time estimate at the beginning of all repetitions of the current tests protected static float TimeEstimateOneTest; /// Time estimate of the current test (one repetition) + protected static bool cycleBeginFormOpened; + static SequenceBase() { results = new List(); @@ -113,7 +115,9 @@ namespace TBF.BenchControl.Sequences WMVolumes[i] = new FloatBox() { Name = string.Format("Volume{0}", i), Format = "F2" }; WMErrors[i] = new FloatBox() { Name = string.Format("Error{0}", i), Format = "F2" }; } - } + + cycleBeginFormOpened = false; + } ///------------------------------------------------------------ /// Test related (instance) variables. @@ -555,6 +559,68 @@ namespace TBF.BenchControl.Sequences } + /// + /// Opens a modeless dialog for entering data at the beginning of a procedure (serial numbers) + /// + /// false = OK, true = stop pressed + protected bool OpenCycleBeginForm() + { + IList e; + GenericDevices.IDataEntry dataEntryCmpnt = + TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; + if (dataEntryCmpnt is IHasCycleBeginForm) + { + Bridge.OnActivity(this, "Enter the water meter data"); + State.Create("MainSeq : Enter begin data") + .AddPermanentOperation((dataEntryCmpnt as IHasCycleBeginForm).ShowCycleBeginFormOp(WaterMeters)) + .AddOperation(checkUiOp) + .EnterState(); + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) return true; + } + return false; + } + + + /// + /// Waits until a modeless dialog for entering data at the beginnig of a procedure is closed. + /// This function is typically called at the end of the first test of the procedure. + /// + /// false = OK, true = stop pressed + protected bool CloseCycleBeginForm() + { + IList e; + GenericDevices.IDataEntry dataEntryCmpnt = + TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; + if (dataEntryCmpnt as IHasCycleBeginForm != null) + { + if (!State.LastEvents.Contains(Event.ModelessFormClosed)) + { + /// Wait until modeless dialg is closed + State.Create("MainSeq : Check whether the entry form is closed") + .AddOperation(checkUiOp) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) return true; + } + while (!e.Contains(Event.ModelessFormClosed)); + } + + /// A state without any dataEntryCmpnt operation so that Stop() when entering + /// this state and Start() when entering the following state are executed. + State.Create("MainSeq : Nothing") + .AddOperation(checkUiOp) + .RemovePermanentOperation(dataEntryCmpnt as IOperation) + .EnterState(); + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) return true; + } + return false; + } + + /// /// Main loop where measurements are collected. /// diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs index 9425e451d..f0d7473c0 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs @@ -311,9 +311,14 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters Bridge.OnActivity(this, Strings.Test_completed); //------------------------------------------------ - /// + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stopTest; + } + /// Optionally supress pulses from the large water meter - /// if (testParams.SupressTrills) { WMPulses[0] = 0; @@ -321,7 +326,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters } /// - /// Populate TestRasult data entity with data + /// Populate TestResult data entity with data /// tstRslt.TimeEnd = DateTime.Now; UpdateTestRsltWithAveragedData(tstRslt); @@ -375,7 +380,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr; } - tstRslt.Meters[i].SerialNr = "not specified"; + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; tstRslt.Meters[i].VolumeStart = 0; /// [l] tstRslt.Meters[i].VolumeEnd = 0; /// [l] diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 98ca7b8ae..92fe55e31 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -522,9 +522,15 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection } while (!e.Contains(Event.PreviousStopped)); - /// + + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stop; + } + /// Optionally supress pulses from the large water meter - /// if (testParams.SupressTrills) { WMPulses[0] = 0; @@ -532,7 +538,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection } /// - /// Populate TestRasult data entity with data + /// Populate TestResult data entity with data /// tstRslt.TimeEnd = DateTime.Now; UpdateTestRsltWithAveragedData(tstRslt); @@ -584,11 +590,11 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr; } - tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString(); - tstRslt.Meters[i].VolumeStart = 0; /// liter - tstRslt.Meters[i].VolumeEnd = 0; /// liter + 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].VolumeRef = tstRslt.VolumeCTV; /// liter + tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// liter if (WMRefPulses[i] != 0) { tstRslt.Meters[i].VolumeMeter *= ((float)cBrd.EtPulses(0) / (float)WMRefPulses[i]); @@ -601,7 +607,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection tstRslt.Meters[i].VolumeErrorPct = 0; /// Not used } - tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// liter + tstRslt.CombinedMeters[iCmbnd].VolumeRef = tstRslt.VolumeCTV; /// liter tstRslt.CombinedMeters[iCmbnd].VolumeMeter = tstRslt.Meters[2 * iCmbnd].VolumeMeter + tstRslt.Meters[2 * iCmbnd + 1].VolumeMeter; tstRslt.CombinedMeters[iCmbnd].PulsesMaster = cBrd.EtPulses(0); diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 0662d702d..2832e8686 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -412,6 +412,13 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection Bridge.OnActivity(this, Strings.Test_completed); //------------------------------------------------ + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stopTest; + } + /// /// Populate TestResult data entity with data /// @@ -453,8 +460,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection tstRslt.TimeDivEnd5 = 0; for (int i = 0; i < Program.WMsCount; i++) { - tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString(); - tstRslt.Meters[i].VolumeMeter = tstRslt.Meters[i].VolumeEnd - tstRslt.Meters[i].VolumeStart; + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; + tstRslt.Meters[i].VolumeMeter = tstRslt.Meters[i].VolumeEnd - tstRslt.Meters[i].VolumeStart; tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// liter tstRslt.Meters[i].PulsesMeter = 0; tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster; diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index 2c939ac25..b93d20a3d 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -237,6 +237,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStart Bridge.OnActivity(this, Strings.Test_completed); //------------------------------------------------ + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stopTest; + } + /// /// Populate TestResult data entity with data /// @@ -273,7 +280,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart { if (sensPath.RegisterReaders[i] != null) { - tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString(); + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; tstRslt.Meters[i].VolumeStart = 0; /// liter tstRslt.Meters[i].VolumeEnd = 0; /// liter if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0; diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs index 8497cb879..349d5e1dc 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs @@ -320,6 +320,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod Bridge.OnActivity(this, Strings.Test_completed); //------------------------------------------------ + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stopTest; + } + /// /// Populate TestResult data entity with data /// @@ -363,7 +370,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod { if (sensPath.RegisterReaders[i] != null) { - tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString(); + tstRslt.Meters[i].SerialNr = (WaterMeters.Count > i) ? WaterMeters[i].SerialNr : string.Empty; tstRslt.Meters[i].VolumeStart = 0; /// liter tstRslt.Meters[i].VolumeEnd = 0; /// liter if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0; diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs index 015152fcb..4dcf01ba3 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs @@ -303,6 +303,13 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration Bridge.OnActivity(this, Strings.Test_completed); //------------------------------------------------ + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (cycleBeginFormOpened) + { + cycleBeginFormOpened = false; + if (CloseCycleBeginForm()) goto stopTest; + } + /// /// Populate TestResult data entity with data ///