修改监控部分功能

This commit is contained in:
2026-05-09 17:49:46 +08:00
parent 06a5f9707d
commit 52ece8211b
14 changed files with 456 additions and 383 deletions

View File

@@ -18,9 +18,9 @@ namespace SamplePre.Communication
/// <param name="connectionParams">连接参数</param>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public static ICommunication CreateCommunication(CommProtocolType protocolType, string connectionParams)
public static CommunicationBase CreateCommunication(CommProtocolType protocolType, string connectionParams)
{
ICommunication comm = null;
CommunicationBase comm = null;
switch (protocolType)
{
@@ -41,21 +41,21 @@ namespace SamplePre.Communication
}
public static ICommunication CreateS7(string connectionParams)
public static CommunicationBase CreateS7(string connectionParams)
{
string[] params1 = connectionParams.Split(':');
if(params1 == null || params1.Length < 3) return null;
//ICommunication comm = new S7PlcCommunicator(CpuType.S71500, "192.168.10.2", 0, 1);
ICommunication comm = new S7PlcCommunicator(CpuType.S71500, params1[0], int.Parse( params1[1]), int.Parse( params1[2]));
CommunicationBase comm = new S7PlcCommunicator(CpuType.S71500, params1[0], int.Parse( params1[1]), int.Parse( params1[2]));
return comm;
}
public static ICommunication CreateModbusTcp(string connectionParams)
public static CommunicationBase CreateModbusTcp(string connectionParams)
{
string[] params1 = connectionParams.Split(':');
if (params1 == null || params1.Length < 2) return null;
ICommunication comm = new ModbusTcpCommunicator(params1[0], int.Parse(params1[1]));
CommunicationBase comm = new ModbusTcpCommunicator(params1[0], int.Parse(params1[1]));
return comm;
}