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