From ea6c9818cf05939a2d71222c0e95f12dd1dfeb81 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 10 Dec 2014 22:39:53 +0100 Subject: [PATCH] - Tank emptying remaining time indication - Bug fixed: When copying a procwdure ItemId was not correctly set, remained 0 - Always create a message log when device initialization is completed successfully --- .../Cameras/IdcCamera/IdcCamera.cs | 6 ++-- .../BenchControl/Elde/ControlBoardDev.cs | 2 ++ .../BenchControl/Greco/Ambient.cs | 4 ++- .../BenchControl/MettlerToledo/BalanceDev.cs | 6 ++-- .../MettlerToledo/BalanceNewDev.cs | 2 +- .../BenchControl/Operations/TimerOp.cs | 36 +++++++++++++++---- .../BenchControl/Sequences/MainSeq.cs | 15 +++++--- .../Resources/Strings.Designer.cs | 18 ++++++++++ TestBenchFramework/Resources/Strings.de.resx | 6 ++++ TestBenchFramework/Resources/Strings.resx | 6 ++++ .../UiControls/ProceduresCtrl.cs | 7 ++-- 11 files changed, 86 insertions(+), 22 deletions(-) diff --git a/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs b/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs index 6efd39715..2d061305f 100644 --- a/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs +++ b/TestBenchFramework/BenchControl/Cameras/IdcCamera/IdcCamera.cs @@ -96,9 +96,9 @@ namespace TBF.BenchControl.Cameras.IdcCamera if (idcCameraCfg.DebugLevel != Entities.DebugMode.DetectedOff) { - log.WarnFormat("Detected: {0} on COM{1} ver. {2}", Name, idcCameraCfg.ComPortNr, Idc100.Version); - } - } + log.FatalFormat("Successfully initialized device {0}", ToString()); + } + } public void RunDeviceBefore() { diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs index 7f56c1832..6ec4eca25 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs @@ -212,6 +212,8 @@ namespace TBF.BenchControl.Elde EtCalib, DiverterEdge, BalanceRange); + + log.FatalFormat("Successfully initialized device {0}", ToString()); } /// Run this device diff --git a/TestBenchFramework/BenchControl/Greco/Ambient.cs b/TestBenchFramework/BenchControl/Greco/Ambient.cs index 1991b4cf2..edc211d34 100644 --- a/TestBenchFramework/BenchControl/Greco/Ambient.cs +++ b/TestBenchFramework/BenchControl/Greco/Ambient.cs @@ -75,7 +75,9 @@ namespace TBF.BenchControl.Greco serialPort.Open(); measurementBuilder = new StringBuilder(40); msrmntState = MsrmntState.Busy; - } + + log.FatalFormat("Successfully initialized device {0}", ToString()); + } /// Run this device public void RunDeviceBefore() diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs index 301fa5478..9759f5797 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs @@ -22,7 +22,7 @@ namespace TBF.BenchControl.MettlerToledo /// Warn: Start measurement when busy is true /// private static readonly ILog log = LogManager.GetLogger(typeof(BalanceDev)); - public override string ToString() { return string.Format("{0}, Mettler-Toledo Balance", balanceCfg.Name); } + public override string ToString() { return string.Format("{0} - Mettler-Toledo Balance", balanceCfg.Name); } /// /// Enumeration of balances via static fields and methods @@ -100,7 +100,9 @@ namespace TBF.BenchControl.MettlerToledo serialPort = new SerialPort(comPortName, balanceCfg.BaudRate, balanceCfg.Parity, balanceCfg.DataBits, balanceCfg.StopBits); serialPort.Handshake = balanceCfg.Handshake; serialPort.Open(); - } + + log.FatalFormat("Successfully initialized device {0}", ToString()); + } public bool IsEmpty(float mass) { diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs index fca67c332..8a3927f5c 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewDev.cs @@ -21,7 +21,7 @@ namespace TBF.BenchControl.MettlerToledo /// Warn: Start measurement when busy is true /// private static readonly ILog log = LogManager.GetLogger(typeof(BalanceNewDev)); - public override string ToString() { return string.Format("Mettler-Toledo Balance with SN"); } + public override string ToString() { return string.Format("{0} - Mettler-Toledo Balance with SN", balanceCfg.Name); } public static void ResetStaticProperties() { } diff --git a/TestBenchFramework/BenchControl/Operations/TimerOp.cs b/TestBenchFramework/BenchControl/Operations/TimerOp.cs index b234bf3d9..4d130dc95 100644 --- a/TestBenchFramework/BenchControl/Operations/TimerOp.cs +++ b/TestBenchFramework/BenchControl/Operations/TimerOp.cs @@ -28,18 +28,36 @@ namespace TBF.BenchControl.Operations /// Set by constructors int timerTime; Event eventExpired; + TBF.Boxes.IntBox remainingTimeSec; /// /// Constructors, optional argument is a timer name (you can create more then one timer) /// - public TimerOp(int timerTime, Event eventExpired) - { - this.timerTime = timerTime; - this.eventExpired = eventExpired; - } - public TimerOp(int timerTime) - : this(timerTime, Event.TimerExpired) + public TimerOp(int timerTimeSec, Event eventExpired, TBF.Boxes.IntBox remainingTimeSec) { + this.timerTime = timerTimeSec; + this.eventExpired = eventExpired; + this.remainingTimeSec = remainingTimeSec; + } + public TimerOp(int timerTimeSec, Event eventExpired) + : this(timerTimeSec, eventExpired, null) + { + } + public TimerOp(int timerTime, TBF.Boxes.IntBox remainingTimeSec) + : this(timerTime, Event.TimerExpired, remainingTimeSec) + { + } + public TimerOp(int timerTime) + : this(timerTime, Event.TimerExpired, null) + { + } + + void UpdateRemainingTime() + { + if (remainingTimeSec != null) + { + remainingTimeSec.Val = System.Math.Max(expireTime - StateMachine.Time, 0); + } } /// Time period (TimeSpan) @@ -48,10 +66,14 @@ namespace TBF.BenchControl.Operations timeExpired = false; timerStarted = true; expireTime = StateMachine.Time + timerTime; + + UpdateRemainingTime(); } public Event Run() { + UpdateRemainingTime(); + if (timerStarted && !timeExpired && StateMachine.Time >= expireTime) { timeExpired = true; diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index a70a71146..4de7aab70 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -54,8 +54,8 @@ namespace TBF.BenchControl.Sequences while (e.Contains(Event.ValvesBusy)); //-------------------------------------------------------------------------------------------- - Bridge.OnActivity(this, Strings.Emptying_tank); - State startNew = State.Create("MainSeq : Emptying tanks, Starting cameras") + IntBox remainingTime = new IntBox(); + State startNew = State.Create("MainSeq : Emptying tanks, Starting cameras") .AddOperation(checkUiOp); foreach (var cmpnt in StateMachine.Components) { @@ -87,14 +87,17 @@ namespace TBF.BenchControl.Sequences } if (balanceEmptyTime > 0) { - startNew.AddOperation(new TimerOp(balanceEmptyTime)) + startNew.AddOperation(new TimerOp(balanceEmptyTime, remainingTime)) .AddOperation(StateMachine.ControlBoard.SetValvesOp(allEmptyingValves, null)); } startNew.EnterState(); do { - e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnActivity(this, string.Format("{0}, {1} {2} {3}", Strings.Emptying_tank, + Strings.remaining_time, remainingTime.Val.ToString(), Strings.sec)); + + e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.Error)) goto error; if (e.Contains(Event.UiCmdStop) && !e.Contains(Event.ValvesBusy) && @@ -102,13 +105,15 @@ namespace TBF.BenchControl.Sequences { goto stop_emptying; } - } + } while (e.Contains(Event.TimerBusy) || e.Contains(Event.CameraBusy) || e.Contains(Event.ValvesBusy)); if (e.Contains(Event.CameraOpFailed)) goto error; /// TODO: resolve in some other way + Bridge.OnActivity(this, Strings.Emptying_tank); + stop_emptying: //-------------------------------------------------------------------------------------------- State stopEmptying = State.Create("MainSeq : Stop emptying of water tanks") diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index e1b9d0331..ad202db68 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1473,6 +1473,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to remaining time. + /// + internal static string remaining_time { + get { + return ResourceManager.GetString("remaining_time", resourceCulture); + } + } + /// /// Looks up a localized string similar to < &Remove. /// @@ -1554,6 +1563,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to s. + /// + internal static string sec { + get { + return ResourceManager.GetString("sec", resourceCulture); + } + } + /// /// Looks up a localized string similar to Selected results:. /// diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 3d8c7c091..d9924fc82 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -765,4 +765,10 @@ Prüfstand starten + + remaining time + + + s + \ No newline at end of file diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 642b93aee..687f2c34c 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -853,4 +853,10 @@ Starting the system + + remaining time + + + s + \ No newline at end of file diff --git a/TestBenchFramework/UiControls/ProceduresCtrl.cs b/TestBenchFramework/UiControls/ProceduresCtrl.cs index d6ec05f55..ab957d8a3 100644 --- a/TestBenchFramework/UiControls/ProceduresCtrl.cs +++ b/TestBenchFramework/UiControls/ProceduresCtrl.cs @@ -116,7 +116,7 @@ namespace TBF.UiControls public void AddOne() { - /// Find an unused test name + /// Find an unused procedure name string newName; for (int nameId = 1; true; nameId++) { @@ -126,7 +126,7 @@ namespace TBF.UiControls if (notUsed) break; } - base.AddOne(new Entities.Procedure(newName, MyItems.Count)); + base.AddOne(new Entities.Procedure(newName, MyItems.Count + 1)); } public new void RemoveSelected() @@ -187,7 +187,8 @@ namespace TBF.UiControls /// Make a copy of the selected procedure Entities.Procedure newProcedure = selectedProcedure.Clone(); newProcedure.Name = selectedProcedure.Name + Strings.New_name_copy; - newProcedure.CreationUser = Entities.User.CurrentUser.Name; + newProcedure.ItemNr = MyItems.Count; + newProcedure.CreationUser = Entities.User.CurrentUser.Name; newProcedure.CreationTime = DateTime.Now; if ((new ProcedureDlg(newProcedure)).ShowDialog() == DialogResult.OK)