SRDInitializeHomeRoutine.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.SRD;
  7. using CyberX8_RT.Modules.Transporter;
  8. using MECF.Framework.Common.Routine;
  9. using MECF.Framework.Common.Utilities;
  10. namespace CyberX8_RT.Modules.SRD
  11. {
  12. public class SRDInitializeHomeRoutine : RoutineBase, IRoutine
  13. {
  14. private enum InitializeStep
  15. {
  16. Initialize,
  17. InitializeWait,
  18. SwitchOn,
  19. SwitchOnWait,
  20. Home,
  21. HomeWait,
  22. End
  23. }
  24. #region 内部变量
  25. private SRDInitializeRoutine _initializeRoutine;
  26. private SRDSwitchOnRoutine _switchOnRoutine;
  27. private SRDHomeRoutine _homeRoutine;
  28. #endregion
  29. /// <summary>
  30. /// 构造函数
  31. /// </summary>
  32. /// <param name="module"></param>
  33. public SRDInitializeHomeRoutine(string module) : base(module)
  34. {
  35. _initializeRoutine = new SRDInitializeRoutine(module);
  36. _switchOnRoutine = new SRDSwitchOnRoutine(module);
  37. _homeRoutine = new SRDHomeRoutine(module);
  38. }
  39. /// <summary>
  40. /// 中止
  41. /// </summary>
  42. public void Abort()
  43. {
  44. Runner.Stop("Manual Abort");
  45. }
  46. /// <summary>
  47. /// 监控
  48. /// </summary>
  49. /// <returns></returns>
  50. public RState Monitor()
  51. {
  52. Runner.Run(InitializeStep.Initialize, () => _initializeRoutine.Start() == RState.Running, _delay_1ms)
  53. .WaitWithStopCondition(InitializeStep.InitializeWait, () => CommonFunction.CheckRoutineEndState(_initializeRoutine), () => CommonFunction.CheckRoutineStopState(_initializeRoutine))
  54. .Run(InitializeStep.SwitchOn, () => _switchOnRoutine.Start() == RState.Running, _delay_1ms)
  55. .WaitWithStopCondition(InitializeStep.SwitchOnWait, () => CommonFunction.CheckRoutineEndState(_switchOnRoutine), () => CommonFunction.CheckRoutineStopState(_switchOnRoutine))
  56. .Run(InitializeStep.Home, () => _homeRoutine.Start() == RState.Running, _delay_1ms)
  57. .WaitWithStopCondition(InitializeStep.HomeWait, () => CommonFunction.CheckRoutineEndState(_homeRoutine), () => CommonFunction.CheckRoutineStopState(_homeRoutine))
  58. .End(InitializeStep.End, NullFun, _delay_1ms);
  59. return Runner.Status;
  60. }
  61. /// <summary>
  62. /// 启动
  63. /// </summary>
  64. /// <param name="objs"></param>
  65. /// <returns></returns>
  66. public RState Start(params object[] objs)
  67. {
  68. if (!CheckPreCondition())
  69. {
  70. return RState.Failed;
  71. }
  72. return Runner.Start(Module, "Start Initialize Home");
  73. }
  74. private bool CheckPreCondition()
  75. {
  76. SrdCommonDevice srdCommon = DEVICE.GetDevice<SrdCommonDevice>($"{Module}.Common");
  77. bool isSimulator = SC.GetValue<bool>("System.IsSimulatorMode");
  78. if (!isSimulator && srdCommon.CommonData.WaferPresent)
  79. {
  80. LOG.WriteLog(eEvent.ERR_SRD, Module, $"Wafer is present");
  81. return false;
  82. }
  83. if (!srdCommon.CommonData.ChuckVacuum)
  84. {
  85. LOG.WriteLog(eEvent.ERR_SRD, Module, $"Chuck Vacuum is on");
  86. return false;
  87. }
  88. int vacuumOffLimit = SC.GetValue<int>("SRD.ChuckVacuumOffLimit");
  89. if (srdCommon.CommonData.VacuumValue < vacuumOffLimit)
  90. {
  91. LOG.WriteLog(eEvent.ERR_SRD, Module, $"VacuumValue:{srdCommon.CommonData.VacuumValue}, VacuumOff Limit:{vacuumOffLimit}");
  92. return false;
  93. }
  94. if (srdCommon.CommonData.ChuckATMOn)
  95. {
  96. LOG.WriteLog(eEvent.ERR_SRD, Module, $"Chuck ATM is on");
  97. return false;
  98. }
  99. return true;
  100. }
  101. }
  102. }