IModbusAsciiAsync.cs 4.34 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Threading;
using static GeneralGommunication.Modbus_Transaction;

namespace GeneralGommunication
{
    public interface IModbusAsciiAsync : INotifyPropertyChanged
    {
        /// <summary>
        /// 通讯速度测量模块
        /// </summary>
        CommSpeedMeasuring Csm { get; }

        /// <summary>
        /// 包出错次数
        /// </summary>
        int ErrCnt { get; }

        /// <summary>
        /// 有数据需要发送
        /// </summary>
24
        event SendDataEventHandler SendMsgEvent;
潘栩锋's avatar
潘栩锋 committed
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

        /// <summary>
        /// 设备连接状态改变
        /// </summary>
        event DeviceConnectEventHander DeviceConnectEvent;

        /// <summary>
        /// 通讯中
        /// </summary>
        bool IsBusy();

        /// <summary>
        /// 检查发生列表是否包含某条指令
        /// </summary>
        /// <param name="deviceNo"></param>
        /// <param name="desription"></param>
        /// <returns></returns>
        bool Contain(int deviceNo, string desription);

        /// <summary>
        /// 设备是否连接成功
        /// </summary>
        /// <param name="deviceNo"></param>
        /// <returns></returns>
        bool IsConnected(byte deviceNo);

        /// <summary>
        /// 接收回调调用
        /// </summary>
        /// <param name="recBuf"></param>
        void RecMsg(byte[] recBuf);

        /// <summary>
        /// 复位全部状态,通常由于通讯模块检测到连接断开导致的
        /// </summary>
        void ResetMsg();

        /// <summary>
        /// 添加 通讯任务
        /// </summary>
        /// <param name="tran"></param>
        void AddTran(Modbus_Transaction tran);

        /// <summary>
        /// 读多个Holding REGs
        /// </summary>
        /// <param name="deviceNo"></param>
        /// <param name="addr"></param>
        /// <param name="cnt"></param>
        /// <param name="desription"></param>
        /// <param name="parseU16FuncPack"></param>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        /// <returns></returns>
        Modbus_Transaction Do_03(int deviceNo, int addr, int cnt,
            string desription,
           ParseU16FuncPackHandler parseU16FuncPack,
           CallBackHandler asyncDelegate, object asyncContext);

        /// <summary>
        /// 读多个Input REGs
        /// </summary>
        /// <param name="deviceNo"></param>
        /// <param name="addr"></param>
        /// <param name="cnt"></param>
        /// <param name="desription"></param>
        /// <param name="parseU16FuncPack"></param>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        /// <returns></returns>
        Modbus_Transaction Do_04(int deviceNo, int addr, int cnt,
            string desription,
           ParseU16FuncPackHandler parseU16FuncPack,
           CallBackHandler asyncDelegate, object asyncContext);

        /// <summary>
        /// 写单个 Holding REG
        /// </summary>
        /// <param name="deviceNo"></param>
        /// <param name="addr"></param>
        /// <param name="cnt"></param>
        /// <param name="desription"></param>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        /// <returns></returns>
        Modbus_Transaction Do_06(int deviceNo, int addr, UInt16 value,
            string desription,
           CallBackHandler asyncDelegate, object asyncContext);

        /// <summary>
        /// 写多个 Holding REG
        /// </summary>
        /// <param name="deviceNo"></param>
        /// <param name="addr"></param>
        /// <param name="cnt"></param>
        /// <param name="desription"></param>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        /// <returns></returns>
        Modbus_Transaction Do_10(int deviceNo, int addr, IEnumerable<UInt16> datas,
           string desription,
           CallBackHandler asyncDelegate, object asyncContext);

        /// <summary>
        /// <para>任务内部转为发送的字节</para>
        /// <para>用于自定义指令</para>
        /// </summary>
        /// <param name="tran"></param>
        void ToSendBuf(Modbus_Transaction tran);
    }
}