/// <summary> /// 初始化 /// </summary> public void Init() { eventHandlers = new Dictionary <Type, EventHandler <YEventArgs> >(); eventHandlers[typeof(PipeReceived)] = whenPipeReceived; App.EventStore.Subscribe(eventHandlers); //HmiPro 软件保活 YUtil.SetInterval(60000, keepHmiAlive); Logger = LoggerHelper.Create(GetType().ToString()); }
/// <summary> /// 创建行处理TCP服务端(若logger参数为空则用ILoggerFactory初始化内部日志) /// </summary> /// <param name="logger">配合依赖注入的参数</param> public LineAbstractTcpServer(ILogger <LineAbstractTcpServer> logger = null) { if (logger == null) { _logger = LoggerHelper.Create <LineAbstractTcpServer>(); return; } _logger = logger; }
/// <summary> /// 注入配置信息 /// </summary> /// <param name="hmiProName"></param> /// <param name="hmiProPath"></param> public CmdParseService(string hmiProName, string hmiProPath) { UnityIocService.AssertIsFirstInject(GetType()); this.hmiProName = hmiProName; this.hmiProPath = hmiProPath; Logger = LoggerHelper.Create(GetType().ToString()); executors = new Dictionary <Type, Func <object, ExecRest> >(); executors[typeof(CmdActions.StartHmiPro)] = startHmiPro; executors[typeof(CmdActions.CloseHmiPro)] = closeHmiPro; }
/// <summary> /// 创建行处理TCP客户端(若logger参数为空则用ILoggerFactory初始化内部日志) /// </summary> /// <param name="logger"></param> /// <param name="iP">IP</param> /// <param name="port">端口</param> public LineTcpClient(ILogger <LineTcpClient <T> > logger, IPAddress iP, int port) { if (iP == null) { throw new ArgumentNullException(nameof(iP)); } _endpoint = new IPEndPoint(iP, port); _socket = new Socket(SocketType.Stream, ProtocolType.Tcp); _bcol = new BlockingCollection <T>(); _keyGenerator = SnowFlakeGenerator.Instance(); if (logger == null) { _logger = LoggerHelper.Create <LineTcpClient <T> >(); return; } _logger = logger; }
/// <summary> /// 注入管道名称 /// </summary> /// <param name="pipeName"></param> public PipeService(string pipeName) { this.pipeName = pipeName; Logger = LoggerHelper.Create(GetType().ToString()); }
/// <summary> /// 初始化日志 /// </summary> static App() { Logger = LoggerHelper.Create("Asylum"); EventStore = new YEventStore(); }
/// <summary> /// 代理注入 /// </summary> /// <param name="cmdParse"></param> public HttpParse(CmdParseService cmdParse) { UnityIocService.AssertIsFirstInject(GetType()); this.cmdPrase = cmdParse; Logger = LoggerHelper.Create(GetType().ToString()); }