DeviceTest extended to 3 components.

This commit is contained in:
Milan Hanajik 2017-01-13 15:27:36 +01:00
parent e730ee1541
commit 2199679d28
3 changed files with 445 additions and 118 deletions

View File

@ -36,19 +36,32 @@
this.startButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.configureComponentButton = new System.Windows.Forms.Button();
this.componentNameTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.componentClassNameComboBox = new System.Windows.Forms.ComboBox();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton0 = new System.Windows.Forms.RadioButton();
this.configureButton = new System.Windows.Forms.Button();
this.componentNameTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.componentClassNameComboBox = new System.Windows.Forms.ComboBox();
this.stopButton = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.configureComponent2Button = new System.Windows.Forms.Button();
this.component2NameTextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.component2ClassNameComboBox = new System.Windows.Forms.ComboBox();
this.radioButton24 = new System.Windows.Forms.RadioButton();
this.radioButton23 = new System.Windows.Forms.RadioButton();
this.radioButton22 = new System.Windows.Forms.RadioButton();
this.radioButton21 = new System.Windows.Forms.RadioButton();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// parentClassNameComboBox
@ -114,105 +127,40 @@
this.groupBox1.Controls.Add(this.parentClassNameComboBox);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(405, 106);
this.groupBox1.Size = new System.Drawing.Size(405, 105);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Parent component";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.radioButton4);
this.groupBox2.Controls.Add(this.radioButton3);
this.groupBox2.Controls.Add(this.radioButton2);
this.groupBox2.Controls.Add(this.radioButton1);
this.groupBox2.Controls.Add(this.radioButton0);
this.groupBox2.Controls.Add(this.configureButton);
this.groupBox2.Controls.Add(this.configureComponentButton);
this.groupBox2.Controls.Add(this.componentNameTextBox);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.componentClassNameComboBox);
this.groupBox2.Location = new System.Drawing.Point(12, 127);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(405, 238);
this.groupBox2.Size = new System.Drawing.Size(405, 105);
this.groupBox2.TabIndex = 9;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Component";
//
// radioButton4
// configureComponentButton
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(77, 206);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(51, 17);
this.radioButton4.TabIndex = 9;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "spare";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
this.configureComponentButton.Location = new System.Drawing.Point(77, 68);
this.configureComponentButton.Name = "configureComponentButton";
this.configureComponentButton.Size = new System.Drawing.Size(129, 28);
this.configureComponentButton.TabIndex = 4;
this.configureComponentButton.Text = "Configure";
this.configureComponentButton.UseVisualStyleBackColor = true;
this.configureComponentButton.Click += new System.EventHandler(this.configureComponentButton_Click);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(77, 183);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(51, 17);
this.radioButton3.TabIndex = 8;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "spare";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(77, 160);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(51, 17);
this.radioButton2.TabIndex = 7;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "spare";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(77, 137);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(106, 17);
this.radioButton1.TabIndex = 6;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "ReadPressureOp";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton0
//
this.radioButton0.AutoSize = true;
this.radioButton0.Location = new System.Drawing.Point(77, 114);
this.radioButton0.Name = "radioButton0";
this.radioButton0.Size = new System.Drawing.Size(94, 17);
this.radioButton0.TabIndex = 5;
this.radioButton0.TabStop = true;
this.radioButton0.Text = "Stop operation";
this.radioButton0.UseVisualStyleBackColor = true;
this.radioButton0.CheckedChanged += new System.EventHandler(this.radioButton0_CheckedChanged);
//
// configureButton
//
this.configureButton.Location = new System.Drawing.Point(77, 68);
this.configureButton.Name = "configureButton";
this.configureButton.Size = new System.Drawing.Size(129, 28);
this.configureButton.TabIndex = 4;
this.configureButton.Text = "Configure";
this.configureButton.UseVisualStyleBackColor = true;
this.configureButton.Click += new System.EventHandler(this.configureButton_Click);
//
// nameTextBox
// componentNameTextBox
//
this.componentNameTextBox.Enabled = false;
this.componentNameTextBox.Location = new System.Drawing.Point(77, 44);
this.componentNameTextBox.Name = "nameTextBox";
this.componentNameTextBox.Name = "componentNameTextBox";
this.componentNameTextBox.Size = new System.Drawing.Size(299, 20);
this.componentNameTextBox.TabIndex = 3;
//
@ -234,14 +182,74 @@
this.label2.TabIndex = 1;
this.label2.Text = "Class";
//
// classNameComboBox
// componentClassNameComboBox
//
this.componentClassNameComboBox.FormattingEnabled = true;
this.componentClassNameComboBox.Location = new System.Drawing.Point(77, 19);
this.componentClassNameComboBox.Name = "classNameComboBox";
this.componentClassNameComboBox.Name = "componentClassNameComboBox";
this.componentClassNameComboBox.Size = new System.Drawing.Size(299, 21);
this.componentClassNameComboBox.TabIndex = 0;
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(13, 118);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(51, 17);
this.radioButton4.TabIndex = 9;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "spare";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(13, 95);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(51, 17);
this.radioButton3.TabIndex = 8;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "spare";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(13, 72);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(51, 17);
this.radioButton2.TabIndex = 7;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "spare";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(13, 49);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(106, 17);
this.radioButton1.TabIndex = 6;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "ReadPressureOp";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton0
//
this.radioButton0.AutoSize = true;
this.radioButton0.Location = new System.Drawing.Point(13, 26);
this.radioButton0.Name = "radioButton0";
this.radioButton0.Size = new System.Drawing.Size(94, 17);
this.radioButton0.TabIndex = 5;
this.radioButton0.TabStop = true;
this.radioButton0.Text = "Stop operation";
this.radioButton0.UseVisualStyleBackColor = true;
this.radioButton0.CheckedChanged += new System.EventHandler(this.radioButton0_CheckedChanged);
//
// stopButton
//
this.stopButton.Location = new System.Drawing.Point(431, 73);
@ -252,11 +260,137 @@
this.stopButton.UseVisualStyleBackColor = true;
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.configureComponent2Button);
this.groupBox3.Controls.Add(this.component2NameTextBox);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.label4);
this.groupBox3.Controls.Add(this.component2ClassNameComboBox);
this.groupBox3.Location = new System.Drawing.Point(12, 238);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(405, 105);
this.groupBox3.TabIndex = 11;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Component 2";
//
// configureComponent2Button
//
this.configureComponent2Button.Location = new System.Drawing.Point(77, 68);
this.configureComponent2Button.Name = "configureComponent2Button";
this.configureComponent2Button.Size = new System.Drawing.Size(129, 28);
this.configureComponent2Button.TabIndex = 4;
this.configureComponent2Button.Text = "Configure";
this.configureComponent2Button.UseVisualStyleBackColor = true;
this.configureComponent2Button.Click += new System.EventHandler(this.configureComponent2Button_Click);
//
// component2NameTextBox
//
this.component2NameTextBox.Enabled = false;
this.component2NameTextBox.Location = new System.Drawing.Point(77, 44);
this.component2NameTextBox.Name = "component2NameTextBox";
this.component2NameTextBox.Size = new System.Drawing.Size(299, 20);
this.component2NameTextBox.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(11, 47);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(35, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Name";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(11, 22);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 13);
this.label4.TabIndex = 1;
this.label4.Text = "Class";
//
// component2ClassNameComboBox
//
this.component2ClassNameComboBox.FormattingEnabled = true;
this.component2ClassNameComboBox.Location = new System.Drawing.Point(77, 19);
this.component2ClassNameComboBox.Name = "component2ClassNameComboBox";
this.component2ClassNameComboBox.Size = new System.Drawing.Size(299, 21);
this.component2ClassNameComboBox.TabIndex = 0;
//
// radioButton24
//
this.radioButton24.AutoSize = true;
this.radioButton24.Location = new System.Drawing.Point(212, 118);
this.radioButton24.Name = "radioButton24";
this.radioButton24.Size = new System.Drawing.Size(51, 17);
this.radioButton24.TabIndex = 9;
this.radioButton24.TabStop = true;
this.radioButton24.Text = "spare";
this.radioButton24.UseVisualStyleBackColor = true;
this.radioButton24.CheckedChanged += new System.EventHandler(this.radioButton24_CheckedChanged);
//
// radioButton23
//
this.radioButton23.AutoSize = true;
this.radioButton23.Location = new System.Drawing.Point(212, 95);
this.radioButton23.Name = "radioButton23";
this.radioButton23.Size = new System.Drawing.Size(51, 17);
this.radioButton23.TabIndex = 8;
this.radioButton23.TabStop = true;
this.radioButton23.Text = "spare";
this.radioButton23.UseVisualStyleBackColor = true;
this.radioButton23.CheckedChanged += new System.EventHandler(this.radioButton23_CheckedChanged);
//
// radioButton22
//
this.radioButton22.AutoSize = true;
this.radioButton22.Location = new System.Drawing.Point(212, 72);
this.radioButton22.Name = "radioButton22";
this.radioButton22.Size = new System.Drawing.Size(51, 17);
this.radioButton22.TabIndex = 7;
this.radioButton22.TabStop = true;
this.radioButton22.Text = "spare";
this.radioButton22.UseVisualStyleBackColor = true;
this.radioButton22.CheckedChanged += new System.EventHandler(this.radioButton22_CheckedChanged);
//
// radioButton21
//
this.radioButton21.AutoSize = true;
this.radioButton21.Location = new System.Drawing.Point(212, 49);
this.radioButton21.Name = "radioButton21";
this.radioButton21.Size = new System.Drawing.Size(106, 17);
this.radioButton21.TabIndex = 6;
this.radioButton21.TabStop = true;
this.radioButton21.Text = "ReadPressureOp";
this.radioButton21.UseVisualStyleBackColor = true;
this.radioButton21.CheckedChanged += new System.EventHandler(this.radioButton21_CheckedChanged);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.radioButton24);
this.groupBox4.Controls.Add(this.radioButton4);
this.groupBox4.Controls.Add(this.radioButton23);
this.groupBox4.Controls.Add(this.radioButton0);
this.groupBox4.Controls.Add(this.radioButton22);
this.groupBox4.Controls.Add(this.radioButton3);
this.groupBox4.Controls.Add(this.radioButton21);
this.groupBox4.Controls.Add(this.radioButton1);
this.groupBox4.Controls.Add(this.radioButton2);
this.groupBox4.Location = new System.Drawing.Point(12, 349);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(405, 145);
this.groupBox4.TabIndex = 12;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Operations";
//
// DeviceTestDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(496, 377);
this.ClientSize = new System.Drawing.Size(496, 502);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.stopButton);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.startButton);
@ -269,6 +403,10 @@
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
}
@ -283,7 +421,7 @@
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button configureButton;
private System.Windows.Forms.Button configureComponentButton;
private System.Windows.Forms.TextBox componentNameTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
@ -294,6 +432,17 @@
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton0;
private System.Windows.Forms.Button stopButton;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.RadioButton radioButton24;
private System.Windows.Forms.RadioButton radioButton23;
private System.Windows.Forms.RadioButton radioButton22;
private System.Windows.Forms.RadioButton radioButton21;
private System.Windows.Forms.Button configureComponent2Button;
private System.Windows.Forms.TextBox component2NameTextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox component2ClassNameComboBox;
private System.Windows.Forms.GroupBox groupBox4;
}
}

