HomeRoutine.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 EFEM.RT.Devices;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  10. namespace EFEM.RT.Routines.LP
  11. {
  12. internal class HomeRoutine : CommonRoutine, IRoutine
  13. {
  14. enum Home
  15. {
  16. Reset,
  17. Home,
  18. Wait,
  19. }
  20. private SCConfigItem _scHomeTimeout = null;
  21. private int _timeoutHome = 0;
  22. public ModuleName Chamber { get; set; }
  23. LoadPortBaseDevice _device = null;
  24. public HomeRoutine(string module, string name)
  25. {
  26. Module = module;
  27. Name = name;
  28. }
  29. public bool Initalize()
  30. {
  31. _scHomeTimeout = SC.GetConfigItem("LoadPort.TimeLimitLoadportLoad");
  32. return true;
  33. }
  34. public Result Start(params object[] objs)
  35. {
  36. _timeoutHome = _scHomeTimeout.IntValue;
  37. Reset();
  38. _device = DEVICE.GetDevice<LoadPortBaseDevice>(Chamber.ToString());
  39. EV.PostMessage(Chamber.ToString(), EventEnum.HomeBegins, Chamber.ToString());
  40. string reason = string.Empty;
  41. if (SC.GetValue<bool>("System.LPRobotActionIntervene"))
  42. {
  43. if(!CheckLoadportMotionInterlock(Chamber, out reason))
  44. {
  45. EV.PostMessage(Chamber.ToString(), EventEnum.HomeFailed, reason);
  46. return Result.FAIL;
  47. }
  48. }
  49. if (Chamber == ModuleName.LP1)
  50. {
  51. if (DeviceModel.SensorRBNotExtendSIMF1 != null && DeviceModel.SensorRBNotExtendSIMF1.Value)
  52. {
  53. EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, "robot Extend to LP1.");
  54. }
  55. }
  56. else
  57. {
  58. if (DeviceModel.SensorRBNotExtendSIMF2 != null && DeviceModel.SensorRBNotExtendSIMF2.Value)
  59. {
  60. EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, "robot Extend to LP2.");
  61. }
  62. }
  63. return Result.RUN;
  64. }
  65. public Result Monitor()
  66. {
  67. try
  68. {
  69. LoadportReset((int)Home.Reset, _device, "reset", _timeoutHome, Notify, Stop);
  70. LoadportInit((int)Home.Home, _device, "home", Notify, Stop);
  71. WaitLoadportMotion((int)Home.Wait, _device, "homing...", _timeoutHome, Notify, Stop);
  72. }
  73. catch (RoutineBreakException)
  74. {
  75. return Result.RUN;
  76. }
  77. catch (RoutineFaildException)
  78. {
  79. return Result.FAIL;
  80. }
  81. EV.PostMessage(ModuleName.System.ToString(), EventEnum.HomeEnds, ModuleName.System.ToString());
  82. return Result.DONE;
  83. }
  84. protected override void Notify(string message)
  85. {
  86. EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Home sequence :{0}", message));
  87. }
  88. /// <summary>
  89. /// prepare process failed
  90. /// </summary>
  91. /// <param name="failReason"></param>
  92. /// <param name="reactor"></param>
  93. protected override void Stop(string failReason)
  94. {
  95. string reason = String.Empty;
  96. EV.PostMessage(Module, EventEnum.HomeFailed, failReason);
  97. }
  98. }
  99. }