1. 功能码列表:
0x01 读线圈状态(Read Coils)
0x02 读离散输入状态(Read Discrete Inputs )
0x03 读保持寄存器(Read Holding Registers )
0x04 读输入寄存器(Read Input Registers)
0x05 写单线圈(Write Single Coil )
0x06 写单寄存器(Write Single Register)
0x07 读取异常状态(限串行线)(Read Exception Status (Serial Line only) )
0x08 通信系统诊断(限串行线)(Diagnostics (Serial Line only) )
0x09-0x0A无
0x0B 获取串行通信事件计数器(Get Comm Event Counter (Serial Line only) )
0x0C 获取串行通信事件日志 ( Get Comm Event Log (Serial Line only) )
0x0D-0x0E无
0x0F 写多个线圈(Write Multiple Coils)
0x10 写多个寄存器(Write Multiple registers)
0x11 报告服务器ID(仅串行线)(Report Server ID (Serial Line only) )
0x12-0x13无
0x14 读文件记录(Read File Record )
0x15 写文件记录(Write File Record)
0x16 带屏蔽字写入寄存器(Mask Write Register )
0x17 读/写多个寄存器(Read/Write Multiple registers)
0x18 读取先进先出(FIFO)队列(Read FIFO Queue)
0x19-0x2A无
0x2B 封装接口传输(Encapsulated Interface Transport .)
2. 分主站,从站,主站是客户端,从站是服务端。启动时先启动从站(服务端),然后主站再连上从站,获取信息。
3. Device and Modbus 地址表(最大地址看设备)
Device address | Modbus address | Description | Function | R/W | Comments |
1...10000 | address-1 | Coils(outputs) | 01 | Read/Write | 05 and 15 |
10001...20000 | address-10001 | Discrete Inputs | 02 | Read | |
40001...50000 | address-40001 | Holding Registers | 03 | Read/Write | 06,16,22 and 23 |
30001...40000 | address-30001 | Input Registers | 04 | Read |
4. 用C#做了一个小工具,用作Modbus TCP 学习的总结,链接见:https://download.csdn.net/download/garyaofq/88396590
界面左侧启动从站(自动门),右侧启动主站(RDS控制系统),启动3秒后锁定地址和端口。在右侧界面可以读,写线圈和寄存器。同时实时显示地址0-9的值。 帮助和左侧窗口显示功能码说明。
C#代码,引用EasyModbus,下面是详细的代码:
.\Modbus_Slave\MainForm.cs
/*
* Created by SharpDevelop.
* User: yaof
* Date: 2023/10/3
* Time: 19:19
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EasyModbus;
namespace Modbus_Slave
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
EasyModbus.ModbusServer modbusServer=null;
System.Data.DataTable dt=new System.Data.DataTable ();
System.Threading.Thread th;
System.Threading.Thread thc;
System.Threading.Thread thcc;
EasyModbus.ModbusClient Master = null;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
thcc=new System.Threading.Thread (new System.Threading.ThreadStart(counterclock));
//创建一个服务,作为从站设备,等待主站查询或设置
//从站可以不设置IP
modbusServer = new ModbusServer();
th=new System.Threading.Thread (new System.Threading.ThreadStart(monitor));
System.Data.DataColumn dc=new System.Data.DataColumn ("address");
dt.Columns.Add(dc);
dc=new System.Data.DataColumn ("value");
dt.Columns.Add(dc);
for(var m=0;m<10;m++)
{
System.Data.DataRow dr=dt.NewRow();
dr[0]=m.ToString();
dr[1]="0";
dt.Rows.Add(dr);
}
dataGridView1 .DataSource=dt;
dataGridView1.Columns[0].Width=50;
dataGridView1 .Columns[1].Width=50;
dataGridView1 .ScrollBars=ScrollBars.None;
//
// TODO: Add constructor code after the InitializeComponent() call.
//
this.Master = new ModbusClient();
this.slaveIP.Text = "127.0.0.1";
this.slavePort.Text = "502";
this.SlaveAddress.Text="1";
var slaveid=int.Parse(this.SlaveAddress.Text);
byte[] bytes = BitConverter.GetBytes(slaveid);//将int32转换为字节数组
Master.UnitIdentifier =bytes[0];
thc=new System.Threading.Thread (new System.Threading.ThreadStart(connectequipment));
string bodystr="<html><head><H5>Device and Modbus address ranges</H5></head><body>";
bodystr+="<table style='font-size:10px;'><tr><td>Device address</td><td>Modbus address</td><td>Description</td><td>Function</td><td>R/W</td><td>Comments</td></tr>";
bodystr+="<tr><td>1...10000</td><td>address-1</td><td>Coils(outputs)</td><td>01</td><td>Read/Write</td><td>05 and 15</td></tr>";
bodystr+="<tr><td>10001...20000</td><td>address-10001</td><td>Discrete Inputs</td><td>02</td><td>Read</td><td></td></tr>";
bodystr+="<tr><td>40001...50000</td><td>address-40001</td><td>Holding Registers</td><td>03</td><td>Read/Write</td><td>06,16,22 and 23</td></tr>";
bodystr+="<tr><td>30001...40000</td><td>address-30001</td><td>Input Registers</td><td>04</td><td>Read</td><td></td></tr>";
bodystr+="</table></body></html>";
webBrowser1.DocumentText=bodystr;
button3.BackColor =Color.Red;
button5.BackColor =Color.Red;
button6.BackColor =Color.Red;
button3.Enabled =true;
button5.Enabled =true;
button6.Enabled =true;
}
private bool UpdateCoil(int modbusaddress,int mvalue)
{
var slaveid=int.Parse(this.SlaveAddress.Text);
byte[] bytes = BitConverter.GetBytes(slaveid);//将int32转换为字节数组
modbusServer.UnitIdentifier=bytes[0];
try
{
Master.WriteSingleCoil(modbusaddress, mvalue==1?true:false);
}
catch
{
return false;
}
return true;
}
private void UpdateRegister(int modbusaddress,int mvalue)
{
var slaveid=int.Parse(this.SlaveAddress.Text);
byte[] bytes = BitConverter.GetBytes(slaveid);//将int32转换为字节数组
modbusServer.UnitIdentifier=bytes[0];
Master.WriteSingleRegister(modbusaddress,mvalue);
}
public void counterclock()
{
for(var m=3;m>=0;m--)
{
if(counter.InvokeRequired)
{
counter.Invoke(new Action(()=>{
counter.Text=m.ToString();
}));
}else
{
counter.Text=m.ToString();
}
System.Threading .SpinWait.SpinUntil(() => false, 1000);
//System.Threading .Thread.Sleep(1000);
}
}
public void connectequipment()
{
//延时9秒启动服务,在此期间可以设置端口
System.Threading .Thread.Sleep(3000);
var SlaveIP="";
var SlavePort="";
if(slaveIP.InvokeRequired)
{
slaveIP.Invoke(new Action(()=>{
SlaveIP =slaveIP.Text;
slaveIP.Enabled=false;
}));
}else
{
SlaveIP =slaveIP.Text;
slaveIP.Enabled=false;
}
if(slavePort.InvokeRequired)
{
slavePort.Invoke(new Action(()=>{
SlavePort =slavePort.Text;
slavePort.Enabled=false;
}));
}else
{
SlavePort =slavePort.Text;
slavePort.Enabled=false;
}
Master.Connect(this.slaveIP.Text, int.Parse(this.slavePort.Text));
}
public void monitor()
{
//延时9秒启动服务,在此期间可以设置端口
System.Threading .Thread.Sleep(3000);
if(serverPort.InvokeRequired)
{
serverPort.Invoke(new Action(()=>{
serverPort.Enabled =false;
modbusServer.Port=int.Parse(this.serverPort.Text);
}));
}else
{
serverPort.Enabled =false;
modbusServer.Port=int.Parse(this.serverPort.Text);
}
modbusServer.Listen();
while(true)
{
//主站监控
if(Master.Connected)
{
bool[] coilvalue=Master.ReadCoils(0,10);
for(var m=0;m<10;m++)
{
System.Data.DataRow dr=dt.Rows[m];
dr[0]=m;
dr[1]=coilvalue[(m)% 10000]==true?1:0;
}
}
System.Threading .Thread.Sleep(500);
}
}
void Button2Click(object sender, EventArgs e)
{
if(comboBox1.SelectedItem.ToString()=="05")
{
UpdateCoil(int.Parse(address.Text),int.Parse(value.Text));
}else if(comboBox1.SelectedItem.ToString()=="06")
{
UpdateRegister(40000+int.Parse(address.Text),int.Parse(value.Text));
}
}
void MainFormFormClosing(object sender, FormClosingEventArgs e)
{
th.Abort();
Master.Disconnect();
}
void HelpToolStripMenuItemClick(object sender, EventArgs e)
{
string funstr="Function 01 (01hex) Read Coils\r\n";
funstr+="Function 02(02hex) Read Discrete Inputs\r\n";
funstr+="Function 03 (03hex) Read Holding Registers\r\n";
funstr+="Function 04 (04hex) Read Input Registers\r\n";
funstr+="Function 05 (05hex) Write Single Coil\r\n";
funstr+="Function 06 (06hex) Write Single Register\r\n";
funstr+="Function 15 (0Fhex) Write Multiple Coils\r\n";
funstr+="Function 16 (10hex) Write Multiple Registers\r\n";
MessageBox.Show(funstr);
}
void Button1Click(object sender, EventArgs e)
{
var slaveid=int.Parse(this.SlaveAddress.Text);
byte[] bytes = BitConverter.GetBytes(slaveid);//将int32转换为字节数组
modbusServer.UnitIdentifier=bytes[0];
try
{
if(comboBox2.SelectedItem.ToString()=="01")
{
bool[] coilstatus=Master.ReadCoils(int.Parse(saddress.Text),1);
svalue.Text=coilstatus[0]==true?"1":"0";
}else if(comboBox2.SelectedItem.ToString()=="02")
{
bool[] coilstatus=Master.ReadDiscreteInputs(10000+int.Parse(saddress.Text),1);
svalue.Text=coilstatus[0]==true?"1":"0";
}else if(comboBox2.SelectedItem.ToString()=="03")
{
int[] coilstatus=Master.ReadHoldingRegisters(40000+int.Parse(saddress.Text),1);
svalue.Text=coilstatus[0].ToString();
}else if(comboBox2.SelectedItem.ToString()=="04")
{
int[] coilstatus=Master.ReadInputRegisters(30000+int.Parse(saddress.Text),1);
svalue.Text=coilstatus[0].ToString();
}
}
catch
{
}
}
void Button3Click(object sender, EventArgs e)
{
thcc.Start();
th.Start();
thc.Start();
button3.BackColor =Color.Green;
button5.BackColor =Color.Gray;
button6.BackColor =Color.Gray;
button5.Enabled =false;
button6.Enabled =false;
}
void Button4Click(object sender, EventArgs e)
{
if(comboBox1.SelectedItem.ToString()=="05")
{
UpdateCoil(int.Parse(address.Text),1);
}else if(comboBox1.SelectedItem.ToString()=="06")
{
UpdateRegister(40000+int.Parse(address.Text),1);
}
}
void Button5Click(object sender, EventArgs e)
{
//仅启动从站
thcc.Start();
th.Start();
button5.BackColor =Color.Green;
button3.Enabled =false;
button3.BackColor =Color.Gray;
}
void Button6Click(object sender, EventArgs e)
{
//仅启动主站
thc.Start();
button6.BackColor =Color.Green;
}
/**************************************************************************************
* 0x01 读线圈状态(Read Coils)
0x02 读离散输入状态(Read Discrete Inputs )
0x03 读保持寄存器(Read Holding Registers )
0x04 读输入寄存器(Read Input Registers)
0x05 写单线圈(Write Single Coil )
0x06 写单寄存器(Write Single Register)
0x07 读取异常状态(限串行线)(Read Exception Status (Serial Line only) )
0x08 通信系统诊断(限串行线)(Diagnostics (Serial Line only) )
0x09-0x0A无
0x0B 获取串行通信事件计数器(Get Comm Event Counter (Serial Line only) )
0x0C 获取串行通信事件日志 ( Get Comm Event Log (Serial Line only) )
0x0D-0x0E无
0x0F 写多个线圈(Write Multiple Coils)
0x10 写多个寄存器(Write Multiple registers)
0x11 报告服务器ID(仅串行线)(Report Server ID (Serial Line only) )
0x12-0x13无
0x14 读文件记录(Read File Record )
0x15 写文件记录(Write File Record)
0x16 带屏蔽字写入寄存器(Mask Write Register )
0x17 读/写多个寄存器(Read/Write Multiple registers)
0x18 读取先进先出(FIFO)队列(Read FIFO Queue)
0x19-0x2A无
0x2B 封装接口传输(Encapsulated Interface Transport .)
********************************************************************************/
}
}
.\Modbus_Slave\MainForm.Designer.cs
/*
* Created by SharpDevelop.
* User: yaof
* Date: 2023/9/5
* Time: 7:35
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
namespace Modbus_Slave
{
partial class MainForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.TextBox serverPort;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox address;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TextBox value;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox slaveIP;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox slavePort;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox SlaveAddress;
private System.Windows.Forms.Label counter;
public System.Windows.Forms.WebBrowser webBrowser1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.TextBox saddress;
private System.Windows.Forms.TextBox svalue;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Label label12;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button5 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.counter = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.serverPort = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button6 = new System.Windows.Forms.Button();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.button4 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button2 = new System.Windows.Forms.Button();
this.value = new System.Windows.Forms.TextBox();
this.address = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.svalue = new System.Windows.Forms.TextBox();
this.saddress = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.SlaveAddress = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.slaveIP = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.slavePort = new System.Windows.Forms.TextBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.label12 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label12);
this.groupBox1.Controls.Add(this.button5);
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.webBrowser1);
this.groupBox1.Controls.Add(this.counter);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.serverPort);
this.groupBox1.Location = new System.Drawing.Point(12, 33);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(343, 288);
this.groupBox1.TabIndex = 10;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "从站_Server/Equipment";
//
// button5
//
this.button5.Location = new System.Drawing.Point(241, 56);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(65, 23);
this.button5.TabIndex = 22;
this.button5.Text = "启动从站";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.Button5Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(155, 56);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(65, 23);
this.button3.TabIndex = 21;
this.button3.Text = "启动服务";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.Button3Click);
//
// webBrowser1
//
this.webBrowser1.Location = new System.Drawing.Point(6, 85);
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(331, 197);
this.webBrowser1.TabIndex = 20;
//
// counter
//
this.counter.Location = new System.Drawing.Point(132, 56);
this.counter.Name = "counter";
this.counter.Size = new System.Drawing.Size(52, 23);
this.counter.TabIndex = 19;
this.counter.Text = "3";
this.counter.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.counter.UseMnemonic = false;
//
// label4
//
this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.label4.Location = new System.Drawing.Point(6, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(331, 23);
this.label4.TabIndex = 17;
this.label4.Text = "模拟现场设备,接收命令,返回数据";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label2
//
this.label2.Location = new System.Drawing.Point(9, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 23);
this.label2.TabIndex = 13;
this.label2.Text = "PORT";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label2.UseMnemonic = false;
//
// serverPort
//
this.serverPort.Location = new System.Drawing.Point(67, 58);
this.serverPort.Name = "serverPort";
this.serverPort.Size = new System.Drawing.Size(59, 21);
this.serverPort.TabIndex = 11;
this.serverPort.Text = "502";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button6);
this.groupBox2.Controls.Add(this.tabControl1);
this.groupBox2.Controls.Add(this.label11);
this.groupBox2.Controls.Add(this.SlaveAddress);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.slaveIP);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.slavePort);
this.groupBox2.Location = new System.Drawing.Point(361, 33);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(181, 288);
this.groupBox2.TabIndex = 11;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "主站_Client/RDS";
//
// button6
//
this.button6.Location = new System.Drawing.Point(8, 101);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(65, 23);
this.button6.TabIndex = 23;
this.button6.Text = "启动主站";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.Button6Click);
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(6, 139);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(157, 143);
this.tabControl1.TabIndex = 29;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.button4);
this.tabPage1.Controls.Add(this.comboBox1);
this.tabPage1.Controls.Add(this.button2);
this.tabPage1.Controls.Add(this.value);
this.tabPage1.Controls.Add(this.address);
this.tabPage1.Controls.Add(this.label6);
this.tabPage1.Controls.Add(this.label7);
this.tabPage1.Controls.Add(this.label8);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(149, 117);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "控制";
this.tabPage1.UseVisualStyleBackColor = true;
//
// button4
//
this.button4.Location = new System.Drawing.Point(75, 86);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(53, 23);
this.button4.TabIndex = 34;
this.button4.Text = "写\"1\"";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.Button4Click);
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"05",
"06"});
this.comboBox1.Location = new System.Drawing.Point(69, 5);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(59, 20);
this.comboBox1.TabIndex = 33;
this.comboBox1.Text = "05";
//
// button2
//
this.button2.Location = new System.Drawing.Point(10, 86);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(53, 23);
this.button2.TabIndex = 29;
this.button2.Text = "写值";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.Button2Click);
//
// value
//
this.value.Location = new System.Drawing.Point(69, 59);
this.value.Name = "value";
this.value.Size = new System.Drawing.Size(59, 21);
this.value.TabIndex = 27;
this.value.Text = "0";
//
// address
//
this.address.Location = new System.Drawing.Point(69, 32);
this.address.Name = "address";
this.address.Size = new System.Drawing.Size(59, 21);
this.address.TabIndex = 26;
this.address.Text = "0";
//
// label6
//
this.label6.Location = new System.Drawing.Point(6, 3);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(57, 23);
this.label6.TabIndex = 25;
this.label6.Text = "功能码";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label7
//
this.label7.Location = new System.Drawing.Point(6, 57);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(57, 23);
this.label7.TabIndex = 24;
this.label7.Text = "值";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label8
//
this.label8.Location = new System.Drawing.Point(6, 30);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(57, 23);
this.label8.TabIndex = 23;
this.label8.Text = "地址";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.comboBox2);
this.tabPage2.Controls.Add(this.button1);
this.tabPage2.Controls.Add(this.svalue);
this.tabPage2.Controls.Add(this.saddress);
this.tabPage2.Controls.Add(this.label5);
this.tabPage2.Controls.Add(this.label1);
this.tabPage2.Controls.Add(this.label3);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(149, 117);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "状态";
this.tabPage2.UseVisualStyleBackColor = true;
//
// comboBox2
//
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Items.AddRange(new object[] {
"01",
"03",
"02",
"04"});
this.comboBox2.Location = new System.Drawing.Point(69, 5);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(59, 20);
this.comboBox2.TabIndex = 32;
this.comboBox2.Text = "01";
//
// button1
//
this.button1.Location = new System.Drawing.Point(33, 86);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 31;
this.button1.Text = "读值";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// svalue
//
this.svalue.Location = new System.Drawing.Point(69, 59);
this.svalue.Name = "svalue";
this.svalue.Size = new System.Drawing.Size(59, 21);
this.svalue.TabIndex = 29;
this.svalue.Text = "0";
//
// saddress
//
this.saddress.Location = new System.Drawing.Point(69, 32);
this.saddress.Name = "saddress";
this.saddress.Size = new System.Drawing.Size(59, 21);
this.saddress.TabIndex = 28;
this.saddress.Text = "0";
//
// label5
//
this.label5.Location = new System.Drawing.Point(6, 3);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(57, 23);
this.label5.TabIndex = 25;
this.label5.Text = "功能码";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label1
//
this.label1.Location = new System.Drawing.Point(6, 57);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(57, 23);
this.label1.TabIndex = 24;
this.label1.Text = "值";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label3
//
this.label3.Location = new System.Drawing.Point(6, 30);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(57, 23);
this.label3.TabIndex = 23;
this.label3.Text = "地址";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label11
//
this.label11.Location = new System.Drawing.Point(6, 72);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(52, 23);
this.label11.TabIndex = 19;
this.label11.Text = "ADDRESS";
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label11.UseMnemonic = false;
//
// SlaveAddress
//
this.SlaveAddress.Location = new System.Drawing.Point(64, 74);
this.SlaveAddress.Name = "SlaveAddress";
this.SlaveAddress.Size = new System.Drawing.Size(59, 21);
this.SlaveAddress.TabIndex = 18;
this.SlaveAddress.Text = "1";
//
// label10
//
this.label10.Location = new System.Drawing.Point(6, 17);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(52, 23);
this.label10.TabIndex = 17;
this.label10.Text = "IP";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label10.UseMnemonic = false;
//
// slaveIP
//
this.slaveIP.Location = new System.Drawing.Point(64, 19);
this.slaveIP.Name = "slaveIP";
this.slaveIP.Size = new System.Drawing.Size(110, 21);
this.slaveIP.TabIndex = 16;
this.slaveIP.Text = "127.0.0.1";
//
// label9
//
this.label9.Location = new System.Drawing.Point(6, 45);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(52, 23);
this.label9.TabIndex = 15;
this.label9.Text = "PORT";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label9.UseMnemonic = false;
//
// slavePort
//
this.slavePort.Location = new System.Drawing.Point(64, 47);
this.slavePort.Name = "slavePort";
this.slavePort.Size = new System.Drawing.Size(59, 21);
this.slavePort.TabIndex = 14;
this.slavePort.Text = "502";
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(727, 25);
this.menuStrip1.TabIndex = 12;
this.menuStrip1.Text = "menuStrip1";
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(47, 21);
this.helpToolStripMenuItem.Text = "Help";
this.helpToolStripMenuItem.Click += new System.EventHandler(this.HelpToolStripMenuItemClick);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.dataGridView1);
this.groupBox3.Location = new System.Drawing.Point(548, 33);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(167, 280);
this.groupBox3.TabIndex = 32;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "实时显示地址1-10内容";
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(6, 19);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(155, 255);
this.dataGridView1.TabIndex = 32;
//
// label12
//
this.label12.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.label12.Location = new System.Drawing.Point(6, 40);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(331, 17);
this.label12.TabIndex = 23;
this.label12.Text = "一般从站先启动,主站再连指定从站";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(727, 328);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Modbus_Slave_Server";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
}
}