From 4e01284bb4b6f106cc89d6c27cb2e3a5e49fa128 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 30 Jul 2021 11:37:04 +0200 Subject: [PATCH] Update S7 test x REAL --- Test-S7/TestMainForm.Designer.cs | 1094 ++++++++++++++------------- Test-S7/TestMainForm.cs | 1212 ++++++++++++++++-------------- 2 files changed, 1207 insertions(+), 1099 deletions(-) diff --git a/Test-S7/TestMainForm.Designer.cs b/Test-S7/TestMainForm.Designer.cs index 851d0e3c..f2c793cc 100644 --- a/Test-S7/TestMainForm.Designer.cs +++ b/Test-S7/TestMainForm.Designer.cs @@ -28,551 +28,576 @@ /// private void InitializeComponent() { - this.txtIP = new System.Windows.Forms.TextBox(); - this.lblIP = new System.Windows.Forms.Label(); - this.cbCpuType = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.txtMemArea = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.txtMemSize = new System.Windows.Forms.TextBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.btnReadString = new System.Windows.Forms.Button(); - this.btnReadDWord = new System.Windows.Forms.Button(); - this.btnReadWord = new System.Windows.Forms.Button(); - this.btnReadReal = new System.Windows.Forms.Button(); - this.btnReadByte = new System.Windows.Forms.Button(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.txtOut = new System.Windows.Forms.TextBox(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.textBox2 = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.txtSlot = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); - this.txtRack = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.tslConn = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); - this.tslRTime = new System.Windows.Forms.ToolStripStatusLabel(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.btnStrWrite = new System.Windows.Forms.Button(); - this.btnNumWriteB = new System.Windows.Forms.Button(); - this.btnNumWriteDW = new System.Windows.Forms.Button(); - this.btnNumWriteW = new System.Windows.Forms.Button(); - this.txtWriteVal2 = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); - this.txtWriteVal1 = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.txtWriteAddr2 = new System.Windows.Forms.TextBox(); - this.label10 = new System.Windows.Forms.Label(); - this.txtWriteAddr1 = new System.Windows.Forms.TextBox(); - this.label7 = new System.Windows.Forms.Label(); - this.groupBox1.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.groupBox3.SuspendLayout(); - this.statusStrip1.SuspendLayout(); - this.groupBox4.SuspendLayout(); - this.SuspendLayout(); - // - // txtIP - // - this.txtIP.Location = new System.Drawing.Point(85, 23); - this.txtIP.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtIP.Name = "txtIP"; - this.txtIP.Size = new System.Drawing.Size(109, 22); - this.txtIP.TabIndex = 0; - this.txtIP.Text = "192.168.0.51"; - this.txtIP.TextChanged += new System.EventHandler(this.txtIP_TextChanged); - // - // lblIP - // - this.lblIP.AutoSize = true; - this.lblIP.Location = new System.Drawing.Point(16, 26); - this.lblIP.Name = "lblIP"; - this.lblIP.Size = new System.Drawing.Size(63, 17); - this.lblIP.TabIndex = 1; - this.lblIP.Text = "IP ADDR"; - // - // cbCpuType - // - this.cbCpuType.FormattingEnabled = true; - this.cbCpuType.Items.AddRange(new object[] { + this.txtIP = new System.Windows.Forms.TextBox(); + this.lblIP = new System.Windows.Forms.Label(); + this.cbCpuType = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.txtMemArea = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.txtMemSize = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.btnReadString = new System.Windows.Forms.Button(); + this.btnReadDWord = new System.Windows.Forms.Button(); + this.btnReadWord = new System.Windows.Forms.Button(); + this.btnReadReal = new System.Windows.Forms.Button(); + this.btnReadByte = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.txtOut = new System.Windows.Forms.TextBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.txtSlot = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.txtRack = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.tslConn = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); + this.tslRTime = new System.Windows.Forms.ToolStripStatusLabel(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.btnStrWrite = new System.Windows.Forms.Button(); + this.btnNumWriteB = new System.Windows.Forms.Button(); + this.btnNumWriteDW = new System.Windows.Forms.Button(); + this.btnNumWriteW = new System.Windows.Forms.Button(); + this.txtWriteVal2 = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.txtWriteVal1 = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.txtWriteAddr2 = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.txtWriteAddr1 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.btnNumWriteReal = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.statusStrip1.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.SuspendLayout(); + // + // txtIP + // + this.txtIP.Location = new System.Drawing.Point(64, 19); + this.txtIP.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtIP.Name = "txtIP"; + this.txtIP.Size = new System.Drawing.Size(83, 20); + this.txtIP.TabIndex = 0; + this.txtIP.Text = "192.168.0.51"; + this.txtIP.TextChanged += new System.EventHandler(this.txtIP_TextChanged); + // + // lblIP + // + this.lblIP.AutoSize = true; + this.lblIP.Location = new System.Drawing.Point(12, 21); + this.lblIP.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblIP.Name = "lblIP"; + this.lblIP.Size = new System.Drawing.Size(51, 13); + this.lblIP.TabIndex = 1; + this.lblIP.Text = "IP ADDR"; + // + // cbCpuType + // + this.cbCpuType.FormattingEnabled = true; + this.cbCpuType.Items.AddRange(new object[] { "S7200", "S7300", "S7400", "S71200", "S71500"}); - this.cbCpuType.Location = new System.Drawing.Point(85, 62); - this.cbCpuType.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.cbCpuType.Name = "cbCpuType"; - this.cbCpuType.Size = new System.Drawing.Size(109, 24); - this.cbCpuType.TabIndex = 2; - this.cbCpuType.Text = "S7300"; - this.cbCpuType.SelectedIndexChanged += new System.EventHandler(this.cbCpuType_SelectedIndexChanged); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(7, 64); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(72, 17); - this.label1.TabIndex = 3; - this.label1.Text = "CPU Type"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(9, 23); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(80, 17); - this.label2.TabIndex = 5; - this.label2.Text = "MEM AREA"; - // - // txtMemArea - // - this.txtMemArea.Location = new System.Drawing.Point(156, 20); - this.txtMemArea.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtMemArea.Name = "txtMemArea"; - this.txtMemArea.Size = new System.Drawing.Size(117, 22); - this.txtMemArea.TabIndex = 4; - this.txtMemArea.Text = "DB700.DBB0"; - this.txtMemArea.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.txtMemArea.TextChanged += new System.EventHandler(this.txtMemArea_TextChanged); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(9, 80); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(113, 17); - this.label3.TabIndex = 7; - this.label3.Text = "MEM SIZE BYTE"; - // - // txtMemSize - // - this.txtMemSize.Location = new System.Drawing.Point(156, 78); - this.txtMemSize.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtMemSize.Name = "txtMemSize"; - this.txtMemSize.Size = new System.Drawing.Size(117, 22); - this.txtMemSize.TabIndex = 6; - this.txtMemSize.Text = "52"; - this.txtMemSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.txtMemSize.TextChanged += new System.EventHandler(this.txtMemSize_TextChanged); - // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox1.Controls.Add(this.btnReadString); - this.groupBox1.Controls.Add(this.btnReadDWord); - this.groupBox1.Controls.Add(this.btnReadWord); - this.groupBox1.Controls.Add(this.btnReadReal); - this.groupBox1.Controls.Add(this.btnReadByte); - this.groupBox1.Controls.Add(this.textBox1); - this.groupBox1.Controls.Add(this.txtMemArea); - this.groupBox1.Controls.Add(this.txtMemSize); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Controls.Add(this.label2); - this.groupBox1.Location = new System.Drawing.Point(468, 12); - this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox1.Size = new System.Drawing.Size(387, 105); - this.groupBox1.TabIndex = 8; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Memoria: READ param"; - // - // btnReadString - // - this.btnReadString.Location = new System.Drawing.Point(279, 75); - this.btnReadString.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnReadString.Name = "btnReadString"; - this.btnReadString.Size = new System.Drawing.Size(101, 25); - this.btnReadString.TabIndex = 11; - this.btnReadString.Text = "READ String"; - this.btnReadString.UseVisualStyleBackColor = true; - this.btnReadString.Click += new System.EventHandler(this.btnReadString_Click); - // - // btnReadDWord - // - this.btnReadDWord.Location = new System.Drawing.Point(279, 47); - this.btnReadDWord.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnReadDWord.Name = "btnReadDWord"; - this.btnReadDWord.Size = new System.Drawing.Size(101, 25); - this.btnReadDWord.TabIndex = 10; - this.btnReadDWord.Text = "READ DW"; - this.btnReadDWord.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage; - this.btnReadDWord.UseVisualStyleBackColor = true; - this.btnReadDWord.Click += new System.EventHandler(this.btnReadDWord_Click); - // - // btnReadWord - // - this.btnReadWord.Location = new System.Drawing.Point(279, 18); - this.btnReadWord.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnReadWord.Name = "btnReadWord"; - this.btnReadWord.Size = new System.Drawing.Size(101, 25); - this.btnReadWord.TabIndex = 10; - this.btnReadWord.Text = "READ W"; - this.btnReadWord.UseVisualStyleBackColor = true; - this.btnReadWord.Click += new System.EventHandler(this.btnReadWord_Click); - // - // btnReadReal - // - this.btnReadReal.Location = new System.Drawing.Point(235, 48); - this.btnReadReal.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnReadReal.Name = "btnReadReal"; - this.btnReadReal.Size = new System.Drawing.Size(40, 25); - this.btnReadReal.TabIndex = 9; - this.btnReadReal.Text = "REAL"; - this.btnReadReal.UseVisualStyleBackColor = true; - this.btnReadReal.Click += new System.EventHandler(this.btnReadReal_Click); - // - // btnReadByte - // - this.btnReadByte.Location = new System.Drawing.Point(156, 47); - this.btnReadByte.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnReadByte.Name = "btnReadByte"; - this.btnReadByte.Size = new System.Drawing.Size(73, 25); - this.btnReadByte.TabIndex = 9; - this.btnReadByte.Text = "READ B"; - this.btnReadByte.UseVisualStyleBackColor = true; - this.btnReadByte.Click += new System.EventHandler(this.btnReadByte_Click); - // - // textBox1 - // - this.textBox1.BackColor = System.Drawing.SystemColors.Menu; - this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.Location = new System.Drawing.Point(12, 44); - this.textBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(127, 33); - this.textBox1.TabIndex = 8; - this.textBox1.Text = "Indicare tipo memoria e size del tipo"; - // - // groupBox2 - // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.cbCpuType.Location = new System.Drawing.Point(64, 50); + this.cbCpuType.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.cbCpuType.Name = "cbCpuType"; + this.cbCpuType.Size = new System.Drawing.Size(83, 21); + this.cbCpuType.TabIndex = 2; + this.cbCpuType.Text = "S7300"; + this.cbCpuType.SelectedIndexChanged += new System.EventHandler(this.cbCpuType_SelectedIndexChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(5, 52); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(56, 13); + this.label1.TabIndex = 3; + this.label1.Text = "CPU Type"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(7, 19); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(64, 13); + this.label2.TabIndex = 5; + this.label2.Text = "MEM AREA"; + // + // txtMemArea + // + this.txtMemArea.Location = new System.Drawing.Point(117, 16); + this.txtMemArea.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtMemArea.Name = "txtMemArea"; + this.txtMemArea.Size = new System.Drawing.Size(89, 20); + this.txtMemArea.TabIndex = 4; + this.txtMemArea.Text = "DB700.DBB0"; + this.txtMemArea.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.txtMemArea.TextChanged += new System.EventHandler(this.txtMemArea_TextChanged); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(7, 65); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(90, 13); + this.label3.TabIndex = 7; + this.label3.Text = "MEM SIZE BYTE"; + // + // txtMemSize + // + this.txtMemSize.Location = new System.Drawing.Point(117, 63); + this.txtMemSize.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtMemSize.Name = "txtMemSize"; + this.txtMemSize.Size = new System.Drawing.Size(89, 20); + this.txtMemSize.TabIndex = 6; + this.txtMemSize.Text = "52"; + this.txtMemSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.txtMemSize.TextChanged += new System.EventHandler(this.txtMemSize_TextChanged); + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.btnReadString); + this.groupBox1.Controls.Add(this.btnReadDWord); + this.groupBox1.Controls.Add(this.btnReadWord); + this.groupBox1.Controls.Add(this.btnReadReal); + this.groupBox1.Controls.Add(this.btnReadByte); + this.groupBox1.Controls.Add(this.textBox1); + this.groupBox1.Controls.Add(this.txtMemArea); + this.groupBox1.Controls.Add(this.txtMemSize); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Location = new System.Drawing.Point(351, 10); + this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox1.Size = new System.Drawing.Size(290, 85); + this.groupBox1.TabIndex = 8; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Memoria: READ param"; + // + // btnReadString + // + this.btnReadString.Location = new System.Drawing.Point(209, 61); + this.btnReadString.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnReadString.Name = "btnReadString"; + this.btnReadString.Size = new System.Drawing.Size(76, 20); + this.btnReadString.TabIndex = 11; + this.btnReadString.Text = "READ String"; + this.btnReadString.UseVisualStyleBackColor = true; + this.btnReadString.Click += new System.EventHandler(this.btnReadString_Click); + // + // btnReadDWord + // + this.btnReadDWord.Location = new System.Drawing.Point(209, 38); + this.btnReadDWord.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnReadDWord.Name = "btnReadDWord"; + this.btnReadDWord.Size = new System.Drawing.Size(76, 20); + this.btnReadDWord.TabIndex = 10; + this.btnReadDWord.Text = "READ DW"; + this.btnReadDWord.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage; + this.btnReadDWord.UseVisualStyleBackColor = true; + this.btnReadDWord.Click += new System.EventHandler(this.btnReadDWord_Click); + // + // btnReadWord + // + this.btnReadWord.Location = new System.Drawing.Point(209, 15); + this.btnReadWord.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnReadWord.Name = "btnReadWord"; + this.btnReadWord.Size = new System.Drawing.Size(76, 20); + this.btnReadWord.TabIndex = 10; + this.btnReadWord.Text = "READ W"; + this.btnReadWord.UseVisualStyleBackColor = true; + this.btnReadWord.Click += new System.EventHandler(this.btnReadWord_Click); + // + // btnReadReal + // + this.btnReadReal.Location = new System.Drawing.Point(176, 39); + this.btnReadReal.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnReadReal.Name = "btnReadReal"; + this.btnReadReal.Size = new System.Drawing.Size(30, 20); + this.btnReadReal.TabIndex = 9; + this.btnReadReal.Text = "REAL"; + this.btnReadReal.UseVisualStyleBackColor = true; + this.btnReadReal.Click += new System.EventHandler(this.btnReadReal_Click); + // + // btnReadByte + // + this.btnReadByte.Location = new System.Drawing.Point(117, 38); + this.btnReadByte.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnReadByte.Name = "btnReadByte"; + this.btnReadByte.Size = new System.Drawing.Size(55, 20); + this.btnReadByte.TabIndex = 9; + this.btnReadByte.Text = "READ B"; + this.btnReadByte.UseVisualStyleBackColor = true; + this.btnReadByte.Click += new System.EventHandler(this.btnReadByte_Click); + // + // textBox1 + // + this.textBox1.BackColor = System.Drawing.SystemColors.Menu; + this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox1.Location = new System.Drawing.Point(9, 36); + this.textBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(95, 27); + this.textBox1.TabIndex = 8; + this.textBox1.Text = "Indicare tipo memoria e size del tipo"; + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.AutoSize = true; - this.groupBox2.Controls.Add(this.txtOut); - this.groupBox2.Location = new System.Drawing.Point(12, 190); - this.groupBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox2.Size = new System.Drawing.Size(843, 402); - this.groupBox2.TabIndex = 9; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Risultati"; - // - // txtOut - // - this.txtOut.BackColor = System.Drawing.SystemColors.Desktop; - this.txtOut.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtOut.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtOut.ForeColor = System.Drawing.Color.Yellow; - this.txtOut.Location = new System.Drawing.Point(3, 17); - this.txtOut.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtOut.Multiline = true; - this.txtOut.Name = "txtOut"; - this.txtOut.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtOut.Size = new System.Drawing.Size(837, 383); - this.txtOut.TabIndex = 0; - this.txtOut.Text = "..."; - // - // groupBox3 - // - this.groupBox3.Controls.Add(this.textBox2); - this.groupBox3.Controls.Add(this.label6); - this.groupBox3.Controls.Add(this.txtSlot); - this.groupBox3.Controls.Add(this.label5); - this.groupBox3.Controls.Add(this.txtRack); - this.groupBox3.Controls.Add(this.label4); - this.groupBox3.Controls.Add(this.cbCpuType); - this.groupBox3.Controls.Add(this.txtIP); - this.groupBox3.Controls.Add(this.lblIP); - this.groupBox3.Controls.Add(this.label1); - this.groupBox3.Location = new System.Drawing.Point(12, 12); - this.groupBox3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox3.Size = new System.Drawing.Size(448, 105); - this.groupBox3.TabIndex = 10; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "Parametri PLC"; - // - // textBox2 - // - this.textBox2.BackColor = System.Drawing.SystemColors.Menu; - this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox2.Location = new System.Drawing.Point(301, 38); - this.textBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.textBox2.Multiline = true; - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(140, 54); - this.textBox2.TabIndex = 7; - this.textBox2.Text = "S7-1200/S7-1500: 0/0\r\nS7-300/S7-400: 0/2\r\nSlot > 0 se eth ext"; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(301, 14); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(114, 17); - this.label6.TabIndex = 6; - this.label6.Text = "Note Rack / Slot:"; - // - // txtSlot - // - this.txtSlot.Location = new System.Drawing.Point(253, 62); - this.txtSlot.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtSlot.Name = "txtSlot"; - this.txtSlot.Size = new System.Drawing.Size(41, 22); - this.txtSlot.TabIndex = 5; - this.txtSlot.Text = "2"; - this.txtSlot.TextChanged += new System.EventHandler(this.txtSlot_TextChanged); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(208, 64); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(32, 17); - this.label5.TabIndex = 4; - this.label5.Text = "Slot"; - // - // txtRack - // - this.txtRack.Location = new System.Drawing.Point(253, 23); - this.txtRack.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtRack.Name = "txtRack"; - this.txtRack.Size = new System.Drawing.Size(41, 22); - this.txtRack.TabIndex = 5; - this.txtRack.Text = "0"; - this.txtRack.TextChanged += new System.EventHandler(this.txtRack_TextChanged); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(208, 26); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(40, 17); - this.label4.TabIndex = 4; - this.label4.Text = "Rack"; - // - // statusStrip1 - // - this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.groupBox2.AutoSize = true; + this.groupBox2.Controls.Add(this.txtOut); + this.groupBox2.Location = new System.Drawing.Point(9, 154); + this.groupBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox2.Size = new System.Drawing.Size(632, 327); + this.groupBox2.TabIndex = 9; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Risultati"; + // + // txtOut + // + this.txtOut.BackColor = System.Drawing.SystemColors.Desktop; + this.txtOut.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtOut.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtOut.ForeColor = System.Drawing.Color.Yellow; + this.txtOut.Location = new System.Drawing.Point(2, 15); + this.txtOut.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtOut.Multiline = true; + this.txtOut.Name = "txtOut"; + this.txtOut.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtOut.Size = new System.Drawing.Size(628, 310); + this.txtOut.TabIndex = 0; + this.txtOut.Text = "..."; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.textBox2); + this.groupBox3.Controls.Add(this.label6); + this.groupBox3.Controls.Add(this.txtSlot); + this.groupBox3.Controls.Add(this.label5); + this.groupBox3.Controls.Add(this.txtRack); + this.groupBox3.Controls.Add(this.label4); + this.groupBox3.Controls.Add(this.cbCpuType); + this.groupBox3.Controls.Add(this.txtIP); + this.groupBox3.Controls.Add(this.lblIP); + this.groupBox3.Controls.Add(this.label1); + this.groupBox3.Location = new System.Drawing.Point(9, 10); + this.groupBox3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox3.Size = new System.Drawing.Size(336, 85); + this.groupBox3.TabIndex = 10; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Parametri PLC"; + // + // textBox2 + // + this.textBox2.BackColor = System.Drawing.SystemColors.Menu; + this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox2.Location = new System.Drawing.Point(226, 31); + this.textBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(105, 44); + this.textBox2.TabIndex = 7; + this.textBox2.Text = "S7-1200/S7-1500: 0/0\r\nS7-300/S7-400: 0/2\r\nSlot > 0 se eth ext"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(226, 11); + this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(91, 13); + this.label6.TabIndex = 6; + this.label6.Text = "Note Rack / Slot:"; + // + // txtSlot + // + this.txtSlot.Location = new System.Drawing.Point(190, 50); + this.txtSlot.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtSlot.Name = "txtSlot"; + this.txtSlot.Size = new System.Drawing.Size(32, 20); + this.txtSlot.TabIndex = 5; + this.txtSlot.Text = "2"; + this.txtSlot.TextChanged += new System.EventHandler(this.txtSlot_TextChanged); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(156, 52); + this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(25, 13); + this.label5.TabIndex = 4; + this.label5.Text = "Slot"; + // + // txtRack + // + this.txtRack.Location = new System.Drawing.Point(190, 19); + this.txtRack.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtRack.Name = "txtRack"; + this.txtRack.Size = new System.Drawing.Size(32, 20); + this.txtRack.TabIndex = 5; + this.txtRack.Text = "0"; + this.txtRack.TextChanged += new System.EventHandler(this.txtRack_TextChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(156, 21); + this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(33, 13); + this.label4.TabIndex = 4; + this.label4.Text = "Rack"; + // + // statusStrip1 + // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tslConn, this.toolStripStatusLabel1, this.toolStripProgressBar1, this.tslRTime}); - this.statusStrip1.Location = new System.Drawing.Point(0, 598); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 13, 0); - this.statusStrip1.Size = new System.Drawing.Size(869, 26); - this.statusStrip1.TabIndex = 11; - this.statusStrip1.Text = "statusStrip1"; - // - // tslConn - // - this.tslConn.Name = "tslConn"; - this.tslConn.Size = new System.Drawing.Size(72, 21); - this.tslConn.Text = "Conn: ND"; - // - // toolStripStatusLabel1 - // - this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(13, 21); - this.toolStripStatusLabel1.Text = "|"; - // - // toolStripProgressBar1 - // - this.toolStripProgressBar1.Name = "toolStripProgressBar1"; - this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 20); - // - // tslRTime - // - this.tslRTime.Name = "tslRTime"; - this.tslRTime.Size = new System.Drawing.Size(37, 21); - this.tslRTime.Text = "...ms"; - // - // groupBox4 - // - this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.statusStrip1.Location = new System.Drawing.Point(0, 485); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 10, 0); + this.statusStrip1.Size = new System.Drawing.Size(652, 22); + this.statusStrip1.TabIndex = 11; + this.statusStrip1.Text = "statusStrip1"; + // + // tslConn + // + this.tslConn.Name = "tslConn"; + this.tslConn.Size = new System.Drawing.Size(59, 17); + this.tslConn.Text = "Conn: ND"; + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(10, 17); + this.toolStripStatusLabel1.Text = "|"; + // + // toolStripProgressBar1 + // + this.toolStripProgressBar1.Name = "toolStripProgressBar1"; + this.toolStripProgressBar1.Size = new System.Drawing.Size(75, 16); + // + // tslRTime + // + this.tslRTime.Name = "tslRTime"; + this.tslRTime.Size = new System.Drawing.Size(32, 17); + this.tslRTime.Text = "...ms"; + // + // groupBox4 + // + this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox4.Controls.Add(this.btnStrWrite); - this.groupBox4.Controls.Add(this.btnNumWriteB); - this.groupBox4.Controls.Add(this.btnNumWriteDW); - this.groupBox4.Controls.Add(this.btnNumWriteW); - this.groupBox4.Controls.Add(this.txtWriteVal2); - this.groupBox4.Controls.Add(this.label9); - this.groupBox4.Controls.Add(this.txtWriteVal1); - this.groupBox4.Controls.Add(this.label8); - this.groupBox4.Controls.Add(this.txtWriteAddr2); - this.groupBox4.Controls.Add(this.label10); - this.groupBox4.Controls.Add(this.txtWriteAddr1); - this.groupBox4.Controls.Add(this.label7); - this.groupBox4.Location = new System.Drawing.Point(12, 117); - this.groupBox4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBox4.Size = new System.Drawing.Size(843, 71); - this.groupBox4.TabIndex = 12; - this.groupBox4.TabStop = false; - this.groupBox4.Text = "Memoria: WRITE param"; - // - // btnStrWrite - // - this.btnStrWrite.Location = new System.Drawing.Point(799, 25); - this.btnStrWrite.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnStrWrite.Name = "btnStrWrite"; - this.btnStrWrite.Size = new System.Drawing.Size(41, 23); - this.btnStrWrite.TabIndex = 10; - this.btnStrWrite.Text = "SW"; - this.btnStrWrite.UseVisualStyleBackColor = true; - this.btnStrWrite.Click += new System.EventHandler(this.btnStrWrite_Click); - // - // btnNumWriteB - // - this.btnNumWriteB.Location = new System.Drawing.Point(329, 5); - this.btnNumWriteB.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnNumWriteB.Name = "btnNumWriteB"; - this.btnNumWriteB.Size = new System.Drawing.Size(48, 23); - this.btnNumWriteB.TabIndex = 10; - this.btnNumWriteB.Text = "B"; - this.btnNumWriteB.UseVisualStyleBackColor = true; - this.btnNumWriteB.Click += new System.EventHandler(this.btnNumWriteB_Click); - // - // btnNumWriteDW - // - this.btnNumWriteDW.Location = new System.Drawing.Point(329, 44); - this.btnNumWriteDW.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnNumWriteDW.Name = "btnNumWriteDW"; - this.btnNumWriteDW.Size = new System.Drawing.Size(48, 23); - this.btnNumWriteDW.TabIndex = 10; - this.btnNumWriteDW.Text = "DW"; - this.btnNumWriteDW.UseVisualStyleBackColor = true; - this.btnNumWriteDW.Click += new System.EventHandler(this.btnNumWriteDW_Click); - // - // btnNumWriteW - // - this.btnNumWriteW.Location = new System.Drawing.Point(329, 23); - this.btnNumWriteW.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.btnNumWriteW.Name = "btnNumWriteW"; - this.btnNumWriteW.Size = new System.Drawing.Size(48, 23); - this.btnNumWriteW.TabIndex = 10; - this.btnNumWriteW.Text = "W"; - this.btnNumWriteW.UseVisualStyleBackColor = true; - this.btnNumWriteW.Click += new System.EventHandler(this.btnNumWriteW_Click); - // - // txtWriteVal2 - // - this.txtWriteVal2.Location = new System.Drawing.Point(612, 25); - this.txtWriteVal2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtWriteVal2.Name = "txtWriteVal2"; - this.txtWriteVal2.Size = new System.Drawing.Size(187, 22); - this.txtWriteVal2.TabIndex = 8; - this.txtWriteVal2.Text = "SAMUELEL"; - this.txtWriteVal2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(571, 27); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(36, 17); - this.label9.TabIndex = 9; - this.label9.Text = "STR"; - // - // txtWriteVal1 - // - this.txtWriteVal1.Location = new System.Drawing.Point(237, 25); - this.txtWriteVal1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtWriteVal1.Name = "txtWriteVal1"; - this.txtWriteVal1.Size = new System.Drawing.Size(85, 22); - this.txtWriteVal1.TabIndex = 8; - this.txtWriteVal1.Text = "987654321"; - this.txtWriteVal1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(197, 27); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(39, 17); - this.label8.TabIndex = 9; - this.label8.Text = "NUM"; - // - // txtWriteAddr2 - // - this.txtWriteAddr2.Location = new System.Drawing.Point(448, 25); - this.txtWriteAddr2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtWriteAddr2.Name = "txtWriteAddr2"; - this.txtWriteAddr2.Size = new System.Drawing.Size(116, 22); - this.txtWriteAddr2.TabIndex = 6; - this.txtWriteAddr2.Text = "DB701.DBB0"; - this.txtWriteAddr2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(389, 27); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(59, 17); - this.label10.TabIndex = 7; - this.label10.Text = "ADDR 2"; - // - // txtWriteAddr1 - // - this.txtWriteAddr1.Location = new System.Drawing.Point(71, 25); - this.txtWriteAddr1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.txtWriteAddr1.Name = "txtWriteAddr1"; - this.txtWriteAddr1.Size = new System.Drawing.Size(123, 22); - this.txtWriteAddr1.TabIndex = 6; - this.txtWriteAddr1.Text = "DB701.DBB0"; - this.txtWriteAddr1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(5, 27); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(59, 17); - this.label7.TabIndex = 7; - this.label7.Text = "ADDR 1"; - // - // TestMainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(869, 624); - this.Controls.Add(this.groupBox4); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.groupBox3); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox1); - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.Name = "TestMainForm"; - this.Text = "SIEMENS S7 TEST"; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.groupBox3.ResumeLayout(false); - this.groupBox3.PerformLayout(); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); - this.groupBox4.ResumeLayout(false); - this.groupBox4.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + this.groupBox4.Controls.Add(this.btnNumWriteReal); + this.groupBox4.Controls.Add(this.btnStrWrite); + this.groupBox4.Controls.Add(this.btnNumWriteB); + this.groupBox4.Controls.Add(this.btnNumWriteDW); + this.groupBox4.Controls.Add(this.btnNumWriteW); + this.groupBox4.Controls.Add(this.txtWriteVal2); + this.groupBox4.Controls.Add(this.label9); + this.groupBox4.Controls.Add(this.txtWriteVal1); + this.groupBox4.Controls.Add(this.label8); + this.groupBox4.Controls.Add(this.txtWriteAddr2); + this.groupBox4.Controls.Add(this.label10); + this.groupBox4.Controls.Add(this.txtWriteAddr1); + this.groupBox4.Controls.Add(this.label7); + this.groupBox4.Location = new System.Drawing.Point(9, 95); + this.groupBox4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.groupBox4.Size = new System.Drawing.Size(632, 58); + this.groupBox4.TabIndex = 12; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "Memoria: WRITE param"; + // + // btnStrWrite + // + this.btnStrWrite.Location = new System.Drawing.Point(599, 20); + this.btnStrWrite.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnStrWrite.Name = "btnStrWrite"; + this.btnStrWrite.Size = new System.Drawing.Size(31, 19); + this.btnStrWrite.TabIndex = 10; + this.btnStrWrite.Text = "SW"; + this.btnStrWrite.UseVisualStyleBackColor = true; + this.btnStrWrite.Click += new System.EventHandler(this.btnStrWrite_Click); + // + // btnNumWriteB + // + this.btnNumWriteB.Location = new System.Drawing.Point(244, 8); + this.btnNumWriteB.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnNumWriteB.Name = "btnNumWriteB"; + this.btnNumWriteB.Size = new System.Drawing.Size(36, 19); + this.btnNumWriteB.TabIndex = 10; + this.btnNumWriteB.Text = "B"; + this.btnNumWriteB.UseVisualStyleBackColor = true; + this.btnNumWriteB.Click += new System.EventHandler(this.btnNumWriteB_Click); + // + // btnNumWriteDW + // + this.btnNumWriteDW.Location = new System.Drawing.Point(280, 27); + this.btnNumWriteDW.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnNumWriteDW.Name = "btnNumWriteDW"; + this.btnNumWriteDW.Size = new System.Drawing.Size(36, 19); + this.btnNumWriteDW.TabIndex = 10; + this.btnNumWriteDW.Text = "DW"; + this.btnNumWriteDW.UseVisualStyleBackColor = true; + this.btnNumWriteDW.Click += new System.EventHandler(this.btnNumWriteDW_Click); + // + // btnNumWriteW + // + this.btnNumWriteW.Location = new System.Drawing.Point(244, 27); + this.btnNumWriteW.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnNumWriteW.Name = "btnNumWriteW"; + this.btnNumWriteW.Size = new System.Drawing.Size(36, 19); + this.btnNumWriteW.TabIndex = 10; + this.btnNumWriteW.Text = "W"; + this.btnNumWriteW.UseVisualStyleBackColor = true; + this.btnNumWriteW.Click += new System.EventHandler(this.btnNumWriteW_Click); + // + // txtWriteVal2 + // + this.txtWriteVal2.Location = new System.Drawing.Point(492, 20); + this.txtWriteVal2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtWriteVal2.Name = "txtWriteVal2"; + this.txtWriteVal2.Size = new System.Drawing.Size(108, 20); + this.txtWriteVal2.TabIndex = 8; + this.txtWriteVal2.Text = "SAMUELEL"; + this.txtWriteVal2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(455, 22); + this.label9.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(29, 13); + this.label9.TabIndex = 9; + this.label9.Text = "STR"; + // + // txtWriteVal1 + // + this.txtWriteVal1.Location = new System.Drawing.Point(178, 20); + this.txtWriteVal1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtWriteVal1.Name = "txtWriteVal1"; + this.txtWriteVal1.Size = new System.Drawing.Size(65, 20); + this.txtWriteVal1.TabIndex = 8; + this.txtWriteVal1.Text = "987654321"; + this.txtWriteVal1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(148, 22); + this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(32, 13); + this.label8.TabIndex = 9; + this.label8.Text = "NUM"; + // + // txtWriteAddr2 + // + this.txtWriteAddr2.Location = new System.Drawing.Point(361, 20); + this.txtWriteAddr2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtWriteAddr2.Name = "txtWriteAddr2"; + this.txtWriteAddr2.Size = new System.Drawing.Size(88, 20); + this.txtWriteAddr2.TabIndex = 6; + this.txtWriteAddr2.Text = "DB701.DBB0"; + this.txtWriteAddr2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(317, 22); + this.label10.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(47, 13); + this.label10.TabIndex = 7; + this.label10.Text = "ADDR 2"; + // + // txtWriteAddr1 + // + this.txtWriteAddr1.Location = new System.Drawing.Point(53, 20); + this.txtWriteAddr1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.txtWriteAddr1.Name = "txtWriteAddr1"; + this.txtWriteAddr1.Size = new System.Drawing.Size(93, 20); + this.txtWriteAddr1.TabIndex = 6; + this.txtWriteAddr1.Text = "DB701.DBB0"; + this.txtWriteAddr1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(4, 22); + this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(47, 13); + this.label7.TabIndex = 7; + this.label7.Text = "ADDR 1"; + // + // btnNumWriteReal + // + this.btnNumWriteReal.Location = new System.Drawing.Point(280, 8); + this.btnNumWriteReal.Margin = new System.Windows.Forms.Padding(2); + this.btnNumWriteReal.Name = "btnNumWriteReal"; + this.btnNumWriteReal.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.btnNumWriteReal.Size = new System.Drawing.Size(36, 19); + this.btnNumWriteReal.TabIndex = 11; + this.btnNumWriteReal.Text = "RE"; + this.btnNumWriteReal.UseVisualStyleBackColor = true; + this.btnNumWriteReal.Click += new System.EventHandler(this.btnNumWriteReal_Click); + // + // TestMainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(652, 507); + this.Controls.Add(this.groupBox4); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.Name = "TestMainForm"; + this.Text = "SIEMENS S7 TEST"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -620,6 +645,7 @@ private System.Windows.Forms.Button btnReadReal; private System.Windows.Forms.Button btnNumWriteB; private System.Windows.Forms.Button btnNumWriteDW; - } + private System.Windows.Forms.Button btnNumWriteReal; + } } diff --git a/Test-S7/TestMainForm.cs b/Test-S7/TestMainForm.cs index e92f1f4c..2f83283b 100644 --- a/Test-S7/TestMainForm.cs +++ b/Test-S7/TestMainForm.cs @@ -15,619 +15,701 @@ using System.Diagnostics; namespace Test_S7 { - public partial class TestMainForm : Form - { - /// - /// Configurazione valori da LEGGERE dal PLC - /// - public otherData[] memMapR; - /// - /// Configurazione valori da SCRIVERE nel PLC - /// - public otherData[] memMapW; - /// - /// Byte dimensione buffer dati memoria (da file map) - /// - public int numByte = 0; - /// - /// Lungh massima stringhe - /// - protected int maxStrChar = 20; - /// - /// Oggetto PLC da ri-utilizzare... - /// - protected Plc currPLC; - /// - /// indica se serva refresh parametri e quindi PLC... - /// - bool needRefresh = true; - /// - /// Oggetto cronometro x test vari... - /// - protected Stopwatch sw = new Stopwatch(); - /// - /// parametri di connessione - /// - protected connParam parametri; - /// - /// titolo x log/debug - /// - protected string titolo = ""; - /// - /// contenuto x log/debug - /// - protected string contenuto = ""; - /// - /// oggetto logging - /// - public static Logger lg; + public partial class TestMainForm : Form + { + #region Private Fields - public TestMainForm() - { - InitializeComponent(); + /// + /// indica se serva refresh parametri e quindi PLC... + /// + private bool needRefresh = true; - myInit(); - } - /// - /// inizializzo - /// - private void myInit() - { - lg = LogManager.GetCurrentClassLogger(); - // inizializzo parametri... - parametri = new connParam() - { - ipAdrr = "127.0.0.1", - tipoCpu = CpuType.S7200, - slot = 0, - rack = 0 - }; - setParamPlc(); - } - /// - /// Imposto parametri PLC - /// - private void setParamPlc() - { - txtOut.Text = ""; - // SE è necessario refresh... - if (needRefresh) - { - lg.Info("Refreshing connection..."); - try + #endregion Private Fields + + #region Protected Fields + + /// + /// contenuto x log/debug + /// + protected string contenuto = ""; + + /// + /// Oggetto PLC da ri-utilizzare... + /// + protected Plc currPLC; + + /// + /// Lungh massima stringhe + /// + protected int maxStrChar = 20; + + /// + /// parametri di connessione + /// + protected connParam parametri; + + /// + /// Oggetto cronometro x test vari... + /// + protected Stopwatch sw = new Stopwatch(); + + /// + /// titolo x log/debug + /// + protected string titolo = ""; + + #endregion Protected Fields + + #region Public Fields + + /// + /// oggetto logging + /// + public static Logger lg; + + /// + /// Configurazione valori da LEGGERE dal PLC + /// + public otherData[] memMapR; + + /// + /// Configurazione valori da SCRIVERE nel PLC + /// + public otherData[] memMapW; + + /// + /// Byte dimensione buffer dati memoria (da file map) + /// + public int numByte = 0; + + #endregion Public Fields + + #region Public Constructors + + public TestMainForm() { - short.TryParse(txtSlot.Text, out parametri.slot); - short.TryParse(txtRack.Text, out parametri.rack); - parametri.tipoCpu = (CpuType)Enum.Parse(typeof(CpuType), cbCpuType.SelectedItem.ToString()); - parametri.ipAdrr = txtIP.Text.Trim(); - titolo = "PARAM PLC (pre connect)"; - contenuto = string.Format("IP: {0}{1}", parametri.ipAdrr, Environment.NewLine); - contenuto += string.Format("CPU: {0}{1}", parametri.tipoCpu, Environment.NewLine); - contenuto += string.Format("RACK: {0}{1}", parametri.rack, Environment.NewLine); - contenuto += string.Format("SLOT: {0}", parametri.slot, Environment.NewLine); + InitializeComponent(); + + myInit(); } - catch (Exception exc) + + #endregion Public Constructors + + #region Private Methods + + private void btnNumWriteB_Click(object sender, EventArgs e) { - lg.Error(exc, "Errore in parse parametri"); + setParamPlc(); + eseguiScritturaByte(); } - // ora tento avvio PLC... SE PING OK... - if (testPing() == IPStatus.Success) + + private void btnNumWriteDW_Click(object sender, EventArgs e) { - try - { - currPLC = new Plc(parametri.tipoCpu, parametri.ipAdrr, parametri.rack, parametri.slot); - currPLC.Open(); - if (currPLC.IsConnected) titolo = "CONNESSIONE AVVENUTA"; - } - catch (Exception exc) - { - lg.Error(exc, "Errore in INIT PLC"); - } - needRefresh = false; + setParamPlc(); + eseguiScritturaDWord(); } - // carico conf vettore memoria... - loadMemConf(); - // mostra output - showOut(titolo, contenuto); - } - } - /// - /// Caricamento conf memoria DB del SIEMENS - /// - private void loadMemConf() - { - // carico conf memoria - utils.loadConfFile(ref memMapR, filePath("MMapR"), 1, ref numByte); - utils.loadConfFile(ref memMapW, filePath("MMapW"), 1, ref numByte); - } - /// - /// Restituisce path completo file da chaive configurazione - /// - /// chaive conf x file richiesto - /// - protected string filePath(string keyFile) - { - return string.Format(@"{0}\{1}", utils.confDir, utils.CRS(keyFile)); - } - /// - /// Esecuzione lettura! - /// - private void eseguiLetturaByte() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtMemArea.Text); - int numByte = 1; - int.TryParse(txtMemSize.Text, out numByte); - Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); - titolo = string.Format("READ BLOCK MEM BYTE: {0} --> {1} byte", txtMemArea.Text, numByte); - contenuto = ""; - string byteVal = ""; - for (int i = 0; i < memByteRead.Length; i++) + + private void btnNumWriteReal_Click(object sender, EventArgs e) { - byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0'); - contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine); + setParamPlc(); + eseguiScritturaReal(); } - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Esecuzione lettura WORD! - /// - private void eseguiLetturaWord() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtMemArea.Text); - int numByte = 1; - int.TryParse(txtMemSize.Text, out numByte); - Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); - titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte); - contenuto = ""; - ushort shortVal = 0; - string byteValA = ""; - string byteValB = ""; - for (int i = 0; i < memByteRead.Length / 2; i++) + + private void btnNumWriteW_Click(object sender, EventArgs e) { - byteValA = Convert.ToString(memByteRead[i * 2], 2).PadLeft(8, '0'); - byteValB = Convert.ToString(memByteRead[i * 2 + 1], 2).PadLeft(8, '0'); - shortVal = S7.Net.Types.Word.FromByteArray(memByteRead.Skip(2 * i).Take(2).ToArray()); - contenuto += string.Format("W{0:000}: {1} | {2}-{3}{4}", i, shortVal, byteValA, byteValB, Environment.NewLine); + setParamPlc(); + eseguiScritturaWord(); } - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Esecuzione lettura DWORD! - /// - private void eseguiLetturaDWord() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtMemArea.Text); - int numByte = 1; - int.TryParse(txtMemSize.Text, out numByte); - Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); - titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte); - contenuto = ""; - uint intVal = 0; - string byteValA = ""; - string byteValB = ""; - string byteValC = ""; - string byteValD = ""; - for (int i = 0; i < memByteRead.Length / 4; i++) + + private void btnReadByte_Click(object sender, EventArgs e) { - byteValA = Convert.ToString(memByteRead[i * 4], 2).PadLeft(8, '0'); - byteValB = Convert.ToString(memByteRead[i * 4 + 1], 2).PadLeft(8, '0'); - byteValC = Convert.ToString(memByteRead[i * 4 + 2], 2).PadLeft(8, '0'); - byteValD = Convert.ToString(memByteRead[i * 4 + 3], 2).PadLeft(8, '0'); - intVal = S7.Net.Types.DWord.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray()); - contenuto += string.Format("W{0:000}: {1} | {2}-{3}-{4}-{5}{6}", i, intVal, byteValA, byteValB, byteValC, byteValD, Environment.NewLine); + setParamPlc(); + eseguiLetturaByte(); } - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Esecuzione lettura Real! - /// - private void eseguiLetturaReal() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtMemArea.Text); - int numByte = 1; - int.TryParse(txtMemSize.Text, out numByte); - Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); - titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte); - contenuto = ""; - double realVal = 0; - string byteValA = ""; - string byteValB = ""; - string byteValC = ""; - string byteValD = ""; - for (int i = 0; i < memByteRead.Length / 4; i++) + + private void btnReadDWord_Click(object sender, EventArgs e) { - byteValA = Convert.ToString(memByteRead[i * 4], 2).PadLeft(8, '0'); - byteValB = Convert.ToString(memByteRead[i * 4 + 1], 2).PadLeft(8, '0'); - byteValC = Convert.ToString(memByteRead[i * 4 + 2], 2).PadLeft(8, '0'); - byteValD = Convert.ToString(memByteRead[i * 4 + 3], 2).PadLeft(8, '0'); - realVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray()); - contenuto += string.Format("W{0:000}: {1} | {2}-{3}-{4}-{5}{6}", i, realVal, byteValA, byteValB, byteValC, byteValD, Environment.NewLine); + setParamPlc(); + eseguiLetturaDWord(); } - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Esecuzione lettura tipo STRING! - /// - private void eseguiLetturaString() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtMemArea.Text); - int numByte = 1; - int.TryParse(txtMemSize.Text, out numByte); - Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); - titolo = string.Format("READ BLOCK MEM STRING: {0} --> {1} byte", txtMemArea.Text, numByte); - contenuto = ""; - string byteVal = ""; - // i primi 2 byte sono LUNGHEZZA MAX e lungh effettiva quindi setto il NUM BYTE.... - for (int i = 0; i < 2; i++) + + /// + /// Lettura real + /// + /// + /// + private void btnReadReal_Click(object sender, EventArgs e) { - byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0'); - contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine); + setParamPlc(); + eseguiLetturaReal(); } - // prendo 2° valore (num max valori) - numByte = memByteRead[1]; - // poi prendo la stringa... - string outVal = ""; - for (int i = 2; i < numByte + 2; i++) + + private void btnReadString_Click(object sender, EventArgs e) { - outVal += Char.ConvertFromUtf32(memByteRead[i]); + setParamPlc(); + eseguiLetturaString(); } - contenuto += string.Format("{0}{1}", outVal, Environment.NewLine); - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Test connessione CNC - /// - /// - private bool testCncConn() - { - bool answ = false; - IPStatus pingStatus = testPing(); - // se passa il ping faccio il resto... - if (pingStatus != IPStatus.Success) - { - titolo = "Errore ping"; - contenuto = string.Format("Reply Status per {0}: {1}", parametri.ipAdrr, pingStatus); - showOut(titolo, contenuto); - } - else - { - if (!currPLC.IsConnected) currPLC.Open(); - if (!currPLC.IsAvailable) + + private void btnReadWord_Click(object sender, EventArgs e) { - - titolo = "Errore Disponibilità"; - contenuto = string.Format("{0} | {1}", currPLC.LastErrorCode, currPLC.LastErrorString); - currPLC.ClearLastError(); - showOut(titolo, contenuto); + setParamPlc(); + eseguiLetturaWord(); } - else + + /// + /// Scrivo memoria tipo STRING + /// + /// + /// + private void btnStrWrite_Click(object sender, EventArgs e) { - if (!currPLC.IsConnected) - { - titolo = "Errore connessione"; - contenuto = string.Format("{0} | {1}", currPLC.LastErrorCode, currPLC.LastErrorString); - currPLC.ClearLastError(); - showOut(titolo, contenuto); - tslConn.Text = "NO Connection"; - } - else - { - tslConn.Text = "Connection OK"; - answ = true; - } + setParamPlc(); + eseguiScritturaString(); } - } - return answ; - } - /// - /// test ping all'indirizzo impostato nei parametri - /// - /// - private IPStatus testPing() - { - IPStatus answ = IPStatus.Unknown; ; - IPAddress address; - PingReply reply; - Ping pingSender = new Ping(); - address = IPAddress.Loopback; - IPAddress.TryParse(parametri.ipAdrr, out address); - reply = pingSender.Send(address, 100); - answ = reply.Status; - return answ; - } - - /// - /// formatta un numero in forma binaria 0/1 a 32 bit (4 byte) - /// - /// - /// - public static string binaryForm(int valore) - { - string answ = ""; - try - { - answ = string.Format(new BinaryFormatter(), "{0:B}", valore); - } - catch - { } - return answ; - } - - protected void showOut(string title, string content) - { - string outText = ""; - // a video - outText += string.Format("{0}--------------------------------------------------------------------------------------{0}", Environment.NewLine); - outText += string.Format("- {0}{1}", title, Environment.NewLine); - outText += string.Format("--------------------------------------------------------------------------------------{0}", Environment.NewLine); - outText += string.Format("{0}{1}", content, Environment.NewLine); - outText += string.Format("--------------------------------------------------------------------------------------{0}{0}", Environment.NewLine); - - // aggiorno visualizzazione - txtOut.Text += outText; - // loggo! - lg.Info(outText); - } - - /// - /// Esecuzione SCRITTURA Byte! - /// - private void eseguiScritturaByte() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtWriteAddr1.Text); - byte num2write = 0; - string val2write = txtWriteVal2.Text; - byte.TryParse(txtWriteVal1.Text, out num2write); - byte[] DB_Byte = new byte[1]; - DB_Byte[0] = num2write; - currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); - titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); - contenuto = ""; - contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); - string byteVal = ""; - for (int i = 0; i < DB_Byte.Length; i++) + private void cbCpuType_SelectedIndexChanged(object sender, EventArgs e) { - byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0'); - contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine); + needRefresh = true; } - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Esecuzione SCRITTURA WORD! - /// - private void eseguiScritturaWord() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtWriteAddr1.Text); - UInt16 num2write = 0; - string val2write = txtWriteVal2.Text; - UInt16.TryParse(txtWriteVal1.Text, out num2write); - byte[] DB_Byte = new byte[2]; - S7.Net.Types.Word.ToByteArray(num2write).CopyTo(DB_Byte, 0); - currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); - titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); - contenuto = ""; - contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); - string byteVal = ""; - for (int i = 0; i < DB_Byte.Length; i++) + + /// + /// Esecuzione lettura! + /// + private void eseguiLetturaByte() { - byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0'); - contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine); + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtMemArea.Text); + int numByte = 1; + int.TryParse(txtMemSize.Text, out numByte); + Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); + titolo = string.Format("READ BLOCK MEM BYTE: {0} --> {1} byte", txtMemArea.Text, numByte); + contenuto = ""; + string byteVal = ""; + for (int i = 0; i < memByteRead.Length; i++) + { + byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0'); + contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); } - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Esecuzione SCRITTURA DWORD! - /// - private void eseguiScritturaDWord() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtWriteAddr1.Text); - uint num2write = 0; - string val2write = txtWriteVal2.Text; - uint.TryParse(txtWriteVal1.Text, out num2write); - byte[] DB_Byte = new byte[4]; - S7.Net.Types.DWord.ToByteArray(num2write).CopyTo(DB_Byte, 0); - currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); - titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); - contenuto = ""; - contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); - string byteVal = ""; - for (int i = 0; i < DB_Byte.Length; i++) + + /// + /// Esecuzione lettura DWORD! + /// + private void eseguiLetturaDWord() { - byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0'); - contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine); + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtMemArea.Text); + int numByte = 1; + int.TryParse(txtMemSize.Text, out numByte); + Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); + titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte); + contenuto = ""; + uint intVal = 0; + string byteValA = ""; + string byteValB = ""; + string byteValC = ""; + string byteValD = ""; + for (int i = 0; i < memByteRead.Length / 4; i++) + { + byteValA = Convert.ToString(memByteRead[i * 4], 2).PadLeft(8, '0'); + byteValB = Convert.ToString(memByteRead[i * 4 + 1], 2).PadLeft(8, '0'); + byteValC = Convert.ToString(memByteRead[i * 4 + 2], 2).PadLeft(8, '0'); + byteValD = Convert.ToString(memByteRead[i * 4 + 3], 2).PadLeft(8, '0'); + intVal = S7.Net.Types.DWord.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray()); + contenuto += string.Format("W{0:000}: {1} | {2}-{3}-{4}-{5}{6}", i, intVal, byteValA, byteValB, byteValC, byteValD, Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); } - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } - /// - /// Esecuzione SCRITTURA String! - /// - private void eseguiScritturaString() - { - sw.Restart(); - if (testCncConn()) - { - // decodifico memoria... - memAddress memoria = new memAddress(txtWriteAddr2.Text); - int num2write = 0; - // verifico di no sforare con lunghezza - string val2write = txtWriteVal2.Text; - // se è maggiore di maxStrChar TRIMMA::: - if (val2write.Length > maxStrChar) + + /// + /// Esecuzione lettura Real! + /// + private void eseguiLetturaReal() { - val2write = val2write.Substring(0, 20); + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtMemArea.Text); + int numByte = 1; + int.TryParse(txtMemSize.Text, out numByte); + Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); + titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte); + contenuto = ""; + double realVal = 0; + string byteValA = ""; + string byteValB = ""; + string byteValC = ""; + string byteValD = ""; + for (int i = 0; i < memByteRead.Length / 4; i++) + { + byteValA = Convert.ToString(memByteRead[i * 4], 2).PadLeft(8, '0'); + byteValB = Convert.ToString(memByteRead[i * 4 + 1], 2).PadLeft(8, '0'); + byteValC = Convert.ToString(memByteRead[i * 4 + 2], 2).PadLeft(8, '0'); + byteValD = Convert.ToString(memByteRead[i * 4 + 3], 2).PadLeft(8, '0'); + realVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray()); + contenuto += string.Format("W{0:000}: {1} | {2}-{3}-{4}-{5}{6}", i, realVal, byteValA, byteValB, byteValC, byteValD, Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); } - // scambio spazi con underscore... e MAIUSCOLO!!! - val2write = val2write.Replace(' ', '_').ToUpper(); - num2write = val2write.Length; - byte[] DB_Byte = new byte[maxStrChar + 2]; - // primi 2 byte sono 20 (fix) e lung effettiva... - DB_Byte[0] = 20; - DB_Byte[1] = (byte)num2write; - // converto 1-1 i char in byte... - for (int i = 0; i < num2write; i++) + + /// + /// Esecuzione lettura tipo STRING! + /// + private void eseguiLetturaString() { - DB_Byte[2 + i] = (byte)(val2write[i]); + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtMemArea.Text); + int numByte = 1; + int.TryParse(txtMemSize.Text, out numByte); + Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); + titolo = string.Format("READ BLOCK MEM STRING: {0} --> {1} byte", txtMemArea.Text, numByte); + contenuto = ""; + string byteVal = ""; + // i primi 2 byte sono LUNGHEZZA MAX e lungh effettiva quindi setto il NUM BYTE.... + for (int i = 0; i < 2; i++) + { + byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0'); + contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine); + } + // prendo 2° valore (num max valori) + numByte = memByteRead[1]; + // poi prendo la stringa... + string outVal = ""; + for (int i = 2; i < numByte + 2; i++) + { + outVal += Char.ConvertFromUtf32(memByteRead[i]); + } + contenuto += string.Format("{0}{1}", outVal, Environment.NewLine); + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); } - currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); - titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); - contenuto = ""; - contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | stringa: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); - showOut(titolo, contenuto); - } - sw.Stop(); - tslRTime.Text = string.Format("{0}", sw.Elapsed); - } + /// + /// Esecuzione lettura WORD! + /// + private void eseguiLetturaWord() + { + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtMemArea.Text); + int numByte = 1; + int.TryParse(txtMemSize.Text, out numByte); + Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte); + titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte); + contenuto = ""; + ushort shortVal = 0; + string byteValA = ""; + string byteValB = ""; + for (int i = 0; i < memByteRead.Length / 2; i++) + { + byteValA = Convert.ToString(memByteRead[i * 2], 2).PadLeft(8, '0'); + byteValB = Convert.ToString(memByteRead[i * 2 + 1], 2).PadLeft(8, '0'); + shortVal = S7.Net.Types.Word.FromByteArray(memByteRead.Skip(2 * i).Take(2).ToArray()); + contenuto += string.Format("W{0:000}: {1} | {2}-{3}{4}", i, shortVal, byteValA, byteValB, Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); + } - /// - /// Scrivo memoria tipo STRING - /// - /// - /// - private void btnStrWrite_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiScritturaString(); - } + /// + /// Esecuzione SCRITTURA Byte! + /// + private void eseguiScritturaByte() + { + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtWriteAddr1.Text); + byte num2write = 0; + string val2write = txtWriteVal2.Text; + byte.TryParse(txtWriteVal1.Text, out num2write); + byte[] DB_Byte = new byte[1]; + DB_Byte[0] = num2write; + currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); + titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); + contenuto = ""; + contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); + string byteVal = ""; + for (int i = 0; i < DB_Byte.Length; i++) + { + byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0'); + contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); + } - private void txtIP_TextChanged(object sender, EventArgs e) - { - needRefresh = true; - } + /// + /// Esecuzione SCRITTURA DWORD! + /// + private void eseguiScritturaDWord() + { + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtWriteAddr1.Text); + uint num2write = 0; + string val2write = txtWriteVal2.Text; + uint.TryParse(txtWriteVal1.Text, out num2write); + byte[] DB_Byte = new byte[4]; + S7.Net.Types.DWord.ToByteArray(num2write).CopyTo(DB_Byte, 0); + currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); + titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); + contenuto = ""; + contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); + string byteVal = ""; + for (int i = 0; i < DB_Byte.Length; i++) + { + byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0'); + contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); + } - private void txtRack_TextChanged(object sender, EventArgs e) - { - needRefresh = true; - } + private void eseguiScritturaReal() + { + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtWriteAddr1.Text); + double num2write = 0; + double.TryParse(txtWriteVal1.Text.Replace(".", ","), out num2write); + byte[] DB_Byte = new byte[4]; + S7.Net.Types.Double.ToByteArray(num2write).CopyTo(DB_Byte, 0); + currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); + titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); + contenuto = ""; + contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); + string byteVal = ""; + for (int i = 0; i < DB_Byte.Length; i++) + { + byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0'); + contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); + } - private void cbCpuType_SelectedIndexChanged(object sender, EventArgs e) - { - needRefresh = true; - } + /// + /// Esecuzione SCRITTURA String! + /// + private void eseguiScritturaString() + { + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtWriteAddr2.Text); + int num2write = 0; + // verifico di no sforare con lunghezza + string val2write = txtWriteVal2.Text; + // se è maggiore di maxStrChar TRIMMA::: + if (val2write.Length > maxStrChar) + { + val2write = val2write.Substring(0, 20); + } + // scambio spazi con underscore... e MAIUSCOLO!!! + val2write = val2write.Replace(' ', '_').ToUpper(); + num2write = val2write.Length; + byte[] DB_Byte = new byte[maxStrChar + 2]; + // primi 2 byte sono 20 (fix) e lung effettiva... + DB_Byte[0] = 20; + DB_Byte[1] = (byte)num2write; + // converto 1-1 i char in byte... + for (int i = 0; i < num2write; i++) + { + DB_Byte[2 + i] = (byte)(val2write[i]); + } + currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); + titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); + contenuto = ""; + contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | stringa: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); + } - private void txtSlot_TextChanged(object sender, EventArgs e) - { - needRefresh = true; - } + /// + /// Esecuzione SCRITTURA WORD! + /// + private void eseguiScritturaWord() + { + sw.Restart(); + if (testCncConn()) + { + // decodifico memoria... + memAddress memoria = new memAddress(txtWriteAddr1.Text); + UInt16 num2write = 0; + string val2write = txtWriteVal2.Text; + UInt16.TryParse(txtWriteVal1.Text, out num2write); + byte[] DB_Byte = new byte[2]; + S7.Net.Types.Word.ToByteArray(num2write).CopyTo(DB_Byte, 0); + currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte); + titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text); + contenuto = ""; + contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine); + string byteVal = ""; + for (int i = 0; i < DB_Byte.Length; i++) + { + byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0'); + contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine); + } + showOut(titolo, contenuto); + } + sw.Stop(); + tslRTime.Text = string.Format("{0}", sw.Elapsed); + } - private void txtMemArea_TextChanged(object sender, EventArgs e) - { - needRefresh = true; - } + /// + /// Caricamento conf memoria DB del SIEMENS + /// + private void loadMemConf() + { + // carico conf memoria + utils.loadConfFile(ref memMapR, filePath("MMapR"), 1, ref numByte); + utils.loadConfFile(ref memMapW, filePath("MMapW"), 1, ref numByte); + } - private void txtMemSize_TextChanged(object sender, EventArgs e) - { - needRefresh = true; - } + /// + /// inizializzo + /// + private void myInit() + { + lg = LogManager.GetCurrentClassLogger(); + // inizializzo parametri... + parametri = new connParam() + { + ipAdrr = "127.0.0.1", + tipoCpu = CpuType.S7200, + slot = 0, + rack = 0 + }; + setParamPlc(); + } - private void btnReadByte_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiLetturaByte(); - } + /// + /// Imposto parametri PLC + /// + private void setParamPlc() + { + txtOut.Text = ""; + // SE è necessario refresh... + if (needRefresh) + { + lg.Info("Refreshing connection..."); + try + { + short.TryParse(txtSlot.Text, out parametri.slot); + short.TryParse(txtRack.Text, out parametri.rack); + parametri.tipoCpu = (CpuType)Enum.Parse(typeof(CpuType), cbCpuType.SelectedItem.ToString()); + parametri.ipAdrr = txtIP.Text.Trim(); + titolo = "PARAM PLC (pre connect)"; + contenuto = string.Format("IP: {0}{1}", parametri.ipAdrr, Environment.NewLine); + contenuto += string.Format("CPU: {0}{1}", parametri.tipoCpu, Environment.NewLine); + contenuto += string.Format("RACK: {0}{1}", parametri.rack, Environment.NewLine); + contenuto += string.Format("SLOT: {0}", parametri.slot, Environment.NewLine); + } + catch (Exception exc) + { + lg.Error(exc, "Errore in parse parametri"); + } + // ora tento avvio PLC... SE PING OK... + if (testPing() == IPStatus.Success) + { + try + { + currPLC = new Plc(parametri.tipoCpu, parametri.ipAdrr, parametri.rack, parametri.slot); + currPLC.Open(); + if (currPLC.IsConnected) titolo = "CONNESSIONE AVVENUTA"; + } + catch (Exception exc) + { + lg.Error(exc, "Errore in INIT PLC"); + } + needRefresh = false; + } + // carico conf vettore memoria... + loadMemConf(); + // mostra output + showOut(titolo, contenuto); + } + } - private void btnReadWord_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiLetturaWord(); - } + /// + /// Test connessione CNC + /// + /// + private bool testCncConn() + { + bool answ = false; + IPStatus pingStatus = testPing(); + // se passa il ping faccio il resto... + if (pingStatus != IPStatus.Success) + { + titolo = "Errore ping"; + contenuto = string.Format("Reply Status per {0}: {1}", parametri.ipAdrr, pingStatus); + showOut(titolo, contenuto); + } + else + { + if (!currPLC.IsConnected) currPLC.Open(); + if (!currPLC.IsAvailable) + { + titolo = "Errore Disponibilità"; + contenuto = string.Format("{0} | {1}", currPLC.LastErrorCode, currPLC.LastErrorString); + currPLC.ClearLastError(); + showOut(titolo, contenuto); + } + else + { + if (!currPLC.IsConnected) + { + titolo = "Errore connessione"; + contenuto = string.Format("{0} | {1}", currPLC.LastErrorCode, currPLC.LastErrorString); + currPLC.ClearLastError(); + showOut(titolo, contenuto); + tslConn.Text = "NO Connection"; + } + else + { + tslConn.Text = "Connection OK"; + answ = true; + } + } + } + return answ; + } - private void btnReadString_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiLetturaString(); - } + /// + /// test ping all'indirizzo impostato nei parametri + /// + /// + private IPStatus testPing() + { + IPStatus answ = IPStatus.Unknown; ; + IPAddress address; + PingReply reply; + Ping pingSender = new Ping(); + address = IPAddress.Loopback; + IPAddress.TryParse(parametri.ipAdrr, out address); + reply = pingSender.Send(address, 100); + answ = reply.Status; + return answ; + } - private void btnReadDWord_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiLetturaDWord(); - } - /// - /// Lettura real - /// - /// - /// - private void btnReadReal_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiLetturaReal(); - } + private void txtIP_TextChanged(object sender, EventArgs e) + { + needRefresh = true; + } - private void btnNumWriteB_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiScritturaByte(); - } + private void txtMemArea_TextChanged(object sender, EventArgs e) + { + needRefresh = true; + } - private void btnNumWriteDW_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiScritturaDWord(); - } + private void txtMemSize_TextChanged(object sender, EventArgs e) + { + needRefresh = true; + } - private void btnNumWriteW_Click(object sender, EventArgs e) - { - setParamPlc(); - eseguiScritturaWord(); - } - } + private void txtRack_TextChanged(object sender, EventArgs e) + { + needRefresh = true; + } -} + private void txtSlot_TextChanged(object sender, EventArgs e) + { + needRefresh = true; + } + + #endregion Private Methods + + #region Protected Methods + + /// + /// Restituisce path completo file da chaive configurazione + /// + /// chaive conf x file richiesto + /// + protected string filePath(string keyFile) + { + return string.Format(@"{0}\{1}", utils.confDir, utils.CRS(keyFile)); + } + + protected void showOut(string title, string content) + { + string outText = ""; + // a video + outText += string.Format("{0}--------------------------------------------------------------------------------------{0}", Environment.NewLine); + outText += string.Format("- {0}{1}", title, Environment.NewLine); + outText += string.Format("--------------------------------------------------------------------------------------{0}", Environment.NewLine); + outText += string.Format("{0}{1}", content, Environment.NewLine); + outText += string.Format("--------------------------------------------------------------------------------------{0}{0}", Environment.NewLine); + + // aggiorno visualizzazione + txtOut.Text += outText; + // loggo! + lg.Info(outText); + } + + #endregion Protected Methods + + #region Public Methods + + /// + /// formatta un numero in forma binaria 0/1 a 32 bit (4 byte) + /// + /// + /// + public static string binaryForm(int valore) + { + string answ = ""; + try + { + answ = string.Format(new BinaryFormatter(), "{0:B}", valore); + } + catch + { } + return answ; + } + + #endregion Public Methods + } +} \ No newline at end of file