PLCAccessorsCreater.cs 817 B

1234567891011121314151617181920212223242526272829
  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. /// <summary>
  11. /// 创建PLC访问器
  12. /// </summary>
  13. /// <param name="data">PLC信息</param>
  14. /// <returns></returns>
  15. /// <exception cref="Exception"> </exception>
  16. public IPLCAccessor Create(PLCInfo data)
  17. {
  18. switch (data.Type)
  19. {
  20. case PLCType.Siemens:
  21. return new SiemensS7PLC(data.IP, data.Port, data.Rack, data.Slot);
  22. default:
  23. return new VitrualRedisPLC(data, "127.0.0.1,database=1,prefix=Sorting:");
  24. }
  25. }
  26. }
  27. }