From 1ccdcf9bd2b5a7b08111de37e6feb60f59d8c6d6 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 10 Apr 2017 15:23:37 +0200 Subject: [PATCH] Possibility to reload previous results, MainSeq modified - CreateNewBatchResults() and RestoreBatchResults(), ver. 2.12.538 --- Results/DB.cs | 25 + TestBenchFramework/BenchControl/Events.cs | 7 +- .../BenchControl/Operations/CheckUIOp.cs | 9 +- .../BenchControl/Sequences/MainSeq.cs | 443 ++++++++---------- .../Forms/PreviousResultCtrl.Designer.cs | 248 +++++----- .../Forms/PreviousResultCtrl.cs | 30 +- .../Forms/PreviousResultsDlg.cs | 43 +- TestBenchFramework/MainWnd.cs | 24 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- .../Resources/Strings.Designer.cs | 27 +- TestBenchFramework/Resources/Strings.cs.resx | 12 +- TestBenchFramework/Resources/Strings.de.resx | 4 +- TestBenchFramework/Resources/Strings.resx | 6 +- .../Screens/ResultsTabPageCtrl.Designer.cs | 36 +- .../Screens/ResultsTabPageCtrl.cs | 22 +- TestBenchFramework/UiBridge/Bridge.cs | 2 + TestBenchFramework/UiBridge/Enums.cs | 1 + 17 files changed, 512 insertions(+), 431 deletions(-) diff --git a/Results/DB.cs b/Results/DB.cs index 4593f469a..4ba14057f 100644 --- a/Results/DB.cs +++ b/Results/DB.cs @@ -270,5 +270,30 @@ namespace Results return true; } + + public static Batch LoadBatch(int batchNr) + { + IList batches; + ISession session = DB.CreateSession(); + if (session == null) return null; + + TestDataList = session.QueryOver().List(); + ComponentsList = session.QueryOver().List(); + WaterMeterDataList = session.QueryOver().List(); + + try + { + batches = session.QueryOver() + .Where(x => (x.BatchNr == batchNr)) + .List(); + } + catch (Exception exc) + { + log.FatalFormat("Cannot load batch #{0}: {1}", batchNr, exc.Message); + return null; + } + + return (batches.Count > 0) ? batches[0] : null; + } } } diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs index ed6b9d9c4..b5240f7d2 100644 --- a/TestBenchFramework/BenchControl/Events.cs +++ b/TestBenchFramework/BenchControl/Events.cs @@ -115,6 +115,7 @@ namespace TBF.BenchControl TurnPumpOnOffDone, /// CheckUi events + UiCmdReloadBatch, UiCmdStartTest, UiCmdStartQ1, UiCmdStartQ2, @@ -123,9 +124,9 @@ namespace TBF.BenchControl UiCmdStop, UiCmdPurgeBegin, UiCmdPurgeEnd, - UiCmdEmptyTank1, - UiCmdEmptyTank2, - UiCmdEmptyTank3, + UiCmdDrainTank1, + UiCmdDrainTank2, + UiCmdDrainTank3, UiCmdBreak, UiCmdResetResults, UiCmdAcceptResults, diff --git a/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs b/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs index 41c879532..dfe467071 100644 --- a/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs +++ b/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs @@ -77,7 +77,8 @@ namespace TBF.BenchControl.Operations switch (cmd) { /// Bench Control Panel buttons - case UI2BenchCmd.StartTest: return Event.UiCmdStartTest; + case UI2BenchCmd.ReloadBatch: return Event.UiCmdReloadBatch; + case UI2BenchCmd.StartTest: return Event.UiCmdStartTest; case UI2BenchCmd.StartQ1: return Event.UiCmdStartQ1; case UI2BenchCmd.StartQ2: return Event.UiCmdStartQ2; case UI2BenchCmd.StartQ3: return Event.UiCmdStartQ3; @@ -85,9 +86,9 @@ namespace TBF.BenchControl.Operations case UI2BenchCmd.Stop: return Event.UiCmdStop; case UI2BenchCmd.PurgeBegin: return Event.UiCmdPurgeBegin; case UI2BenchCmd.PurgeEnd: return Event.UiCmdPurgeEnd; - case UI2BenchCmd.DrainTank1: return Event.UiCmdEmptyTank1; - case UI2BenchCmd.DrainTank2: return Event.UiCmdEmptyTank2; - case UI2BenchCmd.DrainTank3: return Event.UiCmdEmptyTank3; + case UI2BenchCmd.DrainTank1: return Event.UiCmdDrainTank1; + case UI2BenchCmd.DrainTank2: return Event.UiCmdDrainTank2; + case UI2BenchCmd.DrainTank3: return Event.UiCmdDrainTank3; case UI2BenchCmd.Break: return Event.UiCmdBreak; case UI2BenchCmd.ResetResults: return Event.UiCmdResetResults; case UI2BenchCmd.AcceptResults: return Event.UiCmdAcceptResults; diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index ac88c8c5e..73ca15f32 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -32,6 +32,7 @@ namespace TBF.BenchControl.Sequences IList simultWithEvacuationParams; + System.Windows.Forms.Form modelessDlg; /// delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList tests, IList multiTestParams); @@ -64,7 +65,7 @@ namespace TBF.BenchControl.Sequences log.Fatal("--------------------------------------"); } } - + /// void CloseIPerlCommForm() { UiBridge.Bridge.OnCloseModelessForm(this, null); @@ -219,106 +220,46 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------------------------------------- select_procedure: - /// Make sure the CycleBeginForm is closed (after an abnormal procedure/test end, etc.) - CloseBeginForm(); - - selection = MakeSelection(MKSelContext.ProcedureNotSelected); - - //-------------------------------- - Bridge.Bench2UI(ButtonsEtc.StopBtnEn); - StateMachine.LoadProcedure(false); - if (StateMachine.Procedure == null) goto select_procedure; + CloseBeginForm(); /// Make sure the CycleBeginForm is closed (after an abnormal end, etc.) + + do + { + selection = MakeSelection(MKSelContext.ProcedureNotSelected); + StateMachine.LoadProcedure(false); + } + while (StateMachine.Procedure == null); /// Make sure a valid procedure is selected /// /// Procedure selected at this point, a new batch was started /// - StateMachine.LoadProcedureParams(StateMachine.Procedure); + StateMachine.LoadProcedureParams(StateMachine.Procedure); - /// - /// Prepare new water meters - /// - foreach (var wm in WaterMeters) wm.ClearData(); /// Clean water meter data + Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Enable STOP button - bool compound = (StateMachine.Procedure.MetersKind == MetersKind.Combined); - bool heatMeters = (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter); - int waterMetersCount = Math.Min(WaterMeters.Count, heatMeters ? Config.Data.HeatMetersCount : (compound ? Config.Data.CompoundWMsCount : Config.Data.WMsCount)); - /// - Results.Entities.WaterMeterData[] waterMeterData = new Results.Entities.WaterMeterData[waterMetersCount]; - /// - int[] waterMeterParts = new int[waterMetersCount]; - for (int wmNr = 0; wmNr < waterMetersCount; wmNr++) + if (selection == Selection.RestoreBatch) { - int ix = compound ? (2 * wmNr) : wmNr; + BatchRslts = RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, /// Original batch number + Program.LocalSettings.BatchNr, /// New batch number + StateMachine.Procedure); + } + else + { + BatchRslts = CreateNewBatchResults(Program.LocalSettings.BatchNr, StateMachine.Procedure); + } + - waterMeterParts[wmNr] = Utils.PartNr(wmNr + 1, compound); - waterMeterData[wmNr] = new Results.Entities.WaterMeterData() - { - ProductName = WaterMeters[ix].ProductName, - Producer = WaterMeters[ix].Producer, - - L = WaterMeters[ix].L, - DN = WaterMeters[ix].DN, - Mounting = WaterMeters[ix].Mounting, - - Q4_Qmax = WaterMeters[ix].Q4_Qmax, - Q3_Qn = WaterMeters[ix].Q3_Qn, - Q2_Qt = WaterMeters[ix].Q2_Qt, - Q1_Qmin = WaterMeters[ix].Q1_Qmin, - - MetrologicalClass = WaterMeters[ix].MetrologicalClass, - TemperatureClass = WaterMeters[ix].TemperatureClass, - PressureLossClass = WaterMeters[ix].PressureLossClass, - MaxAdmissiblePressure = WaterMeters[ix].MaxAdmissiblePressure, - FlowProfileSensitivityClass = WaterMeters[ix].FlowProfileSensitivityClass, - - ApprovalInfo = WaterMeters[ix].ApprovalInfo, - Certificate = WaterMeters[ix].Certificate, - - PulsesPerLtr = WaterMeters[ix].PulsesPerLtr, - - Text1 = WaterMeters[ix].Text1, - Text2 = WaterMeters[ix].Text2, - Text3 = WaterMeters[ix].Text3, - Text4 = WaterMeters[ix].Text4, - Text5 = WaterMeters[ix].Text5, - - Compound = compound, - HeatMeter = heatMeters, - }; - - if (compound) - { - int auxIx = 2 * wmNr + 1; - waterMeterData[wmNr].ProducerAux = WaterMeters[auxIx].Producer; - waterMeterData[wmNr].Q3_Qn_Aux = WaterMeters[auxIx].Q3_Qn; - waterMeterData[wmNr].MetrologicalClassAux = WaterMeters[auxIx].MetrologicalClass; - waterMeterData[wmNr].ApprovalInfoAux = WaterMeters[auxIx].ApprovalInfo; - } - -#if ORACLE_DB - BenchControl.WaterMeters.iPerl.WaterMeter iPerl = WaterMeters[wmNr] as BenchControl.WaterMeters.iPerl.WaterMeter; - if (iPerl != null) - { - waterMeterData[wmNr].WMTypeId = iPerl.WMType_ID; - waterMeterData[wmNr].WMTypeRev = iPerl.WMType_Rev; - } -#endif - } - - /// - /// Prepare empty results - /// - BatchRslts = Results.BatchResults.NewFromProcedure(Program.LocalSettings.BatchNr, - (BenchInfo != null) ? BenchInfo.TestBenchId : 1, - Users.GlobalData.CurrentUser.UserName, Users.GlobalData.CurrentUser.Number, Program.Version, - StateMachine.Procedure, waterMeterData, waterMeterParts); StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime; Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure)); - /// Display 'Cycle Begin Form' - if (OpenCycleBeginForm()) goto stop; + /// + /// Display 'Cycle Begin Form' in case of a normal batch (not a restored batch) + /// + if (selection != Selection.RestoreBatch) + { + if (OpenCycleBeginForm()) goto stop; + } /// Find purge suquences TransitionSequence purgeBegin = null; @@ -335,9 +276,11 @@ namespace TBF.BenchControl.Sequences { goto assume_bench_filled; } - else if (selection == Selection.Cycle && benchFilled) + else if ((selection == Selection.Cycle && benchFilled) || (selection == Selection.RestoreBatch)) { - //-------------------------------- + /// + /// Always ask a question in case of a restored batch + /// State.Create("MainSeq : Answer a question") .AddOperation(new Operations.AskYesNoOp(Strings.Fill_with_water)) .AddOperation(checkUiOp) @@ -417,7 +360,7 @@ namespace TBF.BenchControl.Sequences benchFilled = true; Bridge.Bench2UI(ButtonsEtc.ShowBenchFilled); - if (selection != Selection.PurgeBegin) + if (selection != Selection.PurgeBegin && selection != Selection.RestoreBatch) { goto cycle_or_test_selected; } @@ -1040,33 +983,23 @@ namespace TBF.BenchControl.Sequences } /// - /// Selection done in MakeSelection() + /// Return values of MakeSelection() /// - public enum Selection - { - /// Handled inside MakeSelection() - None, - DrainTank1, - DrainTank2, - DrainTank3, - CloseTank1, - CloseTank2, - CloseTank3, - CameraTest, - - /// Used as return values - Cycle, - RestOfCycle, - Test, - Q1, - Q2, - Q3, - Stop, - PurgeBegin, - PurgeEnd, + public enum Selection + { + PurgeBegin, + PurgeEnd, Break, - SaveResults, - } + Cycle, + RestOfCycle, + Test, + Q1, + Q2, + Q3, + SaveResults, + RestoreBatch, + } + /// /// Idle loop to make a procedure or test selection. @@ -1074,14 +1007,15 @@ namespace TBF.BenchControl.Sequences /// /// Context where MakeSelection() is called /// - /// Selection.Cycle + /// Selection.PurgeBegin + /// Selection.PurgeEnd + /// Selection.Break + /// Selection.Cycle /// Selection.Test /// Selection.Q1 /// Selection.Q2 /// Selection.Q3 - /// Selection.Stop - /// Selection.PurgeBegin - /// Selection.PurgeEnd + /// Selection.SaveResults /// private Selection MakeSelection(MKSelContext context) { @@ -1096,7 +1030,6 @@ namespace TBF.BenchControl.Sequences DoubleBox mass3 = new DoubleBox(); IList e; - Selection selection; while (true) { @@ -1130,7 +1063,7 @@ namespace TBF.BenchControl.Sequences (((StateMachine.Scale2 != null) && (StateMachine.DrainValve2 != null) && !draining2) ? ButtonsEtc.DrainTankBtn2En : 0) | (((StateMachine.Scale3 != null) && (StateMachine.DrainValve3 != null) && !draining3) ? ButtonsEtc.DrainTankBtn3En : 0)); - selection = Selection.None; + State.Create("MainSeq : Select an activity") .AddOperation(checkUiOp) .AddOperation((StateMachine.Scale1 != null) ? StateMachine.Scale1.ReadMassOp(ref mass1) : null) @@ -1141,32 +1074,42 @@ namespace TBF.BenchControl.Sequences do { e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - else if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop; - else if (e.Contains(Event.UiCmdCameraTest)) selection = Selection.CameraTest; - else if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.DrainTank1; - else if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.DrainTank2; - else if (e.Contains(Event.UiCmdEmptyTank3)) selection = Selection.DrainTank3; - else if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val)) selection = Selection.CloseTank1; - else if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val)) selection = Selection.CloseTank2; - else if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val)) selection = Selection.CloseTank3; - else if (e.Contains(Event.UiCmdPurgeBegin)) return Selection.PurgeBegin; /// Value used to branch the code later on - else if (e.Contains(Event.UiCmdPurgeEnd)) return Selection.PurgeEnd; - else if (e.Contains(Event.UiCmdBreak) && context == MKSelContext.InsideProcedure) return Selection.Break; - else if (e.Contains(Event.UiCmdStartTest)) return Selection.Test; - else if (e.Contains(Event.UiCmdStartQ1)) return Selection.Q1; - else if (e.Contains(Event.UiCmdStartQ2)) return Selection.Q2; - else if (e.Contains(Event.UiCmdStartQ3)) return Selection.Q3; - else if (e.Contains(Event.UiCmdStartCycle)) return Selection.Cycle; - else if (e.Contains(Event.UiCmdAcceptResults)) return Selection.SaveResults; - } - while (selection == Selection.None); + + /// Handled inside MakeSelection() inside the selection loop + if (e.Contains(Event.Error)) break; + if (e.Contains(Event.UiCmdStop)) break; + if (e.Contains(Event.UiCmdDrainTank1)) break; + if (e.Contains(Event.UiCmdDrainTank2)) break; + if (e.Contains(Event.UiCmdDrainTank3)) break; + if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val)) break; + if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val)) break; + if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val)) break; - if (selection == Selection.CameraTest) - { - CameraTest(); - } - else if (selection == Selection.Stop) + /// Quit the selection loop and leave MakeSelection() + if (e.Contains(Event.UiCmdBreak) && context == MKSelContext.InsideProcedure) return Selection.Break; + if (e.Contains(Event.UiCmdPurgeBegin)) return Selection.PurgeBegin; + if (e.Contains(Event.UiCmdPurgeEnd)) return Selection.PurgeEnd; + if (e.Contains(Event.UiCmdStartCycle)) return Selection.Cycle; + if (e.Contains(Event.UiCmdStartTest)) return Selection.Test; + if (e.Contains(Event.UiCmdStartQ1)) return Selection.Q1; + if (e.Contains(Event.UiCmdStartQ2)) return Selection.Q2; + if (e.Contains(Event.UiCmdStartQ3)) return Selection.Q3; + if (e.Contains(Event.UiCmdAcceptResults)) return Selection.SaveResults; + if (e.Contains(Event.UiCmdReloadBatch)) return Selection.RestoreBatch; + } + while (true); + + + if (e.Contains(Event.Error)) + { + ///------------------------------------ + Bridge.OnActivity(this, Strings.Error); + ///------------------------------------ + State.Create("MainSeq : ERROR state") + .EnterState(); + while (true) StateMachine.WaitRunDevsRunOps(); /// Endless loop + } + else if (e.Contains(Event.UiCmdStop)) { if (draining1 || draining2 || draining3) { @@ -1182,12 +1125,13 @@ namespace TBF.BenchControl.Sequences while (!e.Contains(Event.ValvesSet)); draining1 = draining2 = draining3 = false; } - selection = Selection.None; } - else if ((selection == Selection.DrainTank1) && !draining1) + else if (e.Contains(Event.UiCmdDrainTank1) && !draining1) { draining1 = true; + ///-------------------------------------------- Bridge.OnActivity(this, Strings.Emptying_tank); + ///-------------------------------------------- Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | (draining2 ? 0 : ButtonsEtc.DrainTankBtn2En) | @@ -1198,10 +1142,12 @@ namespace TBF.BenchControl.Sequences do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); } - else if ((selection == Selection.DrainTank2) && !draining2) + else if (e.Contains(Event.UiCmdDrainTank2) && !draining2) { draining2 = true; + ///-------------------------------------------- Bridge.OnActivity(this, Strings.Emptying_tank); + ///-------------------------------------------- Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | (draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) | @@ -1212,10 +1158,12 @@ namespace TBF.BenchControl.Sequences do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); } - else if ((selection == Selection.DrainTank3) && !draining3) + else if (e.Contains(Event.UiCmdDrainTank3) && !draining3) { draining3 = true; + ///-------------------------------------------- Bridge.OnActivity(this, Strings.Emptying_tank); + ///-------------------------------------------- Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | (draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) | @@ -1226,7 +1174,7 @@ namespace TBF.BenchControl.Sequences do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); } - else if (selection == Selection.CloseTank1) + else if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val)) { State.Create("MainSeq : Close tank 1") .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve1)) @@ -1235,7 +1183,7 @@ namespace TBF.BenchControl.Sequences while (!e.Contains(Event.ValvesSet)); draining1 = false; } - else if (selection == Selection.CloseTank2) + else if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val)) { State.Create("MainSeq : Close tank 2") .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve2)) @@ -1244,7 +1192,7 @@ namespace TBF.BenchControl.Sequences while (!e.Contains(Event.ValvesSet)); draining2 = false; } - else if (selection == Selection.CloseTank3) + else if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val)) { State.Create("MainSeq : Close tank 3") .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve3)) @@ -1254,102 +1202,111 @@ namespace TBF.BenchControl.Sequences draining3 = false; } } - - error: - Bridge.OnActivity(this, Strings.Error); - State.Create("MainSeq : ERROR state") - .EnterState(); - while (true) StateMachine.WaitRunDevsRunOps(); } - /// - /// Perform a camera test - /// - void CameraTest() - { - IList e; - camera_test: - Bridge.OnActivity(this, "Camera test"); - //--------------------------------------------------------- - Bridge.Bench2UI(ButtonsEtc.StartTestBtnsEn | ButtonsEtc.StopBtnEn); - State.Create("MainSeq : 1 = Grab, 2 = Live, 3 = Focus, Stop = Quit camera test") - .AddOperation(checkUiOp) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.UiCmdStop)) return; - if (e.Contains(Event.UiCmdStartQ1)) goto grab; - if (e.Contains(Event.UiCmdStartQ2)) goto live; - if (e.Contains(Event.UiCmdStartQ3)) goto focus; - } - while (true); + /// + /// Create a new empty batch results from the procedure + /// + /// New batch number + /// Selected procedure + /// Created BatchResults + Results.BatchResults CreateNewBatchResults(int newBatchNr, Procedure procedure) + { + /// + /// Prepare new water meters + /// + foreach (var wm in WaterMeters) wm.ClearData(); /// Clean water meter data - grab: - Bridge.Bench2UI(ButtonsEtc.StopBtnEn); - State.Create("MainSeq : Press 'Stop' to continue") - .AddOperation(checkUiOp) - .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].GrabImageOp() : null) - .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].GrabImageOp() : null) - .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].GrabImageOp() : null) - .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].GrabImageOp() : null) - .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].GrabImageOp() : null) - .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].GrabImageOp() : null) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.UiCmdStop)) goto camera_test; - } - while (true); + bool compound = (StateMachine.Procedure.MetersKind == MetersKind.Combined); + bool heatMeters = (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter); + int waterMetersCount = Math.Min(WaterMeters.Count, heatMeters ? Config.Data.HeatMetersCount : (compound ? Config.Data.CompoundWMsCount : Config.Data.WMsCount)); + /// + Results.Entities.WaterMeterData[] waterMeterData = new Results.Entities.WaterMeterData[waterMetersCount]; + /// + int[] waterMeterParts = new int[waterMetersCount]; + for (int wmNr = 0; wmNr < waterMetersCount; wmNr++) + { + int ix = compound ? (2 * wmNr) : wmNr; - live: - Bridge.Bench2UI(ButtonsEtc.StopBtnEn); - State.Create("MainSeq : Press 'Stop' to stop.") - .AddOperation(checkUiOp) - .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].LiveStreamOp(false) : null) - .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].LiveStreamOp(false) : null) - .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].LiveStreamOp(false) : null) - .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].LiveStreamOp(false) : null) - .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].LiveStreamOp(false) : null) - .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].LiveStreamOp(false) : null) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.UiCmdStop)) goto camera_test; - } - while (true); + waterMeterParts[wmNr] = Utils.PartNr(wmNr + 1, compound); + waterMeterData[wmNr] = new Results.Entities.WaterMeterData() + { + ProductName = WaterMeters[ix].ProductName, + Producer = WaterMeters[ix].Producer, - focus: - Bridge.Bench2UI(ButtonsEtc.StopBtnEn); - State.Create("MainSeq : Press 'Stop' to stop.") - .AddOperation(checkUiOp) - .AddOperation((Cameras.Count > 0 && Cameras[0] != null && (Cameras[0].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[0].LiveStreamOp(true) : null) - .AddOperation((Cameras.Count > 1 && Cameras[1] != null && (Cameras[1].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[1].LiveStreamOp(true) : null) - .AddOperation((Cameras.Count > 2 && Cameras[2] != null && (Cameras[2].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[2].LiveStreamOp(true) : null) - .AddOperation((Cameras.Count > 3 && Cameras[3] != null && (Cameras[3].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[3].LiveStreamOp(true) : null) - .AddOperation((Cameras.Count > 4 && Cameras[4] != null && (Cameras[4].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[4].LiveStreamOp(true) : null) - .AddOperation((Cameras.Count > 5 && Cameras[5] != null && (Cameras[5].Cfg.DebugLevel != DebugMode.DetectedOff)) ? Cameras[5].LiveStreamOp(true) : null) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.UiCmdStop)) goto camera_test; - } - while (true); + L = WaterMeters[ix].L, + DN = WaterMeters[ix].DN, + Mounting = WaterMeters[ix].Mounting, - error: - Bridge.OnActivity(this, Strings.Error); - State.Create("MainSeq : ERROR state") - .EnterState(); - while (true) StateMachine.WaitRunDevsRunOps(); - } + Q4_Qmax = WaterMeters[ix].Q4_Qmax, + Q3_Qn = WaterMeters[ix].Q3_Qn, + Q2_Qt = WaterMeters[ix].Q2_Qt, + Q1_Qmin = WaterMeters[ix].Q1_Qmin, + + MetrologicalClass = WaterMeters[ix].MetrologicalClass, + TemperatureClass = WaterMeters[ix].TemperatureClass, + PressureLossClass = WaterMeters[ix].PressureLossClass, + MaxAdmissiblePressure = WaterMeters[ix].MaxAdmissiblePressure, + FlowProfileSensitivityClass = WaterMeters[ix].FlowProfileSensitivityClass, + + ApprovalInfo = WaterMeters[ix].ApprovalInfo, + Certificate = WaterMeters[ix].Certificate, + + PulsesPerLtr = WaterMeters[ix].PulsesPerLtr, + + Text1 = WaterMeters[ix].Text1, + Text2 = WaterMeters[ix].Text2, + Text3 = WaterMeters[ix].Text3, + Text4 = WaterMeters[ix].Text4, + Text5 = WaterMeters[ix].Text5, + + Compound = compound, + HeatMeter = heatMeters, + }; + + if (compound) + { + int auxIx = 2 * wmNr + 1; + waterMeterData[wmNr].ProducerAux = WaterMeters[auxIx].Producer; + waterMeterData[wmNr].Q3_Qn_Aux = WaterMeters[auxIx].Q3_Qn; + waterMeterData[wmNr].MetrologicalClassAux = WaterMeters[auxIx].MetrologicalClass; + waterMeterData[wmNr].ApprovalInfoAux = WaterMeters[auxIx].ApprovalInfo; + } + +#if ORACLE_DB + BenchControl.WaterMeters.iPerl.WaterMeter iPerl = WaterMeters[wmNr] as BenchControl.WaterMeters.iPerl.WaterMeter; + if (iPerl != null) + { + waterMeterData[wmNr].WMTypeId = iPerl.WMType_ID; + waterMeterData[wmNr].WMTypeRev = iPerl.WMType_Rev; + } +#endif + } + + /// Prepare empty results + return Results.BatchResults.NewFromProcedure(newBatchNr, + (BenchInfo != null) ? BenchInfo.TestBenchId : 1, + Users.GlobalData.CurrentUser.UserName, + Users.GlobalData.CurrentUser.Number, + Program.Version, + StateMachine.Procedure, + waterMeterData, + waterMeterParts); + } + + + /// + /// Reload batch results from Results database given the batch number + /// + /// Original batch number + /// New unique batch number + /// Reloaded procedure + /// + Results.BatchResults RestoreBatchResults(int oriBatchNr, int newBatchNr, Procedure procedure) + { + return Results.BatchResults.FromBatch(Results.DB.LoadBatch(oriBatchNr)); + } void CollectSimultSteps() diff --git a/TestBenchFramework/Forms/PreviousResultCtrl.Designer.cs b/TestBenchFramework/Forms/PreviousResultCtrl.Designer.cs index 72964352f..3cdac85ee 100644 --- a/TestBenchFramework/Forms/PreviousResultCtrl.Designer.cs +++ b/TestBenchFramework/Forms/PreviousResultCtrl.Designer.cs @@ -28,135 +28,135 @@ /// private void InitializeComponent() { - this.sendButton = new System.Windows.Forms.Button(); - this.sentCheckBox = new System.Windows.Forms.CheckBox(); - this.failedCountLabel = new System.Windows.Forms.Label(); - this.passedCountLabel = new System.Windows.Forms.Label(); - this.purchaseOrderLabel = new System.Windows.Forms.Label(); - this.procedureLabel = new System.Windows.Forms.Label(); - this.endTimeLabel = new System.Windows.Forms.Label(); - this.startTimeLabel = new System.Windows.Forms.Label(); - this.batchNrLabel = new System.Windows.Forms.Label(); - this.showButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // sendButton - // - this.sendButton.Location = new System.Drawing.Point(832, 2); - this.sendButton.Name = "sendButton"; - this.sendButton.Size = new System.Drawing.Size(104, 23); - this.sendButton.TabIndex = 15; - this.sendButton.Text = "Again"; - this.sendButton.UseVisualStyleBackColor = true; - this.sendButton.Click += new System.EventHandler(this.sendButton_Click); - // - // sentCheckBox - // - this.sentCheckBox.AutoSize = true; - this.sentCheckBox.Location = new System.Drawing.Point(748, 6); - this.sentCheckBox.Name = "sentCheckBox"; - this.sentCheckBox.Size = new System.Drawing.Size(48, 17); - this.sentCheckBox.TabIndex = 14; - this.sentCheckBox.Text = "Sent"; - this.sentCheckBox.UseVisualStyleBackColor = true; - // - // failedCountLabel - // - this.failedCountLabel.AutoSize = true; - this.failedCountLabel.Location = new System.Drawing.Point(681, 7); - this.failedCountLabel.Name = "failedCountLabel"; - this.failedCountLabel.Size = new System.Drawing.Size(48, 13); - this.failedCountLabel.TabIndex = 13; - this.failedCountLabel.Text = "failedCnt"; - // - // passedCountLabel - // - this.passedCountLabel.AutoSize = true; - this.passedCountLabel.Location = new System.Drawing.Point(590, 7); - this.passedCountLabel.Name = "passedCountLabel"; - this.passedCountLabel.Size = new System.Drawing.Size(57, 13); - this.passedCountLabel.TabIndex = 12; - this.passedCountLabel.Text = "passedCnt"; - // - // purchaseOrderLabel - // - this.purchaseOrderLabel.AutoSize = true; - this.purchaseOrderLabel.Location = new System.Drawing.Point(481, 7); - this.purchaseOrderLabel.Name = "purchaseOrderLabel"; - this.purchaseOrderLabel.Size = new System.Drawing.Size(77, 13); - this.purchaseOrderLabel.TabIndex = 11; - this.purchaseOrderLabel.Text = "purchaseOrder"; - // - // procedureLabel - // - this.procedureLabel.AutoSize = true; - this.procedureLabel.Location = new System.Drawing.Point(328, 7); - this.procedureLabel.Name = "procedureLabel"; - this.procedureLabel.Size = new System.Drawing.Size(55, 13); - this.procedureLabel.TabIndex = 10; - this.procedureLabel.Text = "procedure"; - // - // endTimeLabel - // - this.endTimeLabel.AutoSize = true; - this.endTimeLabel.Location = new System.Drawing.Point(185, 7); - this.endTimeLabel.Name = "endTimeLabel"; - this.endTimeLabel.Size = new System.Drawing.Size(48, 13); - this.endTimeLabel.TabIndex = 9; - this.endTimeLabel.Text = "endTime"; - // - // startTimeLabel - // - this.startTimeLabel.AutoSize = true; - this.startTimeLabel.Location = new System.Drawing.Point(54, 7); - this.startTimeLabel.Name = "startTimeLabel"; - this.startTimeLabel.Size = new System.Drawing.Size(50, 13); - this.startTimeLabel.TabIndex = 8; - this.startTimeLabel.Text = "startTime"; - // - // batchNrLabel - // - this.batchNrLabel.AutoSize = true; - this.batchNrLabel.Location = new System.Drawing.Point(3, 7); - this.batchNrLabel.Name = "batchNrLabel"; - this.batchNrLabel.Size = new System.Drawing.Size(24, 13); - this.batchNrLabel.TabIndex = 16; - this.batchNrLabel.Text = "bNr"; - // - // showButton - // - this.showButton.Location = new System.Drawing.Point(939, 2); - this.showButton.Name = "showButton"; - this.showButton.Size = new System.Drawing.Size(104, 23); - this.showButton.TabIndex = 17; - this.showButton.Text = "Show"; - this.showButton.UseVisualStyleBackColor = true; - this.showButton.Click += new System.EventHandler(this.showButton_Click); - // - // PreviousResultCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.showButton); - this.Controls.Add(this.batchNrLabel); - this.Controls.Add(this.sendButton); - this.Controls.Add(this.sentCheckBox); - this.Controls.Add(this.failedCountLabel); - this.Controls.Add(this.passedCountLabel); - this.Controls.Add(this.purchaseOrderLabel); - this.Controls.Add(this.procedureLabel); - this.Controls.Add(this.endTimeLabel); - this.Controls.Add(this.startTimeLabel); - this.Name = "PreviousResultCtrl"; - this.Size = new System.Drawing.Size(1048, 26); - this.ResumeLayout(false); - this.PerformLayout(); + this.sendReloadButton = new System.Windows.Forms.Button(); + this.sentCheckBox = new System.Windows.Forms.CheckBox(); + this.failedCountLabel = new System.Windows.Forms.Label(); + this.passedCountLabel = new System.Windows.Forms.Label(); + this.purchaseOrderLabel = new System.Windows.Forms.Label(); + this.procedureLabel = new System.Windows.Forms.Label(); + this.endTimeLabel = new System.Windows.Forms.Label(); + this.startTimeLabel = new System.Windows.Forms.Label(); + this.batchNrLabel = new System.Windows.Forms.Label(); + this.showButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // sendReloadButton + // + this.sendReloadButton.Location = new System.Drawing.Point(832, 2); + this.sendReloadButton.Name = "sendReloadButton"; + this.sendReloadButton.Size = new System.Drawing.Size(104, 23); + this.sendReloadButton.TabIndex = 15; + this.sendReloadButton.Text = "Again"; + this.sendReloadButton.UseVisualStyleBackColor = true; + this.sendReloadButton.Click += new System.EventHandler(this.sendReloadButton_Click); + // + // sentCheckBox + // + this.sentCheckBox.AutoSize = true; + this.sentCheckBox.Location = new System.Drawing.Point(748, 6); + this.sentCheckBox.Name = "sentCheckBox"; + this.sentCheckBox.Size = new System.Drawing.Size(48, 17); + this.sentCheckBox.TabIndex = 14; + this.sentCheckBox.Text = "Sent"; + this.sentCheckBox.UseVisualStyleBackColor = true; + // + // failedCountLabel + // + this.failedCountLabel.AutoSize = true; + this.failedCountLabel.Location = new System.Drawing.Point(681, 7); + this.failedCountLabel.Name = "failedCountLabel"; + this.failedCountLabel.Size = new System.Drawing.Size(48, 13); + this.failedCountLabel.TabIndex = 13; + this.failedCountLabel.Text = "failedCnt"; + // + // passedCountLabel + // + this.passedCountLabel.AutoSize = true; + this.passedCountLabel.Location = new System.Drawing.Point(590, 7); + this.passedCountLabel.Name = "passedCountLabel"; + this.passedCountLabel.Size = new System.Drawing.Size(57, 13); + this.passedCountLabel.TabIndex = 12; + this.passedCountLabel.Text = "passedCnt"; + // + // purchaseOrderLabel + // + this.purchaseOrderLabel.AutoSize = true; + this.purchaseOrderLabel.Location = new System.Drawing.Point(481, 7); + this.purchaseOrderLabel.Name = "purchaseOrderLabel"; + this.purchaseOrderLabel.Size = new System.Drawing.Size(77, 13); + this.purchaseOrderLabel.TabIndex = 11; + this.purchaseOrderLabel.Text = "purchaseOrder"; + // + // procedureLabel + // + this.procedureLabel.AutoSize = true; + this.procedureLabel.Location = new System.Drawing.Point(328, 7); + this.procedureLabel.Name = "procedureLabel"; + this.procedureLabel.Size = new System.Drawing.Size(55, 13); + this.procedureLabel.TabIndex = 10; + this.procedureLabel.Text = "procedure"; + // + // endTimeLabel + // + this.endTimeLabel.AutoSize = true; + this.endTimeLabel.Location = new System.Drawing.Point(185, 7); + this.endTimeLabel.Name = "endTimeLabel"; + this.endTimeLabel.Size = new System.Drawing.Size(48, 13); + this.endTimeLabel.TabIndex = 9; + this.endTimeLabel.Text = "endTime"; + // + // startTimeLabel + // + this.startTimeLabel.AutoSize = true; + this.startTimeLabel.Location = new System.Drawing.Point(54, 7); + this.startTimeLabel.Name = "startTimeLabel"; + this.startTimeLabel.Size = new System.Drawing.Size(50, 13); + this.startTimeLabel.TabIndex = 8; + this.startTimeLabel.Text = "startTime"; + // + // batchNrLabel + // + this.batchNrLabel.AutoSize = true; + this.batchNrLabel.Location = new System.Drawing.Point(3, 7); + this.batchNrLabel.Name = "batchNrLabel"; + this.batchNrLabel.Size = new System.Drawing.Size(24, 13); + this.batchNrLabel.TabIndex = 16; + this.batchNrLabel.Text = "bNr"; + // + // showButton + // + this.showButton.Location = new System.Drawing.Point(939, 2); + this.showButton.Name = "showButton"; + this.showButton.Size = new System.Drawing.Size(104, 23); + this.showButton.TabIndex = 17; + this.showButton.Text = "Show"; + this.showButton.UseVisualStyleBackColor = true; + this.showButton.Click += new System.EventHandler(this.showButton_Click); + // + // PreviousResultCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.showButton); + this.Controls.Add(this.batchNrLabel); + this.Controls.Add(this.sendReloadButton); + this.Controls.Add(this.sentCheckBox); + this.Controls.Add(this.failedCountLabel); + this.Controls.Add(this.passedCountLabel); + this.Controls.Add(this.purchaseOrderLabel); + this.Controls.Add(this.procedureLabel); + this.Controls.Add(this.endTimeLabel); + this.Controls.Add(this.startTimeLabel); + this.Name = "PreviousResultCtrl"; + this.Size = new System.Drawing.Size(1048, 26); + this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.Button sendButton; + private System.Windows.Forms.Button sendReloadButton; private System.Windows.Forms.CheckBox sentCheckBox; private System.Windows.Forms.Label failedCountLabel; private System.Windows.Forms.Label passedCountLabel; diff --git a/TestBenchFramework/Forms/PreviousResultCtrl.cs b/TestBenchFramework/Forms/PreviousResultCtrl.cs index 289244ce2..16a166d99 100644 --- a/TestBenchFramework/Forms/PreviousResultCtrl.cs +++ b/TestBenchFramework/Forms/PreviousResultCtrl.cs @@ -12,7 +12,8 @@ namespace TBF.Forms { public partial class PreviousResultCtrl : UserControl { - PreviousResultsDlg parent; + readonly PreviousResultsDlg parent; + readonly bool reloadEn; public int BatchNr; public DateTime StarTime; @@ -28,10 +29,12 @@ namespace TBF.Forms InitializeComponent(); } - public PreviousResultCtrl(PreviousResultsDlg parent, int bnr, DateTime s, DateTime e, string proc, string pOrd, int passCnt, int failCnt, bool sent) + public PreviousResultCtrl(PreviousResultsDlg parent, int bnr, DateTime s, DateTime e, string proc, string pOrd, int passCnt, int failCnt, bool sent, bool reloadEn) : this() { this.parent = parent; + this.reloadEn = reloadEn; + BatchNr = bnr; StarTime = s; EndTime = e; @@ -52,17 +55,17 @@ namespace TBF.Forms #if MUNICH sentCheckBox.Text = Strings.Printed; sentCheckBox.Checked = Sent; - sendButton.Enabled = true; /// 'Print again' function always available - sendButton.Text = Strings.Print_again; + sendReloadButton.Enabled = true; /// 'Print again' function always available + sendReloadButton.Text = reloadEn ? Strings.Reload : Strings.Print_again; #elif ORACLE_DB sentCheckBox.Text = Strings.Sent; sentCheckBox.Checked = Sent; - sendButton.Enabled = !Sent; - sendButton.Text = Strings.Again; + sendReloadButton.Enabled = reloadEn || !Sent; + sendReloadButton.Text = reloadEn ? Strings.Reload : Strings.Save_again; #else sentCheckBox.Visible = false; - sendButton.Enabled = false; - sendButton.Visible = false; + sendReloadButton.Enabled = false; + sendReloadButton.Visible = false; #endif showButton.Text = Strings.Show; } @@ -72,16 +75,19 @@ namespace TBF.Forms this.Sent = sent; #if MUNICH sentCheckBox.Checked = sent; - sendButton.Enabled = true; + sendReloadButton.Enabled = true; #elif ORACLE_DB sentCheckBox.Checked = sent; - sendButton.Enabled = !sent; + sendReloadButton.Enabled = !sent; #endif } - private void sendButton_Click(object sender, EventArgs e) + private void sendReloadButton_Click(object sender, EventArgs e) { - parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr)); + if (reloadEn) + parent.OnReload(this, new PreviousResultIdEventArgs(BatchNr)); + else + parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr)); } private void showButton_Click(object sender, EventArgs e) diff --git a/TestBenchFramework/Forms/PreviousResultsDlg.cs b/TestBenchFramework/Forms/PreviousResultsDlg.cs index caba29bb6..ea7031595 100644 --- a/TestBenchFramework/Forms/PreviousResultsDlg.cs +++ b/TestBenchFramework/Forms/PreviousResultsDlg.cs @@ -23,11 +23,13 @@ namespace TBF.Forms ISession session; int currentBatchNr; IList batches; + bool reloadEn; - public PreviousResultsDlg() + public PreviousResultsDlg(bool reloadEn) { InitializeComponent(); + this.reloadEn = reloadEn; currentBatchNr = Program.LocalSettings.BatchNr; SendAgainHandler += delegate(object sndr, PreviousResultIdEventArgs args) @@ -43,6 +45,12 @@ namespace TBF.Forms }; } + public PreviousResultsDlg() + : this(false) + { + } + + private void PreviousResultsDlg_Load(object sender, EventArgs e) { Localize(); @@ -66,6 +74,26 @@ namespace TBF.Forms } + + public void OnReload(object sender, PreviousResultIdEventArgs data) + { + foreach (var batch in batches) + { + if (batch.BatchNr == data.BatchNr) + { + TBF.UiBridge.Bridge.BatchNr = batch.BatchNr; + Program.MainWnd.UpdateProcedure(batch.ProcedureName); + TBF.UiBridge.Bridge.Ui2Bench(TBF.UiBridge.UI2BenchCmd.ReloadBatch); + break; + } + } + + DialogResult = DialogResult.Cancel; + Close(); + } + + + public event EventHandler SendAgainHandler; /// @@ -74,8 +102,14 @@ namespace TBF.Forms public void OnSendAgain(object sender, PreviousResultIdEventArgs data) { if (SendAgainHandler == null) return; - try { SendAgainHandler(sender, data); } - catch (Exception e) { log.Error("SendAgainHandler(...) failed", e); } + try + { + SendAgainHandler(sender, data); + } + catch (Exception e) + { + log.Error("SendAgainHandler(...) failed", e); + } } public void DoSendAgain(object sender, PreviousResultIdEventArgs data) @@ -216,7 +250,8 @@ namespace TBF.Forms b.WaterMeters[0].PurchaseOrder, passedCount, failedCount, - b.RsltsSent)); + b.RsltsSent, + reloadEn)); } ResumeLayout(); diff --git a/TestBenchFramework/MainWnd.cs b/TestBenchFramework/MainWnd.cs index 6a57ba16a..0b9795bfb 100644 --- a/TestBenchFramework/MainWnd.cs +++ b/TestBenchFramework/MainWnd.cs @@ -443,21 +443,27 @@ namespace TBF private void procedureComboBox_SelectedIndexChanged(object sender, EventArgs e) { - ProcedureName = procedureComboBox.Text; + UpdateProcedure(procedureComboBox.Text); + } + + public void UpdateProcedure(string procedureName) + { + procedureComboBox.Text = procedureName; + ProcedureName = procedureName; BenchControlPanel.ReloadTests(); - if (CurrentProcedure != null && CurrentProcedure.Description != null) - { - descriptionLabel.Text = CurrentProcedure.Description; - } + if (CurrentProcedure != null && CurrentProcedure.Description != null) + { + descriptionLabel.Text = CurrentProcedure.Description; + } if (CurrentProcedure != null && testProgressControls != null) { testProgressControls.ProcedureSelectedInUI(this, new UiBridge.ProcedureSelectedEventArgs(CurrentProcedure)); } if (!string.IsNullOrEmpty(ProcedureName)) - { - Program.LocalSettings.LastProcedureName = ProcedureName; - Program.LocalSettings.Save(); - } + { + Program.LocalSettings.LastProcedureName = ProcedureName; + Program.LocalSettings.Save(); + } } private void MainWnd_FormClosing(object sender, FormClosingEventArgs e) diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 7327e0901..b23adcc18 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.12.536.1")] -[assembly: AssemblyFileVersion("2.12.536.1")] +[assembly: AssemblyVersion("2.12.538.1")] +[assembly: AssemblyFileVersion("2.12.538.1")] diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 420f874f8..34b65cb1a 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -150,15 +150,6 @@ namespace TBF.Resources { } } - /// - /// Looks up a localized string similar to Again. - /// - internal static string Again { - get { - return ResourceManager.GetString("Again", resourceCulture); - } - } - /// /// Looks up a localized string similar to Air density [kg/m3]. /// @@ -3228,6 +3219,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Reload. + /// + internal static string Reload { + get { + return ResourceManager.GetString("Reload", resourceCulture); + } + } + /// /// Looks up a localized string similar to remaining time. /// @@ -3390,6 +3390,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Save again. + /// + internal static string Save_again { + get { + return ResourceManager.GetString("Save_again", resourceCulture); + } + } + /// /// Looks up a localized string similar to Save column widths. /// diff --git a/TestBenchFramework/Resources/Strings.cs.resx b/TestBenchFramework/Resources/Strings.cs.resx index 694bdf901..d22e50a29 100644 --- a/TestBenchFramework/Resources/Strings.cs.resx +++ b/TestBenchFramework/Resources/Strings.cs.resx @@ -1164,8 +1164,8 @@ Tisk výsledů vodoměrů - - Znovu + + Uložit znovu Predešlé výsledky @@ -1275,4 +1275,10 @@ Zopakovat - \ No newline at end of file + + Znovu otevřít + + + Zobrazit + + diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 761314640..68ecc9c48 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -1155,8 +1155,8 @@ Wasserzählerergebnisse drucken - - Wieder + + Wieder speichern Vorherige Ergebnisse diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 7d8104c1d..74e4589a7 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1363,8 +1363,8 @@ Print watermeter results - - Again + + Save again Sent @@ -1714,4 +1714,4 @@ Turning direction - \ No newline at end of file + diff --git a/TestBenchFramework/Screens/ResultsTabPageCtrl.Designer.cs b/TestBenchFramework/Screens/ResultsTabPageCtrl.Designer.cs index 642239011..f9813ec82 100644 --- a/TestBenchFramework/Screens/ResultsTabPageCtrl.Designer.cs +++ b/TestBenchFramework/Screens/ResultsTabPageCtrl.Designer.cs @@ -32,8 +32,9 @@ namespace TBF.Screens private void InitializeComponent() { this.splitContainer = new System.Windows.Forms.SplitContainer(); + this.reloadPreviousResultsButton = new System.Windows.Forms.Button(); this.columnWidthsButton = new System.Windows.Forms.Button(); - this.previousResultsButton = new System.Windows.Forms.Button(); + this.showPreviousResultsButton = new System.Windows.Forms.Button(); this.configureButton = new System.Windows.Forms.Button(); this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); @@ -54,8 +55,9 @@ namespace TBF.Screens // splitContainer.Panel1 // this.splitContainer.Panel1.BackColor = System.Drawing.SystemColors.Control; + this.splitContainer.Panel1.Controls.Add(this.reloadPreviousResultsButton); this.splitContainer.Panel1.Controls.Add(this.columnWidthsButton); - this.splitContainer.Panel1.Controls.Add(this.previousResultsButton); + this.splitContainer.Panel1.Controls.Add(this.showPreviousResultsButton); this.splitContainer.Panel1.Controls.Add(this.configureButton); // // splitContainer.Panel2 @@ -65,6 +67,17 @@ namespace TBF.Screens this.splitContainer.SplitterDistance = 42; this.splitContainer.TabIndex = 0; // + // reloadPreviousResultsButton + // + this.reloadPreviousResultsButton.Enabled = false; + this.reloadPreviousResultsButton.Location = new System.Drawing.Point(405, 10); + this.reloadPreviousResultsButton.Name = "reloadPreviousResultsButton"; + this.reloadPreviousResultsButton.Size = new System.Drawing.Size(147, 30); + this.reloadPreviousResultsButton.TabIndex = 3; + this.reloadPreviousResultsButton.Text = "Reload previous results"; + this.reloadPreviousResultsButton.UseVisualStyleBackColor = true; + this.reloadPreviousResultsButton.Click += new System.EventHandler(this.reloadPreviousResultsButton_Click); + // // columnWidthsButton // this.columnWidthsButton.Location = new System.Drawing.Point(126, 10); @@ -75,15 +88,15 @@ namespace TBF.Screens this.columnWidthsButton.UseVisualStyleBackColor = true; this.columnWidthsButton.Click += new System.EventHandler(this.columnWidthsButton_Click); // - // previousResultsButton + // showPreviousResultsButton // - this.previousResultsButton.Location = new System.Drawing.Point(252, 10); - this.previousResultsButton.Name = "previousResultsButton"; - this.previousResultsButton.Size = new System.Drawing.Size(147, 30); - this.previousResultsButton.TabIndex = 2; - this.previousResultsButton.Text = "Previous results"; - this.previousResultsButton.UseVisualStyleBackColor = true; - this.previousResultsButton.Click += new System.EventHandler(this.previousResultsButton_Click); + this.showPreviousResultsButton.Location = new System.Drawing.Point(252, 10); + this.showPreviousResultsButton.Name = "showPreviousResultsButton"; + this.showPreviousResultsButton.Size = new System.Drawing.Size(147, 30); + this.showPreviousResultsButton.TabIndex = 2; + this.showPreviousResultsButton.Text = "Show previous results"; + this.showPreviousResultsButton.UseVisualStyleBackColor = true; + this.showPreviousResultsButton.Click += new System.EventHandler(this.showPreviousResultsButton_Click); // // configureButton // @@ -129,6 +142,7 @@ namespace TBF.Screens private System.Windows.Forms.Button configureButton; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel; private System.Windows.Forms.Button columnWidthsButton; - private System.Windows.Forms.Button previousResultsButton; + private System.Windows.Forms.Button showPreviousResultsButton; + private System.Windows.Forms.Button reloadPreviousResultsButton; } } diff --git a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs index f6d50d259..f2225e761 100644 --- a/TestBenchFramework/Screens/ResultsTabPageCtrl.cs +++ b/TestBenchFramework/Screens/ResultsTabPageCtrl.cs @@ -62,6 +62,14 @@ namespace TBF.Screens else OnTestCompleted(sender, args); }; + + Bridge.ButtonsEtcHandler += delegate(object sndr, ButtonsEtcEventArgs args) + { + if (InvokeRequired) + Invoke(new EventHandler(OnButtonsEtc), sndr, args); + else + OnButtonsEtc(sndr, args); + }; } void OnProcedureSelected(object sender, ProcedureSelectedEventArgs args) @@ -74,12 +82,17 @@ namespace TBF.Screens RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts); } + void OnButtonsEtc(object sender, UiBridge.ButtonsEtcEventArgs args) + { + reloadPreviousResultsButton.Enabled = ((args.Flags & UiBridge.ButtonsEtc.ProcedureCmbBoxEn) != 0); + } + private void ResultsTabPageCtrl_Load(object sender, EventArgs e) { // Localization configureButton.Text = Strings.Configure; columnWidthsButton.Text = Strings.Save_column_widths; - previousResultsButton.Text = Strings.Previous_results; + showPreviousResultsButton.Text = Strings.Previous_results; MetersArrangement = Program.LocalSettings.ResultsConfigMeters; TestsArrangement = Program.LocalSettings.ResultsConfigTests; @@ -143,11 +156,16 @@ namespace TBF.Screens /// /// Clear the results /// - private void previousResultsButton_Click(object sender, EventArgs e) + private void showPreviousResultsButton_Click(object sender, EventArgs e) { new TBF.Forms.PreviousResultsDlg().ShowDialog(); } + private void reloadPreviousResultsButton_Click(object sender, EventArgs e) + { + new TBF.Forms.PreviousResultsDlg(true).ShowDialog(); + } + #region Redraw /// diff --git a/TestBenchFramework/UiBridge/Bridge.cs b/TestBenchFramework/UiBridge/Bridge.cs index 4278b3314..591d91488 100644 --- a/TestBenchFramework/UiBridge/Bridge.cs +++ b/TestBenchFramework/UiBridge/Bridge.cs @@ -16,6 +16,8 @@ namespace TBF.UiBridge public static readonly Queue Ui2MachineQueue; + public static int BatchNr; + public static string SelectedProcedureName { get { return Program.MainWnd.ProcedureName; } diff --git a/TestBenchFramework/UiBridge/Enums.cs b/TestBenchFramework/UiBridge/Enums.cs index a7b665220..bfe0867af 100644 --- a/TestBenchFramework/UiBridge/Enums.cs +++ b/TestBenchFramework/UiBridge/Enums.cs @@ -7,6 +7,7 @@ namespace TBF.UiBridge public enum UI2BenchCmd { None = 0, + ReloadBatch, StartTest, StartQ1, StartQ2,