SchedulerLoadLock.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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.Device;
  7. using Aitex.Core.RT.Fsm;
  8. using Aitex.Core.RT.Log;
  9. using Aitex.Core.Util;
  10. using Aitex.Sorter.Common;
  11. using EfemDualSchedulerLib.Schedulers;
  12. using MECF.Framework.Common.Equipment;
  13. using MECF.Framework.Common.Schedulers;
  14. using MECF.Framework.Common.SubstrateTrackings;
  15. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadLocks;
  16. using MECF.Framework.RT.ModuleLibrary.BufferModules;
  17. using MECF.Framework.RT.ModuleLibrary.LLModules;
  18. using MECF.Framework.RT.ModuleLibrary.SystemModules;
  19. namespace EfemDualSchedulerLib.Schedulers
  20. {
  21. public class SchedulerLoadLock : SchedulerModule
  22. {
  23. public override bool IsAvailable
  24. {
  25. get { return _loadLock.IsReady && _loadLock.IsOnline && CheckTaskDone(); }
  26. }
  27. public override bool IsOnline
  28. {
  29. get { return _loadLock.IsOnline; }
  30. }
  31. public override bool IsError
  32. {
  33. get { return _loadLock.IsError; }
  34. }
  35. private LoadLockModuleBase _loadLock;
  36. public LoadLockModuleBase Entity
  37. {
  38. get
  39. {
  40. return _loadLock;
  41. }
  42. }
  43. private ModuleName _taskRobot;
  44. private int _taskSlot;
  45. private int _entityTaskToken = (int)FSM_MSG.NONE;
  46. private EnumTransferType TransferType { get; set; }
  47. public SchedulerLoadLock(ModuleName module) : base(module.ToString())
  48. {
  49. _loadLock = EquipmentManager.Modules[module] as LoadLockModuleBase;
  50. }
  51. void OnFieldChanged(object sender, string name, object fieldValue)
  52. {
  53. if (name == nameof(_loadLock.IsOnline))
  54. {
  55. bool v = (bool)fieldValue;
  56. if (!v && _task != TaskType.None)
  57. {
  58. LOG.Warning($"{Module} abort {_task} since offline");
  59. _task = TaskType.None;
  60. }
  61. }
  62. }
  63. public void Reset()
  64. {
  65. _task = TaskType.None;
  66. }
  67. public override bool PrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  68. {
  69. _task = TaskType.PrepareTransfer;
  70. _taskRobot = robot;
  71. _taskSlot = slot;
  72. TransferType = type;
  73. _loadLock.PrepareTransfer(robot, Hand.Blade1, slot, type, out string reason);
  74. LogTaskStart(_task, $"{robot} {type} slot {slot + 1}");
  75. return _entityTaskToken != (int)FSM_MSG.NONE;
  76. }
  77. internal bool CheckAtAtm()
  78. {
  79. //LoadLock deviceLL = DEVICE.GetDevice<LoadLock>(_module);
  80. //return deviceLL.CheckAtm();
  81. return true;
  82. }
  83. internal bool CheckAtVacuum()
  84. {
  85. //LoadLock deviceLL = DEVICE.GetDevice<LoadLock>(_module);
  86. //return deviceLL.CheckVacuum();
  87. return true;
  88. }
  89. public override bool IsReadyForPick(ModuleName robot, Hand hand, int slot)
  90. {
  91. if (!_loadLock.CheckReadyForTransfer(robot, hand, slot, EnumTransferType.Pick, out string reason))
  92. return false;
  93. return WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(_module), slot);
  94. }
  95. public override bool IsReadyForPlace(ModuleName robot, Hand hand, int slot)
  96. {
  97. if (!_loadLock.CheckReadyForTransfer(robot, hand, slot, EnumTransferType.Place, out string reason))
  98. return false;
  99. return WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(_module), slot);
  100. }
  101. public override bool Cooling(int coolingTime)
  102. {
  103. _task = TaskType.Cooling;
  104. //_entityTaskToken = _loadLock.InvokeCooling(coolingTime);
  105. LogTaskStart(_task, $"{Module} cooling {coolingTime} seconds");
  106. return _entityTaskToken != (int)FSM_MSG.NONE;
  107. }
  108. public bool Monitor()
  109. {
  110. return true;
  111. }
  112. public bool CheckTaskDone()
  113. {
  114. bool ret = false;
  115. switch (_task)
  116. {
  117. case TaskType.None:
  118. ret = true;
  119. break;
  120. case TaskType.PrepareTransfer:
  121. //ret = _loadLock.CheckReadyForTransfer(_taskRobot, TransferType);
  122. break;
  123. case TaskType.PreCooling:
  124. //ret = _loadLock.IsPreCoolingDone();
  125. break;
  126. }
  127. if (ret && _task != TaskType.None)
  128. {
  129. LogTaskDone(_task, "");
  130. _task = TaskType.None;
  131. }
  132. return ret;
  133. }
  134. }
  135. }