diff --git a/Modbus.Net/ModBus.Net/ConfigurationManager.Designer.cs b/Modbus.Net/ModBus.Net/ConfigurationManager.Designer.cs index 198b10d..24b249a 100644 --- a/Modbus.Net/ModBus.Net/ConfigurationManager.Designer.cs +++ b/Modbus.Net/ModBus.Net/ConfigurationManager.Designer.cs @@ -77,23 +77,5 @@ namespace ModBus.Net { return ResourceManager.GetString("IP", resourceCulture); } } - - /// - /// 查找类似 502 的本地化字符串。 - /// - internal static string Port { - get { - return ResourceManager.GetString("Port", resourceCulture); - } - } - - /// - /// 查找类似 1000 的本地化字符串。 - /// - internal static string SocketTimeOut { - get { - return ResourceManager.GetString("SocketTimeOut", resourceCulture); - } - } } } diff --git a/Modbus.Net/ModBus.Net/ConfigurationManager.resx b/Modbus.Net/ModBus.Net/ConfigurationManager.resx index 27a0a6c..49d5134 100644 --- a/Modbus.Net/ModBus.Net/ConfigurationManager.resx +++ b/Modbus.Net/ModBus.Net/ConfigurationManager.resx @@ -123,10 +123,4 @@ 192.168.3.247 - - 502 - - - 1000 - \ No newline at end of file diff --git a/Modbus.Net/ModBus.Net/TcpProtocalLinker.cs b/Modbus.Net/ModBus.Net/TcpProtocalLinker.cs index 06c0ff4..f51c4a3 100644 --- a/Modbus.Net/ModBus.Net/TcpProtocalLinker.cs +++ b/Modbus.Net/ModBus.Net/TcpProtocalLinker.cs @@ -10,15 +10,23 @@ namespace ModBus.Net /// 连接对象 /// - protected TcpProtocalLinker() + protected TcpProtocalLinker() : this(ConfigurationManager.IP) { - //初始化连对象 - _baseConnector = new TcpConnector(ConfigurationManager.IP, int.Parse(ConfigurationManager.Port), false); + } protected TcpProtocalLinker(string ip) { - _baseConnector = new TcpConnector(ip, int.Parse(ConfigurationManager.Port), false); + int port; + if (ConfigurationManager.ResourceManager.GetString("Port") != null && int.TryParse(ConfigurationManager.ResourceManager.GetString("Port"),out port)) + { + + } + else + { + port = 502; + } + _baseConnector = new TcpConnector(ip, port, false); } } } \ No newline at end of file