From ada2568ff1d83e6f521a755685a03082a3217440 Mon Sep 17 00:00:00 2001 From: "parallelbgls@outlook.com" Date: Sat, 30 Aug 2014 09:58:53 +0800 Subject: [PATCH] 2014-08-30 update 1 small changes in ResourceManager --- .../ConfigurationManager.Designer.cs | 18 ------------------ .../ModBus.Net/ConfigurationManager.resx | 6 ------ Modbus.Net/ModBus.Net/TcpProtocalLinker.cs | 16 ++++++++++++---- 3 files changed, 12 insertions(+), 28 deletions(-) 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