LoadLockModule.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Aitex.Core.RT.DataCenter;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Device.Unit;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.OperationCenter;
  11. using Aitex.Core.Utilities;
  12. using Aitex.Sorter.Common;
  13. using MECF.Framework.Common.Equipment;
  14. using MECF.Framework.Common.Schedulers;
  15. using MECF.Framework.Common.SubstrateTrackings;
  16. using MECF.Framework.RT.ModuleLibrary.LLModules;
  17. namespace JetMainframe.LLs
  18. {
  19. public class LoadLockModule : LoadLockModuleBase
  20. {
  21. public enum STATE
  22. {
  23. NotInstall,
  24. NotConnected,
  25. Idle,
  26. Error,
  27. InTransfer,
  28. }
  29. public enum MSG
  30. {
  31. Home,
  32. Disconnected,
  33. Connected,
  34. Reset,
  35. Abort,
  36. Error,
  37. InTransfer,
  38. TransferComplete,
  39. }
  40. public override bool IsReady
  41. {
  42. get
  43. {
  44. return FsmState == (int)STATE.Idle &&
  45. CheckAllMessageProcessed();
  46. }
  47. }
  48. public override bool IsError
  49. {
  50. get { return FsmState == (int)STATE.Error; }
  51. }
  52. public override bool IsInit
  53. {
  54. get { return false; }
  55. }
  56. public LoadLockModule(ModuleName module, int slotCount = 1) : base(slotCount)
  57. {
  58. Name = module.ToString();
  59. Module = module.ToString();
  60. IsOnline = true;
  61. }
  62. public override bool Initialize()
  63. {
  64. InitRoutine();
  65. InitDevice();
  66. InitFsm();
  67. InitOp();
  68. InitData();
  69. return base.Initialize();
  70. }
  71. private void InitRoutine()
  72. {
  73. }
  74. public void InitDevice()
  75. {
  76. }
  77. private void InitData()
  78. {
  79. DATA.Subscribe($"{Module}.Status", () => StringFsmStatus);
  80. DATA.Subscribe($"{Module}.IsOnline", () => IsOnline);
  81. DATA.Subscribe($"{Module}.WaferSize",
  82. () => WaferManager.Instance.GetWaferSize(ModuleHelper.Converter(Module), 0).ToString());
  83. }
  84. private void InitOp()
  85. {
  86. OP.Subscribe($"{Module}.SetOnline",
  87. (string cmd, object[] args) => IsOnline = true);
  88. OP.Subscribe($"{Module}.SetOffline",
  89. (string cmd, object[] args) => IsOnline = false);
  90. OP.Subscribe($"{Module}.Home",
  91. (string cmd, object[] args) =>
  92. CheckToPostMessage((int)MSG.Home));
  93. OP.Subscribe($"{Module}.Reset",
  94. (string cmd, object[] args) =>
  95. CheckToPostMessage((int)MSG.Reset));
  96. OP.Subscribe($"{Module}.Abort",
  97. (string cmd, object[] args) =>
  98. CheckToPostMessage((int)MSG.Abort));
  99. }
  100. private void InitFsm()
  101. {
  102. EnumLoop<STATE>.ForEach((item) =>
  103. {
  104. MapState((int)item, item.ToString());
  105. });
  106. EnumLoop<MSG>.ForEach((item) =>
  107. {
  108. MapMessage((int)item, item.ToString());
  109. });
  110. EnableFsm(100,
  111. IsInstalled
  112. ? STATE.Idle
  113. : STATE.NotInstall);
  114. Transition(STATE.Idle,
  115. MSG.Disconnected, null,
  116. STATE.NotConnected);
  117. Transition(STATE.Idle,
  118. MSG.InTransfer, null,
  119. STATE.InTransfer);
  120. Transition(STATE.InTransfer,
  121. MSG.TransferComplete, null,
  122. STATE.Idle);
  123. Transition(STATE.NotConnected,
  124. MSG.Connected, null,
  125. STATE.Idle);
  126. Transition(STATE.InTransfer,
  127. MSG.Abort, fAbort,
  128. STATE.Idle);
  129. Transition(STATE.Error,
  130. MSG.Reset, null,
  131. STATE.Idle);
  132. }
  133. #region Service Functions
  134. private bool fAbort(object[] param)
  135. {
  136. if (IsOnline)
  137. {
  138. EV.PostWarningLog(Module, "Can't Abort When Online");
  139. return false;
  140. }
  141. return true;
  142. }
  143. public override bool Home(out string reason)
  144. {
  145. reason = string.Empty;
  146. return true;
  147. }
  148. public override void Reset()
  149. {
  150. base.Reset();
  151. }
  152. public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot,
  153. EnumTransferType transferType, out string reason)
  154. {
  155. reason = string.Empty;
  156. return true;
  157. }
  158. public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot,
  159. EnumTransferType transferType, out string reason)
  160. {
  161. reason = string.Empty;
  162. return true;
  163. }
  164. public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType,
  165. out string reason)
  166. {
  167. reason = string.Empty;
  168. return true;
  169. }
  170. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot,
  171. EnumTransferType transferType,
  172. out string reason)
  173. {
  174. reason = string.Empty;
  175. if (transferType == EnumTransferType.Pick && WaferManager.Instance.CheckNoWafer(Module, targetSlot))
  176. {
  177. reason = "target not has wafer";
  178. return false;
  179. }
  180. if (transferType == EnumTransferType.Place && WaferManager.Instance.CheckHasWafer(Module, targetSlot))
  181. {
  182. reason = "target already has wafer";
  183. return false;
  184. }
  185. if (Module == ModuleName.LLA.ToString())
  186. {
  187. return DEVICE.GetDevice<IoSensor>($"System.SensorEFEMRBNotExtendBFA").Value;
  188. }
  189. else if (Module == ModuleName.LLB.ToString())
  190. {
  191. return DEVICE.GetDevice<IoSensor>($"System.SensorEFEMRBNotExtendBFB").Value;
  192. }
  193. return true;
  194. }
  195. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot,
  196. EnumTransferType transferType)
  197. {
  198. CheckToPostMessage(MSG.InTransfer);
  199. }
  200. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot,
  201. EnumTransferType transferType)
  202. {
  203. if (FsmState == (int)STATE.InTransfer)
  204. CheckToPostMessage(MSG.TransferComplete);
  205. }
  206. #endregion
  207. }
  208. }