IoAutoShutter.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Device.Unit;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.IOCore;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.Util;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.Event;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using System.Xml;
  18. namespace Aitex.Core.RT.Device.Unit
  19. {
  20. public class IoAutoShutter : BaseDevice, IDevice
  21. {
  22. public enum ASOpenCloseStatus
  23. {
  24. Unknown,
  25. Open,
  26. Close,
  27. }
  28. public enum ASUpDownStatus
  29. {
  30. Unknown,
  31. Up,
  32. Down,
  33. }
  34. public IoAutoShutter(string module, XmlElement node, string ioModule = "")
  35. {
  36. base.Module = string.IsNullOrEmpty(node.GetAttribute("module")) ? module : node.GetAttribute("module");
  37. base.Name = node.GetAttribute("id");
  38. base.Display = node.GetAttribute("display");
  39. base.DeviceID = node.GetAttribute("schematicId");
  40. _diOpen = ParseDiNode("diOpen", node, ioModule);
  41. _diClose = ParseDiNode("diClose", node, ioModule);
  42. _diUp = ParseDiNode("diUp", node, ioModule);
  43. _diDown = ParseDiNode("diDown", node, ioModule);
  44. _doOpen = ParseDoNode("doOpen", node, ioModule);
  45. _doClose = ParseDoNode("doClose", node, ioModule);
  46. _doUp = ParseDoNode("doUp", node, ioModule);
  47. _doDown = ParseDoNode("doDown", node, ioModule);
  48. }
  49. #region fields
  50. private DIAccessor _diOpen;
  51. private DIAccessor _diClose;
  52. private DIAccessor _diUp;
  53. private DIAccessor _diDown;
  54. private DOAccessor _doOpen;
  55. private DOAccessor _doClose;
  56. private DOAccessor _doUp;
  57. private DOAccessor _doDown;
  58. #endregion
  59. public AlarmEventItem AutoShutterMoveFailedForInterlock { get; set; }
  60. public AlarmEventItem AutoShutterOpenTimeOut { get; set; }
  61. public AlarmEventItem AutoShutterCloseTimeOut { get; set; }
  62. public AlarmEventItem AutoShutterUpTimeOut { get; set; }
  63. public AlarmEventItem AutoShutterDownTimeOut { get; set; }
  64. #region properties
  65. public ASOpenCloseStatus OpenCloseStatus
  66. {
  67. get
  68. {
  69. if (_diOpen != null && _diClose != null && _diOpen.Value && !_diClose.Value)
  70. return ASOpenCloseStatus.Open;
  71. if (_diOpen != null && _diClose != null && !_diOpen.Value && _diClose.Value)
  72. return ASOpenCloseStatus.Close;
  73. return ASOpenCloseStatus.Unknown;
  74. }
  75. }
  76. public ASUpDownStatus UpDownStatus
  77. {
  78. get
  79. {
  80. if (_diUp != null && _diDown != null && _diUp.Value && !_diDown.Value)
  81. return ASUpDownStatus.Up;
  82. if (_diUp != null && _diDown != null && !_diUp.Value && _diDown.Value)
  83. return ASUpDownStatus.Down;
  84. return ASUpDownStatus.Unknown;
  85. }
  86. }
  87. #endregion
  88. public bool Initialize()
  89. {
  90. DATA.Subscribe(Name, "OpenCloseStatus", () => OpenCloseStatus.ToString());
  91. DATA.Subscribe(Name, "UpDownStatus", () => UpDownStatus.ToString());
  92. return true;
  93. }
  94. public void Monitor()
  95. {
  96. }
  97. public void Reset()
  98. {
  99. }
  100. public void Terminate()
  101. {
  102. }
  103. public bool SetOpen(bool isOpen, out string reason)
  104. {
  105. if (isOpen)
  106. {
  107. _doClose.SetValue(!isOpen, out reason);
  108. return _doOpen.SetValue(isOpen, out reason);
  109. }
  110. else
  111. {
  112. _doOpen.SetValue(isOpen, out reason);
  113. return _doClose.SetValue(!isOpen, out reason);
  114. }
  115. }
  116. public bool SetUp(bool isUp, out string reason)
  117. {
  118. if (isUp)
  119. {
  120. _doDown.SetValue(!isUp, out reason);
  121. return _doUp.SetValue(isUp, out reason);
  122. }
  123. else
  124. {
  125. _doUp.SetValue(isUp, out reason);
  126. return _doDown.SetValue(!isUp, out reason);
  127. }
  128. }
  129. }
  130. }