修改
This commit is contained in:
parent
a481c1dc3e
commit
7b0bb441ab
@ -1,28 +1,16 @@
|
||||
using JiShe.CollectBus.Core.Exceptions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace JiShe.CollectBus.Core.Plugins
|
||||
{
|
||||
public class TcpServiceReceivedPlugin : PluginBase, ITcpReceivedPlugin, ITcpConnectingPlugin, ITcpConnectedPlugin, ITcpClosedPlugin
|
||||
public class TcpServiceReceivedPlugin(IServiceProvider serviceProvider) : PluginBase, ITcpReceivedPlugin,
|
||||
ITcpConnectingPlugin, ITcpConnectedPlugin, ITcpClosedPlugin
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public TcpServiceReceivedPlugin(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public async Task OnTcpReceived(ITcpSession client, ReceivedDataEventArgs e)
|
||||
{
|
||||
//TODO:根据指令区别是376还是645协议
|
||||
//TODO:电表: 376.1 645-07 modbus 水表: 118 645-97
|
||||
|
||||
var protocolType = "TestProtocol";
|
||||
IProtocolPlugin? protocolPlugin;
|
||||
@ -35,7 +23,7 @@ namespace JiShe.CollectBus.Core.Plugins
|
||||
// //todo: 直接拿设备信息,根据设备信息使用不同的协议解析服务
|
||||
// break;
|
||||
}
|
||||
protocolPlugin = _serviceProvider.GetKeyedService<IProtocolPlugin>(protocolType);
|
||||
protocolPlugin = serviceProvider.GetKeyedService<IProtocolPlugin>(protocolType);
|
||||
client.Logger.Info($"{protocolPlugin?.Get().Name},{protocolPlugin?.Get().RegularExpression}");
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user