public bool OnInit() { _log.NormalLog(string.Format("ModbusTCPClientHanderTask:Init=>Initing ")); try { //获取配置 _config = ReaderXMLUtil.ReadXMLConfig <ModbusTCPClientConfig>("../../../../conf/Configuration.xml", ModbusTCPClientConfig.ReadConfig, "setup", "ModbusTCPClientHandlerTask")[0]; if (_config.IpAddress == "" || _config.SignalListFilePath == "") { _log.ErrorLog(string.Format("ModbusTCPClientHanderTask Init fail:{0}", "IP address or Signal file path is null!")); return(false); } _setup = new EthernetSetUp(_config.IpAddress, _config.Port); _timeout = new TimeOut("ModbusTCPClientHanderTask", _config.TimeOut, _log); _timeRead = new Timer.Timer(_config.PollingTime); _client = new ModbusTCPClient(_setup, _timeout, _log); //获取点数据 _workbook = XmlSerialiaztion.XmlDeserial <XMLWorkbook>(_config.SignalListFilePath, _log); _points = PointsCollcetCreate.Create(_workbook, _log); //点数据注册 PointsRegister.Register(ref _points, _log); _log.NormalLog(string.Format("ModbusTCPClientHanderTask:Initing=>Inited ")); return(true); } catch (Exception e) { _log.ErrorLog(string.Format("ModbusTCPClientHanderTask Init fail:{0}", e.Message)); return(false); } }
public PointDeviceCollcet CreatePoints(ClientName name) { if (name == ClientName.DL645_1997Client || name == ClientName.DL645_2007Client) { return(PointsCollcetCreate.CreateDL645(_workbook, _log)); } else if (name == ClientName.S7CommClient) { return(PointsCollcetCreate.CreateS7(_workbook, _log)); } else { return(PointsCollcetCreate.Create(_workbook, _log)); } }