ReadAndLoadRoutine.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  9. namespace EFEM.RT.Routines.LP
  10. {
  11. internal class ReadAndLoadRoutine : CommonRoutine, IRoutine
  12. {
  13. public enum LoadFoup
  14. {
  15. ReadID,
  16. LoadFoup,
  17. }
  18. public ModuleName Chamber { get; set; }
  19. private SCConfigItem _scLoadTimeout = null;
  20. private int _timeoutLoad = 0;
  21. //private ReadRFIDRoutine _readFoupIDRoutine = null;
  22. private LoadFoupRoutine _loadFoupRoutine = null;
  23. LoadPortBaseDevice _device = null;
  24. public ReadAndLoadRoutine(string module, string name)
  25. {
  26. //_readFoupIDRoutine = new ReadRFIDRoutine(module,"Read FOUP ID");
  27. _loadFoupRoutine = new LoadFoupRoutine(module, "Load FOUP");
  28. }
  29. public bool Initalize()
  30. {
  31. _scLoadTimeout = SC.GetConfigItem("LoadPort.TimeLimitLoadportLoad");
  32. //_readFoupIDRoutine.Initalize();
  33. _loadFoupRoutine.Initalize();
  34. return true;
  35. }
  36. public void Terminate()
  37. {
  38. }
  39. public Result Start(params object[] objs)
  40. {
  41. _timeoutLoad = _scLoadTimeout.IntValue;
  42. Reset();
  43. //_readFoupIDRoutine.Chamber = Chamber;
  44. _loadFoupRoutine.Chamber = Chamber;
  45. _device = DEVICE.GetDevice<LoadPortBaseDevice>(Chamber.ToString());
  46. EV.PostMessage(Chamber.ToString(), EventEnum.LoadFOUPStart, Chamber.ToString());
  47. return Result.RUN;
  48. }
  49. public Result Monitor()
  50. {
  51. try
  52. {
  53. //ExecuteRoutine((int)LoadFoup.ReadID, "Read Foup ID", _readFoupIDRoutine, Notify, Stop);
  54. ExecuteRoutine((int)LoadFoup.LoadFoup, "Load Foup", _loadFoupRoutine, Notify, Stop);
  55. }
  56. catch (RoutineBreakException)
  57. {
  58. return Result.RUN;
  59. }
  60. catch (RoutineFaildException)
  61. {
  62. return Result.FAIL;
  63. }
  64. EV.PostMessage(Chamber.ToString(), EventEnum.LoadFOUPEnd, Chamber.ToString());
  65. return Result.DONE;
  66. }
  67. public new void Abort()
  68. {
  69. }
  70. protected void ExecuteRoutine(int id, string name, IRoutine routines, Action<string> notify, Action<string> error)
  71. {
  72. Tuple<bool, Result> ret = ExecuteAndWait(id, routines);
  73. if (ret.Item1)
  74. {
  75. if (ret.Item2 == Result.FAIL)
  76. {
  77. error(name);
  78. throw (new RoutineFaildException());
  79. }
  80. else if (ret.Item2 == Result.RUN)
  81. {
  82. throw (new RoutineBreakException());
  83. }
  84. }
  85. }
  86. protected override void Notify(string message)
  87. {
  88. EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Load Foup:{0}", message));
  89. }
  90. /// <summary>
  91. /// prepare process failed
  92. /// </summary>
  93. /// <param name="failReason"></param>
  94. /// <param name="reactor"></param>
  95. protected override void Stop(string failReason)
  96. {
  97. string reason = String.Empty;
  98. EV.PostMessage(Module, EventEnum.LoadFOUPFailed, failReason);
  99. }
  100. }
  101. }