UnloadFoupRoutine.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using Aitex.Sorter.Common;
  6. using athosRT.tool;
  7. using athosRT.FSM;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  10. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
  11. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using MECF.Framework.Common.SubstrateTrackings;
  18. namespace athosRT.Modules.LPs
  19. {
  20. public class UnloadFoupRoutine : ModuleRoutineBase, FSM.IRoutine
  21. {
  22. int _timeout = -1;
  23. public ModuleName _chamber { get; set; }
  24. private RobotBaseDevice _robot = null;
  25. private LoadPortBaseDevice _device = (LoadPortBaseDevice)null;
  26. private string _reason = string.Empty;
  27. public UnloadFoupRoutine(ModuleName chamber, RobotBaseDevice robot) : base(chamber)
  28. {
  29. _chamber = chamber;
  30. _timeout = 3000;
  31. _robot = robot;
  32. }
  33. public void Abort()
  34. {
  35. }
  36. public RState Start(params object[] objs)
  37. {
  38. Reset();
  39. _device = DEVICE.GetDevice<LoadPortBaseDevice>(this._chamber.ToString());
  40. ModuleName chamber = this._chamber;
  41. string module = chamber.ToString();
  42. object[] objArray = new object[1];
  43. chamber = this._chamber;
  44. objArray[0] = (object)chamber.ToString();
  45. //EV.PostMessage<EventEnum>(module, EventEnum.UnloadFOUPStart, objArray);
  46. string reason = string.Empty;
  47. LogObject.Info(this._chamber.ToString(), "Check DockState");
  48. if (this._device.DockState == FoupDockState.Undocked)
  49. {
  50. LogObject.Warning(this._chamber.ToString(), $"lp is unload, can't do again");
  51. return RState.Failed;
  52. }
  53. LogObject.Info(this._chamber.ToString(), "Check LPRobotActionIntervene && CheckLoadportMotionInterlock");
  54. if (SC.GetValue<bool>("System.LPRobotActionIntervene") && !CheckLoadportMotionInterlock())
  55. {
  56. LogObject.Warning(this._chamber.ToString(), "LPRobotActionIntervene && CheckLoadportMotionInterlock");
  57. return RState.Failed;
  58. }
  59. LogObject.Info(this._chamber.ToString(), "Check Is Enable Unload");
  60. if (!this._device.IsEnableUnload(out reason))
  61. {
  62. LogObject.Warning(this._chamber.ToString(), "Is not Enable Unload");
  63. return RState.Failed;
  64. }
  65. LogObject.Info(this._chamber.ToString(), "Is going to Unloadfoup");
  66. return Runner.Start(Module, $"{Module}=>UnloadFoup");
  67. }
  68. public RState Monitor()
  69. {
  70. Runner.Run(UnloadFoupStep.Unload, Unload, WaitLoadportMotion, _timeout)
  71. .End(UnloadFoupStep.WaitLoadportMotion, NullFun, 500);
  72. //.End(UnloadFoupStep.WaitLoadportMotion, WaitLoadportMotion, _timeout);
  73. return Runner.Status;
  74. }
  75. public bool Unload() => _device.Unload(out _reason);
  76. protected bool WaitLoadportMotion()
  77. {
  78. LogObject.Info(Module.ToString(), "正在等待LoadportMotion");
  79. if (_device.CurrentState == LoadPortStateEnum.Error)
  80. return false;
  81. if (!_device.IsReady())
  82. return false;
  83. LogObject.Info(Module.ToString(), "等待Load port Motion完毕");
  84. //Clear WaferInfo
  85. WaferManager.Instance.DeleteWafer(Module, 0, 25);
  86. return true;
  87. }
  88. public bool CheckLoadportMotionInterlock()
  89. {
  90. if (_robot.RobotState != RobotStateEnum.Idle)
  91. {
  92. LogObject.Info(Module.ToString(), "robot非空闲状态");
  93. return false;
  94. }
  95. if (_robot.IsReady())
  96. {
  97. LogObject.Info(Module.ToString(), "robot尚未准备好");
  98. return true;
  99. }
  100. return false;
  101. }
  102. public enum UnloadFoupStep {
  103. Unload,
  104. WaitLoadportMotion
  105. }
  106. }
  107. }