diff --git a/DeviceTest/DeviceTestDlg.Designer.cs b/DeviceTest/DeviceTestDlg.Designer.cs index 21f409178..3077a04ce 100644 --- a/DeviceTest/DeviceTestDlg.Designer.cs +++ b/DeviceTest/DeviceTestDlg.Designer.cs @@ -36,11 +36,11 @@ 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.configureComponent1Button = 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.component1ClassNameComboBox = 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(); @@ -58,10 +58,21 @@ this.radioButton22 = new System.Windows.Forms.RadioButton(); this.radioButton21 = new System.Windows.Forms.RadioButton(); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.radioButton34 = new System.Windows.Forms.RadioButton(); + this.radioButton33 = new System.Windows.Forms.RadioButton(); + this.radioButton32 = new System.Windows.Forms.RadioButton(); + this.radioButton31 = new System.Windows.Forms.RadioButton(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.configureComponent3Button = new System.Windows.Forms.Button(); + this.component3NameTextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.component3ClassNameComboBox = new System.Windows.Forms.ComboBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); this.groupBox4.SuspendLayout(); + this.groupBox5.SuspendLayout(); this.SuspendLayout(); // // parentClassNameComboBox @@ -100,9 +111,9 @@ // // configureParentButton // - this.configureParentButton.Location = new System.Drawing.Point(77, 70); + this.configureParentButton.Location = new System.Drawing.Point(395, 19); this.configureParentButton.Name = "configureParentButton"; - this.configureParentButton.Size = new System.Drawing.Size(129, 28); + this.configureParentButton.Size = new System.Drawing.Size(73, 45); this.configureParentButton.TabIndex = 4; this.configureParentButton.Text = "Configure"; this.configureParentButton.UseVisualStyleBackColor = true; @@ -110,9 +121,10 @@ // // startButton // - this.startButton.Location = new System.Drawing.Point(431, 17); + this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.startButton.Location = new System.Drawing.Point(520, 19); this.startButton.Name = "startButton"; - this.startButton.Size = new System.Drawing.Size(53, 46); + this.startButton.Size = new System.Drawing.Size(73, 45); this.startButton.TabIndex = 7; this.startButton.Text = "Start"; this.startButton.UseVisualStyleBackColor = true; @@ -127,34 +139,34 @@ 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, 105); + this.groupBox1.Size = new System.Drawing.Size(486, 75); this.groupBox1.TabIndex = 8; this.groupBox1.TabStop = false; this.groupBox1.Text = "Parent component"; // // groupBox2 // - this.groupBox2.Controls.Add(this.configureComponentButton); + this.groupBox2.Controls.Add(this.configureComponent1Button); 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.Controls.Add(this.component1ClassNameComboBox); + this.groupBox2.Location = new System.Drawing.Point(12, 93); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(405, 105); + this.groupBox2.Size = new System.Drawing.Size(486, 75); this.groupBox2.TabIndex = 9; this.groupBox2.TabStop = false; - this.groupBox2.Text = "Component"; + this.groupBox2.Text = "Component 1"; // // configureComponentButton // - 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); + this.configureComponent1Button.Location = new System.Drawing.Point(395, 19); + this.configureComponent1Button.Name = "configureComponentButton"; + this.configureComponent1Button.Size = new System.Drawing.Size(73, 45); + this.configureComponent1Button.TabIndex = 4; + this.configureComponent1Button.Text = "Configure"; + this.configureComponent1Button.UseVisualStyleBackColor = true; + this.configureComponent1Button.Click += new System.EventHandler(this.configureComponent1Button_Click); // // componentNameTextBox // @@ -184,11 +196,11 @@ // // componentClassNameComboBox // - this.componentClassNameComboBox.FormattingEnabled = true; - this.componentClassNameComboBox.Location = new System.Drawing.Point(77, 19); - this.componentClassNameComboBox.Name = "componentClassNameComboBox"; - this.componentClassNameComboBox.Size = new System.Drawing.Size(299, 21); - this.componentClassNameComboBox.TabIndex = 0; + this.component1ClassNameComboBox.FormattingEnabled = true; + this.component1ClassNameComboBox.Location = new System.Drawing.Point(77, 19); + this.component1ClassNameComboBox.Name = "componentClassNameComboBox"; + this.component1ClassNameComboBox.Size = new System.Drawing.Size(299, 21); + this.component1ClassNameComboBox.TabIndex = 0; // // radioButton4 // @@ -252,9 +264,10 @@ // // stopButton // - this.stopButton.Location = new System.Drawing.Point(431, 73); + this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.stopButton.Location = new System.Drawing.Point(520, 77); this.stopButton.Name = "stopButton"; - this.stopButton.Size = new System.Drawing.Size(53, 46); + this.stopButton.Size = new System.Drawing.Size(73, 45); this.stopButton.TabIndex = 10; this.stopButton.Text = "Stop"; this.stopButton.UseVisualStyleBackColor = true; @@ -267,18 +280,18 @@ 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.Location = new System.Drawing.Point(12, 174); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(405, 105); + this.groupBox3.Size = new System.Drawing.Size(486, 75); 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.Location = new System.Drawing.Point(395, 19); this.configureComponent2Button.Name = "configureComponent2Button"; - this.configureComponent2Button.Size = new System.Drawing.Size(129, 28); + this.configureComponent2Button.Size = new System.Drawing.Size(73, 45); this.configureComponent2Button.TabIndex = 4; this.configureComponent2Button.Text = "Configure"; this.configureComponent2Button.UseVisualStyleBackColor = true; @@ -368,6 +381,10 @@ // // groupBox4 // + this.groupBox4.Controls.Add(this.radioButton34); + this.groupBox4.Controls.Add(this.radioButton33); + this.groupBox4.Controls.Add(this.radioButton32); + this.groupBox4.Controls.Add(this.radioButton31); this.groupBox4.Controls.Add(this.radioButton24); this.groupBox4.Controls.Add(this.radioButton4); this.groupBox4.Controls.Add(this.radioButton23); @@ -379,16 +396,123 @@ 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.Size = new System.Drawing.Size(581, 145); this.groupBox4.TabIndex = 12; this.groupBox4.TabStop = false; this.groupBox4.Text = "Operations"; // + // radioButton34 + // + this.radioButton34.AutoSize = true; + this.radioButton34.Location = new System.Drawing.Point(405, 118); + this.radioButton34.Name = "radioButton34"; + this.radioButton34.Size = new System.Drawing.Size(51, 17); + this.radioButton34.TabIndex = 13; + this.radioButton34.TabStop = true; + this.radioButton34.Text = "spare"; + this.radioButton34.UseVisualStyleBackColor = true; + this.radioButton34.CheckedChanged += new System.EventHandler(this.radioButton34_CheckedChanged); + // + // radioButton33 + // + this.radioButton33.AutoSize = true; + this.radioButton33.Location = new System.Drawing.Point(405, 95); + this.radioButton33.Name = "radioButton33"; + this.radioButton33.Size = new System.Drawing.Size(51, 17); + this.radioButton33.TabIndex = 12; + this.radioButton33.TabStop = true; + this.radioButton33.Text = "spare"; + this.radioButton33.UseVisualStyleBackColor = true; + this.radioButton33.CheckedChanged += new System.EventHandler(this.radioButton33_CheckedChanged); + // + // radioButton32 + // + this.radioButton32.AutoSize = true; + this.radioButton32.Location = new System.Drawing.Point(405, 72); + this.radioButton32.Name = "radioButton32"; + this.radioButton32.Size = new System.Drawing.Size(51, 17); + this.radioButton32.TabIndex = 11; + this.radioButton32.TabStop = true; + this.radioButton32.Text = "spare"; + this.radioButton32.UseVisualStyleBackColor = true; + this.radioButton32.CheckedChanged += new System.EventHandler(this.radioButton32_CheckedChanged); + // + // radioButton31 + // + this.radioButton31.AutoSize = true; + this.radioButton31.Location = new System.Drawing.Point(405, 49); + this.radioButton31.Name = "radioButton31"; + this.radioButton31.Size = new System.Drawing.Size(106, 17); + this.radioButton31.TabIndex = 10; + this.radioButton31.TabStop = true; + this.radioButton31.Text = "ReadPressureOp"; + this.radioButton31.UseVisualStyleBackColor = true; + this.radioButton31.CheckedChanged += new System.EventHandler(this.radioButton31_CheckedChanged); + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.configureComponent3Button); + this.groupBox5.Controls.Add(this.component3NameTextBox); + this.groupBox5.Controls.Add(this.label5); + this.groupBox5.Controls.Add(this.label6); + this.groupBox5.Controls.Add(this.component3ClassNameComboBox); + this.groupBox5.Location = new System.Drawing.Point(12, 255); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(486, 75); + this.groupBox5.TabIndex = 13; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "Component 3"; + // + // configureComponent3Button + // + this.configureComponent3Button.Location = new System.Drawing.Point(395, 19); + this.configureComponent3Button.Name = "configureComponent3Button"; + this.configureComponent3Button.Size = new System.Drawing.Size(73, 45); + this.configureComponent3Button.TabIndex = 4; + this.configureComponent3Button.Text = "Configure"; + this.configureComponent3Button.UseVisualStyleBackColor = true; + this.configureComponent3Button.Click += new System.EventHandler(this.configureComponent3Button_Click); + // + // component3NameTextBox + // + this.component3NameTextBox.Enabled = false; + this.component3NameTextBox.Location = new System.Drawing.Point(77, 44); + this.component3NameTextBox.Name = "component3NameTextBox"; + this.component3NameTextBox.Size = new System.Drawing.Size(299, 20); + this.component3NameTextBox.TabIndex = 3; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(11, 47); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(35, 13); + this.label5.TabIndex = 2; + this.label5.Text = "Name"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(11, 22); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(32, 13); + this.label6.TabIndex = 1; + this.label6.Text = "Class"; + // + // component3ClassNameComboBox + // + this.component3ClassNameComboBox.FormattingEnabled = true; + this.component3ClassNameComboBox.Location = new System.Drawing.Point(77, 19); + this.component3ClassNameComboBox.Name = "component3ClassNameComboBox"; + this.component3ClassNameComboBox.Size = new System.Drawing.Size(299, 21); + this.component3ClassNameComboBox.TabIndex = 0; + // // DeviceTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(496, 502); + this.ClientSize = new System.Drawing.Size(613, 502); + this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.stopButton); @@ -407,6 +531,8 @@ this.groupBox3.PerformLayout(); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); + this.groupBox5.ResumeLayout(false); + this.groupBox5.PerformLayout(); this.ResumeLayout(false); } @@ -421,11 +547,11 @@ private System.Windows.Forms.Button startButton; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Button configureComponentButton; + private System.Windows.Forms.Button configureComponent1Button; private System.Windows.Forms.TextBox componentNameTextBox; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.ComboBox componentClassNameComboBox; + private System.Windows.Forms.ComboBox component1ClassNameComboBox; private System.Windows.Forms.RadioButton radioButton4; private System.Windows.Forms.RadioButton radioButton3; private System.Windows.Forms.RadioButton radioButton2; @@ -443,6 +569,16 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.ComboBox component2ClassNameComboBox; private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.Button configureComponent3Button; + private System.Windows.Forms.TextBox component3NameTextBox; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.ComboBox component3ClassNameComboBox; + private System.Windows.Forms.RadioButton radioButton34; + private System.Windows.Forms.RadioButton radioButton33; + private System.Windows.Forms.RadioButton radioButton32; + private System.Windows.Forms.RadioButton radioButton31; } } diff --git a/DeviceTest/DeviceTestDlg.cs b/DeviceTest/DeviceTestDlg.cs index d7b7a3536..5acd94d04 100644 --- a/DeviceTest/DeviceTestDlg.cs +++ b/DeviceTest/DeviceTestDlg.cs @@ -18,17 +18,20 @@ namespace DeviceTest IList compClasses; IComponentFactory parentFactory; - IComponentFactory componentFactory; + IComponentFactory component1Factory; IComponentFactory component2Factory; + IComponentFactory component3Factory; IComponentCfg parentCfg; - IComponentCfg componentCfg; + IComponentCfg component1Cfg; IComponentCfg component2Cfg; + IComponentCfg component3Cfg; static IList tbfDevices; static IList tbfComponents; - static TBF.BenchControl.Generic.IComponent tbfComponent4Op; - static TBF.BenchControl.Generic.IComponent tbfComponent24Op; + static TBF.BenchControl.Generic.IComponent tbfComponent1forOp; + static TBF.BenchControl.Generic.IComponent tbfComponent2forOp; + static TBF.BenchControl.Generic.IComponent tbfComponent3forOp; static Thread workerThread; static bool workerThreadRunning; @@ -46,6 +49,11 @@ namespace DeviceTest static IOperation operation23; static IOperation operation24; + static IOperation operation31; + static IOperation operation32; + static IOperation operation33; + static IOperation operation34; + static TBF.Boxes.FloatBox floatBox; static Event evnt; @@ -79,8 +87,9 @@ namespace DeviceTest foreach (var clName in compClasses) { parentClassNameComboBox.Items.Add(clName); - componentClassNameComboBox.Items.Add(clName); + component1ClassNameComboBox.Items.Add(clName); component2ClassNameComboBox.Items.Add(clName); + component3ClassNameComboBox.Items.Add(clName); } try @@ -122,32 +131,32 @@ namespace DeviceTest !string.IsNullOrEmpty(Program.LocalSettings.ComponentName) && !string.IsNullOrEmpty(Program.LocalSettings.ComponentSettings)) { - FactoryFromClassName(Program.LocalSettings.ComponentClassName, ref componentFactory); + FactoryFromClassName(Program.LocalSettings.ComponentClassName, ref component1Factory); using (var reader = new StringReader(Program.LocalSettings.ComponentSettings)) { - IComponentCfg config = (IComponentCfg)(new XmlSerializer(componentFactory.DefaultConfig().GetType())).Deserialize(reader); + IComponentCfg config = (IComponentCfg)(new XmlSerializer(component1Factory.DefaultConfig().GetType())).Deserialize(reader); config.Name = Program.LocalSettings.ComponentName; 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; config.Corrections = null; - config.Factory = componentFactory; - componentCfg = config; + config.Factory = component1Factory; + component1Cfg = config; } - componentClassNameComboBox.Text = Program.LocalSettings.ComponentClassName; + component1ClassNameComboBox.Text = Program.LocalSettings.ComponentClassName; componentNameTextBox.Text = Program.LocalSettings.ComponentName; - UpdateOperations(componentClassNameComboBox.Text); + UpdateOperations(component1ClassNameComboBox.Text); } } catch { - componentFactory = null; - componentCfg = null; - componentClassNameComboBox.Text = string.Empty; + component1Factory = null; + component1Cfg = null; + component1ClassNameComboBox.Text = string.Empty; componentNameTextBox.Text = string.Empty; } @@ -185,6 +194,41 @@ namespace DeviceTest component2ClassNameComboBox.Text = string.Empty; component2NameTextBox.Text = string.Empty; } + + try + { + if (!string.IsNullOrEmpty(Program.LocalSettings.Component3ClassName) && + !string.IsNullOrEmpty(Program.LocalSettings.Component3Name) && + !string.IsNullOrEmpty(Program.LocalSettings.Component3Settings)) + { + FactoryFromClassName(Program.LocalSettings.Component3ClassName, ref component3Factory); + + using (var reader = new StringReader(Program.LocalSettings.Component3Settings)) + { + IComponentCfg config = (IComponentCfg)(new XmlSerializer(component3Factory.DefaultConfig().GetType())).Deserialize(reader); + config.Name = Program.LocalSettings.Component3Name; + config.ParentName = string.IsNullOrEmpty(Program.LocalSettings.Component3ParentName) ? string.Empty : Program.LocalSettings.Component3ParentName; + config.ItemNr = 3; + config.DebugLevel = Config.Entities.DebugMode.Normal; + config.LogLevel = Config.Entities.LogLevel.Debug; + config.Corrections = null; + config.Factory = component3Factory; + component3Cfg = config; + } + + component3ClassNameComboBox.Text = Program.LocalSettings.Component3ClassName; + component3NameTextBox.Text = Program.LocalSettings.Component3Name; + + UpdateOperations3(component3ClassNameComboBox.Text); + } + } + catch + { + component3Factory = null; + component3Cfg = null; + component3ClassNameComboBox.Text = string.Empty; + component3NameTextBox.Text = string.Empty; + } } void SaveSettings() @@ -193,23 +237,28 @@ namespace DeviceTest Program.LocalSettings.ParentName = parentNameTextBox.Text; Program.LocalSettings.ParentSettings = (parentCfg != null) ? parentCfg.CreateDbEntity().Parameters : string.Empty; - Program.LocalSettings.ComponentClassName = componentClassNameComboBox.Text; + Program.LocalSettings.ComponentClassName = component1ClassNameComboBox.Text; Program.LocalSettings.ComponentName = componentNameTextBox.Text; - Program.LocalSettings.ComponentParentName = componentCfg.ParentName; - Program.LocalSettings.ComponentSettings = (componentCfg != null) ? componentCfg.CreateDbEntity().Parameters : string.Empty; + Program.LocalSettings.ComponentParentName = component1Cfg.ParentName; + Program.LocalSettings.ComponentSettings = (component1Cfg != null) ? component1Cfg.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.Component3ClassName = component3ClassNameComboBox.Text; + Program.LocalSettings.Component3Name = component3NameTextBox.Text; + Program.LocalSettings.Component3ParentName = component3Cfg.ParentName; + Program.LocalSettings.Component3Settings = (component3Cfg != null) ? component3Cfg.CreateDbEntity().Parameters : string.Empty; + Program.LocalSettings.Save(); } void UpdateOperations(string className) { - if (className == "Keithley.TempMeter") radioButton1.Text = "ReadPressureOp"; + 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"; @@ -217,23 +266,35 @@ namespace DeviceTest /// void UpdateOperations2(string className) { - if (className == "Keithley.TempMeter") radioButton21.Text = "ReadPressureOp"; + 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"; } + /// + void UpdateOperations3(string className) + { + if (className == "Keithley.TempMeter") radioButton31.Text = "ReadPressureOp"; + else if (className == "Network.Camera.CLP1611") radioButton31.Text = "Livestream"; + else if (className == "Network.Camera.Roi") radioButton31.Text = "RoiDetection"; + else radioButton31.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; } + 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 if (radioButton31.Checked) { return 31; } + else if (radioButton32.Checked) { return 32; } + else if (radioButton33.Checked) { return 33; } + else if (radioButton34.Checked) { return 34; } else return 0; /// stopOperationRadioButton.Checked } @@ -244,11 +305,15 @@ namespace DeviceTest 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(); } + /// + private void radioButton31_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); } + private void radioButton32_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); } + private void radioButton33_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); } + private void radioButton34_CheckedChanged(object sender, EventArgs e) { activeOperationId = GetActiveOperationId(); } /// @@ -313,21 +378,21 @@ namespace DeviceTest } - private void configureComponentButton_Click(object sender, EventArgs e) + private void configureComponent1Button_Click(object sender, EventArgs e) { - bool factoryChanged = FactoryFromClassName(componentClassNameComboBox.Text, ref componentFactory); - if (componentFactory == null) + bool factoryChanged = FactoryFromClassName(component1ClassNameComboBox.Text, ref component1Factory); + if (component1Factory == null) { MessageBox.Show("Invalid component class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } - if (factoryChanged || componentCfg == null) + if (factoryChanged || component1Cfg == null) { - componentCfg = componentFactory.DefaultConfig(); + component1Cfg = component1Factory.DefaultConfig(); } - IComponentCfgCtrl cfgControl = componentCfg.GetControl(); - cfgControl.Config = componentCfg; + IComponentCfgCtrl cfgControl = component1Cfg.GetControl(); + cfgControl.Config = component1Cfg; cfgControl.Config.ItemNr = 1; TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg(); @@ -341,9 +406,9 @@ namespace DeviceTest DialogResult dr = cfgForm.ShowDialog(); if (dr != DialogResult.OK) return; - componentNameTextBox.Text = componentCfg.Name; + componentNameTextBox.Text = component1Cfg.Name; - UpdateOperations(componentClassNameComboBox.Text); + UpdateOperations(component1ClassNameComboBox.Text); } @@ -368,7 +433,7 @@ namespace DeviceTest /// IList compEntities = new List(); if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity()); - if (componentFactory != null && componentCfg != null) compEntities.Add(componentCfg.CreateDbEntity()); + if (component1Factory != null && component1Cfg != null) compEntities.Add(component1Cfg.CreateDbEntity()); cfgForm.TbfComponents = compEntities; cfgForm.ComponentCfgCtrl = cfgControl; @@ -382,20 +447,61 @@ namespace DeviceTest } + private void configureComponent3Button_Click(object sender, EventArgs e) + { + bool factoryChanged = FactoryFromClassName(component3ClassNameComboBox.Text, ref component3Factory); + if (component3Factory == null) + { + MessageBox.Show("Invalid component class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + if (factoryChanged || component3Cfg == null) + { + component3Cfg = component3Factory.DefaultConfig(); + } + IComponentCfgCtrl cfgControl = component3Cfg.GetControl(); + cfgControl.Config = component3Cfg; + cfgControl.Config.ItemNr = 1; + + TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg(); + /// + IList compEntities = new List(); + if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity()); + if (component1Factory != null && component1Cfg != null) compEntities.Add(component1Cfg.CreateDbEntity()); + if (component2Factory != null && component2Cfg != null) compEntities.Add(component2Cfg.CreateDbEntity()); + cfgForm.TbfComponents = compEntities; + + cfgForm.ComponentCfgCtrl = cfgControl; + cfgForm.UnlockAfterStart = true; + DialogResult dr = cfgForm.ShowDialog(); + if (dr != DialogResult.OK) return; + + component3NameTextBox.Text = component3Cfg.Name; + + UpdateOperations3(component3ClassNameComboBox.Text); + } + + private void startButton_Click(object sender, EventArgs e) { tbfComponents.Clear(); tbfDevices.Clear(); - tbfComponent4Op = null; + tbfComponent1forOp = null; operation1 = null; operation2 = null; operation3 = null; operation4 = null; - tbfComponent24Op = null; + tbfComponent2forOp = null; operation21 = null; operation22 = null; operation23 = null; operation24 = null; + tbfComponent3forOp = null; + operation31 = null; + operation32 = null; + operation33 = null; + operation34 = null; workerThreadRunning = false; string initializedDeviceName = "none"; @@ -413,11 +519,11 @@ namespace DeviceTest tbfDevices.Add(dev); } } - if (componentFactory != null && componentCfg != null) + if (component1Factory != null && component1Cfg != null) { - TBF.BenchControl.Generic.IComponent component = componentFactory.GetComponent(componentCfg, tbfComponents); + TBF.BenchControl.Generic.IComponent component = component1Factory.GetComponent(component1Cfg, tbfComponents); tbfComponents.Add(component); - tbfComponent4Op = component; + tbfComponent1forOp = component; IDevice dev = component as IDevice; if (dev != null) { @@ -430,7 +536,7 @@ namespace DeviceTest { TBF.BenchControl.Generic.IComponent component2 = component2Factory.GetComponent(component2Cfg, tbfComponents); tbfComponents.Add(component2); - tbfComponent24Op = component2; + tbfComponent2forOp = component2; IDevice dev = component2 as IDevice; if (dev != null) { @@ -439,6 +545,19 @@ namespace DeviceTest tbfDevices.Add(dev); } } + if (component3Factory != null && component3Cfg != null) + { + TBF.BenchControl.Generic.IComponent component3 = component3Factory.GetComponent(component3Cfg, tbfComponents); + tbfComponents.Add(component3); + tbfComponent3forOp = component3; + IDevice dev = component3 as IDevice; + if (dev != null) + { + initializedDeviceName = dev.Name; + dev.Initialize(); + tbfDevices.Add(dev); + } + } if (tbfComponents.Count == 0) throw new Exception("There are no components"); @@ -453,7 +572,7 @@ namespace DeviceTest startButton.Enabled = false; stopButton.Enabled = true; configureComponent2Button.Enabled = false; - configureComponentButton.Enabled = false; + configureComponent1Button.Enabled = false; configureParentButton.Enabled = false; } catch (Exception exc) @@ -472,7 +591,7 @@ namespace DeviceTest startButton.Enabled = true; stopButton.Enabled = false; configureComponent2Button.Enabled = true; - configureComponentButton.Enabled = true; + configureComponent1Button.Enabled = true; configureParentButton.Enabled = true; } } @@ -484,33 +603,48 @@ namespace DeviceTest int previousOperation = 0; - if (tbfComponent4Op is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter) + if (tbfComponent1forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter) { - operation1 = (tbfComponent4Op as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox); + operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox); } - else if (tbfComponent4Op is TBF.BenchControl.Network.Camera.CLP1611.Camera) + else if (tbfComponent1forOp 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(); + operation1 = (tbfComponent1forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(); + operation2 = (tbfComponent1forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).HRLiveStreamOp(); } - else if (tbfComponent4Op is TBF.BenchControl.Network.Camera.Roi.Roi) + else if (tbfComponent1forOp is TBF.BenchControl.Network.Camera.Roi.Roi) { - operation1 = (tbfComponent4Op as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); + operation1 = (tbfComponent1forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); } - if (tbfComponent24Op is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter) + if (tbfComponent2forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter) { - operation21 = (tbfComponent24Op as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox); + operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox); } - else if (tbfComponent24Op is TBF.BenchControl.Network.Camera.CLP1611.Camera) + else if (tbfComponent2forOp 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(); + operation21 = (tbfComponent2forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(); + operation22 = (tbfComponent2forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).HRLiveStreamOp(); } - else if (tbfComponent24Op is TBF.BenchControl.Network.Camera.Roi.Roi) + else if (tbfComponent2forOp is TBF.BenchControl.Network.Camera.Roi.Roi) { - operation21 = (tbfComponent24Op as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); + operation21 = (tbfComponent2forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); + } + + + if (tbfComponent3forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter) + { + operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter).ReadPressureOp(ref floatBox); + } + else if (tbfComponent3forOp is TBF.BenchControl.Network.Camera.CLP1611.Camera) + { + operation31 = (tbfComponent3forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).LiveStreamOp(); + operation33 = (tbfComponent3forOp as TBF.BenchControl.Network.Camera.CLP1611.Camera).HRLiveStreamOp(); + } + else if (tbfComponent3forOp is TBF.BenchControl.Network.Camera.Roi.Roi) + { + operation31 = (tbfComponent3forOp as TBF.BenchControl.Network.Camera.Roi.Roi).RoiDetectionOp(); } @@ -522,7 +656,7 @@ namespace DeviceTest { foreach (var d in tbfDevices) d.RunDeviceBefore(); - if (tbfComponent4Op != null) + if (tbfComponent1forOp != null) { previousOperation = activeOperationLocal; activeOperationLocal = activeOperationId; @@ -538,6 +672,10 @@ namespace DeviceTest 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; + case 31: if (operation31 != null) operation31.Start(); Debug.WriteLine("op31.Start()"); break; + case 32: if (operation32 != null) operation32.Start(); Debug.WriteLine("op32.Start()"); break; + case 33: if (operation33 != null) operation33.Start(); Debug.WriteLine("op33.Start()"); break; + case 34: if (operation34 != null) operation34.Start(); Debug.WriteLine("op34.Start()"); break; } } else if (previousOperation == activeOperationLocal && activeOperationLocal != 0) @@ -552,6 +690,10 @@ namespace DeviceTest 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; + case 31: if (operation31 != null) evnt = operation31.Run(); Debug.WriteLine("op31.Run() -> {0}", evnt); break; + case 32: if (operation32 != null) evnt = operation32.Run(); Debug.WriteLine("op32.Run() -> {0}", evnt); break; + case 33: if (operation33 != null) evnt = operation33.Run(); Debug.WriteLine("op33.Run() -> {0}", evnt); break; + case 34: if (operation34 != null) evnt = operation34.Run(); Debug.WriteLine("op34.Run() -> {0}", evnt); break; default: evnt = Event.None; break; } } @@ -567,6 +709,10 @@ namespace DeviceTest 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; + case 31: if (operation31 != null) operation31.Stop(); Debug.WriteLine("op31.Stop()"); break; + case 32: if (operation32 != null) operation32.Stop(); Debug.WriteLine("op32.Stop()"); break; + case 33: if (operation33 != null) operation33.Stop(); Debug.WriteLine("op33.Stop()"); break; + case 34: if (operation34 != null) operation34.Stop(); Debug.WriteLine("op34.Stop()"); break; } } } @@ -590,9 +736,10 @@ namespace DeviceTest startButton.Enabled = true; stopButton.Enabled = false; - configureComponent2Button.Enabled = true; - configureComponentButton.Enabled = true; configureParentButton.Enabled = true; + configureComponent1Button.Enabled = true; + configureComponent2Button.Enabled = true; + configureComponent3Button.Enabled = true; } private void DeviceTestDlg_FormClosing(object sender, FormClosingEventArgs e) diff --git a/DeviceTest/LocalSettings.cs b/DeviceTest/LocalSettings.cs index c84e6184c..08bfaef9e 100644 --- a/DeviceTest/LocalSettings.cs +++ b/DeviceTest/LocalSettings.cs @@ -25,6 +25,11 @@ namespace DeviceTest public string Component2ParentName; public string Component2Settings; + public string Component3ClassName; + public string Component3Name; + public string Component3ParentName; + public string Component3Settings; + public LocalSettings() { }