IModbusClient.cs 3.25 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace FLY.Modbus
{
    /// <summary>
    /// 异常有异常事件
    /// </summary>
    public interface IModbusClient 
    {

        /// <summary>
        /// 读多个 COIL
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="cnt"></param>
        /// <param name="AsyncDelegate"></param>
        /// <param name="AsyncState"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_01(UInt16 addr, UInt16 cnt, Action<bool[],object> AsyncDelegate, object AsyncState);


        /// <summary>
        /// 读多个Holding REGs
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="cnt"></param>
        /// <param name="AsyncDelegate"></param>
        /// <param name="AsyncState"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_03(UInt16 addr, UInt16 cnt, Action<UInt16[], object> AsyncDelegate, object AsyncState);

        /// <summary>
        /// Write Single Coil
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_05(UInt16 addr, bool data);


        /// <summary>
        /// Write Single Coil,带返回
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="data"></param>
        /// <param name="AsyncDelegate"></param>
        /// <param name="AsyncState"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_05(UInt16 addr, bool data, Action<object> AsyncDelegate, object AsyncState);


        /// <summary>
        /// 写多个coil
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="datas"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_0F(UInt16 addr, bool[] datas);


        /// <summary>
        /// 写多个coil,带返回
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="datas"></param>
        /// <param name="AsyncDelegate"></param>
        /// <param name="AsyncState"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_0F(UInt16 addr, bool[] datas, Action<object> AsyncDelegate, object AsyncState);


        /// <summary>
        /// 写多个REG
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="datas"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_10(UInt16 addr, UInt16[] datas);


        /// <summary>
        /// 写多个REG,带返回
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="datas"></param>
        /// <param name="AsyncDelegate"></param>
        /// <param name="AsyncState"></param>
        /// <returns></returns>
        ModbusClient_Errno Do_10(UInt16 addr, UInt16[] datas, Action<object> AsyncDelegate, object AsyncState);
    }

    /// <summary>
    /// modbus客户端,指令返回值
    /// </summary>
    public enum ModbusClient_Errno
    {
        /// <summary>
        /// 成功
        /// </summary>
        OK = 0,
        /// <summary>
        /// 失败,trans 出错
        /// </summary>
        TOO_MUCH_TRANS = -1,
    }
}