SchedulerModule.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. public int InTransferSlot
  56. {
  57. get
  58. {
  59. return _inTransferSlot;
  60. }
  61. }
  62. protected string _module;
  63. protected TaskType _task = TaskType.None;
  64. protected EnumTransferType _inTransferType;
  65. protected int _inTransferSlot;
  66. protected ModuleName _inProcessRobot;
  67. public Dictionary<int, long> WaferArriveTicks { get; set; }
  68. public SchedulerModule(string module)
  69. {
  70. _module = module;
  71. WaferArriveTicks = new Dictionary<int, long>();
  72. WaferArriveTicks[0] = DateTime.Now.Ticks;
  73. WaferArriveTicks[1] = WaferArriveTicks[0];
  74. }
  75. protected void LogTaskStart(TaskType cmd, string message)
  76. {
  77. EV.PostInfoLog("Scheduler", $"Task start:{_module}, {cmd}, {message}");
  78. }
  79. protected void LogTaskDone(TaskType cmd, string message)
  80. {
  81. EV.PostInfoLog("Scheduler", $"Task done:{_module}, {cmd}, {message}");
  82. }
  83. public void ResetTask()
  84. {
  85. _task = TaskType.None;
  86. }
  87. public bool WaitTransfer(ModuleName robot, EnumTransferType transferType, int slot)
  88. {
  89. _task = TaskType.TransferTarget;
  90. _inProcessRobot = robot;
  91. _inTransferType = transferType;
  92. _inTransferSlot = slot;
  93. LogTaskStart(_task, $"Note {robot} in transfer");
  94. return true;
  95. }
  96. public bool IsWaitTransfer(ModuleName robot)
  97. {
  98. return _task == TaskType.TransferTarget && _inProcessRobot == robot;
  99. }
  100. public bool IsWaitTransfer(ModuleName robot, EnumTransferType transferType)
  101. {
  102. return _task == TaskType.TransferTarget && _inProcessRobot == robot && _inTransferType==transferType;
  103. }
  104. public virtual bool StopWaitTransfer(ModuleName robot)
  105. {
  106. LogTaskDone(_task, $"Note {robot} transfer complete");
  107. _inProcessRobot = ModuleName.System;
  108. _task = TaskType.None;
  109. WaferArriveTicks[_inTransferSlot] = DateTime.Now.Ticks;
  110. return true;
  111. }
  112. public bool HasWafer(int slot)
  113. {
  114. return WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(_module), slot);
  115. }
  116. public bool NoWafer(int slot)
  117. {
  118. return WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(_module), slot);
  119. }
  120. public virtual bool IsReadyForPick(ModuleName robot, int slot, Hand blade)
  121. {
  122. return true;
  123. }
  124. public virtual bool IsReadyForPlace(ModuleName robot, int slot, Hand blade)
  125. {
  126. return true;
  127. }
  128. public virtual bool PrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  129. {
  130. return true;
  131. }
  132. public virtual bool PostTransfer(ModuleName robot, EnumTransferType type, int slot)
  133. {
  134. StopWaitTransfer(robot);
  135. return true;
  136. }
  137. public virtual bool PostTransfer(ModuleName robot )
  138. {
  139. StopWaitTransfer(robot);
  140. return true;
  141. }
  142. public virtual bool Process(string recipeName, bool isCleanRecipe, bool withDummyWafer, WaferInfo wafer)
  143. {
  144. return true;
  145. }
  146. public virtual bool Cooling(int coolingTime)
  147. {
  148. return true;
  149. }
  150. public virtual bool Preheating(float temperature)
  151. {
  152. return true;
  153. }
  154. }
  155. }