RouteManager.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.Fsm;
  7. using Aitex.Core.Common;
  8. using Aitex.Core.RT.DataCenter;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.OperationCenter;
  11. using Aitex.Core.RT.Routine;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.Util;
  14. using MECF.Framework.Common.Equipment;
  15. using MECF.Framework.Common.SubstrateTrackings;
  16. using Venus_Core;
  17. using Venus_RT.Modules.PMs;
  18. namespace Venus_RT.Modules
  19. {
  20. class RouteManager : Entity, IEntity
  21. {
  22. public enum MSG
  23. {
  24. MoveWafer,
  25. ReturnWafer,
  26. HomeUnit,
  27. PauseAuto,
  28. ResumeAuto,
  29. Stop,
  30. StartCycle,
  31. HOME,
  32. RESET,
  33. ABORT,
  34. ERROR,
  35. SetAutoMode,
  36. SetManualMode,
  37. ResetIdleCleanTime,
  38. ResetIdlePurgeTime,
  39. CreateJob,
  40. PauseJob,
  41. ResumeJob,
  42. StartJob,
  43. StopJob,
  44. AbortJob,
  45. JobDone,
  46. CassetteLeave, //For unload light control off afer job done
  47. Map,
  48. ReturnAllWafer,
  49. }
  50. public PMEntity PMA { get; private set; }
  51. public PMEntity PMB { get; private set; }
  52. public TMEntity TM { get; private set; }
  53. public LLEntity LLA { get; private set; }
  54. public LLEntity LLB { get; private set; }
  55. public EfemEntity EFEM { get; private set; }
  56. public string Name { get; set; }
  57. public RouteManager()
  58. {
  59. Name = "System";
  60. if (ModuleHelper.IsInstalled(ModuleName.PMA))
  61. PMA = new PMEntity(ModuleName.PMA);
  62. if (ModuleHelper.IsInstalled(ModuleName.PMB))
  63. PMB = new PMEntity(ModuleName.PMB);
  64. if (ModuleHelper.IsInstalled(ModuleName.TM))
  65. TM = new TMEntity();
  66. if (ModuleHelper.IsInstalled(ModuleName.LLA))
  67. LLA = new LLEntity(ModuleName.LLA);
  68. if (ModuleHelper.IsInstalled(ModuleName.LLB))
  69. LLB = new LLEntity(ModuleName.LLB);
  70. fsm = new StateMachine<RouteManager>(Name, (int)RtState.Init, 200);
  71. SubscribeOperation();
  72. }
  73. public bool Check(int msg, out string reason, params object[] args)
  74. {
  75. if (!fsm.FindTransition(fsm.State, msg))
  76. {
  77. reason = String.Format("{0} is in {1} state,can not do {2}", Name, 0, (MSG)msg);
  78. return false;
  79. }
  80. if (msg == (int)MSG.StartCycle)
  81. {
  82. //if (!IsAutoMode)
  83. {
  84. reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
  85. return false;
  86. }
  87. }
  88. reason = "";
  89. return true;
  90. }
  91. protected override bool Init()
  92. {
  93. PMA?.Initialize();
  94. PMB?.Initialize();
  95. TM?.Initialize();
  96. LLA?.Initialize();
  97. LLB?.Initialize();
  98. return true;
  99. }
  100. void SubscribeOperation()
  101. {
  102. OP.Subscribe("CreateWafer", InvokeCreateWafer);
  103. OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
  104. }
  105. private bool InvokeCreateWafer(string arg1, object[] args)
  106. {
  107. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  108. int slot = (int)args[1];
  109. WaferStatus state = WaferStatus.Normal;
  110. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  111. {
  112. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  113. {
  114. EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
  115. }
  116. else if (WaferManager.Instance.CreateWafer(chamber, slot, state) != null)
  117. {
  118. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  119. }
  120. }
  121. else
  122. {
  123. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  124. return false;
  125. }
  126. return true;
  127. }
  128. private bool InvokeDeleteWafer(string arg1, object[] args)
  129. {
  130. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  131. int slot = (int)args[1];
  132. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  133. {
  134. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  135. {
  136. WaferManager.Instance.DeleteWafer(chamber, slot);
  137. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  138. }
  139. else
  140. {
  141. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  142. }
  143. }
  144. else
  145. {
  146. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  147. return false;
  148. }
  149. return true;
  150. }
  151. }
  152. }