LoadPortLoadRoutine.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using Aitex.Core.Common;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.Routine;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Sorter.Common;
  9. using JetEfemLib.Efems;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  13. using MECF.Framework.RT.ModuleLibrary.SystemModules;
  14. namespace JetEfemLib.LPs
  15. {
  16. class LoadPortLoadRoutine : ModuleRoutineBase, IStepRoutine
  17. {
  18. enum RoutineStep
  19. {
  20. Clamp,
  21. Dock,
  22. OpenDoor,
  23. QueryStatus1,
  24. WaitRobotIdle,
  25. Map,
  26. GetWaferInfo,
  27. QueryStatus2,
  28. End,
  29. }
  30. private int _timeout = 0;
  31. private LoadPortModule _lpModule;
  32. public LoadPortLoadRoutine(LoadPortModule lpModule) : base(lpModule.Module)
  33. {
  34. _lpModule = lpModule;
  35. Name = "Load";
  36. }
  37. public bool Initalize()
  38. {
  39. return true;
  40. }
  41. public RState Start(params object[] objs)
  42. {
  43. Reset();
  44. _timeout = SC.GetValue<int>("EFEM.LoadPort.HomeTimeout");
  45. var waferSize = _lpModule.LPDevice.GetCurrentWaferSize();
  46. if (waferSize != WaferSize.WS8 && waferSize != WaferSize.WS12)
  47. {
  48. EV.PostWarningLog(Module, $"{Module} get wafer size abnormal, can not load");
  49. return RState.Failed;
  50. }
  51. if (!_lpModule.LPDevice.IsPresent || !_lpModule.LPDevice.IsPlacement)
  52. {
  53. EV.PostWarningLog(Module, $"{Module} not found carrier, can not load");
  54. return RState.Failed;
  55. }
  56. return Runner.Start(_lpModule.Module, Name);
  57. }
  58. public RState Monitor()
  59. {
  60. Runner.Run(RoutineStep.Clamp, Clamp, CheckDevice, _timeout * 1000)
  61. //.Run(RoutineStep.Dock, Dock, CheckDevice, _timeout *1000)
  62. .Run(RoutineStep.OpenDoor, OpenDoor, CheckDevice, _timeout * 1000)
  63. .Run(RoutineStep.GetWaferInfo, QueryMapInfo, CheckDevice, _timeout * 1000)
  64. .End(RoutineStep.QueryStatus2, QueryStatus, CheckOpenDoor, _timeout * 1000);
  65. return Runner.Status;
  66. }
  67. bool Clamp()
  68. {
  69. Notify($"Start clamp {_lpModule.LPDevice.Name}");
  70. if (!_lpModule.LPDevice.Clamp(out string reason))
  71. {
  72. Stop(reason);
  73. return false;
  74. }
  75. return true;
  76. }
  77. bool Dock()
  78. {
  79. if (!_lpModule.LPDevice.Dock(out string reason))
  80. {
  81. Stop(reason);
  82. return false;
  83. }
  84. return true;
  85. }
  86. bool CheckDevice()
  87. {
  88. return !(_lpModule.LPDevice.Error || _lpModule.LPDevice.IsBusy);
  89. }
  90. bool OpenDoor()
  91. {
  92. Notify($"Start OpenDoorAndMap {_lpModule.LPDevice.Name}");
  93. if (!_lpModule.LPDevice.OpenDoor(out string reason))
  94. {
  95. Stop(reason);
  96. return false;
  97. }
  98. return true;
  99. }
  100. bool CheckOpenDoor()
  101. {
  102. return !(_lpModule.LPDevice.Error || _lpModule.LPDevice.IsBusy || _lpModule.LPDevice.DoorState != FoupDoorState.Open);
  103. }
  104. bool QueryMapInfo()
  105. {
  106. Notify($"Start to get wafer info {_lpModule.LPDevice.Name}");
  107. if (!_lpModule.LPDevice.GetMapInfo(out string reason))
  108. {
  109. Stop(reason);
  110. return false;
  111. }
  112. return true;
  113. }
  114. bool QueryStatus()
  115. {
  116. Notify($"Start query status {_lpModule.LPDevice.Name}");
  117. if (!_lpModule.LPDevice.QueryState(out string reason))
  118. {
  119. Stop(reason);
  120. return false;
  121. }
  122. return true;
  123. }
  124. public void Abort()
  125. {
  126. }
  127. }
  128. }