From 49a004d7fee964c35ed11fc37dc56e9a2be12f0c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 15 Jan 2015 03:51:33 +0100 Subject: [PATCH] DataEntry dlg at the beginning closes at the end of the 1st test (at the latest) --- TODO.txt | 1 - .../BenchControl/Sequences/MainSeq.cs | 124 +++++++++++------- 2 files changed, 80 insertions(+), 45 deletions(-) diff --git a/TODO.txt b/TODO.txt index 4d05364c2..4bbc85628 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,3 @@ -- zdruzeny: vysledky na process obrazovke sa opakuju 3x - s/n sa nedostalo do vysledkov - oprava process obrazovky diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 6e00951a7..e6a068623 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -29,7 +29,9 @@ namespace TBF.BenchControl.Sequences /// public IList Execute(Entities.Test dummyArg) { - /// Operations running in more then one state + bool beginningDlgClosed = true; + + /// Operations running in more then one state checkUiOp = new CheckUIOp(true); IList e; @@ -209,19 +211,8 @@ namespace TBF.BenchControl.Sequences case Event.UiCmdStop: goto stop; } - //-------------------------------- - 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)) goto stop; - } + if (OpenDataEntryBeginning()) goto stop; + beginningDlgClosed = false; assume_bench_filled: @@ -283,6 +274,12 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------- e = testMethodSequence.Execute(test); + if (!beginningDlgClosed) + { + beginningDlgClosed = true; + if (OpenDataEntryBeginning()) goto stop; + } + if (e.Contains(Event.Error)) goto error; if (e.Contains(Event.OpArgumentError)) goto config_error; if (e.Contains(Event.UiCmdStop)) goto stop; @@ -316,9 +313,15 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------- e = testMethodSequence.Execute(test); - if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.OpArgumentError)) goto config_error; - if (e.Contains(Event.UiCmdStop)) goto stop; + if (!beginningDlgClosed) + { + beginningDlgClosed = true; + if (OpenDataEntryBeginning()) goto stop; + } + + if (e.Contains(Event.Error)) goto error; + if (e.Contains(Event.OpArgumentError)) goto config_error; + if (e.Contains(Event.UiCmdStop)) goto stop; } } @@ -340,37 +343,11 @@ namespace TBF.BenchControl.Sequences //-------------------------------- string protocolTitle = string.Empty; - dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; + GenericDevices.IDataEntry dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; if (dataEntryCmpnt != null) { Bridge.OnActivity(this, "Enter the protocol data"); - if (dataEntryCmpnt is IHasCycleBeginForm) - { - 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)) goto stop; - } - 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)) goto stop; - } - if (dataEntryCmpnt is IHasCycleEndForm) { /// Open the modeless form for the end of the cycle @@ -715,6 +692,65 @@ 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; + } + return false; + } /// /// Perform a camera test