diff --git a/TODO.txt b/TODO.txt index 301bebc5d..b02a50934 100644 --- a/TODO.txt +++ b/TODO.txt @@ -20,7 +20,6 @@ Stare: - process page je napisana iba pre jeden zdruzeny vodomer - vyber vysledkov na obrazovke - IDC100 kamera: Ako sa vysporiadat so sync. impulzami, casom startu a stopu? -- PID cisla pre kazdu regulacnu cestu zvlast - Ked je WaterMeterStates dialog a dam Stop -> ide do Error - Kvoli FixedStart testu a kameram by mal RegisterReader vracat 'double' (pripadne 'float') namiesto 'int' (???) - 'zamykanie' hydraulickej schemy diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValve.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValve.cs index 379cf20f6..d1e2edfc3 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValve.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValve.cs @@ -50,7 +50,6 @@ namespace TBF.BenchControl.Elde.RegulValve { if (args.Command == CfgChangeCmd.CfgChange) { - RegulValveCfg.PidCoef = tmpcfg.PidCoef; // TODO PID: Remove RegulValveCfg.StableTimeMs = tmpcfg.StableTimeMs; RegulValveCfg.FlowStableSec = tmpcfg.FlowStableSec; } diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfg.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfg.cs index 2f8c5a286..f173acc99 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfg.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfg.cs @@ -17,7 +17,6 @@ namespace TBF.BenchControl.Elde.RegulValve public int Idx1; /// 1..7 public int DacValueClosed; /// 0..1023 public int DacValueOpen; /// 0..1023 - public int PidCoef; /// 1..100 // TODO PID: Remove public int StableTimeMs; /// 200..1500 ms public bool StoredPositionReuse; /// true = store and re-use previous regulation valve positions public int FlowStableSec; /// 0..60 sec @@ -35,7 +34,6 @@ namespace TBF.BenchControl.Elde.RegulValve Idx1 = 1; DacValueClosed = 100; DacValueOpen = 500; - PidCoef = 20; // TODO PID: Remove StableTimeMs = 500; StoredPositionReuse = false; FlowStableSec = 5; @@ -49,13 +47,12 @@ namespace TBF.BenchControl.Elde.RegulValve public string ToString(int i) { - return string.Format("Name={0}, Parent={1}, Idx1={2}, ADC-Closed={3}, ADC-Open={4}, PID={5}, StabTm={6}ms, PosReuse={7}, FlowStable={8}s", + return string.Format("Name={0}, Parent={1}, Idx1={2}, ADC-Closed={3}, ADC-Open={4}, StabTm={5}ms, PosReuse={6}, FlowStable={7}s", Name, (string.IsNullOrEmpty(ParentName) ? "-" : ParentName), Idx1, DacValueClosed, DacValueOpen, - PidCoef, // TODO PID: Remove StableTimeMs, StoredPositionReuse, FlowStableSec); diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.Designer.cs index 6195b608d..ecddfd9ec 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.Designer.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.Designer.cs @@ -39,8 +39,6 @@ this.dacOpenTextBox = new System.Windows.Forms.TextBox(); this.dacOpenLabel = new System.Windows.Forms.Label(); this.parentNameComboBox = new System.Windows.Forms.ComboBox(); - this.pidCoefLabel = new System.Windows.Forms.Label(); - this.pidCoefTextBox = new System.Windows.Forms.TextBox(); this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox(); this.stableTimeTextBox = new System.Windows.Forms.TextBox(); this.stableTimeLabel = new System.Windows.Forms.Label(); @@ -71,7 +69,7 @@ // positionTextBox // this.positionTextBox.Enabled = false; - this.positionTextBox.Location = new System.Drawing.Point(138, 78); + this.positionTextBox.Location = new System.Drawing.Point(138, 89); this.positionTextBox.Name = "positionTextBox"; this.positionTextBox.Size = new System.Drawing.Size(46, 20); this.positionTextBox.TabIndex = 6; @@ -79,7 +77,7 @@ // positionLabel // this.positionLabel.AutoSize = true; - this.positionLabel.Location = new System.Drawing.Point(28, 81); + this.positionLabel.Location = new System.Drawing.Point(28, 92); this.positionLabel.Name = "positionLabel"; this.positionLabel.Size = new System.Drawing.Size(18, 13); this.positionLabel.TabIndex = 5; @@ -88,7 +86,7 @@ // parentNameLabel // this.parentNameLabel.AutoSize = true; - this.parentNameLabel.Location = new System.Drawing.Point(28, 57); + this.parentNameLabel.Location = new System.Drawing.Point(28, 68); this.parentNameLabel.Name = "parentNameLabel"; this.parentNameLabel.Size = new System.Drawing.Size(69, 13); this.parentNameLabel.TabIndex = 3; @@ -97,7 +95,7 @@ // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(138, 30); + this.nameTextBox.Location = new System.Drawing.Point(138, 41); this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.TabIndex = 2; @@ -105,7 +103,7 @@ // nameLabel // this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(28, 33); + this.nameLabel.Location = new System.Drawing.Point(28, 44); this.nameLabel.Name = "nameLabel"; this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.TabIndex = 1; @@ -114,7 +112,7 @@ // classNameLabel // this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(135, 9); + this.classNameLabel.Location = new System.Drawing.Point(135, 14); this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Size = new System.Drawing.Size(89, 13); this.classNameLabel.TabIndex = 0; @@ -123,7 +121,7 @@ // dacClosedLabel // this.dacClosedLabel.AutoSize = true; - this.dacClosedLabel.Location = new System.Drawing.Point(28, 104); + this.dacClosedLabel.Location = new System.Drawing.Point(28, 115); this.dacClosedLabel.Name = "dacClosedLabel"; this.dacClosedLabel.Size = new System.Drawing.Size(93, 13); this.dacClosedLabel.TabIndex = 7; @@ -132,7 +130,7 @@ // dacClosedTextBox // this.dacClosedTextBox.Enabled = false; - this.dacClosedTextBox.Location = new System.Drawing.Point(138, 101); + this.dacClosedTextBox.Location = new System.Drawing.Point(138, 112); this.dacClosedTextBox.Name = "dacClosedTextBox"; this.dacClosedTextBox.Size = new System.Drawing.Size(46, 20); this.dacClosedTextBox.TabIndex = 8; @@ -140,7 +138,7 @@ // dacOpenTextBox // this.dacOpenTextBox.Enabled = false; - this.dacOpenTextBox.Location = new System.Drawing.Point(138, 124); + this.dacOpenTextBox.Location = new System.Drawing.Point(138, 135); this.dacOpenTextBox.Name = "dacOpenTextBox"; this.dacOpenTextBox.Size = new System.Drawing.Size(46, 20); this.dacOpenTextBox.TabIndex = 10; @@ -148,7 +146,7 @@ // dacOpenLabel // this.dacOpenLabel.AutoSize = true; - this.dacOpenLabel.Location = new System.Drawing.Point(28, 127); + this.dacOpenLabel.Location = new System.Drawing.Point(28, 138); this.dacOpenLabel.Name = "dacOpenLabel"; this.dacOpenLabel.Size = new System.Drawing.Size(87, 13); this.dacOpenLabel.TabIndex = 9; @@ -158,33 +156,16 @@ // this.parentNameComboBox.Enabled = false; this.parentNameComboBox.FormattingEnabled = true; - this.parentNameComboBox.Location = new System.Drawing.Point(138, 54); + this.parentNameComboBox.Location = new System.Drawing.Point(138, 65); this.parentNameComboBox.Name = "parentNameComboBox"; this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); this.parentNameComboBox.TabIndex = 4; // - // pidCoefLabel - // - this.pidCoefLabel.AutoSize = true; - this.pidCoefLabel.Location = new System.Drawing.Point(28, 150); - this.pidCoefLabel.Name = "pidCoefLabel"; - this.pidCoefLabel.Size = new System.Drawing.Size(78, 13); - this.pidCoefLabel.TabIndex = 11; - this.pidCoefLabel.Text = "PID Coefficient"; - // - // pidCoefTextBox - // - this.pidCoefTextBox.Enabled = false; - this.pidCoefTextBox.Location = new System.Drawing.Point(138, 147); - this.pidCoefTextBox.Name = "pidCoefTextBox"; - this.pidCoefTextBox.Size = new System.Drawing.Size(46, 20); - this.pidCoefTextBox.TabIndex = 12; - // // storedPosReuseCheckBox // this.storedPosReuseCheckBox.AutoSize = true; this.storedPosReuseCheckBox.Enabled = false; - this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 196); + this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 184); this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox"; this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17); this.storedPosReuseCheckBox.TabIndex = 13; @@ -194,7 +175,7 @@ // stableTimeTextBox // this.stableTimeTextBox.Enabled = false; - this.stableTimeTextBox.Location = new System.Drawing.Point(138, 170); + this.stableTimeTextBox.Location = new System.Drawing.Point(138, 158); this.stableTimeTextBox.Name = "stableTimeTextBox"; this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20); this.stableTimeTextBox.TabIndex = 15; @@ -202,7 +183,7 @@ // stableTimeLabel // this.stableTimeLabel.AutoSize = true; - this.stableTimeLabel.Location = new System.Drawing.Point(28, 173); + this.stableTimeLabel.Location = new System.Drawing.Point(28, 161); this.stableTimeLabel.Name = "stableTimeLabel"; this.stableTimeLabel.Size = new System.Drawing.Size(81, 13); this.stableTimeLabel.TabIndex = 14; @@ -211,7 +192,7 @@ // flowStableSecTextBox // this.flowStableSecTextBox.Enabled = false; - this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 219); + this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 207); this.flowStableSecTextBox.Name = "flowStableSecTextBox"; this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20); this.flowStableSecTextBox.TabIndex = 17; @@ -219,7 +200,7 @@ // flowStableSecLabel // this.flowStableSecLabel.AutoSize = true; - this.flowStableSecLabel.Location = new System.Drawing.Point(28, 222); + this.flowStableSecLabel.Location = new System.Drawing.Point(28, 210); this.flowStableSecLabel.Name = "flowStableSecLabel"; this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13); this.flowStableSecLabel.TabIndex = 16; @@ -402,8 +383,6 @@ this.Controls.Add(this.stableTimeTextBox); this.Controls.Add(this.stableTimeLabel); this.Controls.Add(this.storedPosReuseCheckBox); - this.Controls.Add(this.pidCoefTextBox); - this.Controls.Add(this.pidCoefLabel); this.Controls.Add(this.parentNameComboBox); this.Controls.Add(this.dacOpenTextBox); this.Controls.Add(this.dacOpenLabel); @@ -441,8 +420,6 @@ private System.Windows.Forms.TextBox dacOpenTextBox; private System.Windows.Forms.Label dacOpenLabel; private System.Windows.Forms.ComboBox parentNameComboBox; - private System.Windows.Forms.Label pidCoefLabel; - private System.Windows.Forms.TextBox pidCoefTextBox; private System.Windows.Forms.CheckBox storedPosReuseCheckBox; private System.Windows.Forms.TextBox stableTimeTextBox; private System.Windows.Forms.Label stableTimeLabel; diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs index 090d7e7b1..12d68fd3c 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs @@ -72,7 +72,6 @@ namespace TBF.BenchControl.Elde.RegulValve positionTextBox.Text = config.Idx1.ToString(); dacClosedTextBox.Text = config.DacValueClosed.ToString(); dacOpenTextBox.Text = config.DacValueOpen.ToString(); - pidCoefTextBox.Text = config.PidCoef.ToString(); // TODO PID: Remove stableTimeTextBox.Text = config.StableTimeMs.ToString(); storedPosReuseCheckBox.Checked = config.StoredPositionReuse; flowStableSecTextBox.Text = config.FlowStableSec.ToString(); @@ -90,7 +89,6 @@ namespace TBF.BenchControl.Elde.RegulValve positionTextBox.Enabled = true; dacClosedTextBox.Enabled = true; dacOpenTextBox.Enabled = true; - pidCoefTextBox.Enabled = true; stableTimeTextBox.Enabled = true; storedPosReuseCheckBox.Enabled = true; flowStableSecTextBox.Enabled = true; @@ -121,11 +119,6 @@ namespace TBF.BenchControl.Elde.RegulValve flags |= CfgUpdateFlags.Error; message += Environment.NewLine + "'DAC when Open' should be between 0 and 1023"; } - if (!int.TryParse(pidCoefTextBox.Text, out dummy) || dummy < 0 || dummy > 100) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'PID Coefficient' should be between 0 and 100"; - } if (!int.TryParse(stableTimeTextBox.Text, out dummy) || dummy < 200 || dummy > 1500 || (dummy % 50) != 0) { flags |= CfgUpdateFlags.Error; @@ -180,14 +173,6 @@ namespace TBF.BenchControl.Elde.RegulValve flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange); } - // TODO PID: Remove - tmp = int.Parse(pidCoefTextBox.Text); - if (config.PidCoef != tmp) - { - config.PidCoef = tmp; - flags |= CfgUpdateFlags.AnyChange; - } - tmp = int.Parse(stableTimeTextBox.Text); if (config.StableTimeMs != tmp) { diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs index ca90b3c02..bb301a90a 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs @@ -178,9 +178,9 @@ namespace TBF.BenchControl.Elde.RegulValve TestMethods tm = 0; StopDevs sd = 0; - // TODO PID: Replace 'regulValve.RegulValveCfg.PidCoef' by operation parameter 'pidCoef' + // 'regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef' controlBoard.SendCommand(Command.Start, flowMeterNr, controlBoard.Route, int.MaxValue, tm, - 0.0f, regulValve.RegulValveCfg.PidCoef, 0, sd); + 0.0f, (int)pidCoef, 0, sd); } /// Run this operation diff --git a/TestBenchFramework/BenchControl/OutputPath.cs b/TestBenchFramework/BenchControl/OutputPath.cs index e3d288757..3dc75f9a6 100644 --- a/TestBenchFramework/BenchControl/OutputPath.cs +++ b/TestBenchFramework/BenchControl/OutputPath.cs @@ -27,7 +27,6 @@ namespace TBF.BenchControl Name = name; ValvesOpen = new List(); ValvesClose = new List(); - PidCoef = 10.0f; /// TODO PID: remove } /// Constructor from data entity diff --git a/TestBenchFramework/Entities/OutputPath.cs b/TestBenchFramework/Entities/OutputPath.cs index 5545244c2..f3cfa4804 100644 --- a/TestBenchFramework/Entities/OutputPath.cs +++ b/TestBenchFramework/Entities/OutputPath.cs @@ -27,7 +27,6 @@ namespace TBF.Entities public OutputPath() { - PidCoef = 10.0f; /// TODO PID: remove } public OutputPath(string name, int itemNr) diff --git a/TestBenchFramework/Entities/Test.cs b/TestBenchFramework/Entities/Test.cs index 17442498c..36c7bc396 100644 --- a/TestBenchFramework/Entities/Test.cs +++ b/TestBenchFramework/Entities/Test.cs @@ -10,8 +10,10 @@ namespace TBF.Entities { public virtual int Id { get; protected set; } public virtual int ItemNr { get; set; } - public virtual string Name { get; set; } - public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h] + public virtual string Name { get; set; } + public virtual int Part { get; set; } /// Part=0 ... test of all WM-s + /// Part>0 ... part of a set of tests with the same Name: subset of WM-s is given by MetersPath + public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h] public virtual float Qto { get; set; } /// Water flow high limit in [m3/h] public virtual float Volume { get; set; } /// Test volume (target) in [l] public virtual float TstTime { get; set; } /// Test time (estimate) in [s] @@ -55,6 +57,7 @@ namespace TBF.Entities { Test result = new Test(Name, ItemNr, Procedure); + result.Part = Part; result.Qfrom = Qfrom; result.Qto = Qto; result.Volume = Volume; diff --git a/TestBenchFramework/Entities/TestResult.cs b/TestBenchFramework/Entities/TestResult.cs index 38e3fb862..34a83baf1 100644 --- a/TestBenchFramework/Entities/TestResult.cs +++ b/TestBenchFramework/Entities/TestResult.cs @@ -16,6 +16,7 @@ namespace TBF.Entities /// Values copied from the test (Entities.Test) public virtual int TestId { get; set; } /// Test entity ID to distinguish between tests with the same name public virtual string TestName { get; set; } + public virtual int Part { get; set; } public virtual bool DoNotEvaluate { get; set; } /// Not mapped to the database public virtual bool DoNotPublish { get; set; } /// Not mapped to the database public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h] @@ -130,6 +131,7 @@ namespace TBF.Entities /// Copy test parameters from Entities.Test object TestId = test.Id; TestName = test.Name; + Part = test.Part; Qfrom = test.Qfrom; Qto = test.Qto; Volume = test.Volume; diff --git a/TestBenchFramework/Mappings/OutputPathMap.cs b/TestBenchFramework/Mappings/OutputPathMap.cs index 78f1c99f2..793ab6c87 100644 --- a/TestBenchFramework/Mappings/OutputPathMap.cs +++ b/TestBenchFramework/Mappings/OutputPathMap.cs @@ -14,7 +14,7 @@ namespace TBF.Mappings Map(x => x.Qto); Map(x => x.RegulValve); Map(x => x.FlowMeter); - //Map(x => x.PID); /// TODO PID: enable + Map(x => x.PidCoef); Map(x => x.StartValve); Map(x => x.Diverter); Map(x => x.TempDiv); diff --git a/TestBenchFramework/Mappings/TestMap.cs b/TestBenchFramework/Mappings/TestMap.cs index 2cea9eb45..608153e81 100644 --- a/TestBenchFramework/Mappings/TestMap.cs +++ b/TestBenchFramework/Mappings/TestMap.cs @@ -10,6 +10,7 @@ namespace TBF.Mappings Id(x => x.Id); Map(x => x.ItemNr); Map(x => x.Name); + Map(x => x.Part); Map(x => x.Qfrom); Map(x => x.Qto); Map(x => x.Volume); diff --git a/TestBenchFramework/Mappings/TestResultMap.cs b/TestBenchFramework/Mappings/TestResultMap.cs index cc7025fa1..3398b27d2 100644 --- a/TestBenchFramework/Mappings/TestResultMap.cs +++ b/TestBenchFramework/Mappings/TestResultMap.cs @@ -19,6 +19,7 @@ namespace TBF.Mappings Map(x => x.TestId); Map(x => x.TestName); + Map(x => x.Part); Map(x => x.Qfrom); Map(x => x.Qto); Map(x => x.Volume); diff --git a/TestBenchFramework/ProcedureDlg.cs b/TestBenchFramework/ProcedureDlg.cs index 595af508b..37b9cc3ab 100644 --- a/TestBenchFramework/ProcedureDlg.cs +++ b/TestBenchFramework/ProcedureDlg.cs @@ -330,38 +330,137 @@ namespace TBF #region Metrology12 and Process - Control[] metrology1Editors; - Control[] metrology2Editors; + void PrepareMetrology12AndProcessTabs() + { + PrepareMetrology1Tab(); + PrepareMetrology2Tab(); + PrepareProcess(); + } + + Control[] metrology1Editors; + + public enum MtrlgyClmn + { + Name, + Part, + Qfrom, + Qto, + Volume, + TestTime, + Repeats, + Emptying, + Time2Mass, + Method, + MtrlgyClmnCount + } + + void PrepareMetrology1Tab() + { + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_chdr, Width = 70 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Part, Width = 40 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_from_m3h, Width = 80 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_to_m3h, Width = 80 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Volume_ltr_chdr, Width = 70 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_time_s_chdr, Width = 70 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Repeats_nr_chdr, Width = 80 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Emptying_chdr, Width = 60 }); + //metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Zeroing_chdr, Width = 50 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Time2MassMsrmt_chdr, Width = 70 }); + metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Method_chdr, Width = 150 }); + + ComboBox yesNo1CBox = new ComboBox(); /// control for Emptying + yesNo1CBox.Items.Add(Strings.yes); + yesNo1CBox.Items.Add(Strings.no); + + methodCBox = new ComboBox(); + foreach (var m in TestMethods) methodCBox.Items.Add(m.Cfg.Name); + + metrology1Editors = new Control[] + { + new TextBox(), /// Name + new TextBox(), /// Part + new TextBox(), /// Qfrom + new TextBox(), /// Qto + new TextBox(), /// Volume + new TextBox(), /// Test time + new TextBox(), /// Repeats # + yesNo1CBox, /// Emptying + new TextBox(), /// Time2MassMsrmt + methodCBox, /// Method + }; + + foreach (var ctrl in metrology1Editors) + { + metrology1TabPage.Controls.Add(ctrl); + } + } + + public enum Mtrlgy2Clmn + { + Name, + Part, + Qfrom, + Qto, + ErrLimLo, + ErrLimHi, + Filter, + Mtrlgy2ClmnCount + } + + Control[] metrology2Editors; + + void PrepareMetrology2Tab() + { + metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_chdr, Width = 70 }); + metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Part, Width = 40 }); + metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_from_m3h, Width = 80 }); + metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_to_m3h, Width = 80 }); + metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_limit_neg_pct_chdr, Width = 100 }); + metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_limit_pos_pct_chdr, Width = 100 }); + metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = "Filter", Width = 80 }); /// Strings.Tol_red_pct_chdr + //metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Red_type_chdr, Width = 80 }); + //metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_cor_neg_pct_chdr, Width = 90 }); + //metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_cor_pos_pct_chdr, Width = 90 }); + + metrology2Editors = new Control[] + { + new TextBox(), /// Name + new TextBox(), /// Part + new TextBox(), /// Qfrom + new TextBox(), /// Qto + new TextBox(), /// Err.Lim. - + new TextBox(), /// Err.Lim. + + new TextBox(), /// Filter + }; + + foreach (var ctrl in metrology2Editors) + { + metrology2TabPage.Controls.Add(ctrl); + } + } + + public enum ProcessClmn + { + Name, + Part, + Qfrom, + Qto, + Feeding, + Bench, + Output, + Sensor, + TrnStart, + TrnStop, + ProcessClmnCount + } + Control[] processEditors; - void PrepareMetrology12AndProcessTabs() + void PrepareProcess() { - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_chdr, Width = 70 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_from_m3h, Width = 80 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_to_m3h, Width = 80 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Volume_ltr_chdr, Width = 70 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_time_s_chdr, Width = 70 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Repeats_nr_chdr, Width = 80 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Emptying_chdr, Width = 60 }); - //metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Zeroing_chdr, Width = 50 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Time2MassMsrmt_chdr, Width = 70 }); - metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Method_chdr, Width = 150 }); - //metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_set_method_chdr, Width = 100 }); - //metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Method1_chdr, Width = 100 }); - //metrology1ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Method2_chdr, Width = 110 }); - - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_chdr, Width = 70 }); - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_from_m3h, Width = 80 }); - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_to_m3h, Width = 80 }); - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_limit_neg_pct_chdr, Width = 100 }); - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_limit_pos_pct_chdr, Width = 100 }); - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = "Filter", Width = 80 }); /// Strings.Tol_red_pct_chdr - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Red_type_chdr, Width = 80 }); - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_cor_neg_pct_chdr, Width = 90 }); - metrology2ListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Err_cor_pos_pct_chdr, Width = 90 }); - processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Test_chdr, Width = 70 }); - processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_from_m3h, Width = 80 }); + processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Part, Width = 40 }); + processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_from_m3h, Width = 80 }); processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Q_to_m3h, Width = 80 }); processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Feeding_chdr, Width = 90 }); processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.Bench_chdr, Width = 90 }); @@ -370,76 +469,36 @@ namespace TBF processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.TransitionStart_chdr, Width = 100 }); processListViewEx.Columns.Add(new ColumnHeader { Text = Strings.TransitionEnd_chdr, Width = 100 }); - ComboBox yesNo1CBox = new ComboBox(); /// control for Emptying - yesNo1CBox.Items.Add(Strings.yes); - yesNo1CBox.Items.Add(Strings.no); - - ComboBox yesNo2CBox = new ComboBox(); /// control for Zeroing - yesNo2CBox.Items.Add(Strings.yes); - yesNo2CBox.Items.Add(Strings.no); - - methodCBox = new ComboBox(); - foreach (var m in TestMethods) methodCBox.Items.Add(m.Cfg.Name); - - //ComboBox qmethod = new ComboBox(); - //for (Entities.QSetMethod method = 0; method < Entities.QSetMethod.Count; method++) qmethod.Items.Add(method.ToString()); - //ComboBox method1 = new ComboBox(); - //for (Entities.TestMethod method = 0; method < Entities.TestMethod.Count; method++) method1.Items.Add(method.ToString()); - //ComboBox method2 = new ComboBox(); - //for (Entities.TestMethod2 method = 0; method < Entities.TestMethod2.Count; method++) method2.Items.Add(method.ToString()); - - metrology1Editors = new Control[] + processEditors = new Control[] { - new TextBox(), /// 0 test name - new TextBox(), /// 1 Qfrom - new TextBox(), /// 2 Qto - new TextBox(), /// 3 Volume - new TextBox(), /// 4 Test time - new TextBox(), /// 5 Repeats # - yesNo1CBox, /// 6 Emptying - new TextBox(), /// 7 Time2MassMsrmt - methodCBox, + new TextBox(), /// Name + new TextBox(), /// Part + new TextBox(), /// Qfrom + new TextBox(), /// Qto + new ComboBox(), /// Feeding + new ComboBox(), /// Table + new ComboBox(), /// Output + new ComboBox(), /// Meters + new ComboBox(), /// TransitionStart + new ComboBox(), /// TransitionEnd }; - metrology2Editors = new Control[] - { - new TextBox(), /// 0 test name - new TextBox(), /// 1 Qfrom - new TextBox(), /// 2 Qto - new TextBox(), /// 3 Err.Lim. - - new TextBox(), /// 4 Err.Lim. + - new TextBox(), /// 5 Tol.Red. - new ComboBox(), /// 6 Red.Type - }; + foreach (var path in feedingPaths) ((ComboBox)processEditors[(int)ProcessClmn.Feeding]).Items.Add(path.Name); + foreach (var path in benchPaths) ((ComboBox)processEditors[(int)ProcessClmn.Bench]).Items.Add(path.Name); + foreach (var path in outputPaths) ((ComboBox)processEditors[(int)ProcessClmn.Output]).Items.Add(path.Name); + foreach (var path in metersPaths) ((ComboBox)processEditors[(int)ProcessClmn.Sensor]).Items.Add(path.Name); - processEditors = new Control[] - { - new TextBox(), /// 0 test name - new TextBox(), /// 1 Qfrom - new TextBox(), /// 2 Qto - new ComboBox(), /// 3 Feeding - new ComboBox(), /// 4 Table - new ComboBox(), /// 5 Output - new ComboBox(), /// 6 Meters - new ComboBox(), /// 7 TransitionStart - new ComboBox(), /// 8 TransitionEnd - }; - - foreach (var ctrl in metrology1Editors) metrology1TabPage.Controls.Add(ctrl); - foreach (var ctrl in metrology2Editors) metrology2TabPage.Controls.Add(ctrl); - foreach (var ctrl in processEditors) processTabPage.Controls.Add(ctrl); - - foreach (var path in feedingPaths) ((ComboBox)processEditors[3]).Items.Add(path.Name); - foreach (var path in benchPaths) ((ComboBox)processEditors[4]).Items.Add(path.Name); - foreach (var path in outputPaths) ((ComboBox)processEditors[5]).Items.Add(path.Name); - foreach (var path in metersPaths) ((ComboBox)processEditors[6]).Items.Add(path.Name); - - ((ComboBox)processEditors[7]).Items.Add("---"); - ((ComboBox)processEditors[8]).Items.Add("---"); + ((ComboBox)processEditors[(int)ProcessClmn.TrnStart]).Items.Add("---"); + ((ComboBox)processEditors[(int)ProcessClmn.TrnStop]).Items.Add("---"); foreach (var trans in transitionSequences) { - ((ComboBox)processEditors[7]).Items.Add(trans.Name); - ((ComboBox)processEditors[8]).Items.Add(trans.Name); + ((ComboBox)processEditors[(int)ProcessClmn.TrnStart]).Items.Add(trans.Name); + ((ComboBox)processEditors[(int)ProcessClmn.TrnStop]).Items.Add(trans.Name); + } + + foreach (var ctrl in processEditors) + { + processTabPage.Controls.Add(ctrl); } } @@ -455,43 +514,61 @@ namespace TBF void AddToMetrology12AndProcessTab(Test test) { + /// + /// Common subitems + /// ListViewItem lviMetrlg1 = new ListViewItem(test.Name); /// - ListViewItem lviMetrlg2 = new ListViewItem(test.Name); /// SubItem 0 + ListViewItem lviMetrlg2 = new ListViewItem(test.Name); /// Name ListViewItem lviProcess = new ListViewItem(test.Name); /// lviMetrlg1.Tag = test; lviMetrlg2.Tag = test; lviProcess.Tag = test; + lviMetrlg1.SubItems.Add((test.Part == 0) ? "-" : test.Part.ToString()); /// + lviMetrlg2.SubItems.Add((test.Part == 0) ? "-" : test.Part.ToString()); /// Part + lviProcess.SubItems.Add((test.Part == 0) ? "-" : test.Part.ToString()); /// + lviMetrlg1.SubItems.Add(test.Qfrom.ToString()); /// - lviMetrlg2.SubItems.Add(test.Qfrom.ToString()); /// SubItem 1 + lviMetrlg2.SubItems.Add(test.Qfrom.ToString()); /// Q_from lviProcess.SubItems.Add(test.Qfrom.ToString()); /// lviMetrlg1.SubItems.Add(test.Qto.ToString()); /// - lviMetrlg2.SubItems.Add(test.Qto.ToString()); /// SubItem 2 + lviMetrlg2.SubItems.Add(test.Qto.ToString()); /// Q_to lviProcess.SubItems.Add(test.Qto.ToString()); /// - lviMetrlg1.SubItems.Add(test.Volume.ToString()); /// SubItem 3 - lviMetrlg1.SubItems.Add(test.TstTime.ToString()); /// SubItem 4 - lviMetrlg1.SubItems.Add(test.Repeats.ToString()); /// SubItem 5 - lviMetrlg1.SubItems.Add(test.Emptying ? Strings.yes : Strings.no); /// SubItem 6 - //lviMetrlg1.SubItems.Add(test.Zeroing ? Strings.yes : Strings.no); /// SubItem 7 - lviMetrlg1.SubItems.Add(test.Time2MassMsrmt.ToString()); /// SubItem 7 - lviMetrlg1.SubItems.Add((test.Method != null) ? test.Method.ToString() : string.Empty); /// SubItem 8 + /// + /// Metrology 1 subitems Volume, ... + /// + lviMetrlg1.SubItems.Add(test.Volume.ToString()); + lviMetrlg1.SubItems.Add(test.TstTime.ToString()); + lviMetrlg1.SubItems.Add(test.Repeats.ToString()); + lviMetrlg1.SubItems.Add(test.Emptying ? Strings.yes : Strings.no); + //lviMetrlg1.SubItems.Add(test.Zeroing ? Strings.yes : Strings.no); + lviMetrlg1.SubItems.Add(test.Time2MassMsrmt.ToString()); + lviMetrlg1.SubItems.Add((test.Method != null) ? test.Method.ToString() : string.Empty); - lviMetrlg2.SubItems.Add(test.ErrLimLo.ToString()); /// SubItem 3 - lviMetrlg2.SubItems.Add(test.ErrLimHi.ToString()); /// SubItem 4 - lviMetrlg2.SubItems.Add(test.TolerRed.ToString()); /// SubItem 5 - lviMetrlg2.SubItems.Add(test.RedType.ToString()); /// SubItem 6 + metrology1ListViewEx.Items.Add(lviMetrlg1); - lviProcess.SubItems.Add(test.FeedingPath); /// SubItem 3 - lviProcess.SubItems.Add(test.BenchPath); /// SubItem 4 - lviProcess.SubItems.Add(test.OutputPath); /// SubItem 5 - lviProcess.SubItems.Add(test.MetersPath); /// SubItem 6 - lviProcess.SubItems.Add(string.IsNullOrEmpty(test.TransitionStart) ? "---" : test.TransitionStart); /// SubItem 7 - lviProcess.SubItems.Add(string.IsNullOrEmpty(test.TransitionEnd) ? "---" : test.TransitionEnd); /// SubItem 8 + /// + /// Metrology 2 subitems ErrLimLo, ... + /// + lviMetrlg2.SubItems.Add(test.ErrLimLo.ToString()); + lviMetrlg2.SubItems.Add(test.ErrLimHi.ToString()); + lviMetrlg2.SubItems.Add(test.TolerRed.ToString()); + lviMetrlg2.SubItems.Add(test.RedType.ToString()); + + metrology2ListViewEx.Items.Add(lviMetrlg2); + + /// + /// Process subitems FeedingPath, ... + /// + lviProcess.SubItems.Add(test.FeedingPath); + lviProcess.SubItems.Add(test.BenchPath); + lviProcess.SubItems.Add(test.OutputPath); + lviProcess.SubItems.Add(test.MetersPath); + lviProcess.SubItems.Add(string.IsNullOrEmpty(test.TransitionStart) ? "---" : test.TransitionStart); + lviProcess.SubItems.Add(string.IsNullOrEmpty(test.TransitionEnd) ? "---" : test.TransitionEnd); - metrology1ListViewEx.Items.Add(lviMetrlg1); - metrology2ListViewEx.Items.Add(lviMetrlg2); processListViewEx.Items.Add(lviProcess); } @@ -501,41 +578,36 @@ namespace TBF { ListViewItem lvi = metrology1ListViewEx.Items[i]; Entities.Test entity = (Entities.Test)lvi.Tag; + entity.Name = lvi.Text; - float Qfrom; - bool allOk = Utils.TryParseUFloat(lvi.SubItems[1].Text, out Qfrom); - entity.Qfrom = Qfrom; - - float Qto; - allOk &= Utils.TryParseUFloat(lvi.SubItems[2].Text, out Qto); - entity.Qto = Qto; - - float volume; - allOk &= Utils.TryParseUFloat(lvi.SubItems[3].Text, out volume); - entity.Volume = volume; - - float testTime; - allOk &= Utils.TryParseUFloat(lvi.SubItems[4].Text, out testTime); - entity.TstTime = testTime; - - int repeats; - allOk &= int.TryParse(lvi.SubItems[5].Text, out repeats); - entity.Repeats = repeats; - - if (lvi.SubItems[6].Text.Equals(Strings.yes)) entity.Emptying = true; - else if (lvi.SubItems[6].Text.Equals(Strings.no)) entity.Emptying = false; - - //if (lvi.SubItems[7].Text.Equals(Strings.yes)) entity.Zeroing = true; - //else if (lvi.SubItems[7].Text.Equals(Strings.no)) entity.Zeroing = false; - - int time2MassMsrmt; - allOk &= int.TryParse(lvi.SubItems[7].Text, out time2MassMsrmt); - entity.Time2MassMsrmt = time2MassMsrmt; - - if (methodCBox.Items.Contains(lvi.SubItems[8].Text)) + int part = entity.Part; + if (lvi.SubItems[(int)MtrlgyClmn.Part].Text.Equals("-")) { - entity.Method = lvi.SubItems[8].Text; + entity.Part = 0; + } + else if (int.TryParse(lvi.SubItems[(int)MtrlgyClmn.Part].Text, out part)) + { + entity.Part = part; + } + + float tmp; + if (Utils.TryParseUFloat(lvi.SubItems[(int)MtrlgyClmn.Qfrom].Text, out tmp)) entity.Qfrom = tmp; + if (Utils.TryParseUFloat(lvi.SubItems[(int)MtrlgyClmn.Qto].Text, out tmp)) entity.Qto = tmp; + if (Utils.TryParseUFloat(lvi.SubItems[(int)MtrlgyClmn.Volume].Text, out tmp)) entity.Volume = tmp; + if (Utils.TryParseUFloat(lvi.SubItems[(int)MtrlgyClmn.TestTime].Text,out tmp)) entity.TstTime = tmp; + + int itmp; + if (int.TryParse(lvi.SubItems[(int)MtrlgyClmn.Repeats].Text, out itmp)) entity.Repeats = itmp; + if (int.TryParse(lvi.SubItems[(int)MtrlgyClmn.Time2Mass].Text, out itmp)) entity.Time2MassMsrmt = itmp; + + if (lvi.SubItems[(int)MtrlgyClmn.Emptying].Text.Equals(Strings.yes)) entity.Emptying = true; + else if (lvi.SubItems[(int)MtrlgyClmn.Emptying].Text.Equals(Strings.no)) entity.Emptying = false; + + + if (methodCBox.Items.Contains(lvi.SubItems[(int)MtrlgyClmn.Method].Text)) + { + entity.Method = lvi.SubItems[(int)MtrlgyClmn.Method].Text; } } } @@ -546,27 +618,23 @@ namespace TBF { ListViewItem lvi = metrology2ListViewEx.Items[i]; Entities.Test entity = (Entities.Test)lvi.Tag; + entity.Name = lvi.Text; - float Qfrom; - bool allOk = Utils.TryParseUFloat(lvi.SubItems[1].Text, out Qfrom); - entity.Qfrom = Qfrom; + int part = entity.Part; + if (lvi.SubItems[(int)MtrlgyClmn.Part].Text.Equals("-")) + { + entity.Part = 0; + } + else if (int.TryParse(lvi.SubItems[(int)MtrlgyClmn.Part].Text, out part)) + { + entity.Part = part; + } - float Qto; - allOk &= Utils.TryParseUFloat(lvi.SubItems[2].Text, out Qto); - entity.Qto = Qto; - - float errLimLo; - allOk &= Utils.TryParseSFloat(lvi.SubItems[3].Text, out errLimLo); - entity.ErrLimLo = errLimLo; - - float errLimHi; - allOk &= Utils.TryParseSFloat(lvi.SubItems[4].Text, out errLimHi); - entity.ErrLimHi = errLimHi; - - float filter; - allOk &= Utils.TryParseUFloat(lvi.SubItems[5].Text, out filter); - entity.TolerRed = (double)filter; + float tmp; + if (Utils.TryParseSFloat(lvi.SubItems[(int)Mtrlgy2Clmn.ErrLimLo].Text, out tmp)) entity.ErrLimLo = tmp; + if (Utils.TryParseSFloat(lvi.SubItems[(int)Mtrlgy2Clmn.ErrLimHi].Text, out tmp)) entity.ErrLimHi = tmp; + if (Utils.TryParseUFloat(lvi.SubItems[(int)Mtrlgy2Clmn.Filter].Text, out tmp)) entity.TolerRed = (double)tmp; } } @@ -576,40 +644,89 @@ namespace TBF { ListViewItem lvi = processListViewEx.Items[i]; Entities.Test entity = (Entities.Test)lvi.Tag; + entity.Name = lvi.Text; - float Qfrom; - bool allOk = Utils.TryParseUFloat(lvi.SubItems[1].Text, out Qfrom); - entity.Qfrom = Qfrom; + int part = entity.Part; + if (lvi.SubItems[(int)MtrlgyClmn.Part].Text.Equals("-")) + { + entity.Part = 0; + } + else if (int.TryParse(lvi.SubItems[(int)MtrlgyClmn.Part].Text, out part)) + { + entity.Part = part; + } - float Qto; - allOk &= Utils.TryParseUFloat(lvi.SubItems[2].Text, out Qto); - entity.Qto = Qto; - - if ((processEditors[3] as ComboBox).Items.Contains(lvi.SubItems[3].Text)) entity.FeedingPath= lvi.SubItems[3].Text; - if ((processEditors[4] as ComboBox).Items.Contains(lvi.SubItems[4].Text)) entity.BenchPath = lvi.SubItems[4].Text; - if ((processEditors[5] as ComboBox).Items.Contains(lvi.SubItems[5].Text)) entity.OutputPath = lvi.SubItems[5].Text; - if ((processEditors[6] as ComboBox).Items.Contains(lvi.SubItems[6].Text)) entity.MetersPath = lvi.SubItems[6].Text; - if ((processEditors[7] as ComboBox).Items.Contains(lvi.SubItems[7].Text)) + if ((processEditors[(int)ProcessClmn.Feeding] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.Feeding].Text)) + { + entity.FeedingPath = lvi.SubItems[(int)ProcessClmn.Feeding].Text; + } + if ((processEditors[(int)ProcessClmn.Bench] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.Bench].Text)) + { + entity.BenchPath = lvi.SubItems[(int)ProcessClmn.Bench].Text; + } + if ((processEditors[(int)ProcessClmn.Output] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.Output].Text)) + { + entity.OutputPath = lvi.SubItems[(int)ProcessClmn.Output].Text; + } + if ((processEditors[(int)ProcessClmn.Sensor] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.Sensor].Text)) + { + entity.MetersPath = lvi.SubItems[(int)ProcessClmn.Sensor].Text; + } + if ((processEditors[(int)ProcessClmn.TrnStart] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.TrnStart].Text)) { - entity.TransitionStart = lvi.SubItems[7].Text.Equals("---") ? string.Empty : lvi.SubItems[7].Text; + entity.TransitionStart = lvi.SubItems[(int)ProcessClmn.TrnStart].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)ProcessClmn.TrnStart].Text; } - if ((processEditors[8] as ComboBox).Items.Contains(lvi.SubItems[8].Text)) + if ((processEditors[(int)ProcessClmn.TrnStop] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.TrnStop].Text)) { - entity.TransitionEnd = lvi.SubItems[8].Text.Equals("---") ? string.Empty : lvi.SubItems[8].Text; + entity.TransitionEnd = lvi.SubItems[(int)ProcessClmn.TrnStop].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)ProcessClmn.TrnStop].Text; } } } private void metrology1ListViewEx_SubItemClicked(object sender, SubItemEventArgs e) { - if (!unlocked || e.SubItem >= metrology1Editors.Length) return; - metrology1ListViewEx.StartEditing(metrology1Editors[e.SubItem], e.Item, e.SubItem); + if (unlocked && (e.SubItem < (int)MtrlgyClmn.MtrlgyClmnCount)) + { + metrology1ListViewEx.StartEditing(metrology1Editors[e.SubItem], e.Item, e.SubItem); + } } private void metrology1ListViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) { - if (e.SubItem != 1 && e.SubItem != 2 && e.SubItem != 3 && e.SubItem != 4) return; + int dummy; + if (e.SubItem == (int)MtrlgyClmn.Part) + { + if (e.DisplayText.Equals("-")) return; /// OK + if (!int.TryParse(e.DisplayText, out dummy) || dummy < 1 || dummy > 3) + { + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + return; /// NOK + } + } + + if ((e.SubItem == (int)MtrlgyClmn.Repeats) && !int.TryParse(e.DisplayText, out dummy)) + { + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + return; + } + + if ((e.SubItem == (int)MtrlgyClmn.Emptying) && !(processEditors[(int)MtrlgyClmn.Emptying] as ComboBox).Items.Contains(e.DisplayText)) + { + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + return; + } + + if ((e.SubItem != (int)MtrlgyClmn.Qfrom) && + (e.SubItem != (int)MtrlgyClmn.Qto) && + (e.SubItem != (int)MtrlgyClmn.Volume) && + (e.SubItem != (int)MtrlgyClmn.TestTime)) + { + return; + } float Qfrom = 1.0f; float Qto = 1.0f; @@ -620,28 +737,28 @@ namespace TBF bool calculateTime = false; bool allOk = true; - if (e.SubItem == 1 && Utils.TryParseUFloat(e.DisplayText, out Qfrom)) + if ((e.SubItem == (int)MtrlgyClmn.Qfrom) && Utils.TryParseUFloat(e.DisplayText, out Qfrom)) { - allOk &= Utils.TryParseUFloat(e.Item.SubItems[2].Text, out Qto); - allOk &= Utils.TryParseUFloat(e.Item.SubItems[3].Text, out volume); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out Qto); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Volume].Text, out volume); if (allOk) calculateTime = true; } - else if (e.SubItem == 2 && Utils.TryParseUFloat(e.DisplayText, out Qto)) + else if ((e.SubItem == (int)MtrlgyClmn.Qto) && Utils.TryParseUFloat(e.DisplayText, out Qto)) { - allOk &= Utils.TryParseUFloat(e.Item.SubItems[1].Text, out Qfrom); - allOk &= Utils.TryParseUFloat(e.Item.SubItems[3].Text, out volume); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out Qfrom); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Volume].Text, out volume); if (allOk) calculateTime = true; } - else if (e.SubItem == 3 && Utils.TryParseUFloat(e.DisplayText, out volume)) + else if ((e.SubItem == (int)MtrlgyClmn.Volume) && Utils.TryParseUFloat(e.DisplayText, out volume)) { - allOk &= Utils.TryParseUFloat(e.Item.SubItems[1].Text, out Qfrom); - allOk &= Utils.TryParseUFloat(e.Item.SubItems[2].Text, out Qto); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out Qfrom); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out Qto); if (allOk) calculateTime = true; } - else if (e.SubItem == 4 && Utils.TryParseUFloat(e.DisplayText, out testTime)) + else if ((e.SubItem == (int)MtrlgyClmn.TestTime) && Utils.TryParseUFloat(e.DisplayText, out testTime)) { - allOk &= Utils.TryParseUFloat(e.Item.SubItems[1].Text, out Qfrom); - allOk &= Utils.TryParseUFloat(e.Item.SubItems[2].Text, out Qto); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qfrom].Text, out Qfrom); + allOk &= Utils.TryParseUFloat(e.Item.SubItems[(int)MtrlgyClmn.Qto].Text, out Qto); if (allOk) calculateVolume = true; } @@ -649,12 +766,12 @@ namespace TBF if (calculateTime) { testTime = volume / Qave_lps; - e.Item.SubItems[4].Text = testTime.ToString(); + e.Item.SubItems[(int)MtrlgyClmn.TestTime].Text = testTime.ToString(); } else if (calculateVolume) { volume = testTime * Qave_lps; - e.Item.SubItems[3].Text = volume.ToString(); + e.Item.SubItems[(int)MtrlgyClmn.Volume].Text = volume.ToString(); } else { @@ -665,28 +782,62 @@ namespace TBF private void metrology2ListViewEx_SubItemClicked(object sender, SubItemEventArgs e) { - if (!unlocked || e.SubItem >= metrology2Editors.Length) return; - metrology2ListViewEx.StartEditing(metrology2Editors[e.SubItem], e.Item, e.SubItem); + if (unlocked && + e.SubItem != (int)Mtrlgy2Clmn.Qfrom && + e.SubItem != (int)Mtrlgy2Clmn.Qto && + e.SubItem < (int)Mtrlgy2Clmn.Mtrlgy2ClmnCount) + { + metrology2ListViewEx.StartEditing(metrology2Editors[e.SubItem], e.Item, e.SubItem); + } } private void metrology2ListViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) { - } + int dummy; + if (e.SubItem == (int)MtrlgyClmn.Part) + { + if (e.DisplayText.Equals("-")) return; /// OK + if (!int.TryParse(e.DisplayText, out dummy) || dummy < 1 || dummy > 3) + { + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + return; /// NOK + } + } + + } private void processListViewEx_SubItemClicked(object sender, SubItemEventArgs e) { - if (!unlocked || e.SubItem >= processEditors.Length) return; - processListViewEx.StartEditing(processEditors[e.SubItem], e.Item, e.SubItem); + if (unlocked && + e.SubItem != (int)ProcessClmn.Qfrom && + e.SubItem != (int)ProcessClmn.Qto && + e.SubItem < (int)ProcessClmn.ProcessClmnCount) + { + processListViewEx.StartEditing(processEditors[e.SubItem], e.Item, e.SubItem); + } } private void processListViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) { - if ((e.SubItem == 3 && !(processEditors[3] as ComboBox).Items.Contains(e.DisplayText)) || - (e.SubItem == 4 && !(processEditors[4] as ComboBox).Items.Contains(e.DisplayText)) || - (e.SubItem == 5 && !(processEditors[5] as ComboBox).Items.Contains(e.DisplayText)) || - (e.SubItem == 6 && !(processEditors[6] as ComboBox).Items.Contains(e.DisplayText)) || - (e.SubItem == 7 && !(processEditors[7] as ComboBox).Items.Contains(e.DisplayText)) || - (e.SubItem == 8 && !(processEditors[8] as ComboBox).Items.Contains(e.DisplayText))) + int dummy; + if (e.SubItem == (int)MtrlgyClmn.Part) + { + if (e.DisplayText.Equals("-")) return; /// OK + if (!int.TryParse(e.DisplayText, out dummy) || dummy < 1 || dummy > 3) + { + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + return; /// NOK + } + } + + if (((e.SubItem == (int)ProcessClmn.Feeding) && !(processEditors[(int)ProcessClmn.Feeding] as ComboBox).Items.Contains(e.DisplayText)) || + ((e.SubItem == (int)ProcessClmn.Bench) && !(processEditors[(int)ProcessClmn.Bench] as ComboBox).Items.Contains(e.DisplayText)) || + ((e.SubItem == (int)ProcessClmn.Output) && !(processEditors[(int)ProcessClmn.Output] as ComboBox).Items.Contains(e.DisplayText)) || + ((e.SubItem == (int)ProcessClmn.Sensor) && !(processEditors[(int)ProcessClmn.Sensor] as ComboBox).Items.Contains(e.DisplayText)) || + ((e.SubItem == (int)ProcessClmn.TrnStart)&& !(processEditors[(int)ProcessClmn.TrnStart]as ComboBox).Items.Contains(e.DisplayText)) || + ((e.SubItem == (int)ProcessClmn.TrnStop) && !(processEditors[(int)ProcessClmn.TrnStop] as ComboBox).Items.Contains(e.DisplayText))) { e.DisplayText = e.Item.SubItems[e.SubItem].Text; e.Cancel = true; diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index de74d5d00..468d93fec 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1194,6 +1194,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Part. + /// + internal static string Part { + get { + return ResourceManager.GetString("Part", resourceCulture); + } + } + /// /// Looks up a localized string similar to OK. /// diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 3f40cad83..cf843ac96 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -783,4 +783,7 @@ Durchflussmesser + + Teil + \ No newline at end of file diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 97290be63..2df7d0e52 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -880,4 +880,7 @@ Flowmeter + + Part + \ No newline at end of file