PLCAccessorsCreater.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using HslCommunication.Core;
  2. using System;
  3. using WCS.Core.DataTrans;
  4. using WCS.Entity;
  5. namespace WCS.Service.PLCAccessors
  6. {
  7. public class PlcAccessorsCreater : IPLCAccessorCreater
  8. {
  9. //public IReadWriteNet Create(WCS_PLC data)
  10. //{
  11. // return data.TYPE switch
  12. // {
  13. // PLCType.西门子 => new SiemensS7PLC((int)data.MODEL, data.IP),
  14. // PLCType.三菱 => new MelsecPLC(data.IP, data.PORT),
  15. // PLCType.AB => new AllenBradleyPLC(data.IP),
  16. // PLCType.汇川 => new HuiChuangPLC(data.IP),
  17. // _ => throw new Exception("不支持此PLC")
  18. // };
  19. //}
  20. public IPLCAccessor Create(WCS_PLC data)
  21. {
  22. if (data.TYPE == PLCType.西门子)
  23. return new SiemensS7PLC(data.IP, data.PORT, data.RACK, data.SLOT);
  24. else
  25. throw new Exception("不支持此PLC");
  26. }
  27. //IPLCAccessor IPLCAccessorCreater.Create(WCS_PLC data)
  28. //{
  29. // throw new NotImplementedException();
  30. //}
  31. }
  32. }