diff --git a/Modbus.Net/Modbus.Net/Helper/ControllerHelper.cs b/Modbus.Net/Modbus.Net/Helper/ControllerHelper.cs
index 01a61e2..d9942bf 100644
--- a/Modbus.Net/Modbus.Net/Helper/ControllerHelper.cs
+++ b/Modbus.Net/Modbus.Net/Helper/ControllerHelper.cs
@@ -12,11 +12,10 @@ namespace Modbus.Net
/// 添加一个Controller
///
/// ProtocolLinker实例
- /// 第一参数
- /// 第二参数
+ /// 参数
/// Connector实例
/// 如果没有发现控制器,报错
- public static void AddController(this IProtocolLinker protocolLinker, string param1, int param2, IConnector connector)
+ public static void AddController(this IProtocolLinker protocolLinker, object[] constructorParams, IConnector connector)
{
IController controller = null;
var assemblies = AssemblyHelper.GetAllLibraryAssemblies();
@@ -26,7 +25,7 @@ namespace Modbus.Net
var controllerType = assembly.GetType(assembly.GetName().Name + "." + controllerName);
if (controllerType != null)
{
- controller = assembly.CreateInstance(controllerType.FullName, true, BindingFlags.Default, null, new object[2] { param1, param2 }, null, null) as IController;
+ controller = assembly.CreateInstance(controllerType.FullName, true, BindingFlags.Default, null, constructorParams, null, null) as IController;
break;
}
}
diff --git a/Modbus.Net/Modbus.Net/Linker/ComProtocolLinker.cs b/Modbus.Net/Modbus.Net/Linker/ComProtocolLinker.cs
index ddedad6..361c6b6 100644
--- a/Modbus.Net/Modbus.Net/Linker/ComProtocolLinker.cs
+++ b/Modbus.Net/Modbus.Net/Linker/ComProtocolLinker.cs
@@ -31,7 +31,7 @@ namespace Modbus.Net
connectionTimeout = int.Parse(connectionTimeout != null ? connectionTimeout.ToString() : null ?? ConfigurationReader.GetValue("COM:" + com, "ConnectionTimeout"));
isFullDuplex = bool.Parse(isFullDuplex != null ? isFullDuplex.ToString() : null ?? ConfigurationReader.GetValue("COM:" + com, "FullDuplex"));
BaseConnector = new ComConnector(com + ":" + slaveAddress, baudRate.Value, parity.Value, stopBits.Value, dataBits.Value, handshake.Value, connectionTimeout.Value, isFullDuplex.Value);
- this.AddController(com, slaveAddress, BaseConnector);
+ this.AddController(new object[2] { com, slaveAddress }, BaseConnector);
}
}
}
\ No newline at end of file
diff --git a/Modbus.Net/Modbus.Net/Linker/TcpProtocolLinker.cs b/Modbus.Net/Modbus.Net/Linker/TcpProtocolLinker.cs
index 679a8af..4ef9b99 100644
--- a/Modbus.Net/Modbus.Net/Linker/TcpProtocolLinker.cs
+++ b/Modbus.Net/Modbus.Net/Linker/TcpProtocolLinker.cs
@@ -18,7 +18,7 @@
isFullDuplex = bool.Parse(isFullDuplex != null ? isFullDuplex.ToString() : null ?? ConfigurationReader.GetValue("TCP:" + ip + ":" + port, "FullDuplex"));
//初始化连接对象
BaseConnector = new TcpConnector(ip, port, connectionTimeout.Value, isFullDuplex.Value);
- this.AddController(ip, port, BaseConnector);
+ this.AddController(new object[2] { ip, port }, BaseConnector);
}
}
}
\ No newline at end of file
diff --git a/Modbus.Net/Modbus.Net/Linker/UdpProtocolLinker.cs b/Modbus.Net/Modbus.Net/Linker/UdpProtocolLinker.cs
index 056335a..6fb4d93 100644
--- a/Modbus.Net/Modbus.Net/Linker/UdpProtocolLinker.cs
+++ b/Modbus.Net/Modbus.Net/Linker/UdpProtocolLinker.cs
@@ -18,7 +18,7 @@
isFullDuplex = bool.Parse(isFullDuplex != null ? isFullDuplex.ToString() : null ?? ConfigurationReader.GetValue("UDP:" + ip + ":" + port, "FullDuplex"));
//初始化连接对象
BaseConnector = new UdpConnector(ip, port, connectionTimeout.Value, isFullDuplex.Value);
- this.AddController(ip, port, BaseConnector);
+ this.AddController(new object[2] { ip, port }, BaseConnector);
}
}
}
\ No newline at end of file