EfemHomeAllRoutine.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 JetEfemLib.Efems
  13. {
  14. class EfemHomeAllRoutine : ModuleRoutineBase, IStepRoutine
  15. {
  16. enum RoutineStep
  17. {
  18. HomeRobot,
  19. HomeAligner1,
  20. HomeAligner2,
  21. HomeOtherModules,
  22. End,
  23. }
  24. private IStepRoutine _homeRobotRoutine;
  25. private AlignerModuleBase _aligner1;
  26. private AlignerModuleBase _aligner2;
  27. private LoadPortModuleBase _lp1;
  28. private LoadPortModuleBase _lp2;
  29. private bool _aligner1Installed;
  30. private bool _aligner2Installed;
  31. public EfemHomeAllRoutine(EfemModule module) : base(ModuleName.EfemRobot.ToString())
  32. {
  33. Name = "Home All";
  34. _homeRobotRoutine = new EfemHomeRoutine(module);
  35. _aligner1 = EquipmentManager.Modules[ModuleName.Aligner1] as AlignerModuleBase;
  36. _aligner2 = EquipmentManager.Modules[ModuleName.Aligner2] as AlignerModuleBase;
  37. _lp1 = EquipmentManager.Modules[ModuleName.LP1] as LoadPortModuleBase;
  38. _lp2 = EquipmentManager.Modules[ModuleName.LP2] as LoadPortModuleBase;
  39. System.Diagnostics.Debug.Assert(_aligner1 != null);
  40. System.Diagnostics.Debug.Assert(_aligner2 != null);
  41. System.Diagnostics.Debug.Assert(_lp1 != null);
  42. System.Diagnostics.Debug.Assert(_lp2 != null);
  43. _aligner1Installed = SC.GetValueOrDefault<bool>("System.SetUp.Aligner1.IsInstalled");
  44. _aligner2Installed = SC.GetValueOrDefault<bool>("System.SetUp.Aligner2.IsInstalled");
  45. }
  46. public RState Start(params object[] objs)
  47. {
  48. Reset();
  49. return Runner.Start(ModuleName.EfemRobot.ToString(), Name);
  50. }
  51. public RState Monitor()
  52. {
  53. Runner.Run(RoutineStep.HomeRobot, HomeRobot, CheckHomeRobot)
  54. .Run(RoutineStep.HomeAligner1, HomeAligner1, CheckHomeAligner1)
  55. .Run(RoutineStep.HomeAligner2, HomeAligner2, CheckHomeAligner2)
  56. .End(RoutineStep.End, NullFun, _delay_50ms);
  57. return Runner.Status;
  58. }
  59. public bool HomeRobot()
  60. {
  61. return _homeRobotRoutine.Start() == RState.Running;
  62. }
  63. bool CheckHomeRobot()
  64. {
  65. var status = _homeRobotRoutine.Monitor();
  66. if (status == RState.End)
  67. {
  68. return true;
  69. }
  70. else if (status == RState.Failed || status == RState.Timeout)
  71. {
  72. Runner.Stop($"Home failed.");
  73. return true;
  74. }
  75. return false;
  76. }
  77. public bool HomeAligner1()
  78. {
  79. if(_aligner1Installed)
  80. {
  81. Notify($"Start Home Aligner1");
  82. string reason;
  83. if (!_aligner1.Home(out reason))
  84. {
  85. Stop(reason);
  86. return false;
  87. }
  88. }
  89. return true;
  90. }
  91. bool CheckHomeAligner1()
  92. {
  93. return _aligner1Installed ? !(_aligner1.IsError || !_aligner1.IsReady) : true;
  94. }
  95. public bool HomeAligner2()
  96. {
  97. if (_aligner2Installed)
  98. {
  99. Notify($"Start Home Aligner2");
  100. string reason;
  101. if (!_aligner2.Home(out reason))
  102. {
  103. Stop(reason);
  104. return false;
  105. }
  106. }
  107. return true;
  108. }
  109. bool CheckHomeAligner2()
  110. {
  111. return _aligner2Installed ? !(_aligner2.IsError || !_aligner2.IsReady) : true;
  112. }
  113. public void Abort()
  114. {
  115. }
  116. }
  117. }