Camera.CLP1611 : TestImagesMode itroduced, passed to Measurement command, ver. 2.17.719

This commit is contained in:
Milan Hanajik
2017-10-26 15:20:26 +02:00
parent 52d073cb8c
commit 39af5d29c6
5 changed files with 102 additions and 47 deletions
@@ -297,7 +297,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{ {
if (args.Command == CfgChangeCmd.CfgChange) if (args.Command == CfgChangeCmd.CfgChange)
{ {
CameraCfg.UseTestImages = tmpcfg.UseTestImages; CameraCfg.TestImagesMode = tmpcfg.TestImagesMode;
CameraCfg.TestImagesCount = tmpcfg.TestImagesCount; CameraCfg.TestImagesCount = tmpcfg.TestImagesCount;
} }
} }
@@ -539,7 +539,6 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
} }
public IOperation LiveStreamOp(bool hiRes) public IOperation LiveStreamOp(bool hiRes)
{ {
int wid = hiRes ? 1280 : 640; int wid = hiRes ? 1280 : 640;
@@ -580,11 +579,29 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
/// Prepare the telent command /// Prepare the telent command
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
foreach (var s in roiParams) sb.AppendFormat(" {0}", s); foreach (var s in roiParams) sb.AppendFormat(" {0}", s);
command = string.Format("clp/Measurement -udp {0} {1}{2}{3} 1 7 0 0 0",
int logImagesArg;
switch (CameraCfg.TestImagesMode)
{
default:
case TestImagesMode.None:
case TestImagesMode.LoadImages:
logImagesArg = 0;
break;
case TestImagesMode.SaveFirstImages:
logImagesArg = CameraCfg.TestImagesCount;
break;
case TestImagesMode.SaveLastImages:
logImagesArg = -CameraCfg.TestImagesCount;
break;
}
command = string.Format("clp/Measurement -udp {0} {1}{2}{3} 1 7 0 0 {4}",
NetAdapter.IPAddress, NetAdapter.IPAddress,
measurementUdpPortNr, measurementUdpPortNr,
CameraCfg.UseTestImages ? (" -l " + CameraCfg.TestImagesCount.ToString()) : string.Empty, (CameraCfg.TestImagesMode == TestImagesMode.LoadImages) ? (" -l " + CameraCfg.TestImagesCount.ToString()) : string.Empty,
sb); sb,
logImagesArg);
measurementCommandSent = false; measurementCommandSent = false;
connectionEstablished = false; connectionEstablished = false;
@@ -9,6 +9,15 @@ using TBF.Resources;
namespace TBF.BenchControl.Network.Camera.CLP1611 namespace TBF.BenchControl.Network.Camera.CLP1611
{ {
public enum TestImagesMode
{
None,
SaveFirstImages,
SaveLastImages,
LoadImages,
Count,
}
public class CameraCfg : ComponentCfgBase, IChildComponentCfg public class CameraCfg : ComponentCfgBase, IChildComponentCfg
{ {
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CameraCfg) })[0]; public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CameraCfg) })[0];
@@ -21,7 +30,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
/// ///
public int HardwareAddress; public int HardwareAddress;
public bool DisplayTerminal; public bool DisplayTerminal;
public bool UseTestImages; public TestImagesMode TestImagesMode;
public int TestImagesCount; public int TestImagesCount;
/// Private parameterless constructor invoked by all other (public) constructors /// Private parameterless constructor invoked by all other (public) constructors
@@ -34,18 +43,19 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
Factory = factory; Factory = factory;
ParentName = "Network.Adapter"; ParentName = "Network.Adapter";
HardwareAddress = 1; HardwareAddress = 1;
UseTestImages = false; TestImagesMode = TestImagesMode.None;
TestImagesCount = 0; TestImagesCount = 200;
DebugLevel = Config.Entities.DebugMode.AutoDetect; DebugLevel = Config.Entities.DebugMode.AutoDetect;
} }
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("Name={0}, s/n={1}, Terminal={2}, Use test images={3}, Parent={4}", return string.Format("Name={0}, s/n={1}, Terminal={2}, TestImagesMode={3}, TestImagesCount={4}, Parent={5}",
Name, Name,
HardwareAddress, HardwareAddress,
DisplayTerminal ? Strings.yes : Strings.no, DisplayTerminal ? Strings.yes : Strings.no,
UseTestImages ? Strings.yes : Strings.no, TestImagesMode,
TestImagesCount,
ParentName); ParentName);
} }
} }
@@ -51,6 +51,11 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
} }
} }
for (TestImagesMode mode = 0; mode < TestImagesMode.Count; mode++)
{
testImagesModeComboBox.Items.Add(mode.ToString());
}
Redraw(); Redraw();
} }
@@ -72,9 +77,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
nameTextBox.Text = config.Name; nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
hwAddressTextBox.Text = config.HardwareAddress.ToString(); hwAddressTextBox.Text = config.HardwareAddress.ToString();
useTestImagesCheckBox.Checked = config.UseTestImages;
testImagesCountTextBox.Text = config.TestImagesCount.ToString();
displayTerminalCheckBox.Checked = config.DisplayTerminal; displayTerminalCheckBox.Checked = config.DisplayTerminal;
testImagesModeComboBox.Text = config.TestImagesMode.ToString();
testImagesCountTextBox.Text = config.TestImagesCount.ToString();
} }
public void Unlock() public void Unlock()
@@ -82,9 +87,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true; parentNameComboBox.Enabled = true;
hwAddressTextBox.Enabled = true; hwAddressTextBox.Enabled = true;
useTestImagesCheckBox.Enabled = true;
testImagesCountTextBox.Enabled = true;
displayTerminalCheckBox.Enabled = true; displayTerminalCheckBox.Enabled = true;
testImagesModeComboBox.Enabled = true;
testImagesCountTextBox.Enabled = true;
} }
public CfgUpdateFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
@@ -104,13 +109,19 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
message += Environment.NewLine + string.Format("'{0}' is not correct", hwAddressLabel.Text); message += Environment.NewLine + string.Format("'{0}' is not correct", hwAddressLabel.Text);
} }
if (useTestImagesCheckBox.Checked && if (!testImagesModeComboBox.Items.Contains(testImagesModeComboBox.Text))
(!int.TryParse(testImagesCountTextBox.Text, out dummy) || dummy < 1 || dummy > 50))
{ {
flags |= CfgUpdateFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("'{0}' should be between 1 and 50", testImagesCountLabel.Text); message += Environment.NewLine + string.Format("Invalid {0}", testImagesModeLabel.Text);
} }
if (!int.TryParse(testImagesCountTextBox.Text, out dummy) || dummy < 1 || dummy > 200)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format("Invalid {0}", testImagesCountLabel.Text);
}
return flags; return flags;
} }
@@ -122,8 +133,14 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
string newParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; string newParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
int newHWAddress = int.Parse(hwAddressTextBox.Text); int newHWAddress = int.Parse(hwAddressTextBox.Text);
TestImagesMode newTestImagesMode = 0;
for (TestImagesMode mode = 0; mode < TestImagesMode.Count; mode++)
{
if (testImagesModeComboBox.Text == mode.ToString()) newTestImagesMode = mode;
}
int newTestImagesCount = int.Parse(testImagesCountTextBox.Text); int newTestImagesCount = int.Parse(testImagesCountTextBox.Text);
if (config.Name != nameTextBox.Text || if (config.Name != nameTextBox.Text ||
config.ParentName != newParentName || config.ParentName != newParentName ||
config.HardwareAddress != newHWAddress || config.HardwareAddress != newHWAddress ||
@@ -137,10 +154,11 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange); flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
} }
if (config.UseTestImages != useTestImagesCheckBox.Checked ||
if (config.TestImagesMode != newTestImagesMode ||
config.TestImagesCount != newTestImagesCount) config.TestImagesCount != newTestImagesCount)
{ {
config.UseTestImages = useTestImagesCheckBox.Checked; config.TestImagesMode = newTestImagesMode;
config.TestImagesCount = newTestImagesCount; config.TestImagesCount = newTestImagesCount;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
@@ -39,15 +39,16 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
this.classNameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox(); this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.displayTerminalCheckBox = new System.Windows.Forms.CheckBox(); this.displayTerminalCheckBox = new System.Windows.Forms.CheckBox();
this.useTestImagesCheckBox = new System.Windows.Forms.CheckBox();
this.testImagesCountTextBox = new System.Windows.Forms.TextBox(); this.testImagesCountTextBox = new System.Windows.Forms.TextBox();
this.testImagesCountLabel = new System.Windows.Forms.Label(); this.testImagesCountLabel = new System.Windows.Forms.Label();
this.testImagesModeComboBox = new System.Windows.Forms.ComboBox();
this.testImagesModeLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// hwAddressTextBox // hwAddressTextBox
// //
this.hwAddressTextBox.Enabled = false; this.hwAddressTextBox.Enabled = false;
this.hwAddressTextBox.Location = new System.Drawing.Point(114, 92); this.hwAddressTextBox.Location = new System.Drawing.Point(132, 92);
this.hwAddressTextBox.Name = "hwAddressTextBox"; this.hwAddressTextBox.Name = "hwAddressTextBox";
this.hwAddressTextBox.Size = new System.Drawing.Size(130, 20); this.hwAddressTextBox.Size = new System.Drawing.Size(130, 20);
this.hwAddressTextBox.TabIndex = 6; this.hwAddressTextBox.TabIndex = 6;
@@ -73,7 +74,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
// nameTextBox // nameTextBox
// //
this.nameTextBox.Enabled = false; this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(114, 41); this.nameTextBox.Location = new System.Drawing.Point(132, 41);
this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2; this.nameTextBox.TabIndex = 2;
@@ -90,7 +91,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
// classNameLabel // classNameLabel
// //
this.classNameLabel.AutoSize = true; this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(111, 17); this.classNameLabel.Location = new System.Drawing.Point(129, 17);
this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13); this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0; this.classNameLabel.TabIndex = 0;
@@ -100,7 +101,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
// //
this.parentNameComboBox.Enabled = false; this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true; this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(114, 66); this.parentNameComboBox.Location = new System.Drawing.Point(132, 66);
this.parentNameComboBox.Name = "parentNameComboBox"; this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4; this.parentNameComboBox.TabIndex = 4;
@@ -109,28 +110,17 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
// //
this.displayTerminalCheckBox.AutoSize = true; this.displayTerminalCheckBox.AutoSize = true;
this.displayTerminalCheckBox.Enabled = false; this.displayTerminalCheckBox.Enabled = false;
this.displayTerminalCheckBox.Location = new System.Drawing.Point(114, 122); this.displayTerminalCheckBox.Location = new System.Drawing.Point(133, 122);
this.displayTerminalCheckBox.Name = "displayTerminalCheckBox"; this.displayTerminalCheckBox.Name = "displayTerminalCheckBox";
this.displayTerminalCheckBox.Size = new System.Drawing.Size(99, 17); this.displayTerminalCheckBox.Size = new System.Drawing.Size(99, 17);
this.displayTerminalCheckBox.TabIndex = 7; this.displayTerminalCheckBox.TabIndex = 7;
this.displayTerminalCheckBox.Text = "Display terminal"; this.displayTerminalCheckBox.Text = "Display terminal";
this.displayTerminalCheckBox.UseVisualStyleBackColor = true; this.displayTerminalCheckBox.UseVisualStyleBackColor = true;
// //
// useTestImagesCheckBox
//
this.useTestImagesCheckBox.AutoSize = true;
this.useTestImagesCheckBox.Enabled = false;
this.useTestImagesCheckBox.Location = new System.Drawing.Point(114, 156);
this.useTestImagesCheckBox.Name = "useTestImagesCheckBox";
this.useTestImagesCheckBox.Size = new System.Drawing.Size(101, 17);
this.useTestImagesCheckBox.TabIndex = 10;
this.useTestImagesCheckBox.Text = "Use test images";
this.useTestImagesCheckBox.UseVisualStyleBackColor = true;
//
// testImagesCountTextBox // testImagesCountTextBox
// //
this.testImagesCountTextBox.Enabled = false; this.testImagesCountTextBox.Enabled = false;
this.testImagesCountTextBox.Location = new System.Drawing.Point(114, 178); this.testImagesCountTextBox.Location = new System.Drawing.Point(132, 174);
this.testImagesCountTextBox.Name = "testImagesCountTextBox"; this.testImagesCountTextBox.Name = "testImagesCountTextBox";
this.testImagesCountTextBox.Size = new System.Drawing.Size(46, 20); this.testImagesCountTextBox.Size = new System.Drawing.Size(46, 20);
this.testImagesCountTextBox.TabIndex = 12; this.testImagesCountTextBox.TabIndex = 12;
@@ -138,21 +128,40 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
// testImagesCountLabel // testImagesCountLabel
// //
this.testImagesCountLabel.AutoSize = true; this.testImagesCountLabel.AutoSize = true;
this.testImagesCountLabel.Location = new System.Drawing.Point(28, 181); this.testImagesCountLabel.Location = new System.Drawing.Point(28, 177);
this.testImagesCountLabel.Name = "testImagesCountLabel"; this.testImagesCountLabel.Name = "testImagesCountLabel";
this.testImagesCountLabel.Size = new System.Drawing.Size(71, 13); this.testImagesCountLabel.Size = new System.Drawing.Size(94, 13);
this.testImagesCountLabel.TabIndex = 11; this.testImagesCountLabel.TabIndex = 11;
this.testImagesCountLabel.Text = "Images count"; this.testImagesCountLabel.Text = "Test images count";
//
// testImagesModeComboBox
//
this.testImagesModeComboBox.Enabled = false;
this.testImagesModeComboBox.FormattingEnabled = true;
this.testImagesModeComboBox.Location = new System.Drawing.Point(132, 148);
this.testImagesModeComboBox.Name = "testImagesModeComboBox";
this.testImagesModeComboBox.Size = new System.Drawing.Size(130, 21);
this.testImagesModeComboBox.TabIndex = 14;
//
// testImagesModeLabel
//
this.testImagesModeLabel.AutoSize = true;
this.testImagesModeLabel.Location = new System.Drawing.Point(28, 151);
this.testImagesModeLabel.Name = "testImagesModeLabel";
this.testImagesModeLabel.Size = new System.Drawing.Size(93, 13);
this.testImagesModeLabel.TabIndex = 13;
this.testImagesModeLabel.Text = "Test images mode";
// //
// CameraCfgCtrl // CameraCfgCtrl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.testImagesModeComboBox);
this.Controls.Add(this.testImagesModeLabel);
this.Controls.Add(this.hwAddressTextBox); this.Controls.Add(this.hwAddressTextBox);
this.Controls.Add(this.hwAddressLabel); this.Controls.Add(this.hwAddressLabel);
this.Controls.Add(this.testImagesCountTextBox); this.Controls.Add(this.testImagesCountTextBox);
this.Controls.Add(this.testImagesCountLabel); this.Controls.Add(this.testImagesCountLabel);
this.Controls.Add(this.useTestImagesCheckBox);
this.Controls.Add(this.displayTerminalCheckBox); this.Controls.Add(this.displayTerminalCheckBox);
this.Controls.Add(this.parentNameComboBox); this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.parentNameLabel); this.Controls.Add(this.parentNameLabel);
@@ -177,8 +186,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
private System.Windows.Forms.Label classNameLabel; private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.ComboBox parentNameComboBox; private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.CheckBox displayTerminalCheckBox; private System.Windows.Forms.CheckBox displayTerminalCheckBox;
private System.Windows.Forms.CheckBox useTestImagesCheckBox;
private System.Windows.Forms.TextBox testImagesCountTextBox; private System.Windows.Forms.TextBox testImagesCountTextBox;
private System.Windows.Forms.Label testImagesCountLabel; private System.Windows.Forms.Label testImagesCountLabel;
private System.Windows.Forms.ComboBox testImagesModeComboBox;
private System.Windows.Forms.Label testImagesModeLabel;
} }
} }
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.17.718.1")] [assembly: AssemblyVersion("2.17.719.1")]
[assembly: AssemblyFileVersion("2.17.718.1")] [assembly: AssemblyFileVersion("2.17.719.1")]