View File

@ -19,28 +19,38 @@ namespace DeviceTest
IComponentFactory parentFactory;
IComponentFactory componentFactory;
IComponentFactory component2Factory;
IComponentCfg parentCfg;
IComponentCfg componentCfg;
IComponentCfg component2Cfg;
static IList<TBF.BenchControl.Generic.IDevice> tbfDevices;
static IList<TBF.BenchControl.Generic.IComponent> tbfComponents;
static TBF.BenchControl.Generic.IComponent tbfComponent4Op;
static TBF.BenchControl.Generic.IComponent tbfComponent24Op;
static Thread workerThread;
static bool workerThreadRunning;
static int activeOperationId;
static TBF.Boxes.FloatBox floatBox;
static int activeOperationId;
static IOperation operation1;
static IOperation operation2;
static IOperation operation3;
static IOperation operation4;
static IOperation operation21;
static IOperation operation22;
static IOperation operation23;
static IOperation operation24;
static TBF.Boxes.FloatBox floatBox;
static Event evnt;
static DeviceTestDlg()
{
floatBox = new TBF.Boxes.FloatBox();
@ -70,6 +80,7 @@ namespace DeviceTest
{
parentClassNameComboBox.Items.Add(clName);
componentClassNameComboBox.Items.Add(clName);
component2ClassNameComboBox.Items.Add(clName);
}
try
@ -117,7 +128,7 @@ namespace DeviceTest
{
IComponentCfg config = (IComponentCfg)(new XmlSerializer(componentFactory.DefaultConfig().GetType())).Deserialize(reader);
config.Name = Program.LocalSettings.ComponentName;
config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.ParentComponentName) ? string.Empty : Program.LocalSettings.ParentComponentName;
config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.ComponentParentName) ? string.Empty : Program.LocalSettings.ComponentParentName;
config.ItemNr = 1;
config.DebugLevel = Config.Entities.DebugMode.Normal;
config.LogLevel = Config.Entities.LogLevel.Debug;
@ -128,6 +139,8 @@ namespace DeviceTest
componentClassNameComboBox.Text = Program.LocalSettings.ComponentClassName;
componentNameTextBox.Text = Program.LocalSettings.ComponentName;
UpdateOperations(componentClassNameComboBox.Text);
}
}
catch
@ -137,7 +150,42 @@ namespace DeviceTest
componentClassNameComboBox.Text = string.Empty;
componentNameTextBox.Text = string.Empty;
}
}
try
{
if (!string.IsNullOrEmpty(Program.LocalSettings.Component2ClassName) &&
!string.IsNullOrEmpty(Program.LocalSettings.Component2Name) &&
!string.IsNullOrEmpty(Program.LocalSettings.Component2Settings))
{
FactoryFromClassName(Program.LocalSettings.Component2ClassName, ref component2Factory);
using (var reader = new StringReader(Program.LocalSettings.Component2Settings))
{
IComponentCfg config = (IComponentCfg)(new XmlSerializer(component2Factory.DefaultConfig().GetType())).Deserialize(reader);
config.Name = Program.LocalSettings.Component2Name;
config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.Component2ParentName) ? string.Empty : Program.LocalSettings.Component2ParentName;
config.ItemNr = 2;
config.DebugLevel = Config.Entities.DebugMode.Normal;
config.LogLevel = Config.Entities.LogLevel.Debug;
config.Corrections = null;
config.Factory = component2Factory;
component2Cfg = config;
}
component2ClassNameComboBox.Text = Program.LocalSettings.Component2ClassName;
component2NameTextBox.Text = Program.LocalSettings.Component2Name;
UpdateOperations2(component2ClassNameComboBox.Text);
}
}
catch
{
component2Factory = null;
component2Cfg = null;
component2ClassNameComboBox.Text = string.Empty;
component2NameTextBox.Text = string.Empty;
}
}
void SaveSettings()
{
@ -147,27 +195,61 @@ namespace DeviceTest
Program.LocalSettings.ComponentClassName = componentClassNameComboBox.Text;
Program.LocalSettings.ComponentName = componentNameTextBox.Text;
Program.LocalSettings.ParentComponentName = componentCfg.ParentName;
Program.LocalSettings.ComponentParentName = componentCfg.ParentName;
Program.LocalSettings.ComponentSettings = (componentCfg != null) ? componentCfg.CreateDbEntity().Parameters : string.Empty;
Program.LocalSettings.Component2ClassName = component2ClassNameComboBox.Text;
Program.LocalSettings.Component2Name = component2NameTextBox.Text;
Program.LocalSettings.Component2ParentName = component2Cfg.ParentName;
Program.LocalSettings.Component2Settings = (component2Cfg != null) ? component2Cfg.CreateDbEntity().Parameters : string.Empty;
Program.LocalSettings.Save();
}
void UpdateOperations(string className)
{
if (className == "Keithley.TempMeter") radioButton1.Text = "ReadPressureOp";
else if (className == "Network.Camera.CLP1611") radioButton1.Text = "Livestream";
else if (className == "Network.Camera.RoI") radioButton1.Text = "RoiDetection";
else radioButton1.Text = "spare";
}
///
void UpdateOperations2(string className)
{
if (className == "Keithley.TempMeter") radioButton21.Text = "ReadPressureOp";
else if (className == "Network.Camera.CLP1611") radioButton21.Text = "Livestream";
else if (className == "Network.Camera.RoI") radioButton21.Text = "RoiDetection";
else radioButton21.Text = "spare";
}
int GetActiveOperationId()
{
if (radioButton1.Checked) { return 1; }
else if (radioButton2.Checked) { return 2; }
else if (radioButton3.Checked) { return 3; }
else if (radioButton4.Checked) { return 4; }
else if (radioButton21.Checked) { return 21; }
else if (radioButton22.Checked) { return 22; }
else if (radioButton23.Checked) { return 23; }
else if (radioButton24.Checked) { return 24; }
else return 0; /// stopOperationRadioButton.Checked
}
private void radioButton0_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton1_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton2_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton4_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
///
private void radioButton20_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton21_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton22_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton23_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
private void radioButton24_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); }
int GetActiveOperationId()
{
if (radioButton1.Checked) return 1;
else if (radioButton2.Checked) return 2;
else if (radioButton3.Checked) return 3;
else if (radioButton4.Checked) return 4;
else return 0; /// stopOperationRadioButton.Checked
}
/// <summary>
/// Updates component factory
@ -231,7 +313,7 @@ namespace DeviceTest
}
private void configureButton_Click(object sender, EventArgs e)
private void configureComponentButton_Click(object sender, EventArgs e)
{
bool factoryChanged = FactoryFromClassName(componentClassNameComboBox.Text, ref componentFactory);
if (componentFactory == null)
@ -260,6 +342,43 @@ namespace DeviceTest
if (dr != DialogResult.OK) return;
componentNameTextBox.Text = componentCfg.Name;
UpdateOperations(componentClassNameComboBox.Text);
}
private void configureComponent2Button_Click(object sender, EventArgs e)
{
bool factoryChanged = FactoryFromClassName(component2ClassNameComboBox.Text, ref component2Factory);
if (component2Factory == null)
{
MessageBox.Show("Invalid component class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (factoryChanged || component2Cfg == null)
{
component2Cfg = component2Factory.DefaultConfig();
}
IComponentCfgCtrl cfgControl = component2Cfg.GetControl();
cfgControl.Config = component2Cfg;
cfgControl.Config.ItemNr = 1;
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
///
IList<Config.Entities.Component> compEntities = new List<Config.Entities.Component>();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
if (componentFactory != null && componentCfg != null) compEntities.Add(componentCfg.CreateDbEntity());
cfgForm.TbfComponents = compEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
DialogResult dr = cfgForm.ShowDialog();
if (dr != DialogResult.OK) return;
component2NameTextBox.Text = component2Cfg.Name;
UpdateOperations2(component2ClassNameComboBox.Text);
}
@ -272,6 +391,11 @@ namespace DeviceTest
operation2 = null;
operation3 = null;
operation4 = null;
tbfComponent24Op = null;
operation21 = null;
operation22 = null;
operation23 = null;
operation24 = null;
workerThreadRunning = false;
string initializedDeviceName = "none";
@ -302,6 +426,19 @@ namespace DeviceTest
tbfDevices.Add(dev);
}
}
if (component2Factory != null && component2Cfg != null)
{
TBF.BenchControl.Generic.IComponent component2 = component2Factory.GetComponent(component2Cfg, tbfComponents);
tbfComponents.Add(component2);
tbfComponent24Op = component2;
IDevice dev = component2 as IDevice;
if (dev != null)
{
initializedDeviceName = dev.Name;
dev.Initialize();
tbfDevices.Add(dev);
}
}
if (tbfComponents.Count == 0) throw new Exception("There are no components");
@ -315,7 +452,8 @@ namespace DeviceTest
startButton.Enabled = false;
stopButton.Enabled = true;
configureButton.Enabled = false;
configureComponent2Button.Enabled = false;
configureComponentButton.Enabled = false;
configureParentButton.Enabled = false;
}
catch (Exception exc)
@ -333,10 +471,10 @@ namespace DeviceTest
startButton.Enabled = true;
stopButton.Enabled = false;
configureButton.Enabled = true;
configureComponent2Button.Enabled = true;
configureComponentButton.Enabled = true;
configureParentButton.Enabled = true;
}
}
@ -345,6 +483,7 @@ namespace DeviceTest
int activeOperationLocal = 0;
int previousOperation = 0;
if (tbfComponent4Op is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter)
{
operation1 = (tbfComponent4Op as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox);
@ -352,7 +491,28 @@ namespace DeviceTest
else if (tbfComponent4Op is TBF.BenchControl.Network.Camera.CLP1611.Camera)
{
operation1 = (tbfComponent4Op as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp();
operation2 = (tbfComponent4Op as TBF.BenchControl.Network.Camera.CLP1611.Camera).HRLiveStreamOp();
}
else if (tbfComponent4Op is TBF.BenchControl.Network.Camera.RoI.RoI)
{
operation1 = (tbfComponent4Op as TBF.BenchControl.Network.Camera.RoI.RoI).RoiDetectionOp();
}
if (tbfComponent24Op is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter)
{
operation21 = (tbfComponent24Op as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox);
}
else if (tbfComponent24Op is TBF.BenchControl.Network.Camera.CLP1611.Camera)
{
operation21 = (tbfComponent24Op as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp();
operation22 = (tbfComponent24Op as TBF.BenchControl.Network.Camera.CLP1611.Camera).HRLiveStreamOp();
}
else if (tbfComponent24Op is TBF.BenchControl.Network.Camera.RoI.RoI)
{
operation21 = (tbfComponent24Op as TBF.BenchControl.Network.Camera.RoI.RoI).RoiDetectionOp();
}
while (workerThreadRunning)
{
@ -370,20 +530,28 @@ namespace DeviceTest
{
switch (activeOperationLocal)
{
case 1: if (operation1 != null) operation1.Start(); Debug.WriteLine("op1.Start()"); break;
case 2: if (operation2 != null) operation2.Start(); Debug.WriteLine("op2.Start()"); break;
case 3: if (operation3 != null) operation3.Start(); Debug.WriteLine("op3.Start()"); break;
case 4: if (operation4 != null) operation4.Start(); Debug.WriteLine("op4.Start()"); break;
case 1: if (operation1 != null) operation1.Start(); Debug.WriteLine("op1.Start()"); break;
case 2: if (operation2 != null) operation2.Start(); Debug.WriteLine("op2.Start()"); break;
case 3: if (operation3 != null) operation3.Start(); Debug.WriteLine("op3.Start()"); break;
case 4: if (operation4 != null) operation4.Start(); Debug.WriteLine("op4.Start()"); break;
case 21: if (operation21 != null) operation21.Start(); Debug.WriteLine("op21.Start()"); break;
case 22: if (operation22 != null) operation22.Start(); Debug.WriteLine("op22.Start()"); break;
case 23: if (operation23 != null) operation23.Start(); Debug.WriteLine("op23.Start()"); break;
case 24: if (operation24 != null) operation24.Start(); Debug.WriteLine("op24.Start()"); break;
}
}
else if (previousOperation == activeOperationLocal && activeOperationLocal != 0)
{
switch (activeOperationLocal)
{
case 1: if (operation1 != null) evnt = operation1.Run(); Debug.WriteLine("op1.Run() -> {0}, pressure = {1} kPa", evnt, floatBox); break;
case 2: if (operation2 != null) evnt = operation2.Run(); Debug.WriteLine("op2.Run() -> {0}", evnt); break;
case 3: if (operation3 != null) evnt = operation3.Run(); Debug.WriteLine("op3.Run() -> {0}", evnt); break;
case 4: if (operation4 != null) evnt = operation4.Run(); Debug.WriteLine("op4.Run() -> {0}", evnt); break;
case 1: if (operation1 != null) evnt = operation1.Run(); Debug.WriteLine("op1.Run() -> {0}", evnt); break;
case 2: if (operation2 != null) evnt = operation2.Run(); Debug.WriteLine("op2.Run() -> {0}", evnt); break;
case 3: if (operation3 != null) evnt = operation3.Run(); Debug.WriteLine("op3.Run() -> {0}", evnt); break;
case 4: if (operation4 != null) evnt = operation4.Run(); Debug.WriteLine("op4.Run() -> {0}", evnt); break;
case 21: if (operation21 != null) evnt = operation21.Run(); Debug.WriteLine("op21.Run() -> {0}", evnt); break;
case 22: if (operation22 != null) evnt = operation22.Run(); Debug.WriteLine("op22.Run() -> {0}", evnt); break;
case 23: if (operation23 != null) evnt = operation23.Run(); Debug.WriteLine("op23.Run() -> {0}", evnt); break;
case 24: if (operation24 != null) evnt = operation24.Run(); Debug.WriteLine("op24.Run() -> {0}", evnt); break;
default: evnt = Event.None; break;
}
}
@ -391,10 +559,14 @@ namespace DeviceTest
{
switch (previousOperation)
{
case 1: if (operation1 != null) operation1.Stop(); Debug.WriteLine("op1.Stop()"); break;
case 2: if (operation2 != null) operation2.Stop(); Debug.WriteLine("op2.Stop()"); break;
case 3: if (operation3 != null) operation3.Stop(); Debug.WriteLine("op3.Stop()"); break;
case 4: if (operation4 != null) operation4.Stop(); Debug.WriteLine("op4.Stop()"); break;
case 1: if (operation1 != null) operation1.Stop(); Debug.WriteLine("op1.Stop()"); break;
case 2: if (operation2 != null) operation2.Stop(); Debug.WriteLine("op2.Stop()"); break;
case 3: if (operation3 != null) operation3.Stop(); Debug.WriteLine("op3.Stop()"); break;
case 4: if (operation4 != null) operation4.Stop(); Debug.WriteLine("op4.Stop()"); break;
case 21: if (operation21 != null) operation21.Stop(); Debug.WriteLine("op21.Stop()"); break;
case 22: if (operation22 != null) operation22.Stop(); Debug.WriteLine("op22.Stop()"); break;
case 23: if (operation23 != null) operation23.Stop(); Debug.WriteLine("op23.Stop()"); break;
case 24: if (operation24 != null) operation24.Stop(); Debug.WriteLine("op24.Stop()"); break;
}
}
}
@ -418,7 +590,8 @@ namespace DeviceTest
startButton.Enabled = true;
stopButton.Enabled = false;
configureButton.Enabled = true;
configureComponent2Button.Enabled = true;
configureComponentButton.Enabled = true;
configureParentButton.Enabled = true;
}

View File

@ -17,9 +17,14 @@ namespace DeviceTest
public string ComponentClassName;
public string ComponentName;
public string ParentComponentName;
public string ComponentParentName;
public string ComponentSettings;
public string Component2ClassName;
public string Component2Name;
public string Component2ParentName;
public string Component2Settings;
public LocalSettings()
{
}