From 099d635d3e6d1e92126cdaa366399a34c35143cf Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 7 Apr 2017 12:21:34 +0200 Subject: [PATCH] RoiParams, DetectionImagesCount, P1, P2 are procedure parameters, ver. 2.12.531 --- .../Network/Camera/Roi/ProcedureParams.cs | 32 +++++ .../BenchControl/Network/Camera/Roi/Roi.cs | 4 - .../BenchControl/Network/Camera/Roi/RoiCfg.cs | 19 +-- .../Network/Camera/Roi/RoiCfgCtrl.cs | 59 --------- .../Network/Camera/Roi/RoiCfgCtrl.designer.cs | 123 ++---------------- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- 6 files changed, 49 insertions(+), 192 deletions(-) diff --git a/TestBenchFramework/BenchControl/Network/Camera/Roi/ProcedureParams.cs b/TestBenchFramework/BenchControl/Network/Camera/Roi/ProcedureParams.cs index f38a977c3..742aac6ac 100644 --- a/TestBenchFramework/BenchControl/Network/Camera/Roi/ProcedureParams.cs +++ b/TestBenchFramework/BenchControl/Network/Camera/Roi/ProcedureParams.cs @@ -14,15 +14,27 @@ namespace TBF.BenchControl.Network.Camera.Roi public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams { public float PulsesPerLtr; /// [l^-1] + public int DetectionImagesCount; + public int DetectionPeriod1; + public int DetectionPeriod2; + public string RoiParams; public override void InitializeAll() { PulsesPerLtr = 1.0f; + DetectionImagesCount = 10; + DetectionPeriod1 = 1; + DetectionPeriod2 = 19; + RoiParams = "160 160 79 79 20 79 0 0 360 360 1 50 0 0 50 0"; } string[] paramNames = new string[] { Strings.PulsesPerLtr, + "Images count", + "Period1", + "Period2", + "Parameters" }; public override string ParamName(int i) { return paramNames[i]; } public override int ParamsCount() { return paramNames.Length; } @@ -32,6 +44,10 @@ namespace TBF.BenchControl.Network.Camera.Roi switch (i) { case 0: return PulsesPerLtr.ToString(); + case 1: return DetectionImagesCount.ToString(); + case 2: return DetectionPeriod1.ToString(); + case 3: return DetectionPeriod2.ToString(); + case 4: return RoiParams; default: return string.Empty; } } @@ -42,6 +58,10 @@ namespace TBF.BenchControl.Network.Camera.Roi switch (i) { case 0: PulsesPerLtr = Utils.ParseUFloat(strValue); return; + case 1: DetectionImagesCount = int.Parse(strValue); return; + case 2: DetectionPeriod1 = int.Parse(strValue); return; + case 3: DetectionPeriod2 = int.Parse(strValue); return; + case 4: RoiParams = strValue; return; default: return; } } @@ -52,11 +72,19 @@ namespace TBF.BenchControl.Network.Camera.Roi message = string.Empty; float dummy; + int idummy; switch (i) { case 0: if (Utils.TryParseUFloat(strValue, out dummy)) return true; break; + case 1: + case 2: + case 3: + if (int.TryParse(strValue, out idummy) && idummy >= 1 && idummy <= 50) return true; + break; + case 4: + return true; default: message = "Invalid index"; return false; @@ -69,6 +97,10 @@ namespace TBF.BenchControl.Network.Camera.Roi void CopyContentTo(ProcedureParams prms) { prms.PulsesPerLtr = this.PulsesPerLtr; + prms.DetectionImagesCount = this.DetectionImagesCount; + prms.DetectionPeriod1 = this.DetectionPeriod1; + prms.DetectionPeriod2 = this.DetectionPeriod2; + prms.RoiParams = this.RoiParams; } public IParamsProvider Clone() diff --git a/TestBenchFramework/BenchControl/Network/Camera/Roi/Roi.cs b/TestBenchFramework/BenchControl/Network/Camera/Roi/Roi.cs index c81c432b0..a1f779372 100644 --- a/TestBenchFramework/BenchControl/Network/Camera/Roi/Roi.cs +++ b/TestBenchFramework/BenchControl/Network/Camera/Roi/Roi.cs @@ -146,12 +146,8 @@ namespace TBF.BenchControl.Network.Camera.Roi { if (args.Command == CfgChangeCmd.CfgChange) { - RoiCfg.RoiParams = tmpcfg.RoiParams; - RoiCfg.DetectionImagesCount = tmpcfg.DetectionImagesCount; RoiCfg.LoadImages = tmpcfg.LoadImages; RoiCfg.SaveImages = tmpcfg.SaveImages; - RoiCfg.DetectionPeriod1 = tmpcfg.DetectionPeriod1; - RoiCfg.DetectionPeriod2 = tmpcfg.DetectionPeriod2; } } }; diff --git a/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfg.cs b/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfg.cs index 6fd6d35bd..9437e1134 100644 --- a/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfg.cs +++ b/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfg.cs @@ -15,10 +15,6 @@ namespace TBF.BenchControl.Network.Camera.Roi /// Serialized parameters /// public string PreviousRoi; - public string RoiParams; - public int DetectionImagesCount; - public int DetectionPeriod1; - public int DetectionPeriod2; public bool LoadImages; public bool SaveImages; @@ -33,6 +29,12 @@ namespace TBF.BenchControl.Network.Camera.Roi return procParams; } + public int DetectionImagesCount { get { return ProcParams.DetectionImagesCount; } } + public int DetectionPeriod1 { get { return ProcParams.DetectionPeriod1; } } + public int DetectionPeriod2 { get { return ProcParams.DetectionPeriod2; } } + public string RoiParams { get { return ProcParams.RoiParams; } } + + /// Private parameterless constructor invoked by all other (public) constructors RoiCfg() { @@ -45,18 +47,11 @@ namespace TBF.BenchControl.Network.Camera.Roi Name = name; Factory = factory; ParentName = "Camera"; - RoiParams = string.Empty; - DetectionImagesCount = 15; - DetectionPeriod1 = 1; - DetectionPeriod2 = 1; } public string ToString(int i) { - return string.Format("{0} ({1}), N={2}{3}, P1={4}, P2={5}, Prms={6}", - Name, ParentName, DetectionImagesCount, - LoadImages ? " load" : (SaveImages ? " save" : ""), - DetectionPeriod1, DetectionPeriod2, RoiParams); + return string.Format("{0} ({1}) {2}", Name, ParentName, (LoadImages ? " load images" : (SaveImages ? " save images" : ""))); } } } diff --git a/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.cs b/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.cs index 9a9acf64a..3b6d4ed61 100644 --- a/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.cs @@ -68,12 +68,8 @@ namespace TBF.BenchControl.Network.Camera.Roi nameTextBox.Text = config.Name; parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; previousRoiComboBox.Text = string.IsNullOrEmpty(config.PreviousRoi) ? "---" : config.PreviousRoi; - argsTextBox.Text = config.RoiParams; loadImagesCheckBox.Checked = config.LoadImages; saveImagesCheckBox.Checked = config.SaveImages; - imagesCountTextBox.Text = config.DetectionImagesCount.ToString(); - period1TextBox.Text = config.DetectionPeriod1.ToString(); - period2TextBox.Text = config.DetectionPeriod2.ToString(); } public void Unlock() @@ -81,12 +77,8 @@ namespace TBF.BenchControl.Network.Camera.Roi nameTextBox.Enabled = true; parentNameComboBox.Enabled = true; previousRoiComboBox.Enabled = true; - argsTextBox.Enabled = true; loadImagesCheckBox.Enabled = true; saveImagesCheckBox.Enabled = true; - imagesCountTextBox.Enabled = true; - period1TextBox.Enabled = true; - period2TextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) @@ -105,33 +97,6 @@ namespace TBF.BenchControl.Network.Camera.Roi message += Environment.NewLine + "Invalid 'Previous RoI'"; } - int cnt, p1, p2; - if (!int.TryParse(imagesCountTextBox.Text, out cnt) || cnt < 1 || cnt > 50) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Images count' should be between 1 and 50"; - } - if (!int.TryParse(period1TextBox.Text, out p1) || p1 < 1 || p1 > 50) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Period 1' should be between 1 and 50"; - } - if (!int.TryParse(period2TextBox.Text, out p2) || p2 < 1 || p2 > 50) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Period 2' should be between 1 and 50"; - } - if (p2 < p1) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "Period2 should >= Period1"; - } - if (p2 > p1 && (cnt % 2) != 0) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "When Period2 > Period1, 'Images count' should be even"; - } - if (loadImagesCheckBox.Checked && saveImagesCheckBox.Checked) { flags |= CfgUpdateFlags.Error; @@ -167,12 +132,6 @@ namespace TBF.BenchControl.Network.Camera.Roi flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange); } - if (config.RoiParams != argsTextBox.Text) - { - config.RoiParams = argsTextBox.Text; - flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - } - if (config.LoadImages != loadImagesCheckBox.Checked) { config.LoadImages = loadImagesCheckBox.Checked; @@ -185,24 +144,6 @@ namespace TBF.BenchControl.Network.Camera.Roi flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); } - if (config.DetectionImagesCount != int.Parse(imagesCountTextBox.Text)) - { - config.DetectionImagesCount = int.Parse(imagesCountTextBox.Text); - flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - } - - if (config.DetectionPeriod1 != int.Parse(period1TextBox.Text)) - { - config.DetectionPeriod1 = int.Parse(period1TextBox.Text); - flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - } - - if (config.DetectionPeriod2 != int.Parse(period2TextBox.Text)) - { - config.DetectionPeriod2 = int.Parse(period2TextBox.Text); - flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); - } - if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0) { Roi.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config)); diff --git a/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.designer.cs index b72e30463..b7895665b 100644 --- a/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/Network/Camera/Roi/RoiCfgCtrl.designer.cs @@ -31,8 +31,6 @@ namespace TBF.BenchControl.Network.Camera.Roi /// private void InitializeComponent() { - this.argsTextBox = new System.Windows.Forms.TextBox(); - this.argsLabel = new System.Windows.Forms.Label(); this.parentNameLabel = new System.Windows.Forms.Label(); this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameLabel = new System.Windows.Forms.Label(); @@ -44,35 +42,10 @@ namespace TBF.BenchControl.Network.Camera.Roi this.previousRoiLabel = new System.Windows.Forms.Label(); this.helpLabel1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); - this.imagesCountTextBox = new System.Windows.Forms.TextBox(); - this.imagesCountLabel = new System.Windows.Forms.Label(); this.loadImagesCheckBox = new System.Windows.Forms.CheckBox(); - this.period1TextBox = new System.Windows.Forms.TextBox(); - this.period1Label = new System.Windows.Forms.Label(); - this.period2TextBox = new System.Windows.Forms.TextBox(); - this.period2Label = new System.Windows.Forms.Label(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); this.saveImagesCheckBox = new System.Windows.Forms.CheckBox(); - this.groupBox1.SuspendLayout(); this.SuspendLayout(); // - // argsTextBox - // - this.argsTextBox.Enabled = false; - this.argsTextBox.Location = new System.Drawing.Point(92, 19); - this.argsTextBox.Name = "argsTextBox"; - this.argsTextBox.Size = new System.Drawing.Size(361, 20); - this.argsTextBox.TabIndex = 1; - // - // argsLabel - // - this.argsLabel.AutoSize = true; - this.argsLabel.Location = new System.Drawing.Point(6, 22); - this.argsLabel.Name = "argsLabel"; - this.argsLabel.Size = new System.Drawing.Size(57, 13); - this.argsLabel.TabIndex = 0; - this.argsLabel.Text = "Arguments"; - // // parentNameLabel // this.parentNameLabel.AutoSize = true; @@ -155,7 +128,7 @@ namespace TBF.BenchControl.Network.Camera.Roi // helpLabel1 // this.helpLabel1.AutoSize = true; - this.helpLabel1.Location = new System.Drawing.Point(91, 44); + this.helpLabel1.Location = new System.Drawing.Point(38, 186); this.helpLabel1.Name = "helpLabel1"; this.helpLabel1.Size = new System.Drawing.Size(379, 13); this.helpLabel1.TabIndex = 2; @@ -165,100 +138,28 @@ namespace TBF.BenchControl.Network.Camera.Roi // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(90, 62); + this.label2.Location = new System.Drawing.Point(68, 204); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(350, 13); this.label2.TabIndex = 3; this.label2.Text = "... angSpeed( - ccw +cw) initSpeed minMvmt maxFwdMvmt bkgndCorr"; // - // imagesCountTextBox - // - this.imagesCountTextBox.Enabled = false; - this.imagesCountTextBox.Location = new System.Drawing.Point(92, 84); - this.imagesCountTextBox.Name = "imagesCountTextBox"; - this.imagesCountTextBox.Size = new System.Drawing.Size(46, 20); - this.imagesCountTextBox.TabIndex = 5; - // - // imagesCountLabel - // - this.imagesCountLabel.AutoSize = true; - this.imagesCountLabel.Location = new System.Drawing.Point(6, 87); - this.imagesCountLabel.Name = "imagesCountLabel"; - this.imagesCountLabel.Size = new System.Drawing.Size(71, 13); - this.imagesCountLabel.TabIndex = 4; - this.imagesCountLabel.Text = "Images count"; - // // loadImagesCheckBox // this.loadImagesCheckBox.AutoSize = true; this.loadImagesCheckBox.Enabled = false; - this.loadImagesCheckBox.Location = new System.Drawing.Point(175, 87); + this.loadImagesCheckBox.Location = new System.Drawing.Point(99, 117); this.loadImagesCheckBox.Name = "loadImagesCheckBox"; this.loadImagesCheckBox.Size = new System.Drawing.Size(112, 17); this.loadImagesCheckBox.TabIndex = 6; this.loadImagesCheckBox.Text = "Load images (test)"; this.loadImagesCheckBox.UseVisualStyleBackColor = true; // - // period1TextBox - // - this.period1TextBox.Enabled = false; - this.period1TextBox.Location = new System.Drawing.Point(92, 107); - this.period1TextBox.Name = "period1TextBox"; - this.period1TextBox.Size = new System.Drawing.Size(46, 20); - this.period1TextBox.TabIndex = 9; - // - // period1Label - // - this.period1Label.AutoSize = true; - this.period1Label.Location = new System.Drawing.Point(6, 110); - this.period1Label.Name = "period1Label"; - this.period1Label.Size = new System.Drawing.Size(46, 13); - this.period1Label.TabIndex = 8; - this.period1Label.Text = "Period 1"; - // - // period2TextBox - // - this.period2TextBox.Enabled = false; - this.period2TextBox.Location = new System.Drawing.Point(92, 130); - this.period2TextBox.Name = "period2TextBox"; - this.period2TextBox.Size = new System.Drawing.Size(46, 20); - this.period2TextBox.TabIndex = 11; - // - // period2Label - // - this.period2Label.AutoSize = true; - this.period2Label.Location = new System.Drawing.Point(6, 133); - this.period2Label.Name = "period2Label"; - this.period2Label.Size = new System.Drawing.Size(46, 13); - this.period2Label.TabIndex = 10; - this.period2Label.Text = "Period 2"; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.saveImagesCheckBox); - this.groupBox1.Controls.Add(this.argsTextBox); - this.groupBox1.Controls.Add(this.period2TextBox); - this.groupBox1.Controls.Add(this.argsLabel); - this.groupBox1.Controls.Add(this.period2Label); - this.groupBox1.Controls.Add(this.helpLabel1); - this.groupBox1.Controls.Add(this.period1TextBox); - this.groupBox1.Controls.Add(this.label2); - this.groupBox1.Controls.Add(this.period1Label); - this.groupBox1.Controls.Add(this.loadImagesCheckBox); - this.groupBox1.Controls.Add(this.imagesCountTextBox); - this.groupBox1.Controls.Add(this.imagesCountLabel); - this.groupBox1.Location = new System.Drawing.Point(7, 110); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(477, 169); - this.groupBox1.TabIndex = 7; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "ROI Detection"; - // // saveImagesCheckBox // this.saveImagesCheckBox.AutoSize = true; this.saveImagesCheckBox.Enabled = false; - this.saveImagesCheckBox.Location = new System.Drawing.Point(301, 87); + this.saveImagesCheckBox.Location = new System.Drawing.Point(99, 140); this.saveImagesCheckBox.Name = "saveImagesCheckBox"; this.saveImagesCheckBox.Size = new System.Drawing.Size(132, 17); this.saveImagesCheckBox.TabIndex = 7; @@ -269,9 +170,12 @@ namespace TBF.BenchControl.Network.Camera.Roi // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.groupBox1); + this.Controls.Add(this.helpLabel1); + this.Controls.Add(this.saveImagesCheckBox); + this.Controls.Add(this.label2); this.Controls.Add(this.previousRoiComboBox); this.Controls.Add(this.previousRoiLabel); + this.Controls.Add(this.loadImagesCheckBox); this.Controls.Add(this.parentNameComboBox); this.Controls.Add(this.textBox1); this.Controls.Add(this.label1); @@ -282,8 +186,6 @@ namespace TBF.BenchControl.Network.Camera.Roi this.Name = "RoiCfgCtrl"; this.Size = new System.Drawing.Size(500, 300); this.Load += new System.EventHandler(this.PumpCfgCtrl_Load); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -291,8 +193,6 @@ namespace TBF.BenchControl.Network.Camera.Roi #endregion - private System.Windows.Forms.TextBox argsTextBox; - private System.Windows.Forms.Label argsLabel; private System.Windows.Forms.Label parentNameLabel; private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.Label nameLabel; @@ -304,14 +204,7 @@ namespace TBF.BenchControl.Network.Camera.Roi private System.Windows.Forms.Label previousRoiLabel; private System.Windows.Forms.Label helpLabel1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.TextBox imagesCountTextBox; - private System.Windows.Forms.Label imagesCountLabel; private System.Windows.Forms.CheckBox loadImagesCheckBox; - private System.Windows.Forms.TextBox period1TextBox; - private System.Windows.Forms.Label period1Label; - private System.Windows.Forms.TextBox period2TextBox; - private System.Windows.Forms.Label period2Label; - private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.CheckBox saveImagesCheckBox; } } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 52c6ada36..546f1b0a9 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.530.1")] -[assembly: AssemblyFileVersion("2.12.530.1")] +[assembly: AssemblyVersion("2.12.531.1")] +[assembly: AssemblyFileVersion("2.12.531.1")]