UnloadFoupRoutine.cs 4.1 KB

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