PLCAccessorsCreater.cs 844 B

12345678910111213141516171819202122232425262728293031
  1. using WCS.Core;
  2. using PLCType = WCS.Core.PLCType;
  3. namespace WCS.Service.PLCAccessors
  4. {
  5. /// <summary>
  6. /// PLC访问器创建者
  7. /// </summary>
  8. public class PLCAccessorsCreater : IPLCAccessorCreater
  9. {
  10. public static string RedisConnStr = default;
  11. /// <summary>
  12. /// 创建PLC访问器
  13. /// </summary>
  14. /// <param name="data">PLC信息</param>
  15. /// <returns></returns>
  16. /// <exception cref="Exception"> </exception>
  17. public IPLCAccessor Create(PLCInfo data)
  18. {
  19. switch (data.Type)
  20. {
  21. case PLCType.Siemens:
  22. return new SiemensS7PLC(data.IP, data.Port, data.Rack, data.Slot);
  23. default:
  24. return new VitrualRedisPLC(data, RedisConnStr);
  25. }
  26. }
  27. }
  28. }