SchedulerModule.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.Util;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.SubstrateTrackings;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using Aitex.Core.RT.Device;
  11. using Aitex.Core.RT.Event;
  12. using Aitex.Core.RT.Log;
  13. using Aitex.Sorter.Common;
  14. using VirgoRT.Modules;
  15. using MECF.Framework.Common.Schedulers;
  16. using VirgoRT.Devices;
  17. using Aitex.Core.Common;
  18. namespace VirgoRT.Scheduler
  19. {
  20. public class SchedulerModule
  21. {
  22. public enum TaskType
  23. {
  24. None,
  25. PrepareTransfer,
  26. Pick,
  27. Place,
  28. PickAndPlace,
  29. PostTransfer,
  30. Preprocess,
  31. Process,
  32. PostProcess,
  33. IdlePurgeProcess,
  34. IdleCleanProcess,
  35. PreJobProcess,
  36. CompleteJobProcess,
  37. OpenCover,
  38. CloseCover,
  39. Load,
  40. Unload,
  41. Align,
  42. TransferTarget,
  43. Cooling,
  44. Heating,
  45. Map,
  46. Goto,
  47. }
  48. public ModuleName Module
  49. {
  50. get { return ModuleHelper.Converter(_module); }
  51. }
  52. public virtual bool IsAvailable { get; }
  53. public virtual bool IsOnline { get; }
  54. public virtual bool IsError { get; }
  55. protected string _module;
  56. protected TaskType _task = TaskType.None;
  57. protected EnumTransferType _inTransferType;
  58. protected int _inTransferSlot;
  59. protected ModuleName _inProcessRobot;
  60. public Dictionary<int, long> WaferArriveTicks { get; set; }
  61. private R_TRIG[] firstDetectWaferArriveTrigs = new R_TRIG[25];
  62. public SchedulerModule(string module)
  63. {
  64. _module = module;
  65. WaferArriveTicks = new Dictionary<int, long>();
  66. for(int i=0;i<firstDetectWaferArriveTrigs.Length;i++)
  67. {
  68. firstDetectWaferArriveTrigs[i] = new R_TRIG();
  69. }
  70. WaferArriveTicks[0] = DateTime.Now.Ticks;
  71. WaferArriveTicks[1] = WaferArriveTicks[0];
  72. }
  73. protected void LogTaskStart(TaskType cmd, string message)
  74. {
  75. EV.PostInfoLog("Scheduler", $"Task start:{_module}, {cmd}, {message}");
  76. }
  77. protected void LogTaskDone(TaskType cmd, string message)
  78. {
  79. EV.PostInfoLog("Scheduler", $"Task done:{_module}, {cmd}, {message}");
  80. }
  81. public void ResetTask()
  82. {
  83. _task = TaskType.None;
  84. }
  85. public bool WaitTransfer(ModuleName robot, EnumTransferType transferType, int slot)
  86. {
  87. _task = TaskType.TransferTarget;
  88. _inProcessRobot = robot;
  89. _inTransferType = transferType;
  90. _inTransferSlot = slot;
  91. LogTaskStart(_task, $"Note {robot} in transfer");
  92. return true;
  93. }
  94. public bool IsWaitTransfer(ModuleName robot)
  95. {
  96. return _task == TaskType.TransferTarget && _inProcessRobot == robot;
  97. }
  98. public virtual bool StopWaitTransfer(ModuleName robot)
  99. {
  100. LogTaskDone(_task, $"Note {robot} transfer complete");
  101. _inProcessRobot = ModuleName.System;
  102. _task = TaskType.None;
  103. WaferArriveTicks[_inTransferSlot] = DateTime.Now.Ticks;
  104. return true;
  105. }
  106. public bool HasWafer(int slot)
  107. {
  108. return WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(_module), slot);
  109. }
  110. public bool NoWafer(int slot)
  111. {
  112. return WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(_module), slot);
  113. }
  114. public virtual bool IsReadyForPick(ModuleName robot, int slot, Hand blade)
  115. {
  116. return true;
  117. }
  118. public virtual bool IsReadyForPlace(ModuleName robot, int slot, Hand blade)
  119. {
  120. return true;
  121. }
  122. public virtual bool PrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  123. {
  124. return true;
  125. }
  126. public virtual bool PostTransfer(ModuleName robot, EnumTransferType type, int slot)
  127. {
  128. StopWaitTransfer(robot);
  129. return true;
  130. }
  131. public virtual bool PostTransfer(ModuleName robot )
  132. {
  133. StopWaitTransfer(robot);
  134. return true;
  135. }
  136. public virtual bool Process(string recipeName, bool isCleanRecipe, bool withDummyWafer, WaferInfo wafer)
  137. {
  138. return true;
  139. }
  140. public virtual bool Cooling(int coolingTime)
  141. {
  142. return true;
  143. }
  144. public virtual bool Preheating(float temperature)
  145. {
  146. return true;
  147. }
  148. public virtual WaferInfo GetWaferInfo(int slot)
  149. {
  150. return WaferManager.Instance.GetWafer(ModuleHelper.Converter(_module), slot);
  151. }
  152. public bool FirstDetectWaferArrive(int slot)
  153. {
  154. firstDetectWaferArriveTrigs[slot].CLK = HasWafer(slot);
  155. return firstDetectWaferArriveTrigs[slot].Q;
  156. }
  157. }
  158. }