SchedulerAligner.cs 3.2 KB

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