1
0
mirror of https://github.com/zhaopeiym/IoTClient synced 2025-10-26 22:15:44 +08:00

fix ModbusRtu、ModBusAscii、串口等 奇偶校验。

ModBusTcp读写操作使用说明。
西门子S7 300 beta
This commit is contained in:
BennyZhao
2019-11-13 08:29:39 +08:00
parent 1363ae213c
commit 665724aff4
20 changed files with 801 additions and 281 deletions

View File

@@ -29,7 +29,18 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.rd_ulong = new System.Windows.Forms.RadioButton();
this.rd_short = new System.Windows.Forms.RadioButton();
this.rd_bit = new System.Windows.Forms.RadioButton();
this.rd_discrete = new System.Windows.Forms.RadioButton();
this.button6 = new System.Windows.Forms.Button();
this.rd_float = new System.Windows.Forms.RadioButton();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.cb_baudRate = new System.Windows.Forms.ComboBox();
this.cb_parity = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.cb_portNameSend_server = new System.Windows.Forms.ComboBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.txt_stopBit = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
@@ -41,17 +52,8 @@
this.but_open = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.txt_stationNumber = new System.Windows.Forms.TextBox();
this.rd_ulong = new System.Windows.Forms.RadioButton();
this.label8 = new System.Windows.Forms.Label();
this.rd_short = new System.Windows.Forms.RadioButton();
this.rd_bit = new System.Windows.Forms.RadioButton();
this.label2 = new System.Windows.Forms.Label();
this.rd_discrete = new System.Windows.Forms.RadioButton();
this.button6 = new System.Windows.Forms.Button();
this.rd_float = new System.Windows.Forms.RadioButton();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.txt_baudRate = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.rd_double = new System.Windows.Forms.RadioButton();
this.rd_ushort = new System.Windows.Forms.RadioButton();
this.groupBox3 = new System.Windows.Forms.GroupBox();
@@ -75,112 +77,6 @@
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// cb_portNameSend_server
//
this.cb_portNameSend_server.FormattingEnabled = true;
this.cb_portNameSend_server.Location = new System.Drawing.Point(614, 21);
this.cb_portNameSend_server.Name = "cb_portNameSend_server";
this.cb_portNameSend_server.Size = new System.Drawing.Size(47, 20);
this.cb_portNameSend_server.TabIndex = 24;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(250, 23);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(41, 12);
this.label7.TabIndex = 21;
this.label7.Text = "停止位";
//
// txt_stopBit
//
this.txt_stopBit.Location = new System.Drawing.Point(292, 19);
this.txt_stopBit.Name = "txt_stopBit";
this.txt_stopBit.Size = new System.Drawing.Size(24, 21);
this.txt_stopBit.TabIndex = 22;
this.txt_stopBit.Text = "1";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(176, 24);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(41, 12);
this.label6.TabIndex = 19;
this.label6.Text = "数据位";
//
// txt_dataBit
//
this.txt_dataBit.Location = new System.Drawing.Point(217, 20);
this.txt_dataBit.Name = "txt_dataBit";
this.txt_dataBit.Size = new System.Drawing.Size(24, 21);
this.txt_dataBit.TabIndex = 20;
this.txt_dataBit.Text = "8";
//
// cb_portNameSend
//
this.cb_portNameSend.FormattingEnabled = true;
this.cb_portNameSend.Location = new System.Drawing.Point(34, 20);
this.cb_portNameSend.Name = "cb_portNameSend";
this.cb_portNameSend.Size = new System.Drawing.Size(47, 20);
this.cb_portNameSend.TabIndex = 18;
//
// but_close
//
this.but_close.Location = new System.Drawing.Point(466, 19);
this.but_close.Name = "but_close";
this.but_close.Size = new System.Drawing.Size(75, 23);
this.but_close.TabIndex = 17;
this.but_close.Text = "断开";
this.but_close.UseVisualStyleBackColor = true;
//
// but_server_close
//
this.but_server_close.Location = new System.Drawing.Point(768, 19);
this.but_server_close.Name = "but_server_close";
this.but_server_close.Size = new System.Drawing.Size(75, 23);
this.but_server_close.TabIndex = 16;
this.but_server_close.Text = "关闭服务";
this.but_server_close.UseVisualStyleBackColor = true;
this.but_server_close.Click += new System.EventHandler(this.but_server_close_Click);
//
// but_server_open
//
this.but_server_open.Location = new System.Drawing.Point(665, 19);
this.but_server_open.Name = "but_server_open";
this.but_server_open.Size = new System.Drawing.Size(99, 23);
this.but_server_open.TabIndex = 0;
this.but_server_open.Text = "本地模拟服务";
this.but_server_open.UseVisualStyleBackColor = true;
this.but_server_open.Click += new System.EventHandler(this.but_server_open_Click);
//
// but_open
//
this.but_open.Location = new System.Drawing.Point(385, 18);
this.but_open.Name = "but_open";
this.but_open.Size = new System.Drawing.Size(75, 23);
this.but_open.TabIndex = 1;
this.but_open.Text = "连接";
this.but_open.UseVisualStyleBackColor = true;
this.but_open.Click += new System.EventHandler(this.but_open_Click);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(324, 23);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(29, 12);
this.label5.TabIndex = 15;
this.label5.Text = "站号";
//
// txt_stationNumber
//
this.txt_stationNumber.Location = new System.Drawing.Point(353, 19);
this.txt_stationNumber.Name = "txt_stationNumber";
this.txt_stationNumber.Size = new System.Drawing.Size(25, 21);
this.txt_stationNumber.TabIndex = 14;
this.txt_stationNumber.Text = "1";
//
// rd_ulong
//
this.rd_ulong.AutoSize = true;
@@ -191,15 +87,6 @@
this.rd_ulong.Text = "ulong";
this.rd_ulong.UseVisualStyleBackColor = true;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(587, 25);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(29, 12);
this.label8.TabIndex = 23;
this.label8.Text = "端口";
//
// rd_short
//
this.rd_short.AutoSize = true;
@@ -222,15 +109,6 @@
this.rd_bit.Text = "线圈";
this.rd_bit.UseVisualStyleBackColor = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(86, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 4;
this.label2.Text = "波特率";
//
// rd_discrete
//
this.rd_discrete.AutoSize = true;
@@ -262,6 +140,9 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.cb_baudRate);
this.groupBox2.Controls.Add(this.cb_parity);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.cb_portNameSend_server);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.label7);
@@ -277,29 +158,182 @@
this.groupBox2.Controls.Add(this.txt_stationNumber);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.txt_baudRate);
this.groupBox2.Location = new System.Drawing.Point(13, 11);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(855, 50);
this.groupBox2.TabIndex = 37;
this.groupBox2.TabStop = false;
//
// cb_baudRate
//
this.cb_baudRate.FormattingEnabled = true;
this.cb_baudRate.Items.AddRange(new object[] {
"1200",
"4800",
"9600",
"14400"});
this.cb_baudRate.Location = new System.Drawing.Point(121, 17);
this.cb_baudRate.Name = "cb_baudRate";
this.cb_baudRate.Size = new System.Drawing.Size(47, 20);
this.cb_baudRate.TabIndex = 45;
//
// cb_parity
//
this.cb_parity.FormattingEnabled = true;
this.cb_parity.Items.AddRange(new object[] {
"无",
"奇",
"偶"});
this.cb_parity.Location = new System.Drawing.Point(325, 17);
this.cb_parity.Name = "cb_parity";
this.cb_parity.Size = new System.Drawing.Size(35, 20);
this.cb_parity.TabIndex = 44;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(297, 21);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 12);
this.label3.TabIndex = 43;
this.label3.Text = "奇偶";
//
// cb_portNameSend_server
//
this.cb_portNameSend_server.FormattingEnabled = true;
this.cb_portNameSend_server.Location = new System.Drawing.Point(615, 19);
this.cb_portNameSend_server.Name = "cb_portNameSend_server";
this.cb_portNameSend_server.Size = new System.Drawing.Size(47, 20);
this.cb_portNameSend_server.TabIndex = 42;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(588, 23);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(29, 12);
this.label8.TabIndex = 41;
this.label8.Text = "端口";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(233, 21);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(41, 12);
this.label7.TabIndex = 39;
this.label7.Text = "停止位";
//
// txt_stopBit
//
this.txt_stopBit.Location = new System.Drawing.Point(274, 17);
this.txt_stopBit.Name = "txt_stopBit";
this.txt_stopBit.Size = new System.Drawing.Size(21, 21);
this.txt_stopBit.TabIndex = 40;
this.txt_stopBit.Text = "1";
this.txt_stopBit.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(168, 22);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(41, 12);
this.label6.TabIndex = 37;
this.label6.Text = "数据位";
//
// txt_dataBit
//
this.txt_dataBit.Location = new System.Drawing.Point(209, 18);
this.txt_dataBit.Name = "txt_dataBit";
this.txt_dataBit.Size = new System.Drawing.Size(21, 21);
this.txt_dataBit.TabIndex = 38;
this.txt_dataBit.Text = "8";
this.txt_dataBit.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// cb_portNameSend
//
this.cb_portNameSend.FormattingEnabled = true;
this.cb_portNameSend.Location = new System.Drawing.Point(34, 18);
this.cb_portNameSend.Name = "cb_portNameSend";
this.cb_portNameSend.Size = new System.Drawing.Size(47, 20);
this.cb_portNameSend.TabIndex = 36;
//
// but_close
//
this.but_close.Location = new System.Drawing.Point(495, 16);
this.but_close.Name = "but_close";
this.but_close.Size = new System.Drawing.Size(75, 23);
this.but_close.TabIndex = 35;
this.but_close.Text = "断开";
this.but_close.UseVisualStyleBackColor = true;
this.but_close.Click += new System.EventHandler(this.but_close_Click);
//
// but_server_close
//
this.but_server_close.Location = new System.Drawing.Point(768, 17);
this.but_server_close.Name = "but_server_close";
this.but_server_close.Size = new System.Drawing.Size(75, 23);
this.but_server_close.TabIndex = 34;
this.but_server_close.Text = "关闭服务";
this.but_server_close.UseVisualStyleBackColor = true;
this.but_server_close.Click += new System.EventHandler(this.but_server_close_Click);
//
// but_server_open
//
this.but_server_open.Location = new System.Drawing.Point(666, 17);
this.but_server_open.Name = "but_server_open";
this.but_server_open.Size = new System.Drawing.Size(99, 23);
this.but_server_open.TabIndex = 28;
this.but_server_open.Text = "本地模拟服务";
this.but_server_open.UseVisualStyleBackColor = true;
this.but_server_open.Click += new System.EventHandler(this.but_server_open_Click);
//
// but_open
//
this.but_open.Location = new System.Drawing.Point(416, 16);
this.but_open.Name = "but_open";
this.but_open.Size = new System.Drawing.Size(75, 23);
this.but_open.TabIndex = 29;
this.but_open.Text = "连接";
this.but_open.UseVisualStyleBackColor = true;
this.but_open.Click += new System.EventHandler(this.but_open_Click);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(363, 21);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(29, 12);
this.label5.TabIndex = 33;
this.label5.Text = "站号";
//
// txt_stationNumber
//
this.txt_stationNumber.Location = new System.Drawing.Point(392, 17);
this.txt_stationNumber.Name = "txt_stationNumber";
this.txt_stationNumber.Size = new System.Drawing.Size(21, 21);
this.txt_stationNumber.TabIndex = 32;
this.txt_stationNumber.Text = "1";
this.txt_stationNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(7, 24);
this.label1.Location = new System.Drawing.Point(7, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 3;
this.label1.TabIndex = 30;
this.label1.Text = "端口";
//
// txt_baudRate
// label2
//
this.txt_baudRate.Location = new System.Drawing.Point(127, 19);
this.txt_baudRate.Name = "txt_baudRate";
this.txt_baudRate.Size = new System.Drawing.Size(42, 21);
this.txt_baudRate.TabIndex = 5;
this.txt_baudRate.Text = "9600";
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(82, 22);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 31;
this.label2.Text = "波特率";
//
// rd_double
//
@@ -340,7 +374,7 @@
//
// but_sendData
//
this.but_sendData.Location = new System.Drawing.Point(616, 20);
this.but_sendData.Location = new System.Drawing.Point(616, 18);
this.but_sendData.Name = "but_sendData";
this.but_sendData.Size = new System.Drawing.Size(75, 23);
this.but_sendData.TabIndex = 16;
@@ -350,7 +384,7 @@
//
// txt_dataPackage
//
this.txt_dataPackage.Location = new System.Drawing.Point(424, 21);
this.txt_dataPackage.Location = new System.Drawing.Point(424, 19);
this.txt_dataPackage.Name = "txt_dataPackage";
this.txt_dataPackage.Size = new System.Drawing.Size(186, 21);
this.txt_dataPackage.TabIndex = 17;
@@ -367,7 +401,7 @@
//
// but_read
//
this.but_read.Location = new System.Drawing.Point(133, 18);
this.but_read.Location = new System.Drawing.Point(133, 16);
this.but_read.Name = "but_read";
this.but_read.Size = new System.Drawing.Size(75, 23);
this.but_read.TabIndex = 7;
@@ -390,10 +424,11 @@
this.txt_address.Name = "txt_address";
this.txt_address.Size = new System.Drawing.Size(88, 21);
this.txt_address.TabIndex = 9;
this.txt_address.Text = "1";
//
// but_write
//
this.but_write.Location = new System.Drawing.Point(337, 20);
this.but_write.Location = new System.Drawing.Point(337, 18);
this.but_write.Name = "but_write";
this.but_write.Size = new System.Drawing.Size(75, 23);
this.but_write.TabIndex = 10;
@@ -403,15 +438,16 @@
//
// txt_value
//
this.txt_value.Location = new System.Drawing.Point(256, 20);
this.txt_value.Location = new System.Drawing.Point(256, 18);
this.txt_value.Name = "txt_value";
this.txt_value.Size = new System.Drawing.Size(74, 21);
this.txt_value.TabIndex = 12;
this.txt_value.Text = "3344";
//
// lab_value
//
this.lab_value.AutoSize = true;
this.lab_value.Location = new System.Drawing.Point(228, 24);
this.lab_value.Location = new System.Drawing.Point(228, 22);
this.lab_value.Name = "lab_value";
this.lab_value.Size = new System.Drawing.Size(17, 12);
this.lab_value.TabIndex = 11;
@@ -498,30 +534,13 @@
}
#endregion
private System.Windows.Forms.ComboBox cb_portNameSend_server;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txt_stopBit;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_dataBit;
private System.Windows.Forms.ComboBox cb_portNameSend;
private System.Windows.Forms.Button but_close;
private System.Windows.Forms.Button but_server_close;
private System.Windows.Forms.Button but_server_open;
private System.Windows.Forms.Button but_open;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_stationNumber;
private System.Windows.Forms.RadioButton rd_ulong;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.RadioButton rd_short;
private System.Windows.Forms.RadioButton rd_bit;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.RadioButton rd_discrete;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.RadioButton rd_float;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txt_baudRate;
private System.Windows.Forms.RadioButton rd_double;
private System.Windows.Forms.RadioButton rd_ushort;
private System.Windows.Forms.GroupBox groupBox3;
@@ -540,5 +559,23 @@
private System.Windows.Forms.RadioButton rd_int;
private System.Windows.Forms.RadioButton rd_uint;
private System.Windows.Forms.TextBox txt_content;
private System.Windows.Forms.ComboBox cb_baudRate;
private System.Windows.Forms.ComboBox cb_parity;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox cb_portNameSend_server;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txt_stopBit;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txt_dataBit;
private System.Windows.Forms.ComboBox cb_portNameSend;
private System.Windows.Forms.Button but_close;
private System.Windows.Forms.Button but_server_close;
private System.Windows.Forms.Button but_server_open;
private System.Windows.Forms.Button but_open;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txt_stationNumber;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
}
}