diff --git a/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs b/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs index 77483c5c1..26e7d1f45 100644 --- a/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs +++ b/TBF/Rig/TestMethods/StandingStartMassCollection/StandingStartMassCollectionSeq.cs @@ -486,35 +486,6 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection } while (!e.Contains(Event.ValvesSet)); - ///...MF - ///----------------- - /*delay = 3; - //if (test.TimePump2StartV > 0) - //{ - State.Create(string.Format("{0}({1}) : Delay 5s", test.Method, test.Name)) - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(delay)) //...develop: step 3 - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - - /// Show remaining time - if ((delay = Math.Max(delay, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", "Delay", delay / 60, "min", delay % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", "Delay", delay)); - - if (delay > 0) - delay--; - } - while (!e.Contains(Event.TimerExpired)); - //}*/ - ///----------------- - - ///...MF ///----------------- delay = test.TimeFlow2Mass; @@ -533,13 +504,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } /// Show remaining time - if ((delay = Math.Max(delay, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", "Delay", delay / 60, "min", delay % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", "Delay", delay)); - - if(delay>0) - delay--; + Bridge.OnDelayActivity(this, "Delayed activity: Start the standing start/stop test (diverter switch...)", ref delay); } while (!e.Contains(Event.TimerExpired)); } @@ -561,7 +526,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection double currentFlow = RefFlow.Val; //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); + //Bridge.OnActivity(this, Strings.Measuring_the_weight); //------------------------------------------------ LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); @@ -659,13 +624,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } /// Show remaining time - if ((delay = Math.Max(delay, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", "Delay", delay / 60, "min", delay % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", "Delay", delay)); - - if (delay > 0) - delay--; + Bridge.OnDelayActivity(this, "Delayed activity: Measuring the start mass", ref delay); } while (!e.Contains(Event.ModelessFormClosed) || !e.Contains(Event.ScaleDone)); long readEndTime = StateMachine.Time; @@ -789,6 +748,9 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection retVal = Event.RecoverableError; goto stopTest; } + + /// Show remaining time + Bridge.OnDelayActivity(this, "Delayed activity: Measuring the start mass", ref delay); } while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next)); } @@ -828,15 +790,6 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - /// Show remaining time - if ((remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); - - if (delay > 0) - delay--; - /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); @@ -930,7 +883,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection LogProcessDataHeaderHeatMeters(processDataLogger, "End mass"); //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); + //Bridge.OnActivity(this, Strings.Measuring_the_weight); //------------------------------------------------ delay = test.TimeStop2Mass; @@ -955,13 +908,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection } /// Show remaining time - if ((delay = Math.Max(delay, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", "Delay", delay / 60, "min", delay % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", "Delay", delay)); - - if (delay > 0) - delay--; + Bridge.OnDelayActivity(this, "Delayed activity: Measuring the end mass", ref delay); } while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next)); /// diff --git a/TBF/Rig/TestMethods/StandingStartMassCollectionAdvance/StandingStartMassCollectionAdvanceSeq.cs b/TBF/Rig/TestMethods/StandingStartMassCollectionAdvance/StandingStartMassCollectionAdvanceSeq.cs index 1df89b4c1..513deed04 100644 --- a/TBF/Rig/TestMethods/StandingStartMassCollectionAdvance/StandingStartMassCollectionAdvanceSeq.cs +++ b/TBF/Rig/TestMethods/StandingStartMassCollectionAdvance/StandingStartMassCollectionAdvanceSeq.cs @@ -486,13 +486,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } /// Show remaining time - if ((delay = Math.Max(delay, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", "Delay", delay / 60, "min", delay % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", "Delay", delay)); - - if (delay > 0) - delay--; + Bridge.OnDelayActivity(this, "Delayed activity: Start the standing start/stop test (diverter switch...)", ref delay); } while (!e.Contains(Event.TimerExpired)); } @@ -513,7 +507,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance double currentFlow = RefFlow.Val; //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); + //Bridge.OnActivity(this, Strings.Measuring_the_weight); //------------------------------------------------ LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); @@ -598,7 +592,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance string.Format("{0}({1}) : Grabbing images - valve close", test.Method, test.Name)); } /////// - + delay = test.TimeStop2Mass; Bridge.OnActivity(this, Strings.Grabbing_images);//Strings.Enter_water_meter_data); State.Create(string.Format("{0}({1}) : Enter start states of water meters and Measuring the start mass after residual flow ", test.Method, test.Name, test.TimeStop2Mass)) @@ -613,6 +607,9 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance do { e = StateMachine.WaitRunDevsRunOps(); if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + + /// Show remaining time + Bridge.OnDelayActivity(this, "Delayed activity: Measuring the start mass", ref delay); } while (!e.Contains(Event.ScaleDone/*Event.ModelessFormClosed*/)); @@ -749,6 +746,9 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance retVal = Event.RecoverableError; goto stopTest; } + + /// Show remaining time + Bridge.OnDelayActivity(this, "Delayed activity: Measuring the start mass", ref delay); } while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next)); } @@ -788,12 +788,6 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - /// Show remaining time - if ((remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); - /// Update statistics RefFrequency.Val = cBrd.RefFrequency; RefFlow.Val = outPath.FlowMeter.ReadFlow(); @@ -855,7 +849,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance LogProcessDataHeaderHeatMeters(processDataLogger, "End mass"); //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); + //Bridge.OnActivity(this, Strings.Measuring_the_weight); //------------------------------------------------ delay = test.TimeStop2Mass; @@ -880,13 +874,7 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollectionAdvance } /// Show remaining time - if ((delay = Math.Max(delay, 0)) > 60) - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", "Delay", delay / 60, "min", delay % 60, Strings.sec)); - else - Bridge.OnActivity(this, string.Format("{0} ... {1} s", "Delay", delay)); - - if (delay > 0) - delay--; + Bridge.OnDelayActivity(this, "Delayed activity: Measuring the end mass", ref delay); } while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next)); /// diff --git a/TBF/UiBridge/Bridge.cs b/TBF/UiBridge/Bridge.cs index 226422de1..4895daa75 100644 --- a/TBF/UiBridge/Bridge.cs +++ b/TBF/UiBridge/Bridge.cs @@ -9,6 +9,7 @@ using NHibernate; using Common; using Config.Entities; using SharedDatabase.Entities; +using Config.Resources; namespace TBF.UiBridge { @@ -334,5 +335,35 @@ namespace TBF.UiBridge catch (Exception e) { log.Error("SetpointChangeHandler(...) failed", e); } } public static event EventHandler SetpointChangeHandler; + + public static void OnDelayActivity(object sender, string nextAction, ref int delay) + { + delay = Math.Max(delay, 0); + + string activity; + + if (delay > 60) + { + activity = string.Format( + "{0} in {1} min {2} {3}", + nextAction, + delay / 60, + delay % 60, + Strings.sec); + } + else + { + activity = string.Format( + "{0} in {1} {2}", + nextAction, + delay, + Strings.sec); + } + + OnActivity(sender, activity); + + if (delay > 0) + delay--; + } } }