Continuo funzionalità testing lettura S7

This commit is contained in:
Samuele Locatelli
2020-05-04 17:25:34 +02:00
parent 11ea38f08a
commit 3ec2cbe0e9
4 changed files with 488 additions and 161 deletions
@@ -70,6 +70,7 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ThermoObj.cs" />
<Compile Include="TimingData.cs" />
<Compile Include="utils.cs" />
<EmbeddedResource Include="TestMainForm.resx">
<DependentUpon>TestMainForm.cs</DependentUpon>
+339 -120
View File
@@ -37,16 +37,13 @@
this.label3 = new System.Windows.Forms.Label();
this.txtMemSize = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnReadStruct = new System.Windows.Forms.Button();
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();
@@ -70,12 +67,39 @@
this.label10 = new System.Windows.Forms.Label();
this.txtWriteAddr1 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.btnReadStruct = new System.Windows.Forms.Button();
this.txtOut = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.tabCtrl = new System.Windows.Forms.TabControl();
this.tabReadTest = new System.Windows.Forms.TabPage();
this.tabParam = new System.Windows.Forms.TabPage();
this.tabWriteTest = new System.Windows.Forms.TabPage();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.label11 = new System.Windows.Forms.Label();
this.txtNumRep = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.lblTimeAvg = new System.Windows.Forms.Label();
this.lblTimeMax = new System.Windows.Forms.Label();
this.lblTimeMin = new System.Windows.Forms.Label();
this.lblTotSize = new System.Windows.Forms.Label();
this.lblThroughtput = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tabCtrl.SuspendLayout();
this.tabReadTest.SuspendLayout();
this.tabParam.SuspendLayout();
this.tabWriteTest.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// txtIP
@@ -134,161 +158,129 @@
//
// txtMemArea
//
this.txtMemArea.Location = new System.Drawing.Point(156, 20);
this.txtMemArea.Location = new System.Drawing.Point(148, 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.Size = new System.Drawing.Size(101, 22);
this.txtMemArea.TabIndex = 4;
this.txtMemArea.Text = "DB600.DBB0";
this.txtMemArea.Text = "DB600.DBB20";
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.Location = new System.Drawing.Point(9, 52);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(113, 17);
this.label3.Size = new System.Drawing.Size(123, 17);
this.label3.TabIndex = 7;
this.label3.Text = "MEM SIZE BYTE";
this.label3.Text = "MEM SIZE (BYTE)";
//
// txtMemSize
//
this.txtMemSize.Location = new System.Drawing.Point(156, 78);
this.txtMemSize.Location = new System.Drawing.Point(148, 50);
this.txtMemSize.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtMemSize.Name = "txtMemSize";
this.txtMemSize.Size = new System.Drawing.Size(39, 22);
this.txtMemSize.Size = new System.Drawing.Size(101, 22);
this.txtMemSize.TabIndex = 6;
this.txtMemSize.Text = "2";
this.txtMemSize.Text = "200";
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.txtNumRep);
this.groupBox1.Controls.Add(this.label13);
this.groupBox1.Controls.Add(this.btnReadStruct);
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.Location = new System.Drawing.Point(6, 5);
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.Size = new System.Drawing.Size(521, 105);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Memoria: READ param";
this.groupBox1.Text = "Memoria: READ testing";
//
// btnReadStruct
//
this.btnReadStruct.Location = new System.Drawing.Point(405, 75);
this.btnReadStruct.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnReadStruct.Name = "btnReadStruct";
this.btnReadStruct.Size = new System.Drawing.Size(110, 25);
this.btnReadStruct.TabIndex = 12;
this.btnReadStruct.Text = "Read Struc";
this.btnReadStruct.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
this.btnReadStruct.UseVisualStyleBackColor = true;
this.btnReadStruct.Click += new System.EventHandler(this.btnReadStruct_Click);
//
// btnReadString
//
this.btnReadString.Location = new System.Drawing.Point(201, 75);
this.btnReadString.Location = new System.Drawing.Point(405, 49);
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.Size = new System.Drawing.Size(110, 25);
this.btnReadString.TabIndex = 11;
this.btnReadString.Text = "R String";
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(308, 47);
this.btnReadDWord.Location = new System.Drawing.Point(289, 75);
this.btnReadDWord.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnReadDWord.Name = "btnReadDWord";
this.btnReadDWord.Size = new System.Drawing.Size(72, 25);
this.btnReadDWord.Size = new System.Drawing.Size(110, 25);
this.btnReadDWord.TabIndex = 10;
this.btnReadDWord.Text = "R DW";
this.btnReadDWord.Text = "Read DWord";
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(308, 18);
this.btnReadWord.Location = new System.Drawing.Point(289, 48);
this.btnReadWord.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnReadWord.Name = "btnReadWord";
this.btnReadWord.Size = new System.Drawing.Size(72, 25);
this.btnReadWord.Size = new System.Drawing.Size(110, 25);
this.btnReadWord.TabIndex = 10;
this.btnReadWord.Text = "R W";
this.btnReadWord.Text = "Read Word";
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.Location = new System.Drawing.Point(405, 19);
this.btnReadReal.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnReadReal.Name = "btnReadReal";
this.btnReadReal.Size = new System.Drawing.Size(67, 25);
this.btnReadReal.Size = new System.Drawing.Size(110, 25);
this.btnReadReal.TabIndex = 9;
this.btnReadReal.Text = "R REAL";
this.btnReadReal.Text = "Read 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.Location = new System.Drawing.Point(289, 19);
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.Size = new System.Drawing.Size(110, 25);
this.btnReadByte.TabIndex = 9;
this.btnReadByte.Text = "R Byte";
this.btnReadByte.Text = "Read Byte";
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)
| 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.label11);
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Controls.Add(this.txtSlot);
this.groupBox3.Controls.Add(this.label5);
@@ -298,28 +290,15 @@
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.Location = new System.Drawing.Point(6, 5);
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.Size = new System.Drawing.Size(479, 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, 48);
this.textBox2.TabIndex = 7;
this.textBox2.Text = "S7-1200/S7-1500: 0/1\r\nS7-300/S7-400: 0/2\r\nSlot > 0 se eth ext";
//
// label6
//
this.label6.AutoSize = true;
@@ -375,10 +354,10 @@
this.toolStripStatusLabel1,
this.toolStripProgressBar1,
this.tslRTime});
this.statusStrip1.Location = new System.Drawing.Point(0, 596);
this.statusStrip1.Location = new System.Drawing.Point(0, 583);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 13, 0);
this.statusStrip1.Size = new System.Drawing.Size(869, 28);
this.statusStrip1.Size = new System.Drawing.Size(906, 28);
this.statusStrip1.TabIndex = 11;
this.statusStrip1.Text = "statusStrip1";
//
@@ -421,11 +400,11 @@
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.Location = new System.Drawing.Point(7, 7);
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.Size = new System.Drawing.Size(1809, 71);
this.groupBox4.TabIndex = 12;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Memoria: WRITE param";
@@ -550,41 +529,265 @@
this.label7.TabIndex = 7;
this.label7.Text = "ADDR 1";
//
// btnReadStruct
// txtOut
//
this.btnReadStruct.Location = new System.Drawing.Point(308, 75);
this.btnReadStruct.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnReadStruct.Name = "btnReadStruct";
this.btnReadStruct.Size = new System.Drawing.Size(72, 25);
this.btnReadStruct.TabIndex = 12;
this.btnReadStruct.Text = "R Struc";
this.btnReadStruct.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
this.btnReadStruct.UseVisualStyleBackColor = true;
this.btnReadStruct.Click += new System.EventHandler(this.btnReadStruct_Click);
this.txtOut.BackColor = System.Drawing.SystemColors.Desktop;
this.txtOut.BorderStyle = System.Windows.Forms.BorderStyle.None;
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(4, 21);
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(569, 388);
this.txtOut.TabIndex = 0;
this.txtOut.Text = "...";
//
// groupBox2
//
this.groupBox2.AutoSize = true;
this.groupBox2.Controls.Add(this.txtOut);
this.groupBox2.Location = new System.Drawing.Point(3, 11);
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(579, 428);
this.groupBox2.TabIndex = 9;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Risultati";
//
// tabCtrl
//
this.tabCtrl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabCtrl.Controls.Add(this.tabReadTest);
this.tabCtrl.Controls.Add(this.tabWriteTest);
this.tabCtrl.Controls.Add(this.tabParam);
this.tabCtrl.Location = new System.Drawing.Point(15, 9);
this.tabCtrl.Name = "tabCtrl";
this.tabCtrl.SelectedIndex = 0;
this.tabCtrl.Size = new System.Drawing.Size(879, 143);
this.tabCtrl.TabIndex = 13;
//
// tabReadTest
//
this.tabReadTest.Controls.Add(this.groupBox1);
this.tabReadTest.Location = new System.Drawing.Point(4, 25);
this.tabReadTest.Name = "tabReadTest";
this.tabReadTest.Padding = new System.Windows.Forms.Padding(3);
this.tabReadTest.Size = new System.Drawing.Size(871, 114);
this.tabReadTest.TabIndex = 0;
this.tabReadTest.Text = "Read Test";
this.tabReadTest.UseVisualStyleBackColor = true;
//
// tabParam
//
this.tabParam.Controls.Add(this.groupBox3);
this.tabParam.Location = new System.Drawing.Point(4, 25);
this.tabParam.Name = "tabParam";
this.tabParam.Padding = new System.Windows.Forms.Padding(3);
this.tabParam.Size = new System.Drawing.Size(878, 118);
this.tabParam.TabIndex = 1;
this.tabParam.Text = "Parametri";
this.tabParam.UseVisualStyleBackColor = true;
//
// tabWriteTest
//
this.tabWriteTest.Controls.Add(this.groupBox4);
this.tabWriteTest.Location = new System.Drawing.Point(4, 25);
this.tabWriteTest.Name = "tabWriteTest";
this.tabWriteTest.Size = new System.Drawing.Size(878, 118);
this.tabWriteTest.TabIndex = 2;
this.tabWriteTest.Text = "Write Test";
this.tabWriteTest.UseVisualStyleBackColor = true;
//
// splitContainer1
//
this.splitContainer1.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.splitContainer1.Location = new System.Drawing.Point(15, 158);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.lblThroughtput);
this.splitContainer1.Panel1.Controls.Add(this.label18);
this.splitContainer1.Panel1.Controls.Add(this.lblTotSize);
this.splitContainer1.Panel1.Controls.Add(this.lblTimeMin);
this.splitContainer1.Panel1.Controls.Add(this.lblTimeMax);
this.splitContainer1.Panel1.Controls.Add(this.lblTimeAvg);
this.splitContainer1.Panel1.Controls.Add(this.label16);
this.splitContainer1.Panel1.Controls.Add(this.label15);
this.splitContainer1.Panel1.Controls.Add(this.label14);
this.splitContainer1.Panel1.Controls.Add(this.label12);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.groupBox2);
this.splitContainer1.Size = new System.Drawing.Size(875, 422);
this.splitContainer1.SplitterDistance = 291;
this.splitContainer1.TabIndex = 15;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(301, 39);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(148, 51);
this.label11.TabIndex = 7;
this.label11.Text = "S7-1200/S7-1500: 0/1\r\nS7-300/S7-400: 0/2\r\nSlot > 0 se eth ext";
//
// txtNumRep
//
this.txtNumRep.Location = new System.Drawing.Point(148, 76);
this.txtNumRep.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtNumRep.Name = "txtNumRep";
this.txtNumRep.Size = new System.Drawing.Size(101, 22);
this.txtNumRep.TabIndex = 14;
this.txtNumRep.Text = "1";
this.txtNumRep.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(9, 79);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(90, 21);
this.label13.TabIndex = 15;
this.label13.Text = "# samples";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(19, 20);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(58, 17);
this.label12.TabIndex = 0;
this.label12.Text = "Tot size";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(19, 41);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(70, 17);
this.label14.TabIndex = 1;
this.label14.Text = "TIME: min";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(19, 75);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(73, 17);
this.label15.TabIndex = 2;
this.label15.Text = "TIME: max";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label16.Location = new System.Drawing.Point(19, 58);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(80, 17);
this.label16.TabIndex = 3;
this.label16.Text = "TIME: avg";
//
// lblTimeAvg
//
this.lblTimeAvg.AutoSize = true;
this.lblTimeAvg.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblTimeAvg.Location = new System.Drawing.Point(224, 58);
this.lblTimeAvg.Name = "lblTimeAvg";
this.lblTimeAvg.Size = new System.Drawing.Size(35, 17);
this.lblTimeAvg.TabIndex = 4;
this.lblTimeAvg.Text = "000";
this.lblTimeAvg.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblTimeMax
//
this.lblTimeMax.AutoSize = true;
this.lblTimeMax.Location = new System.Drawing.Point(227, 75);
this.lblTimeMax.Name = "lblTimeMax";
this.lblTimeMax.Size = new System.Drawing.Size(32, 17);
this.lblTimeMax.TabIndex = 5;
this.lblTimeMax.Text = "000";
this.lblTimeMax.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblTimeMin
//
this.lblTimeMin.AutoSize = true;
this.lblTimeMin.Location = new System.Drawing.Point(227, 41);
this.lblTimeMin.Name = "lblTimeMin";
this.lblTimeMin.Size = new System.Drawing.Size(32, 17);
this.lblTimeMin.TabIndex = 6;
this.lblTimeMin.Text = "000";
this.lblTimeMin.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblTotSize
//
this.lblTotSize.AutoSize = true;
this.lblTotSize.Location = new System.Drawing.Point(227, 20);
this.lblTotSize.Name = "lblTotSize";
this.lblTotSize.Size = new System.Drawing.Size(32, 17);
this.lblTotSize.TabIndex = 7;
this.lblTotSize.Text = "000";
this.lblTotSize.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblThroughtput
//
this.lblThroughtput.AutoSize = true;
this.lblThroughtput.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblThroughtput.Location = new System.Drawing.Point(224, 126);
this.lblThroughtput.Name = "lblThroughtput";
this.lblThroughtput.Size = new System.Drawing.Size(35, 17);
this.lblThroughtput.TabIndex = 9;
this.lblThroughtput.Text = "000";
this.lblThroughtput.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label18
//
this.label18.AutoSize = true;
this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label18.Location = new System.Drawing.Point(19, 126);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(71, 21);
this.label18.TabIndex = 8;
this.label18.Text = "Kb/sec";
//
// 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.ClientSize = new System.Drawing.Size(906, 611);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.tabCtrl);
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.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.tabCtrl.ResumeLayout(false);
this.tabReadTest.ResumeLayout(false);
this.tabParam.ResumeLayout(false);
this.tabWriteTest.ResumeLayout(false);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -601,16 +804,12 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtMemSize;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox txtOut;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox txtSlot;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtRack;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button btnReadByte;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel tslConn;
@@ -635,6 +834,26 @@
private System.Windows.Forms.Button btnNumWriteB;
private System.Windows.Forms.Button btnNumWriteDW;
private System.Windows.Forms.Button btnReadStruct;
private System.Windows.Forms.TextBox txtOut;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TabControl tabCtrl;
private System.Windows.Forms.TabPage tabReadTest;
private System.Windows.Forms.TabPage tabWriteTest;
private System.Windows.Forms.TabPage tabParam;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox txtNumRep;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label lblTotSize;
private System.Windows.Forms.Label lblTimeMin;
private System.Windows.Forms.Label lblTimeMax;
private System.Windows.Forms.Label lblTimeAvg;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label lblThroughtput;
private System.Windows.Forms.Label label18;
}
}
+97 -41
View File
@@ -61,6 +61,10 @@ namespace Siemens_S7_Test
/// oggetto logging
/// </summary>
public static Logger lg;
/// <summary>
/// Gestione statistiche
/// </summary>
public TimingData PerfStats;
public TestMainForm()
{
@@ -74,6 +78,7 @@ namespace Siemens_S7_Test
private void myInit()
{
lg = LogManager.GetCurrentClassLogger();
PerfStats = new TimingData();
// inizializzo parametri...
parametri = new connParam()
{
@@ -149,23 +154,45 @@ namespace Siemens_S7_Test
{
return string.Format(@"{0}\{1}", utils.confDir, utils.CRS(keyFile));
}
/// <summary>
/// Aggiorno statistiche mostrate
/// </summary>
protected void updateStats()
{
lblTimeMin.Text = $"{PerfStats.currStat.min:0.00} s";
lblTimeMax.Text = $"{PerfStats.currStat.max:0.00} s";
lblTimeAvg.Text = $"{PerfStats.currStat.avg:0.00} s";
}
/// <summary>
/// Esecuzione lettura!
/// </summary>
private void eseguiLetturaByte()
{
sw.Restart();
PerfStats = new TimingData();
if (testCncConn())
{
// decodifico memoria...
memAddress memoria = new memAddress(txtMemArea.Text);
int numByte = 1;
int.TryParse(txtMemSize.Text, out numByte);
int numTest = 1;
int.TryParse(txtNumRep.Text, out numTest);
Byte[] memByteRead = new byte[0];
// effettuo numero di test secondo indicazioni...
for (int i = 0; i < numTest; i++)
{
sw.Restart();
// eseguo test
memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
sw.Stop();
// salvo risultati
PerfStats.addValue((double)sw.ElapsedMilliseconds / 1000);
}
//var readVal = currPLC.Read("DB600.DBD0");
// mostro update lettura
updateStats();
Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
sw.Stop();
tslRTime.Text = string.Format("{0}", sw.Elapsed);
titolo = string.Format("READ BLOCK MEM BYTE: {0} --> {1} byte", txtMemArea.Text, numByte);
contenuto = "";
@@ -183,15 +210,30 @@ namespace Siemens_S7_Test
/// </summary>
private void eseguiLetturaWord()
{
sw.Restart();
PerfStats = new TimingData();
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);
sw.Stop();
int numTest = 1;
int.TryParse(txtNumRep.Text, out numTest);
Byte[] memByteRead = new byte[0];
// effettuo numero di test secondo indicazioni...
for (int i = 0; i < numTest; i++)
{
sw.Restart();
// eseguo test
memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
sw.Stop();
// salvo risultati
PerfStats.addValue((double)sw.ElapsedMilliseconds / 1000);
}
// mostro update lettura
updateStats();
tslRTime.Text = string.Format("{0}", sw.Elapsed);
titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte);
contenuto = "";
@@ -209,6 +251,54 @@ namespace Siemens_S7_Test
}
}
/// <summary>
/// Esecuzione lettura DWORD!
/// </summary>
private void eseguiLetturaDWord()
{
PerfStats = new TimingData();
if (testCncConn())
{
// decodifico memoria...
memAddress memoria = new memAddress(txtMemArea.Text);
int numByte = 1;
int.TryParse(txtMemSize.Text, out numByte);
int numTest = 1;
int.TryParse(txtNumRep.Text, out numTest);
Byte[] memByteRead = new byte[0];
for (int i = 0; i < numTest; i++)
{
sw.Restart();
// eseguo test
memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
sw.Stop();
// salvo risultati
PerfStats.addValue((double)sw.ElapsedMilliseconds / 1000);
}
// mostro update lettura
updateStats();
tslRTime.Text = string.Format("{0}", sw.Elapsed);
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);
}
}
/// <summary>
/// Esecuzione lettura come struct
/// </summary>
@@ -270,40 +360,6 @@ namespace Siemens_S7_Test
/// <summary>
/// Esecuzione lettura DWORD!
/// </summary>
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);
sw.Stop();
tslRTime.Text = string.Format("{0}", sw.Elapsed);
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);
}
}
/// <summary>
/// Esecuzione lettura Real!
/// </summary>
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Siemens_S7_Test
{
public class TimingData
{
/// <summary>
/// Array dei valori rilevati in secondi
/// </summary>
protected List<double> valori { get; set; }
/// <summary>
/// Statistiche attuali
/// </summary>
public stats currStat;
/// <summary>
/// Tipo dei dati salvato
/// </summary>
public string Tipo { get; set; }
public TimingData()
{
valori = new List<double>();
currStat = new stats();
}
/// <summary>
/// aggiunge dati e restituisce statistiche aggiornate...
/// </summary>
/// <param name="valore"></param>
/// <returns></returns>
public void addValue(double valore)
{
valori.Add(valore);
currStat.min = valori.Min();
currStat.max = valori.Max();
currStat.avg = valori.Average();
}
}
/// <summary>
/// Struttura risultati
/// </summary>
public struct stats
{
public double min;
public double max;
public double avg;
}
}