EfemMapRoutine.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Device.Unit;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using Aitex.Sorter.Common;
  8. using JetEfemLib.LPs;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.RT.ModuleLibrary.LPModules;
  11. using MECF.Framework.RT.ModuleLibrary.SystemModules;
  12. namespace JetEfemLib.Efems
  13. {
  14. public class EfemMapRoutine : ModuleRoutineBase, IStepRoutine
  15. {
  16. enum RoutineStep
  17. {
  18. CheckTargetEnableMap,
  19. Map,
  20. End,
  21. }
  22. private int _mapTimeout;
  23. private ModuleName _target;
  24. private int _thicknessIndex;
  25. //private Hand _hand;
  26. //private bool _autoHand;
  27. private EfemModule _efemModule;
  28. public EfemMapRoutine(EfemModule efemModule) : base("EFEM")
  29. {
  30. Name = "Map";
  31. _efemModule = efemModule;
  32. }
  33. public RState Start(params object[] objs)
  34. {
  35. _mapTimeout = SC.GetValue<int>("EFEM.EfemRobot.MapTimeout");
  36. Reset();
  37. _thicknessIndex = 0;
  38. //if (ModuleHelper.IsLoadPort(_target))
  39. //{
  40. // LoadPortModule lp = Singleton<EquipmentManager>.Instance.Modules[_target] as LoadPortModule;
  41. // _thicknessIndex = lp.LPDevice.GetThicknessIndex();
  42. //}
  43. Notify($"Start map {_target}");
  44. return Runner.Start(ModuleName.EfemRobot.ToString(), Name);
  45. }
  46. public void Init(ModuleName source)
  47. {
  48. //_autoHand = true;
  49. _target = source;
  50. }
  51. public void Abort()
  52. {
  53. Notify($"Abort map {_target}");
  54. }
  55. public RState Monitor()
  56. {
  57. Runner.Wait(RoutineStep.CheckTargetEnableMap, CheckTargetEnableMap)
  58. .Run(RoutineStep.Map, Map, CheckMap, _mapTimeout * 1000)
  59. .End(RoutineStep.End, NullFun, _delay_50ms);
  60. return Runner.Status;
  61. }
  62. public bool CheckTargetEnableMap()
  63. {
  64. Notify($"Check {_target} enable map");
  65. if (!_efemModule.RobotDevice.IsReady())
  66. {
  67. Stop($"Can not map {_target}, EfemRobot is not ready");
  68. return false;
  69. }
  70. if (!ModuleHelper.IsLoadPort(_target) && !ModuleHelper.IsLoadLock(_target))
  71. {
  72. Stop($"Can not map {_target}, only LP or Buf supported");
  73. return false;
  74. }
  75. if (_target == ModuleName.LLA && DEVICE.GetDevice<IoSensor>($"System.SensorBufferABigWaferProtrusion").Value)
  76. {
  77. Stop($"Can not map {_target}, SensorBufferABigWaferProtrusion is on");
  78. return false;
  79. }
  80. if (_target == ModuleName.LLB && DEVICE.GetDevice<IoSensor>($"System.SensorBufferBBigWaferProtrusion").Value)
  81. {
  82. Stop($"Can not map {_target}, SensorBufferBBigWaferProtrusion is on");
  83. return false;
  84. }
  85. if (ModuleHelper.IsLoadPort(_target))
  86. {
  87. LoadPortModuleBase lp = EquipmentManager.Modules[_target] as LoadPortModuleBase;
  88. if (!lp.CheckReadyForMap(ModuleName.EfemRobot, Hand.Blade1, out string reason))
  89. {
  90. Stop(reason);
  91. return false;
  92. }
  93. }
  94. return true;
  95. }
  96. public bool Map()
  97. {
  98. Notify($"Robot start map {_target}");
  99. string reason;
  100. if (!_efemModule.RobotDevice.Map(_target, _thicknessIndex, out reason))
  101. {
  102. Stop(reason);
  103. return false;
  104. }
  105. return true;
  106. }
  107. bool CheckMap()
  108. {
  109. return !_efemModule.RobotDevice.IsError && _efemModule.RobotDevice.IsIdle;
  110. }
  111. }
  112. }