IGeneralComm.cs 1.5 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1
using System;
2
using System.Collections.Generic;
潘栩锋's avatar
潘栩锋 committed
3
using System.ComponentModel;
4 5 6
using System.Linq;
using System.Text;
using System.Threading.Tasks;
潘栩锋's avatar
潘栩锋 committed
7

8
namespace GeneralGommunication
潘栩锋's avatar
潘栩锋 committed
9
{
10 11 12 13 14
    /// <summary>
    /// 通用通讯接口
    /// general communication
    /// </summary>
    public interface IGeneralComm : INotifyPropertyChanged
潘栩锋's avatar
潘栩锋 committed
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
    {
        /// <summary>
        /// IP 地址 and 端口号
        /// </summary>
        string Addr { get; set; }

        /// <summary>
        /// 是否异常
        /// </summary>
        bool IsError { get; }

        /// <summary>
        /// 异常信息
        /// </summary>
        string ErrMsg { get; }

        /// <summary>
        /// 连接成功
        /// </summary>
        bool IsConnected { get; }


        /// <summary>
        /// 运行中
        /// </summary>
        bool IsRunning { get; }

        /// <summary>
        /// 开始
        /// </summary>
        void Start();

        /// <summary>
48
        /// 结束
潘栩锋's avatar
潘栩锋 committed
49 50 51 52 53 54
        /// </summary>
        void Stop();

        /// <summary>
        /// 发送数据
        /// </summary>
55
        /// <param name="buf"></param>
56
        void Write(IEnumerable<byte> buf);
潘栩锋's avatar
潘栩锋 committed
57 58 59 60 61


        /// <summary>
        /// 接收数据
        /// </summary>
62
        event IGeneralCommDataReceivedHandler DataReceived;
潘栩锋's avatar
潘栩锋 committed
63

64 65 66 67
        /// <summary>
        /// 清空输入缓存
        /// </summary>
        void DiscardInBuffer();
潘栩锋's avatar
潘栩锋 committed
68
    }
69 70

    public delegate void IGeneralCommDataReceivedHandler(IGeneralComm sender, byte[] buf);
潘栩锋's avatar
潘栩锋 committed
71
}