SchedulerEfemRobot.cs 3.3 KB

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