diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard12/CycleBeginningForm.cs b/TestBenchFramework/BenchControl/DataEntry/Standard12/CycleBeginningForm.cs index 5f5c2ebfc..e8f1722aa 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Standard12/CycleBeginningForm.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Standard12/CycleBeginningForm.cs @@ -32,7 +32,7 @@ namespace TBF.BenchControl.DataEntry.Standard12 public string SnSuffix; public string Remark; - /// Set to 'true' when the form closes + /// Is set to 'true' when the form closes public bool Completed { get { return completed; } } bool completed; diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs index d212fef73..b3296a761 100644 --- a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs +++ b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs @@ -7,14 +7,19 @@ using TBF.Resources; namespace TBF.BenchControl.Operations { - public partial class MessageBoxForm : Form + public partial class MessageBoxForm : Form, GenericDevices.IHasCompleted { public string Message; - public bool CompletedOK; + + /// Is set to 'true' when the form closes + public bool Completed { get { return completed; } } + bool completed; public MessageBoxForm() { InitializeComponent(); + completed = false; + StartForceCloseHandler(); } private void MessageBoxForm_Load(object sender, EventArgs e) @@ -26,8 +31,27 @@ namespace TBF.BenchControl.Operations private void okButton_Click(object sender, EventArgs e) { - CompletedOK = true; + completed = true; Close(); } + + #region Forced close handling + + public void StartForceCloseHandler() + { + UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args) + { + if (InvokeRequired) { Invoke(new EventHandler(OnForceClose), sender, args); } + else OnForceClose(sender, args); + }; + } + + private void OnForceClose(object sender, EventArgs args) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + #endregion } } diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxOp.cs b/TestBenchFramework/BenchControl/Operations/MessageBoxOp.cs index e9ba68bee..423b7864c 100644 --- a/TestBenchFramework/BenchControl/Operations/MessageBoxOp.cs +++ b/TestBenchFramework/BenchControl/Operations/MessageBoxOp.cs @@ -13,6 +13,7 @@ namespace TBF.BenchControl.Operations MessageBoxForm modelessDlg; string message; + bool completed = false; /// Reference to the operation public MessageBoxOp() @@ -37,21 +38,32 @@ namespace TBF.BenchControl.Operations /// Start this operation public void Start() { - Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this); + completed = false; + Program.MainWnd.Invoke(new MessageBoxFormDlgt(OpenFormDlg), this); } /// Run this operation /// Event.ResultsPrinted public Event Run() { - if (modelessDlg.CompletedOK) return Event.OK; + if (completed || modelessDlg.Completed) + { + completed = true; + modelessDlg = null; + return Event.OK; + } + return Event.None; } /// Stop this operation public void Stop() { - modelessDlg = null; + if (modelessDlg is GenericDevices.IHasCompleted) + { + UiBridge.Bridge.OnCloseModelessForm(this, null); + modelessDlg = null; + } } } } diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index e5521bf4b..000179fdb 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -107,13 +107,18 @@ namespace TBF.BenchControl.Sequences } + protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance) + { + return EmptyTheTank(emptyTankValve, balance, null); + } + /// /// Empties the tank: opens the emptying valve and measures the weight. /// - /// Valve to empty the tank - /// Balance underneath the tank + /// Valve to empty the tank + /// Balance underneath the tank /// Event.Done or Event.Error - protected Event EmptyTheTank(IValve EmptyTankValve, IBalance Balance) + protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance, IOperation extraOperation) { bool stopped = false; @@ -126,7 +131,8 @@ namespace TBF.BenchControl.Sequences State.Create("SequenceBase : Opening the emptying valve") .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(EmptyTankValve, null)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(emptyTankValve, null)) + .AddOperation(extraOperation) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); @@ -136,8 +142,9 @@ namespace TBF.BenchControl.Sequences //-------------------------------- State.Create("SequenceBase : Emptying the tank") .AddOperation(checkUiOp) - .AddOperation(Balance.ReadMassOp(ref Mass)) + .AddOperation(balance.ReadMassOp(ref Mass)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .AddOperation(extraOperation) .EnterState(); do { @@ -154,16 +161,17 @@ namespace TBF.BenchControl.Sequences if (stopped) break; } - while (!Balance.IsEmpty(Mass.Val)); + while (!balance.IsEmpty(Mass.Val)); // // Quit emptying // State.Create("SequenceBase : Closing the emptying valve") .AddOperation(checkUiOp) - .AddOperation(Balance.ReadMassOp(ref Mass)) + .AddOperation(balance.ReadMassOp(ref Mass)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, EmptyTankValve)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, emptyTankValve)) + .AddOperation(extraOperation) .EnterState(); do { @@ -175,10 +183,11 @@ namespace TBF.BenchControl.Sequences State.Create("SequenceBase : Updating the weight") .AddOperation(checkUiOp) - .AddOperation(Balance.ReadMassOp(ref Mass)) + .AddOperation(balance.ReadMassOp(ref Mass)) .AddOperation(new Operations.TimerOp(5)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); + .AddOperation(extraOperation) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index dd1b05326..ddd1f5e23 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -107,22 +107,14 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection } while (!e.Contains(Event.ValvesSet)); - /// - /// Display prompt to emerge temperature meters to appropriate baths for heat meters test - /// - if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) - { - State.Create("FixedStartMassCollection : Show heat meters prompt (exchange temperature meters)") - .AddOperation(checkUiOp) - .AddOperation(new Operations.MessageBoxOp(heatMetersTestParams.Prompt)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.OK)); - } + /// + /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test + /// + IOperation heatMetersPrompt = null; + if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) + { + heatMetersPrompt = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); + } if (!test.Emptying) /// If condition met => skip measuring and force emptying @@ -133,7 +125,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create("FixedStartMassCollection : Measuring the mass of water in the tank") .AddOperation(checkUiOp) .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -155,7 +148,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// /// Empty the water tank /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) + switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance, heatMetersPrompt)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -170,7 +163,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create("FixedStartMassCollection : Starting the pump") .AddOperation(checkUiOp) .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -185,7 +179,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create("FixedStartMassCollection : Setting the flow") .AddOperation(checkUiOp) .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min. - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -224,7 +219,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection .AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefWarm2)) .AddOperation(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefCold1)) .AddOperation(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefCold2)) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index f10494df4..386416e28 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -66,22 +66,16 @@ namespace TBF.BenchControl.TestMethods.FlyingStart TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 }); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - /// - /// Display prompt to emerge temperature meters to appropriate baths for heat meters test - /// - if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) - { - State.Create("FixedStartMassCollection : Show heat meters prompt (exchange temperature meters)") - .AddOperation(checkUiOp) - .AddOperation(new Operations.MessageBoxOp(heatMetersTestParams.Prompt)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.OK)); - } + + /// + /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test + /// + IOperation heatMetersPrompt = null; + if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) + { + heatMetersPrompt = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); + } + //------------------------------------------------ Bridge.OnActivity(this, Strings.Setting_the_flow); @@ -94,7 +88,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart State.Create("FlyingStart : Starting the pump") .AddOperation(checkUiOp) .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -109,6 +104,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart State.Create("FlyingStart : Setting the flow") .AddOperation(checkUiOp) .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min. + .AddOperation(heatMetersPrompt) .EnterState(); do { @@ -143,13 +139,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStart double Tw_last = 0; double Tc_last = 0; - State.Create("FixedStartMassCollection : Check temperature stabilized.") + State.Create("FlyingStart : Check temperature stabilized.") .AddOperation(checkUiOp) .AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefWarm1)) .AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefWarm2)) .AddOperation(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefCold1)) .AddOperation(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefCold2)) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index b93957e1f..bb769170f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -106,22 +106,15 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection while (!e.Contains(Event.ValvesSet)); } - /// - /// Display prompt to emerge temperature meters to appropriate baths for heat meters test - /// - if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) - { - State.Create("FixedStartMassCollection : Show heat meters prompt (exchange temperature meters)") - .AddOperation(checkUiOp) - .AddOperation(new Operations.MessageBoxOp(heatMetersTestParams.Prompt)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.OK)); - } + /// + /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test + /// + IOperation heatMetersPrompt = null; + if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) + { + heatMetersPrompt = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); + } + if (inPath.Pump != null) { @@ -134,7 +127,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(checkUiOp) .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -153,7 +147,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(checkUiOp) .AddOperation(new Operations.TimerOp(test.TimePump2StartV)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -172,7 +167,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(checkUiOp) .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -189,7 +185,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(checkUiOp) .AddOperation(new Operations.TimerOp(test.TimeBeforeFlow)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -211,7 +208,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(checkUiOp) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min. - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -245,13 +243,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection double Tw_last = 0; double Tc_last = 0; - State.Create("FixedStartMassCollection : Check temperature stabilized.") + State.Create("FlyingStartMassCollection : Check temperature stabilized.") .AddOperation(checkUiOp) .AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefWarm1)) .AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefWarm2)) .AddOperation(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefCold1)) .AddOperation(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefCold2)) - .EnterState(); + .AddOperation(heatMetersPrompt) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 1d7469b83..d83dba6be 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.10.358.1")] -[assembly: AssemblyFileVersion("2.10.358.1")] +[assembly: AssemblyVersion("2.10.359.1")] +[assembly: AssemblyFileVersion("2.10.359.1")]