AlignerAlignRoutine.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.EquipmentLibrary.HardwareUnits.Aligners;
  7. using MECF.Framework.RT.ModuleLibrary.AlignerModules;
  8. namespace FutureEfemLib.Aligners
  9. {
  10. class AlignerAlignRoutine : ModuleRoutine, IRoutine
  11. {
  12. enum Align
  13. {
  14. Align,
  15. }
  16. private int _timeout = 0;
  17. private double _angle = 0.0;
  18. private AlignerBase _aligner;
  19. public AlignerAlignRoutine(AlignerModuleBase module)
  20. {
  21. Module = module.Module;
  22. Name = "Align";
  23. _aligner = DEVICE.GetDevice<AlignerBase>($"{ModuleName.Aligner}.{ModuleName.Aligner}");
  24. _angle = SC.GetValue<double>("EFEM.Aligner.DefaultNotchDegree");
  25. }
  26. public bool Initalize()
  27. {
  28. return true;
  29. }
  30. public void Init(double notch)
  31. {
  32. _angle = notch;
  33. }
  34. public Result Start(params object[] objs)
  35. {
  36. Reset();
  37. _timeout = SC.GetValue<int>("EFEM.Aligner.AlignTimeout");
  38. Notify($"Start align to {_angle} degree");
  39. //AlignersState.IsAligning = true;
  40. return Result.RUN;
  41. }
  42. public Result Monitor()
  43. {
  44. //AlignersState.IsAligning = true;
  45. try
  46. {
  47. AlignWafer((int)Align.Align, _angle, _timeout);
  48. }
  49. catch (RoutineBreakException)
  50. {
  51. return Result.RUN;
  52. }
  53. catch (RoutineFaildException)
  54. {
  55. _stepName = "";
  56. return Result.FAIL;
  57. }
  58. Notify("Finished");
  59. // AlignersState.IsAligning = false;
  60. return Result.DONE;
  61. }
  62. public void AlignWafer(int id, double angle, int timeout)
  63. {
  64. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  65. {
  66. //Notify($"Start align to {angle} degree");
  67. string reason;
  68. if (!_aligner.Align(angle, out reason))
  69. {
  70. Stop(reason);
  71. return false;
  72. }
  73. return true;
  74. }, () =>
  75. {
  76. if (_aligner.IsError)
  77. return null;
  78. if (_aligner.IsBusy)
  79. return false;
  80. return true;
  81. }, timeout * 1000);
  82. if (ret.Item1)
  83. {
  84. if (ret.Item2 == Result.FAIL)
  85. {
  86. Stop(string.Format("failed."));
  87. throw (new RoutineFaildException());
  88. }
  89. else if (ret.Item2 == Result.TIMEOUT) //timeout
  90. {
  91. Stop(string.Format("timeout, can not complete in {0} seconds", timeout));
  92. throw (new RoutineFaildException());
  93. }
  94. else
  95. throw (new RoutineBreakException());
  96. }
  97. }
  98. public void Abort()
  99. {
  100. //AlignersState.IsAligning = false;
  101. Notify("Abort");
  102. }
  103. }
  104. }