PLCAccessorsCreater.cs 667 B

12345678910111213141516171819202122
  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. }
  21. }