SchedulerEfemRobot.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.RT.Log;
  8. using Aitex.Core.Util;
  9. using Aitex.Sorter.Common;
  10. using VirgoRT.Modules;
  11. using MECF.Framework.Common.Equipment;
  12. using MECF.Framework.Common.SubstrateTrackings;
  13. namespace VirgoRT.Scheduler
  14. {
  15. public class SchedulerEfemRobot : SchedulerModule
  16. {
  17. public override bool IsAvailable
  18. {
  19. get { return _entity.IsIdle && /*_entity.IsOnline && */CheckTaskDone(); }
  20. }
  21. public override bool IsOnline
  22. {
  23. get { return _entity.IsOnline; }
  24. }
  25. public override bool IsError
  26. {
  27. get { return _entity.IsError; }
  28. }
  29. private EfemEntity _entity = null;
  30. private Hand _hand;
  31. private int _entityTaskToken = (int)FSM_MSG.NONE;
  32. //private Hand _taskSwapPickHand;
  33. //private Hand _taskSwapPlaceHand;
  34. //private int _taskSwapPickSlot;
  35. //private int _taskSwapPlaceSlot;
  36. public ModuleName PreviousTarget { get; set; }
  37. public SchedulerEfemRobot() : base(ModuleName.EfemRobot.ToString())
  38. {
  39. _entity = Singleton<RouteManager>.Instance.EFEM;
  40. PreviousTarget = ModuleName.System;
  41. }
  42. public bool IsReadyForPick(Hand blade)
  43. {
  44. return WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)blade);
  45. }
  46. public bool IsReadyForPlace(Hand blade)
  47. {
  48. return WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)blade);
  49. }
  50. public bool Pick(ModuleName source, int slot, Hand hand)
  51. {
  52. _task = TaskType.Pick;
  53. _hand = hand;
  54. _entityTaskToken = _entity.InvokePick(source, slot, hand, WaferManager.Instance.GetWafer(source, slot).Size);
  55. PreviousTarget = source;
  56. LogTaskStart(_task, $"{source}.{slot + 1}=>{Module}.{hand}");
  57. return true;
  58. }
  59. public bool Place(ModuleName destination, int slot, Hand hand)
  60. {
  61. _task = TaskType.Place;
  62. _hand = hand;
  63. _entityTaskToken = _entity.InvokePlace(destination, slot, hand, WaferManager.Instance.GetWafer(ModuleName.EfemRobot, 0).Size);
  64. LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}");
  65. return true;
  66. }
  67. public bool Map(ModuleName destination )
  68. {
  69. _task = TaskType.Map;
  70. _entityTaskToken = _entity.InvokeMap(destination.ToString());
  71. LogTaskStart(_task, $"{Module} mapping");
  72. PreviousTarget = destination;
  73. return true;
  74. }
  75. public bool Monitor()
  76. {
  77. return true;
  78. }
  79. public bool CheckTaskDone()
  80. {
  81. bool ret = false;
  82. switch (_task)
  83. {
  84. case TaskType.None:
  85. ret = true;
  86. break;
  87. case TaskType.Pick:
  88. ret = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)_hand);
  89. if (ret)
  90. {
  91. WaferArriveTicks[(int) _hand] = DateTime.Now.Ticks;
  92. }
  93. break;
  94. case TaskType.Place:
  95. ret = WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_hand);
  96. break;
  97. case TaskType.Map:
  98. ret = _entity.CheckAcked(_entityTaskToken) && _entity.IsIdle;
  99. break;
  100. }
  101. if (ret && _task != TaskType.None)
  102. {
  103. LogTaskDone(_task, "");
  104. _task = TaskType.None;
  105. }
  106. return ret;
  107. }
  108. }
  109. }