添加HSL,并创建工具类,在IWCS写测试
This commit is contained in:
1 parent
2c178b1810
commit
b0a6dcc035
10 files changed
+1381
-4
No files matched your search
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HHWMS.Web.Support.PLC
|
||||
{
|
||||
public enum PlcType
|
||||
{
|
||||
Siemens,
|
||||
Modbus,
|
||||
Mitsubishi
|
||||
}
|
||||
|
||||
public class PlcFactory
|
||||
{
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
|
||||
public PlcFactory(ILoggerFactory loggerFactory)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
}
|
||||
|
||||
public IPlcDevice CreatePlc(PlcType plcType)
|
||||
{
|
||||
return plcType switch
|
||||
{
|
||||
PlcType.Siemens => new SiemensPlc(_loggerFactory.CreateLogger<SiemensPlc>()),
|
||||
PlcType.Modbus => new ModbusPlc(_loggerFactory.CreateLogger<ModbusPlc>()),
|
||||
PlcType.Mitsubishi => new MitsubishiPlc(_loggerFactory.CreateLogger<MitsubishiPlc>()),
|
||||
_ => throw new ArgumentException("不支持的PLC类型", nameof(plcType))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user