123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using Edge.Core.Domain.FccOrderInfo;
- using Edge.Core.Parser;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Sockets;
- using System.Text;
- using System.Threading.Tasks;
- namespace Edge.Core.Processor
- {
- public interface IDeviceHandler<TRaw, TMessage> where TMessage : MessageBase
- {
- /// <summary>
- /// The communicator has NOT started yet at this stage.
- /// </summary>
- /// <param name="context"></param>
- void Init(IContext<TRaw, TMessage> context);
- /// <summary>
- /// will be called every time that a message incoming from communicator.
- /// </summary>
- /// <param name="context"></param>
- Task Process(IContext<TRaw, TMessage> context);
- /// <summary>
- /// The method will be called from user for a generic test purpose, should implemented this method
- /// to cover most real life time logic to give user a meaningful and confidence result for how this processor would work
- /// when run for real.
- /// The method was guranteed to be called after DeviceHandler.Init, and Communicator.Start
- /// </summary>
- /// <param name="parameters"></param>
- /// <returns>throw exception to indicates the test failed, otherwise, return a Completed task.</returns>
- Task Test(params object[] parameters) { throw new NotImplementedException("暂不支持测试"); }
- /// <summary>
- /// 接收到 MQTT 数据
- /// </summary>
- /// <param name="message">数据 json </param>
- void OnReceiveMqttMessage(string message) { }
- /// <summary>
- /// 发送二维码信息
- /// </summary>
- void SendQRCodeAsync() { }
- ///// <summary>
- ///// 发送实付金额给油机
- ///// </summary>
- ///// <param name="orderInfo"></param>
- //void SendActuallyPaid(FccOrderInfo orderInfo) { }
- ///// <summary>
- ///// 设置tcp连接客户端,所连接的服务端端口
- ///// </summary>
- //void SetTcpClient(TcpClient? client,int? serverPort) { }
- ///// <summary>
- ///// 当与客户端断开链接
- ///// </summary>
- //void OnTcpDisconnect() { }
- }
- public abstract class TestableActivePollingDeviceHandler<TRaw, TMessage> : IDeviceHandler<TRaw, TMessage> where TMessage : MessageBase
- {
- private IContext<TRaw, TMessage> context;
- public virtual void Init(IContext<TRaw, TMessage> context)
- {
- this.context = context;
- }
- public virtual Task Process(IContext<TRaw, TMessage> context)
- {
- throw new NotImplementedException();
- }
- }
- }
|