SchedulerAligner.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.Schedulers;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using VirgoRT.Scheduler;
  13. namespace VirgoRT.Modules.Schedulers
  14. {
  15. public class SchedulerAligner : 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 bool _isCooling;
  31. private DeviceTimer _timerCooling = new DeviceTimer();
  32. private float _paramCoolingTime = 0;
  33. public SchedulerAligner(ModuleName chamber) : base(chamber.ToString())
  34. {
  35. _entity = Singleton<RouteManager>.Instance.EFEM;
  36. _isCooling = chamber == ModuleName.Cooling1 || chamber == ModuleName.Cooling2;
  37. }
  38. public override bool IsReadyForPick(ModuleName robot, int slot, Hand blade)
  39. {
  40. return WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(_module), slot);
  41. }
  42. public override bool IsReadyForPlace(ModuleName robot, int slot, Hand blade)
  43. {
  44. return WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(_module), slot);
  45. }
  46. public override bool Cooling(int coolingTime)
  47. {
  48. _paramCoolingTime = coolingTime;
  49. return base.Cooling(coolingTime);
  50. }
  51. public bool Monitor()
  52. {
  53. return true;
  54. }
  55. public bool Align(float time)
  56. {
  57. _task = TaskType.Align;
  58. LogTaskStart(_task, _isCooling ? $"Cooling {time} seconds": $"Aligning");
  59. _paramCoolingTime = time;
  60. _timerCooling.Start(_paramCoolingTime * 1000);
  61. //token = _entity.InvokeAlign(Module.ToString(), time);
  62. return true;// _token != (int)FSM_MSG.NONE;
  63. }
  64. public override bool PostTransfer(ModuleName robot, EnumTransferType type, int slot)
  65. {
  66. StopWaitTransfer(robot);
  67. if (type == EnumTransferType.Place)
  68. {
  69. _task = TaskType.Align;
  70. LogTaskStart(_task, $"Waiting {_paramCoolingTime} seconds");
  71. _timerCooling.Start(_paramCoolingTime*1000);
  72. }
  73. return true;
  74. }
  75. public override bool PostTransfer(ModuleName robot)
  76. {
  77. StopWaitTransfer(robot);
  78. return true;
  79. }
  80. public bool CheckTaskDone()
  81. {
  82. bool ret = false;
  83. switch (_task)
  84. {
  85. case TaskType.None:
  86. ret = true;
  87. break;
  88. case TaskType.Align:
  89. ret = _timerCooling.IsTimeout() && /* _entity.CheckAcked(_token) &&*/ _entity.IsIdle;
  90. break;
  91. }
  92. if (ret && _task != TaskType.None)
  93. {
  94. LogTaskDone(_task, "");
  95. _task = TaskType.None;
  96. }
  97. return ret;
  98. }
  99. }
  100. }