completo versione di test (POSITIVO) di lettura su S7 Jetco
This commit is contained in:
Generated
+72
-20
@@ -37,6 +37,8 @@
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtMemSize = new System.Windows.Forms.TextBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.btnRead = 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();
|
||||
@@ -46,11 +48,15 @@
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.txtRack = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.btnRead = new System.Windows.Forms.Button();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.tslConn = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.tslRTime = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtIP
|
||||
@@ -146,6 +152,28 @@
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Memoria: parametri lettura";
|
||||
//
|
||||
// btnRead
|
||||
//
|
||||
this.btnRead.Location = new System.Drawing.Point(279, 21);
|
||||
this.btnRead.Name = "btnRead";
|
||||
this.btnRead.Size = new System.Drawing.Size(101, 78);
|
||||
this.btnRead.TabIndex = 9;
|
||||
this.btnRead.Text = "READ";
|
||||
this.btnRead.UseVisualStyleBackColor = true;
|
||||
this.btnRead.Click += new System.EventHandler(this.btnRead_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(6, 44);
|
||||
this.textBox1.Multiline = true;
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(234, 33);
|
||||
this.textBox1.TabIndex = 8;
|
||||
this.textBox1.Text = "Indicare tipo memoria (es DBD) e size del tipo";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
@@ -168,6 +196,7 @@
|
||||
this.txtOut.Location = new System.Drawing.Point(3, 18);
|
||||
this.txtOut.Multiline = true;
|
||||
this.txtOut.Name = "txtOut";
|
||||
this.txtOut.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtOut.Size = new System.Drawing.Size(837, 541);
|
||||
this.txtOut.TabIndex = 0;
|
||||
this.txtOut.Text = "...";
|
||||
@@ -246,33 +275,49 @@
|
||||
this.label4.TabIndex = 4;
|
||||
this.label4.Text = "Rack";
|
||||
//
|
||||
// textBox1
|
||||
// statusStrip1
|
||||
//
|
||||
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(6, 44);
|
||||
this.textBox1.Multiline = true;
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(234, 33);
|
||||
this.textBox1.TabIndex = 8;
|
||||
this.textBox1.Text = "Indicare tipo memoria (es DBD) e size del tipo";
|
||||
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, 667);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(867, 25);
|
||||
this.statusStrip1.TabIndex = 11;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// btnRead
|
||||
// tslConn
|
||||
//
|
||||
this.btnRead.Location = new System.Drawing.Point(279, 21);
|
||||
this.btnRead.Name = "btnRead";
|
||||
this.btnRead.Size = new System.Drawing.Size(101, 78);
|
||||
this.btnRead.TabIndex = 9;
|
||||
this.btnRead.Text = "READ";
|
||||
this.btnRead.UseVisualStyleBackColor = true;
|
||||
this.btnRead.Click += new System.EventHandler(this.btnRead_Click);
|
||||
this.tslConn.Name = "tslConn";
|
||||
this.tslConn.Size = new System.Drawing.Size(72, 20);
|
||||
this.tslConn.Text = "Conn: ND";
|
||||
//
|
||||
// toolStripStatusLabel1
|
||||
//
|
||||
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
|
||||
this.toolStripStatusLabel1.Size = new System.Drawing.Size(13, 20);
|
||||
this.toolStripStatusLabel1.Text = "|";
|
||||
//
|
||||
// tslRTime
|
||||
//
|
||||
this.tslRTime.Name = "tslRTime";
|
||||
this.tslRTime.Size = new System.Drawing.Size(37, 20);
|
||||
this.tslRTime.Text = "...ms";
|
||||
//
|
||||
// toolStripProgressBar1
|
||||
//
|
||||
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
|
||||
this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 19);
|
||||
//
|
||||
// TestMainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(867, 692);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
@@ -284,6 +329,8 @@
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -311,6 +358,11 @@
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.Button btnRead;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel tslConn;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
|
||||
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel tslRTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-9
@@ -11,6 +11,7 @@ using S7.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net;
|
||||
using NLog;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Test_S7
|
||||
{
|
||||
@@ -38,9 +39,9 @@ namespace Test_S7
|
||||
|
||||
private void eseguiLettura()
|
||||
{
|
||||
// parto dal test PING...
|
||||
|
||||
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// inizializzo
|
||||
CpuType tipoCpu = CpuType.S7300;
|
||||
short slot = 0;
|
||||
short rack = 0;
|
||||
@@ -93,9 +94,11 @@ namespace Test_S7
|
||||
contenuto = string.Format("{0} | {1}", plc.LastErrorCode, plc.LastErrorString);
|
||||
plc.ClearLastError();
|
||||
showOut(titolo, contenuto);
|
||||
tslConn.Text = "NO Connection";
|
||||
}
|
||||
else
|
||||
{
|
||||
tslConn.Text = "Connection OK";
|
||||
// inizio riportando dati connessione...
|
||||
titolo = "CONNESSIONE AVVENUTA";
|
||||
contenuto = string.Format("IP: {0}{1}", address, Environment.NewLine);
|
||||
@@ -110,10 +113,11 @@ namespace Test_S7
|
||||
Byte[] fullMem = plc.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
|
||||
titolo = string.Format("READ BLOCK MEM: {0} --> {1} byte", txtMemArea.Text, numByte);
|
||||
contenuto = "";
|
||||
string byteVal = "";
|
||||
for (int i = 0; i < fullMem.Length; i++)
|
||||
{
|
||||
|
||||
contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, binaryForm(fullMem[i]), fullMem[i], Environment.NewLine);
|
||||
byteVal = Convert.ToString(fullMem[i], 2).PadLeft(8, '0');
|
||||
contenuto += string.Format("B{0:000}: {1} | {3}{4}", i, byteVal, fullMem[i], Environment.NewLine);
|
||||
}
|
||||
showOut(titolo, contenuto);
|
||||
}
|
||||
@@ -121,9 +125,11 @@ namespace Test_S7
|
||||
}
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
tslRTime.Text = string.Format("{0}", sw.Elapsed);
|
||||
}
|
||||
/// <summary>
|
||||
/// formatta un numero in forma binaria 0/1
|
||||
/// formatta un numero in forma binaria 0/1 a 32 bit (4 byte)
|
||||
/// </summary>
|
||||
/// <param name="valore"></param>
|
||||
/// <returns></returns>
|
||||
@@ -143,11 +149,11 @@ namespace Test_S7
|
||||
{
|
||||
string outText = "";
|
||||
// a video
|
||||
outText += string.Format("{0}-------------------------------------------{0}", Environment.NewLine);
|
||||
outText += string.Format("{0}--------------------------------------------------------------------------------------{0}", Environment.NewLine);
|
||||
outText += string.Format("- {0} | {1:yyyy.MM.dd HH:mm:ss}{2}", title, DateTime.Now, Environment.NewLine);
|
||||
outText += string.Format("-------------------------------------------{0}", Environment.NewLine);
|
||||
outText += string.Format("--------------------------------------------------------------------------------------{0}", Environment.NewLine);
|
||||
outText += string.Format("{0}{1}", content, Environment.NewLine);
|
||||
outText += string.Format("-------------------------------------------{0}{0}", Environment.NewLine);
|
||||
outText += string.Format("--------------------------------------------------------------------------------------{0}{0}", Environment.NewLine);
|
||||
|
||||
// aggiorno visualizzazione
|
||||
txtOut.Text += outText;
|
||||
|
||||
@@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user