EfemHomeAllRoutine.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.RT.Core.Applications;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes;
  9. using MECF.Framework.RT.ModuleLibrary.AlignerModules;
  10. using MECF.Framework.RT.ModuleLibrary.LPModules;
  11. using MECF.Framework.RT.ModuleLibrary.SystemModules;
  12. namespace FutureEfemLib.Efems
  13. {
  14. class EfemHomeAllRoutine : ModuleRoutine, IRoutine
  15. {
  16. enum RoutineStep
  17. {
  18. HomeRobot,
  19. HomeOtherModules,
  20. }
  21. private IRoutine _homeRobotRoutine;
  22. private AlignerModuleBase _aligner;
  23. private LoadPortModuleBase _lp1;
  24. private LoadPortModuleBase _lp2;
  25. private LoadPortModuleBase _lp3;
  26. public EfemHomeAllRoutine(EfemModule module)
  27. {
  28. Module = ModuleName.EfemRobot.ToString();
  29. Name = "Home All";
  30. _homeRobotRoutine = new EfemHomeRoutine(module);
  31. _aligner = EquipmentManager.Modules[ModuleName.Aligner] as AlignerModuleBase;
  32. _lp1 = EquipmentManager.Modules[ModuleName.LP1] as LoadPortModuleBase;
  33. _lp2 = EquipmentManager.Modules[ModuleName.LP2] as LoadPortModuleBase;
  34. _lp3 = EquipmentManager.Modules[ModuleName.LP3] as LoadPortModuleBase;
  35. System.Diagnostics.Debug.Assert(_aligner!=null);
  36. System.Diagnostics.Debug.Assert(_lp1 != null);
  37. System.Diagnostics.Debug.Assert(_lp2 != null);
  38. System.Diagnostics.Debug.Assert(_lp3 != null);
  39. }
  40. public Result Start(params object[] objs)
  41. {
  42. Reset();
  43. Notify($"Start");
  44. return Result.RUN;
  45. }
  46. public Result Monitor()
  47. {
  48. try
  49. {
  50. ExecuteRoutine((int)RoutineStep.HomeRobot, _homeRobotRoutine);
  51. HomeOtherModules((int)RoutineStep.HomeOtherModules );
  52. }
  53. catch (RoutineBreakException)
  54. {
  55. return Result.RUN;
  56. }
  57. catch (RoutineFaildException)
  58. {
  59. return Result.FAIL;
  60. }
  61. Notify("Finished");
  62. return Result.DONE;
  63. }
  64. public void HomeOtherModules(int id )
  65. {
  66. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  67. {
  68. Notify($"Start Home all EFEM modules");
  69. string reason;
  70. if (!_aligner.Home(out reason))
  71. {
  72. Stop(reason);
  73. return false;
  74. }
  75. if (!_lp1.Home(out reason))
  76. {
  77. Stop(reason);
  78. return false;
  79. }
  80. if (!_lp2.Home(out reason))
  81. {
  82. Stop(reason);
  83. return false;
  84. }
  85. if (!_lp3.Home(out reason))
  86. {
  87. Stop(reason);
  88. return false;
  89. }
  90. return true;
  91. }, () =>
  92. {
  93. if (_aligner.IsError || _lp1.IsError || _lp2.IsError || _lp3.IsError)
  94. {
  95. return null;
  96. }
  97. if (!_aligner.IsReady || !_lp1.IsReady || !_lp2.IsReady || !_lp3.IsReady)
  98. return false;
  99. return true;
  100. } );
  101. if (ret.Item1)
  102. {
  103. if (ret.Item2 == Result.FAIL)
  104. {
  105. Stop(string.Format("Home failed."));
  106. throw (new RoutineFaildException());
  107. }
  108. else
  109. throw (new RoutineBreakException());
  110. }
  111. }
  112. public void Abort()
  113. {
  114. }
  115. }
  116. }