12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using System.Threading.Tasks;
- using Team.Communicate.EventArg;
- using Team.Communicate.Interfaces;
- namespace Team.Communicate.Client
- {
- /// <summary>
- /// 基础的协议连接类
- /// </summary>
- public abstract class BaseConnector : BaseConnector<byte[], byte[]>
- {
- }
- /// <summary>
- /// 基础的协议连接类
- /// </summary>
- public abstract class BaseConnector<TParamIn, TParamOut> : IConnector<TParamIn, TParamOut>
- {
- /// <summary>
- /// 标识Connector的连接关键字
- /// </summary>
- public abstract string ConnectionToken { get; }
- /// <summary>
- /// 是否处于连接状态
- /// </summary>
- public abstract bool IsConnected { get; }
- /// <summary>
- /// 连接PLC
- /// </summary>
- /// <returns>是否连接成功</returns>
- public abstract bool Connect();
- /// <summary>
- /// 连接PLC,异步
- /// </summary>
- /// <returns>是否连接成功</returns>
- public abstract Task<bool> ConnectAsync();
- /// <summary>
- /// 断开PLC
- /// </summary>
- /// <returns>是否断开成功</returns>
- public abstract bool Disconnect();
- /// <summary>
- /// 无返回发送数据
- /// </summary>
- /// <param name="message">需要发送的数据</param>
- /// <returns>是否发送成功</returns>
- public abstract bool SendMsgWithoutReturn(TParamIn message);
- /// <summary>
- /// 无返回发送数据
- /// </summary>
- /// <param name="message">需要发送的数据</param>
- /// <returns>是否发送成功</returns>
- public abstract Task<bool> SendMsgWithoutReturnAsync(TParamIn message);
- /// <summary>
- /// 带返回发送数据
- /// </summary>
- /// <param name="message">需要发送的数据</param>
- /// <returns>是否发送成功</returns>
- public abstract TParamOut SendMsg(TParamIn message);
- /// <summary>
- /// 带返回发送数据
- /// </summary>
- /// <param name="message">需要发送的数据</param>
- /// <returns>是否发送成功</returns>
- public abstract Task<TParamOut> SendMsgAsync(TParamIn message);
- public abstract event EventHandler<string> SendEventHandler;
- public abstract event EventHandler<ExceptionEventArgs<Exception>> SendExceptionEventHandler;
- public abstract event EventHandler<string> ConnectedEventHandler;
- public abstract event EventHandler<ExceptionEventArgs<Exception>> ConnectExceptionEventHandler;
- public abstract event EventHandler<string> ReceiveEventHandler;
- public abstract event EventHandler<ExceptionEventArgs<Exception>> ReceiveExceptionEventHandler;
- public abstract event EventHandler<string> DisConnectEvent;
- public abstract event EventHandler<ExceptionEventArgs<Exception>> DisConnectFailEvent;
- }
- }
|