• 大小: 0.64M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-06-16
  • 语言: C#
  • 标签: Modbus  示例  通讯  C#  

资源简介

本软件适用于西门子S7200PLC,且安装以太网通讯模块,S7200 Modbus Tcp Demo

资源截图

代码片段和文件信息

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 System.IO;
using System.IO.Ports;
using System.Diagnostics;
using System.Net;

using System.Net.Sockets;
using System.Threading;

using System.Runtime.InteropServices;

namespace S7200Modbus_TCP
{
    public partial class Form1 : Form
    {
        public Modbus_TCP M_TCP = new Modbus_TCP();   //

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_FormClosing(object sender FormClosingEventArgs e)
        {
            try
            {
                M_TCP.DisConnect();   //断开 Modbus Tcp
            }
            catch
            { }

            try
            {
                System.Environment.Exit(0);
            }
            catch
            { }
        }
        private void button1_Click(object sender EventArgs e)
        {
            if (M_TCP.Connected == false)
            {
                M_TCP.Connect(textBox1.Text.ToString().Trim() textBox2.Text.ToString().Trim());   //连接 Modbus Tcp
                if (M_TCP.Connected == true)
                {
                    toolStripLabel2.Text = “已连接 IP: “ + textBox1.Text.ToString().Trim();
                    toolStripLabel4.Text = “Port: “ + textBox2.Text.ToString().Trim();
                    button1.Enabled = false;
                    button2.Enabled = true;
                    panel2.Enabled = true;
                    textBox1.ReadOnly = true;
                    textBox2.ReadOnly = true;
                }
                else
                {
                    textBox1.ReadOnly = false;
                    textBox2.ReadOnly = false;
                    toolStripLabel2.Text = “无法连接“;
                    toolStripLabel4.Text = ““;
                }
            }
        }

        private void button2_Click(object sender EventArgs e)
        {
            try
            {
                M_TCP.DisConnect();   //断开 Modbus Tcp
                button1.Enabled = true;
                button2.Enabled = false;
                panel2.Enabled = false;
                textBox1.ReadOnly = false;
                textBox2.ReadOnly = false;

                toolStripLabel2.Text = ““;
                toolStripLabel4.Text = ““;
                button9_Click(button9 null);
                button9_Click(button11 null);
                button9_Click(button12 null);
                button9_Click(button13 null);

                button15.Text = “开始“;
                textBox27.ReadOnly = true;
                isThreadRun = false;

            }
            catch
            { }

        }

        private void button9_Click(object sender EventArgs e)
        {
            Button btn = sender as Button;
            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        189  2020-05-19 14:24  S7200Modbus_TCP\App.config

     文件      37888  2020-05-21 15:40  S7200Modbus_TCP\bin\Debug\S7200Modbus_TCP.exe

     文件        189  2020-05-19 14:24  S7200Modbus_TCP\bin\Debug\S7200Modbus_TCP.exe.config

     文件      65024  2020-05-21 15:40  S7200Modbus_TCP\bin\Debug\S7200Modbus_TCP.pdb

     文件      17135  2020-05-21 15:40  S7200Modbus_TCP\Form1.cs

     文件      56652  2020-05-21 15:39  S7200Modbus_TCP\Form1.Designer.cs

     文件       6383  2020-05-21 15:40  S7200Modbus_TCP\Form1.resx

     文件      14423  2020-05-21 14:16  S7200Modbus_TCP\Modbus_TCP.cs

     文件       1435  2020-05-19 18:59  S7200Modbus_TCP\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7300  2020-05-19 14:36  S7200Modbus_TCP\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1061  2020-05-20 15:23  S7200Modbus_TCP\obj\Debug\S7200Modbus_TCP.csproj.FileListAbsolute.txt

     文件       1012  2020-05-21 15:40  S7200Modbus_TCP\obj\Debug\S7200Modbus_TCP.csproj.GenerateResource.cache

     文件        424  2020-05-21 15:38  S7200Modbus_TCP\obj\Debug\S7200Modbus_TCP.csprojAssemblyReference.cache

     文件      37888  2020-05-21 15:40  S7200Modbus_TCP\obj\Debug\S7200Modbus_TCP.exe

     文件        180  2020-05-21 15:40  S7200Modbus_TCP\obj\Debug\S7200Modbus_TCP.Form1.resources

     文件      65024  2020-05-21 15:40  S7200Modbus_TCP\obj\Debug\S7200Modbus_TCP.pdb

     文件        180  2020-05-19 14:49  S7200Modbus_TCP\obj\Debug\S7200Modbus_TCP.Properties.Resources.resources

     文件        527  2020-05-19 14:24  S7200Modbus_TCP\Program.cs

     文件       1322  2020-05-19 14:24  S7200Modbus_TCP\Properties\AssemblyInfo.cs

     文件       2843  2020-05-19 14:24  S7200Modbus_TCP\Properties\Resources.Designer.cs

     文件       5612  2020-05-19 14:24  S7200Modbus_TCP\Properties\Resources.resx

     文件       1102  2020-05-19 14:24  S7200Modbus_TCP\Properties\Settings.Designer.cs

     文件        249  2020-05-19 14:24  S7200Modbus_TCP\Properties\Settings.settings

     文件       3659  2020-05-19 14:49  S7200Modbus_TCP\S7200Modbus_TCP.csproj

     文件       4365  2020-05-21 15:48  S7200PLC程序\modbus_tcp.mwp

     文件       3437  2017-06-06 20:56  S7200PLC程序\【以太网】S7-200软件Modbus TCP安装库4.0.mwl

     文件        106  2020-05-21 16:05  S7200PLC程序\说明.txt

     文件       1150  2020-05-19 14:24  S7200Modbus_TCP.sln

     文件     604785  2020-05-21 11:07  西门子S7-200寄存器类型.docx

     目录          0  2020-05-19 14:24  S7200Modbus_TCP\obj\Debug\TempPE

............此处省略10个文件信息

评论

共有 条评论