• 大小: 30.83MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-11
  • 语言: C#
  • 标签: C#  ModBus  Tcp  

资源简介

C# ModBus Tcp读写数据 与服务器进行通讯,内包含客户端和服务端源码。

资源截图

代码片段和文件信息

import HslCommunication.Core.Net.NetHandle;
import HslCommunication.Core.Transfer.DataFormat;
import HslCommunication.Core.Types.ActionOperateExThree;
import HslCommunication.Core.Types.ActionOperateExTwo;
import HslCommunication.Core.Types.OperateResult;
import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.Enthernet.ComplexNet.NetComplexClient;
import HslCommunication.Enthernet.PushNet.NetPushClient;
import HslCommunication.Enthernet.SimplifyNet.NetSimplifyClient;
import HslCommunication.ModBus.ModbusTcpNet;
import HslCommunication.Profinet.Melsec.MelsecMcAsciiNet;
import HslCommunication.Profinet.Melsec.MelsecMcNet;
import HslCommunication.Profinet.Siemens.SiemensPLCS;
import HslCommunication.Profinet.Siemens.SiemensS7Net;

import java.util.Arrays;

public class Main {

    public static void main(String[] args) {

        //NetSimplifyClientTest();


        //MelsecTest();
        //PushNetTest();

        //ModbusTcpTets();
        //SiemesTest();



        try {
            //Constructor[] aa = Integer.class.getDeclaredConstructors();
            //int i = (Integer) (aa[1].newInstance(“1“));
            //System.out.println(Utilities.bytes2HexString( Utilities.getBytes(String.format(“%04x“100)“ASCII“)));
            //System.out.println(i);

            //System.out.println(Arrays.toString(“123“.split(“\\.“ )));
            ModbusTcpTets();

        }
        catch (Exception ex){
            System.out.println(ex.getMessage());
        }

        try {
            Thread.sleep(1000);
        } catch (Exception ex) {

        }
    }


    public static void NetSimplifyClientTest() {
        NetSimplifyClient client = new NetSimplifyClient(“127.0.0.1“ 12345);

        OperateResultExOne read = client.ReadFromServer(new NetHandle(2) “测试数据“);
        if (read.IsSuccess) {
            System.out.println(read.Content);
        } else {
            System.out.println(“读取失败:“ + read.Message);
        }
    }


    private static void MelsecTest() {
        MelsecMcNet melsec_net = new MelsecMcNet(“192.168.1.192“ 6001);


        boolean[] M100 = melsec_net.ReadBool(“M100“ (short) 1).Content;            // 读取M100是否通,十进制地址
        boolean[] X1A0 = melsec_net.ReadBool(“X1A0“ (short) 1).Content;            // 读取X1A0是否通,十六进制地址
        boolean[] Y1A0 = melsec_net.ReadBool(“Y1A0“ (short) 1).Content;            // 读取Y1A0是否通,十六进制地址
        boolean[] B1A0 = melsec_net.ReadBool(“B1A0“ (short) 1).Content;            // 读取B1A0是否通,十六进制地址
        short short_D1000 = melsec_net.ReadInt16(“D1000“).Content;                 // 读取D1000的short值  W3C0R3C0 效果是一样的
        int int_D1000 = melsec_net.ReadInt32(“D1000“).Content;                     // 读取D1000-D1001组成的int数据
        float float_D1000 = melsec_net.ReadFloat(“D1000“).Content;                 // 读取D1000-D1001组成的float数据
        long long_D1000 = melsec_net.ReadInt64(“D1000“).Content;                   // 读取D1000-D1003组成的long数据
        double double_D1000 = melsec_net.

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

    .......      2518  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\.gitattributes

    .......      4305  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\.gitignore

     文件     692052  2018-09-14 16:35  HslCommunication-master\HslCommunication-master\.vs\HslCommunication\DesignTimeBuild\.dtbcache

    ..A..H.    278016  2018-09-14 16:35  HslCommunication-master\HslCommunication-master\.vs\HslCommunication\v15\.suo

     文件          0  2018-09-14 10:02  HslCommunication-master\HslCommunication-master\.vs\HslCommunication\v15\Server\sqlite3\db.lock

     文件    3256320  2018-09-14 10:02  HslCommunication-master\HslCommunication-master\.vs\HslCommunication\v15\Server\sqlite3\storage.ide

     文件      32768  2018-09-14 10:02  HslCommunication-master\HslCommunication-master\.vs\HslCommunication\v15\Server\sqlite3\storage.ide-shm

     文件    4404312  2018-09-14 15:46  HslCommunication-master\HslCommunication-master\.vs\HslCommunication\v15\Server\sqlite3\storage.ide-wal

    .......      3746  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\chmHelper.shfbproj

    .......      7067  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\docs\English.md

    .......      6609  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\docs\Melsec.md

    .......      5277  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\docs\ModbusServer.md

    .......      5863  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\docs\ModbusTcp.md

    .......      5790  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\docs\Omron.md

    .......      7026  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\docs\Siemens.md

    .......    132443  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\Download\HslCommunication.jar

    .......    929622  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\Download\HslCommunication.zip

    .......   1091097  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\Download\HslCommunicationDemo.zip

    .......   2851231  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\Download\HSLSharp.zip

    .......    807950  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\Download\ModbusTcpServer.zip

    .......    760592  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\Download\PushNetServer.zip

    .......   4178184  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\Help\HslCommunication.chm

    .......      9354  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication.sln

    .......       425  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication_Java\HslCommunication\HslCommunication.iml

    .......      6633  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication_Java\HslCommunication\out\production\HslCommunication\HslCommunication\Basicframework\SoftBasic.class

    .......       956  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication_Java\HslCommunication\out\production\HslCommunication\HslCommunication\Basicframework\SoftIncrementCount.class

    .......       325  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication_Java\HslCommunication\out\production\HslCommunication\HslCommunication\Basicframework\SoftSecurity.class

    .......      1645  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication_Java\HslCommunication\out\production\HslCommunication\HslCommunication\Basicframework\SoftZipped.class

    .......      2854  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication_Java\HslCommunication\out\production\HslCommunication\HslCommunication\Basicframework\SystemVersion.class

    .......       937  2018-09-13 22:41  HslCommunication-master\HslCommunication-master\HslCommunication_Java\HslCommunication\out\production\HslCommunication\HslCommunication\Core\Address\DeviceAddressbase.class

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

评论

共有 条评论