RouteManager.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 string Name { get; set; }
  53. public RouteManager()
  54. {
  55. Name = "System";
  56. if (SC.GetValue<bool>("System.PMAIsInstalled"))
  57. PMA = new PMEntity(ModuleName.PMA);
  58. if (SC.GetValue<bool>("System.PMBIsInstalled"))
  59. PMB = new PMEntity(ModuleName.PMB);
  60. fsm = new StateMachine<RouteManager>(Name, (int)RtState.Init, 200);
  61. }
  62. public bool Check(int msg, out string reason, params object[] args)
  63. {
  64. if (!fsm.FindTransition(fsm.State, msg))
  65. {
  66. reason = String.Format("{0} is in {1} state,can not do {2}", Name, 0, (MSG)msg);
  67. return false;
  68. }
  69. if (msg == (int)MSG.StartCycle)
  70. {
  71. //if (!IsAutoMode)
  72. {
  73. reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
  74. return false;
  75. }
  76. }
  77. reason = "";
  78. return true;
  79. }
  80. protected override bool Init()
  81. {
  82. PMA?.Initialize();
  83. PMB?.Initialize();
  84. return true;
  85. }
  86. void SubscribeOperation()
  87. {
  88. OP.Subscribe("CreateWafer", InvokeCreateWafer);
  89. OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
  90. }
  91. private bool InvokeCreateWafer(string arg1, object[] args)
  92. {
  93. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  94. int slot = (int)args[1];
  95. WaferStatus state = WaferStatus.Normal;
  96. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  97. {
  98. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  99. {
  100. EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
  101. }
  102. else if (WaferManager.Instance.CreateWafer(chamber, slot, state) != null)
  103. {
  104. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  105. }
  106. }
  107. else
  108. {
  109. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  110. return false;
  111. }
  112. return true;
  113. }
  114. private bool InvokeDeleteWafer(string arg1, object[] args)
  115. {
  116. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  117. int slot = (int)args[1];
  118. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  119. {
  120. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  121. {
  122. WaferManager.Instance.DeleteWafer(chamber, slot);
  123. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  124. }
  125. else
  126. {
  127. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  128. }
  129. }
  130. else
  131. {
  132. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  133. return false;
  134. }
  135. return true;
  136. }
  137. }
  138. }