PlcInfo.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using Prism.Mvvm;
  2. using System;
  3. using TeamAAS_VP.Core.PLCs;
  4. using TeamAAS_VP.Enums;
  5. namespace TeamAAS_VP.Models
  6. {
  7. public class PlcInfo : BindableBase
  8. {
  9. private Guid _Id;
  10. public Guid Id
  11. {
  12. get { return _Id; }
  13. set { SetProperty(ref _Id, value); }
  14. }
  15. private string _Name;
  16. public string Name
  17. {
  18. get { return _Name; }
  19. set { SetProperty(ref _Name, value); }
  20. }
  21. private CommunicationType _CommunicationType;
  22. public CommunicationType CommunicationType
  23. {
  24. get { return _CommunicationType; }
  25. set { SetProperty(ref _CommunicationType, value); }
  26. }
  27. private string _EndpointUrl;
  28. public string EndpointUrl
  29. {
  30. get { return _EndpointUrl; }
  31. set { SetProperty(ref _EndpointUrl, value); }
  32. }
  33. #region Mitsubishi MC
  34. public string PlcIp { get; set; } = "192.168.0.10";
  35. public int PlcPort { get; set; } = 5000;
  36. public bool PlcForwardEnabled { get; set; } = true;
  37. public string PlcPortDevice { get; set; } = "D101";
  38. public string PlcQualityDevice { get; set; } = "D102";
  39. public string PlcDataStartDevice { get; set; } = "D110";
  40. public string PlcReadyBitDevice { get; set; } = "M100";
  41. public string PlcOkBitDevice { get; set; } = "0";
  42. public string PlcNgBitDevice { get; set; } = "0";
  43. public string PlcReceiveBitDevice { get; set; } = "M103";
  44. public string PlcHeartbeatDevice { get; set; } = "M200";
  45. public int PlcHeartbeatIntervalMs { get; set; } = 1000;
  46. public string PlcBitTestDevice { get; set; } = "M3001";
  47. public int PlcMaxDataBytes { get; set; } = 32;
  48. public PlcRfidMapping ToPlcMapping()
  49. {
  50. return new PlcRfidMapping
  51. {
  52. PortDevice = PlcPortDevice,
  53. QualityDevice = PlcQualityDevice,
  54. DataStartDevice = PlcDataStartDevice,
  55. ReadyBitDevice = PlcReadyBitDevice,
  56. OkBitDevice = PlcOkBitDevice,
  57. NgBitDevice = PlcNgBitDevice,
  58. ReceiveBitDevice = PlcReceiveBitDevice,
  59. MaxDataBytes = PlcMaxDataBytes
  60. };
  61. }
  62. public void ApplyMcInfo(MCToPCInfo info)
  63. {
  64. if (info == null) return;
  65. PlcIp = info.PlcIp;
  66. PlcPort = info.PlcPort;
  67. PlcForwardEnabled = info.PlcForwardEnabled;
  68. PlcPortDevice = info.PlcPortDevice;
  69. PlcQualityDevice = info.PlcQualityDevice;
  70. PlcDataStartDevice = info.PlcDataStartDevice;
  71. PlcReadyBitDevice = info.PlcReadyBitDevice;
  72. PlcOkBitDevice = info.PlcOkBitDevice;
  73. PlcNgBitDevice = info.PlcNgBitDevice;
  74. PlcReceiveBitDevice = info.PlcReceiveBitDevice;
  75. PlcHeartbeatDevice = info.PlcHeartbeatDevice;
  76. PlcHeartbeatIntervalMs = info.PlcHeartbeatIntervalMs;
  77. PlcBitTestDevice = info.PlcBitTestDevice;
  78. PlcMaxDataBytes = info.PlcMaxDataBytes;
  79. }
  80. #endregion
  81. }
  82. }